First we need to install nagios and nagios-plugins with the following command:
This will also install microperl in case you want to create some new plugins based on perl. Unfortunately nagios doesn't come with three very important files:
you also need to create /etc/default/nagios with the following line:
This will instruct nagios to start in daemon mode with the specified configuration file. - check_ping (which segfaults, at least on broadcom-2.4). You can compile check_fping which works ok or use the following equivalent script putting it in /usr/libexec/nagios/check_ping.sh :
- check_nrpe (which should have been included in the nagios-plugins or nrpe but it is not). You can get one if you compile the nrpe package and copy check_nrpe from build_dir to /usr/libexec/nagios on WRT. I have found that the default httpd server installed with luci is very limited, so, in order to run the nagios cgi's I have taken the lightttpd route. This web server is very fast, capable and has very small requirements:
I have opted to use the non-SSL service but you can easily adjust the following configuration file to use SSL. Now you have to modify the /etc/lighttpd.conf file as follows:
Some notes: Now we need a way for nagios to send emails when something is wrong (alert e-mails). In order to do that install the ssmtp package: opkg install ssmtp You should edit the following files to properly configure ssmtp: -Â /etc/ssmtp/revaliases:
replace "mail_from@domain.from" with the mail you want all the alerts to appear that they are come FROM. Replace "smtp.of.your.isp" with the MX smarthost of your ISP. This is useful in order to make the email alerts to come from e.g., admin@example.com instead of just "root" (which could be rejected by your ISP). - /etc/ssmtp/ssmtp.conf: change mailhub to be your ISP smarthost and hostname to be your hostname (fully qualified). Now test that sending email works with the following command:
Check the output of the above command carefully: if you get a "Message accepted for delivery" result in the smtp dialog then everything should be ok. Now on to the nagios config. This howto will not cover how to configure your nagios (see http://www.nagios.org for that) but I will pin-point some necessary changes: - /etc/nagios/cgi.cfg:Â
Make sure that nagiosadmin or admin or guest (or whatever other user you include here) are defined in the /etc/lighttpd.user file. This way you can have a very granular control of who can do what. - /etc/nagios/nagios.cfg: Make sure you change the following configuration options in that file as follows:
- /etc/nagios/commands.cfg: Use the following commands for ping and mail:
- /etc/nagios/resource.cfg: Make sure that USER1 is defined as:
Define any other services and hosts as you wish. Lets make lighttpd and nagios to auto-start and start them:
Point your browser to http://your.router.ip.address:81 and you should be ok. If not then you should check the syslog messages and enable any diagnostic logs available in both nagios and lighttpd. I will happily upload check_fping and check_nrpe compiled for broadcom-2.4 if I find how to do it and of course if there are requests from other members. Good luck, 2cpr2011-08-23 09:56:58 (edited by cpr 2011-08-23 09:57:39)
This is year 2011. I had to install lighttpd-mod-alias and add to lighttpd.conf
Nagios is working now! *yay* |
Projects‎ > ‎Arduino Yun‎ > ‎
Installing Nagios on OpenWRT
22011-08-23 09:56:58Â (edited by cpr 2011-08-23 09:57:39) |