We needed a way to monitor all of our NodeJS instances in Zenoss and not just a simple TCP connection. Since we were already using the Cluster plugin for NodeJS ‘http://learnboost.github.com/cluster/’ and we are using the stats plugin for Cluster ‘http://learnboost.github.com/cluster/docs/stats.html’. We decided to write a quick python script to connect to the stats plugin and parse that data to represent it to Zenoss.

You have 2 options… Run this script by itself using Zenoss to connect to the host or if you are using a socket connection or connecting to localhost only then use SNMP.

Download Here .. Download

  • ( IN SNMP ) Options are modifiable ‘exec CheckClusterLiveStats /usr/local/bin/check_clusterlive_stats.py -t tcp -c localhost:8888
  • Or directly in Zenoss ‘/usr/local/bin/check_clusterlive_stats.py -t tcp -c remotehost:8888′

This script can be used to connect to a TCP socket or to a local file socket. Example output from Zenoss Test Command…

Using SNMP Preparing Command...
Executing command /usr/local/zenoss/libexec/check_snmp -H 127.0.0.1 -o .1.3.6.1.4.1.8072.1.3.2.3.1.1.21.67.104.101.99.107.67.108.117.115.116.101.114.76.105.118.101.83.116.97.116.115 -C readonly -R OK against 127.0.0.1
SNMP OK - "Deaths Has not increased, Deaths count is 0 NodeJS cluster OK |restarts=0 workers=4 deaths=0 connections_total=193463 connections_active=0" |

Using Command only...
Preparing Command...
Executing command /usr/local/zenoss/libexec/check_clusterlive_stats.py -t tcp -c remotehost:8888
"Deaths Has not increased, Deaths count is 0 NodeJS cluster OK |restarts=0 workers=4 deaths=0 connections_total=193463 connections_active=0" |

The command above you can run with out snmp. The reason we use snmp because we only allow the stats plugin to run on the localhost interface. So we use snmp to execute the script and in return, it returns the results.

Here is the help output..
check_clusterlive_stats.py -h
Usage: check_clusterlive_stats.py arg --contype=socket|tcp --connection=pathto socket|host:port

Options:
  -h, --help            show this help message and exit
  -t CONTYPE, --contype=CONTYPE
                        socket or tcp
  -c CONNECTION, --connection=CONNECTION
                        /tmp/cluster-repl.sock or localhost:8888
  -w TIMEOUT, --timeout=TIMEOUT
                        int of how long you want this script to wait until it
                        times out

 

 

We needed a way to monitor a few different type of HTTP Status Codes, specifically… ( 400, 404, 500, 503, 504, 200 ). This list is modifiable within the script. Though I’m thinking of turning this list into an option, since everyone might not one to gather the count just for those mentioned above.

So In order to get this data, you will need to use SNMP and install logtail. To make this script work you will need to have an snmpd exec statement in the snmpd.conf file and a crontab entry for the script to run as often as you like.

This script has been tested, using Nginx and Ruby On Rails.
You can download the script here.. Download

  • On cron, remember this is modifiable ‘* * * * * /usr/local/bin/get_http_codes.py -d “/var/log/nginx” -f “www-access.log” >/tmp/errorcount.txt’
  • In snmpd.conf without quotes ‘exec GetHttpStats /bin/cat /tmp/errorcount.txt

In Zenoss you will have to use the check_snmp nagios command or the inherent snmp check from zenoss. The oid you need to use is the UCDavis OID. For instance I’m using 2 exec statements in snmpd.conf, so the OID I am using for this check is this one ‘.1.3.6.1.4.1.2021.8.1.101.2‘ The command I’m using in zenoss is like this ‘check_snmp -H ${dev/manageIp} -C readonly -P 2c -o .1.3.6.1.4.1.2021.8.1.101.2

The current options for get_http_codes.py is ‘-d‘ which is the directory where the log file is located and ‘-f ‘ the name of the logfile. This script uses logtail so that I can always get the difference from the last time I scanned the log file.

The purpose of this script is so that you can graph or create a threshold of how many of the below Http Error Codes you are getting between every check. For instance we run this check every 30 seconds in Cron and in Zenoss and we divide the results by 30 so we can get how many of the error codes are happening per second.
Example of the output of the script is ‘SNMP OK – “Nginx Codes OK|count200=181 count400=1 count404=0 count500=0 count503=0 count504=0″ |

If you have any feature request or have any questions, please leave a comment. Thank you

 

**Note** – once you complete this procedure the startup configuration is gone from the IOS device. If you have not stored the configuration somewhere it’s lost for good!`

  1. Connect to the IOS device (Switch or Router) via telnet or Console.
  2. Type  “enable and press enter to go to privileged mode.
  3. Type  “write erase and press enter to clear the config from nvram.
  4. Typereload and press enter. When asked whether to save the configuration sayno.
    The IOS device will reboot and come back up with the default configuration.
  5. When the device comes back up. Go back into privileged mode (step 2 above).
  6. Typeconfig-register 0×2102 and press enter.
  7. Typewrite mem and press enter.

Now you can create a new configuration and it will be recognized if the IOS device is restarted.

© 2011 LinuxDynasty Suffusion theme by Sayontan Sinha

Warning: fopen(/home/dynasty/linuxdynasty.org/wp-content/plugins/wp-google-plus-one/lib/standard.txt) [function.fopen]: failed to open stream: No such file or directory in /home/dynasty/linuxdynasty.org/wp-content/plugins/wp-google-plus-one/plusone.php on line 104

Warning: fread(): supplied argument is not a valid stream resource in /home/dynasty/linuxdynasty.org/wp-content/plugins/wp-google-plus-one/plusone.php on line 105

Warning: fclose(): supplied argument is not a valid stream resource in /home/dynasty/linuxdynasty.org/wp-content/plugins/wp-google-plus-one/plusone.php on line 106
.