Created
September 7, 2012 19:07
-
-
Save jdorfman/3668683 to your computer and use it in GitHub Desktop.
Revisions
-
jdorfman created this gist
Sep 7, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ #!/bin/bash #Which Grep="`/usr/bin/which grep`" Awk="`/usr/bin/which awk`" Cat="`/usr/bin/which cat`" Sed="`/usr/bin/which sed`" Curl="`/usr/bin/which curl`" # Scrape Nagios $Curl -s --user thebaws:S3cuR3p@55wdBr@ "https://monitoring.example.com/nagios/cgi-bin/status.cgi?host=all&servicestatustypes=28" > data/nagios-count.html # Get host status stats $Cat data/nagios-count.html |$Sed -n "43,46p" > data/hosts $Sed 's/>/ /g;s/</ /g' data/hosts |$Awk {'print $3'} > data/hostnumbers # Extract the numbers HostUp="`$Awk 'NR == 1' data/hostnumbers`" HostDown="`$Awk 'NR == 2' data/hostnumbers`" HostUn="`$Awk 'NR == 3' data/hostnumbers`" HostPend="`$Awk 'NR == 4' data/hostnumbers`" # Send Host Stats to Leftronic $Curl -i -X POST -k -d '{"accessKey": "000000000000000000000000000000000", "streamName": "000000", "point": '"$HostUp"'}' https://www.leftronic.com/customSend/ $Curl -i -X POST -k -d '{"accessKey": "000000000000000000000000000000000", "streamName": "000000", "point": '"$HostDown"'}' https://www.leftronic.com/customSend/ $Curl -i -X POST -k -d '{"accessKey": "000000000000000000000000000000000", "streamName": "000000", "point": '"$HostUn"'}' https://www.leftronic.com/customSend/ $Curl -i -X POST -k -d '{"accessKey": "000000000000000000000000000000000", "streamName": "000000", "point": '"$HostPend"'}' https://www.leftronic.com/customSend/ ####################### # Get Service status stats $Cat data/nagios-count.html |$Sed -n "77,79p" > data/service $Sed 's/>/ /g;s/</ /g' data/service |$Awk {'print $3'} > data/servicenumbers # Extract the numbers ServiceWarn="`$Awk 'NR == 1' data/servicenumbers`" ServiceCrit="`$Awk 'NR == 3' data/servicenumbers`" # Send Host Stats to Leftronic $Curl -i -X POST -k -d '{"accessKey": "000000000000000000000000000000000", "streamName": "00000000", "point": '"$ServiceWarn"'}' https://www.leftronic.com/customSend/ $Curl -i -X POST -k -d '{"accessKey": "000000000000000000000000000000000", "streamName": "00000000", "point": '"$ServiceCrit"'}' https://www.leftronic.com/customSend/