Automate Daily Report : CSV Output
list Brad Radjoo [ Mtn South Africa ]
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. "
list Torsten Richter
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 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. "
- -- +---------------------------------------------------------+
| E-mail : user-c862b499d9fa@xymon.invalid | | | | 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 iEYEARECAAYFAlgzZwkACgkQ7DlmxomQk6w/eACgqxWgVt5/nUH85To9maz/X5Y9 1JwAnA5rGHV+3w2Md2MYNZFvexF0ecNY =uzdY -----END PGP SIGNATURE-----
list Brad Radjoo [ Mtn South Africa ]
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 user-c862b499d9fa@xymon.invalid> wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 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. "- -- +---------------------------------------------------------+ | E-mail : user-c862b499d9fa@xymon.invalid | | | | 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 iEYEARECAAYFAlgzZwkACgkQ7DlmxomQk6w/eACgqxWgVt5/nUH85To9maz/X5Y9 1JwAnA5rGHV+3w2Md2MYNZFvexF0ecNY =uzdY -----END PGP SIGNATURE-----
"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. ”
list Torsten Richter
-----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 user-c862b499d9fa@xymon.invalid> 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. ""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 : user-c862b499d9fa@xymon.invalid | | | | 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-----
list Brad Radjoo [ Mtn South Africa ]
Guten tag Torsten, Just wanted to express my thanks as I got it to work based on the script you sent :-) Here in South Africa, we say in Afrikaans, ³Baie Dankie² (Thank You) Kind Regards, - - - - Bradley
▸
On 2017/02/06, 19:07, "Torsten Richter" <user-c862b499d9fa@xymon.invalid> wrote:
-----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 user-c862b499d9fa@xymon.invalid> 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. ""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 : user-c862b499d9fa@xymon.invalid | | | | 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-----
"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. ”