Owl Nagios check plugin – Basic example inc. Source

1hr41min 1.563e+010 q19.179 dark green on whit...
Image by shannonpatrick17 via Flickr

I wanted to make a nagios check for the OWL energy meter.

First thing to note, don’t run any of the owl stuff while trying to run the check.

Secondly, I included the source so feel free to use Visual C# to hack it.

Third thing is, well, the OWL sensor software is very slow to respond, infact if you don’t get any response from it after a few minutes I recommend turning the kettle on.  The check may take up to 10 minutes (how lame is that?) so I recommend you increase your time outs.

Finally I’m not familiar with Visual Studio, that’s why I did so little in Windows.  I just wanted an output I could work with in a nice dark environment.

The check in bin\release\sensorapp.exe waits for a signal from the transmitter then echos it to command line.  Do with it what you will.  I’m pulling it into a simple .bat file.

Grab the files

Reblog this post [with Zemanta]

Installing the NRPE client, daemon and nagios plugins on debian

We assuming have already configured nrpe on your nagios box and you are sudo’d/root

Steps:

adduser nagios (set the password)
cd /home/nagios
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz
* If this step fails visit http://www.nagios.org/download/addons for the latest URL

tar -zxvf nrpe-2.8.tar.gz
cd nrpe-2.12
apt-get install gcc gawk openssl
apt-get install make
apt-get install libssl-dev
apt-get install nagios-plugins
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
echo “only_from = 0.0.0.1” >> /usr/local/nagios/etc/nrpe.cfg
* Remember to replace 0.0.0.1 with your the IP address of your nagios server

cp init-script.debian /etc/init.d/nrpe
chmod 700 /etc/init.d/nrpe
/etc/init.d/nrpe start

You may want to make this script run on start up
update-rc.d nrpe defaults

Send_NSCA.exe example

1. Make sure you edit your send_nsca.cfg accordingly

2. Copy to c:\test.vbs

Set oArgs = WScript.Arguments.Unnamed
Set WshShell = CreateObject(“WScript.Shell”)
‘ 0 = hostname of local machine
‘ 1 = checkname
‘ 2 = result, 0 is ok, 1 is warn, 2 is crit
‘ 3 = notes from the output
‘ Written by John McLear of Primary Technology 2009
exepath = “c:\program files\montitech\nc_net\config\send_nsca.exe” ‘ path to exe
cfgpath = “c:\program files\montitech\nc_net\config\send_nsca.cfg” ‘ path to cfg
host = “nagios.server.com” ‘host nagios server
tab = Chr(9)
prefix = “c:\windows\system32\cmd.exe /q /c echo “
cmd= prefix & oArgs.Item(0) & tab & oArgs.Item(1) & tab & oArgs.Item(2) & tab & oArgs.Item(3) & ” | ” & chr(34) & exepath & chr(34) & ” -H ” & host & ” -c ” & chr(34) & cfgpath & chr(34)
wscript.echo cmd
‘ Remove or rem out above line after debug
WshShell.Run(cmd)

3. Edit nagios.server.com to your nagios server name.

4. Start – run – cmd – cscript c:\test.vbs Myhostname Mycheckname Status(seebelow)
My Example: cscript c:\test.vbs mooocow simsdbversion 0 3.142