Saturday, 21 July 2012

Nagrestconf on Raspberry PI


This post is quite old now, and out of date. There are new instructions for installing nagios and nagrestconf on Raspbian at http://nagrestconf.smorg.co.uk if you're interested.

So, your Raspberry Pi is set up with Debian (my Pi is running in a cupboard), and now you want to monitor your home network with it. Here's a quick tutorial using nagrestconf to make configuring nagios less of a chore.

Log into the raspberry pi and install gdebi:

apt-get install gdebi

then get the nagrestconf .deb package:

wget http://downloads.sourceforge.net/project/nagrestconf/Debian/nagrestconf_1.0_all.deb

Install nagrestconf and it will automatically install nagios etc.:

gdebi nagrestconf_1.0_all.deb

I had a problem with apache failing to start, which stopped nagios3 from installing. I was able to fix it by adding the www-data group then continuing the install - maybe I had a disk write problem? Fix was:

addgroup www-data
apt-get install --reinstall apache2
dpkg --configure -a
gdebi nagrestconf_1.0_all.deb


If all went well and you see 'Nagrestconf has been configured for http://127.0.0.1/nagrestconf/.' then you should be all set go.

Test that your installation is working by using the REST_setup_local.sh setup script

bash /usr/share/doc/nagrestconf/bulk-loading/REST_setup_local.sh

You should see a lot of lines in the output that say '[Success]' and the output should end with:

-----------------------------------------------------------
- Apply, Check and Restart
-----------------------------------------------------------

curl -knX POST -d 'json={"folder":"local"}' http://127.0.0.1/rest/apply/nagiosconfig
["Success"]

curl -knX GET 'http://127.0.0.1/rest/check/nagiosconfig?json=\{"folder":"local","verbose":"false"\}'
["Total Warnings: 0, Total Errors: 0"]

curl -knX POST -d 'json={"folder":"local"}' http://127.0.0.1/rest/restart/nagios
["Config saved and Nagios restart request sent."]

root@raspberrypi:~#


You have tested that the REST interface works so now test that the Web interface works. By default only connections from localhost are allowed to use the nagrestconf gui. Now, I don't run a graphical Desktop on my Raspberry PI so I have to use ssh to forward a port on my linux laptop to the local port on the raspberry pi. This is very easy. Just:

# Run this on the desktop/laptop
# change 10.0.0.10 to the address of your Pi
ssh -L 8181:127.0.0.1:80 root@10.0.0.10


Then put 'http://127.0.0.1:8181/nagrestconf/' in the Browser's address bar, and you should see the Nagrestconf GUI as shown at the top of this blog entry. The nagios gui is available at the raspberry pi's address plus '/nagios3' and is shown below:

No comments:

Post a Comment