[Xymon] Automate Daily Report : CSV Output

Torsten Richter bb4 at richter-it.net
Mon Feb 6 18:07:47 CET 2017


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Brad,

yes I am since I had a few days off :)
I was able to get the script and removed everything that was for our
environment only.
You'll have to adjust the variables and replace <YOURSERVERHERE> with
the name of your web server url:

- -------------------------------8<-------------------------------
#!/usr/bin/env ksh
###############################################################
# File  : dailyshow.sh
# Author: Torsten Richter
###############################################################
#
# switch for debugging
#
# set -xv
#
# definition of used variables (adjust to suit your needs)
#
BBHOME="${HOME}/bb"
BBWEB="${BBHOME}/server/www"
RPTDIR="${BBWEB}/rep"
LOGDIR="${BBHOME}/var"
AWK="/usr/bin/awk"
BNAME="/usr/bin/basename"
CAT="/bin/cat"
CHM="/bin/chmod"
CP="/bin/cp"
CUT="/usr/bin/cut"
DATE="/bin/date"
DNAME="/usr/bin/dirname"
GET="/usr/bin/lynx"
GREP="/bin/egrep"
HEAD="/usr/bin/head"
HNAME="/bin/hostname"
MAIL="/usr/bin/mpack"
PING="/bin/ping"
RM="/bin/rm"
SCP="/usr/bin/scp"
SED="/bin/sed"
SSH="/usr/bin/ssh"
TAIL="/usr/bin/tail"
TCH="/bin/touch"
TR="/usr/bin/tr"
DAY="$(${DATE} --date="yesterday" +%d)"
MONTH="$(${DATE} --date="yesterday" +%m)"
YEAR="$(${DATE} --date="yesterday" +%Y)"
YR="$(${DATE} --date="yesterday" +%y)"
PATTERN="Report is available "
PRGNAME=$(${BNAME} $0|${AWK} -F\. '{print $1}')
REPORT="bigbrother_${YR}${MONTH}${DAY}.csv"
URL="http://<YOURSERVERHERE>/xymon-cgi/report.sh?start-mon=${MONTH}&start-day=${DAY}&start-yr=${YEAR}&end-mon=${MONTH}&end-day=${DAY}&end-yr=${YEAR}&style=crit&csvdelim=%2C&DoCSV=Generate+spreadsheet"
###############################################################
# nothing to configure below this point
###############################################################
${GET} -dump "${URL}" > /tmp/${PRGNAME}.$$
REPORTLOCATION="$(${GREP} "${PATTERN}" /tmp/${PRGNAME}.$$|${AWK} -F\"
'{print $2}')"
REPORTNAME="$(${BNAME} ${REPORTLOCATION})"
${CP} ${RPTDIR}/${REPORTNAME} /tmp/${REPORT}
#
# end of program
#
- ------------------------------->8-------------------------------

Regards,
Torsten

On 04.02.2017 10:30, Brad Radjoo [ MTN South Africa ] wrote:
> Hello Torsten, I trust you are well
> 
> I was really hoping if you were able to still get hold of that script :-)
> 
> 
> Kind Regards,
> 
> - - - -
> Brad
> 
> 
> 
> 
> 
> On 2016/11/21, 23:28, "Xymon on behalf of Torsten Richter"
> <xymon-bounces at xymon.com on behalf of bb4 at richter-it.net> wrote:
> 
> Hi Brad,
> 
> I wrote a script at my last job that more or less did what you want to
> achieve.
> Basically it downloaded the report with lynx and then renamed it and
> uploaded it somewhere else with scp but this part can also be adapted to
> send an email with the csv as attachment.
> Unfortunately I did not copy the script when I left the company but I
> can ask a colleague if he could send me the script and I can then send
> it to you if you want. But this would take 1 or 2 days.
> 
> Regards
> Torsten
> 
> On 21.11.2016 16:06, Brad Radjoo [ MTN South Africa ] wrote:
>>>> G'Day,
>>>>
>>>> Is there a way to generate an availability report of the past 24 hours
>>>> in csv format and set that to e-mail myself on a daily basis ?
>>>>
>>>> I notice that it uses the xymon-cgi/report.sh script
>>>>
>>>>
>>>> Kind Regards,
>>>>
>>>> - - - -
>>>> Bradley
>>>>
>>>>
>>>>
>>>> "This email is confidential. If you have received it in error, you are
>>>> on notice of its status. Please notify us immediately by reply email and
>>>> then delete this message from your system. Please do not copy it or use
>>>> it for any purpose, or disclose its contents to any other person as to
>>>> do so could be a breach of confidentiality. Thank you for your
>>>> co-operation. "
>>>>
>>>> "The information contained in this message is intended solely for the
>>>> individual to whom it is specifically and originally addressed. This
>>>> message and its contents may contain confidential or privileged
>>>> information from MTN Group. If you are not the intended recipient, you
>>>> are hereby notified that any disclosure or distribution, is strictly
>>>> prohibited. If you receive this email in error, please notify MTN Group
>>>> immediately and delete it. MTN Group does not accept any liability or
>>>> responsibility if action is taken in reliance on the contents of this
>>>> information . Note that all personal emails are not authorized by MTN
>>>> Group. "
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Xymon mailing list
>>>> Xymon at xymon.com
>>>> http://lists.xymon.com/mailman/listinfo/xymon
>>>>
> 
>> _______________________________________________
>> Xymon mailing list
>> Xymon at xymon.com
>> http://lists.xymon.com/mailman/listinfo/xymon
> 
> 
> "This email is confidential. If you have received it in error, you are on notice of its status. Please notify us immediately by reply email and then delete this message from your system. Please do not copy it or use it for any purpose, or disclose its contents to any other person as to do so could be a breach of confidentiality. Thank you for your co-operation. "
> 
> “The information contained in this message is intended solely for the individual to whom it is specifically and originally addressed. This message and its contents may contain confidential or privileged information from MTN Group. If you are not the intended recipient, you are hereby notified that any disclosure or distribution, is strictly prohibited. If you receive this email in error, please notify MTN Group immediately and delete it. MTN Group does not accept any liability or responsibility if action is taken in reliance on the contents of this information . Note that all personal emails are not authorized by MTN Group. ”
> 

- -- 
+---------------------------------------------------------+
| E-mail  : bb4 [at] richter-it.net			  |
|							  |
| Homepage: http://www.richter-it.net/			  |
+---------------------------------------------------------+
Download my public key from:
http://keys.gnupg.net/pks/lookup?search=0x899093AC&op=get
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iEYEARECAAYFAliYrWMACgkQ7DlmxomQk6wtCwCdFd6+VzATxDX2AN8GvfOfpoBD
jg0AnjUjhlPtNVOoOAp2JaTHP0WO/1IM
=eZN2
-----END PGP SIGNATURE-----



More information about the Xymon mailing list