Speciel subject – Nagios with Raspberry Pi – anno May 2013
Another old post moved from my first blog. This is from the first special subject in may 2013
Introduction
First week started great and I was ahead and took it easy. Install Nagios on raspberry Pi with no problem and was able to start the service.
Now a week with frustration started, how to machines to be monitored by Nagios. And installing of plug-ins.
NAGIOS HELL WEEK – First week
As I said before the Nagios was installed be due time to get some hands on this little piece of nice software and see how it would work.
Monday we had a lot of presentations from the other students so no work done in those lessons.
Tuesday it was research time. Google a lot to find any good guides to what kind of plug-ins, and how to install them. There is a lot of different plug-ins that can be downloaded at Nagios exchange Here. But haven’t found out how to install them yet. They are tar.gz files but have no idea where to put them.
Next really day for work on special subject was Saturday. 12 hours dedicated to special subject would have to turn something good out of it. And it was here my frustrations took over. My Nagios install did not work. Reinstalled it 4 times and different install just adds a new problem.
- No apache was installed. And can´t install it after Nagios because it depends on it. It makes an error and halts.
- Nagios-core, Nagios-common are not configured – system halt.
- Error code 127 “plug-in missing” Local host wil not run.
- Nagios is running
- Sudo apt-get update
- Sudo apt-get upgrade
- Sudo apt-get install Nagios
Nagios documentation is quite good and starts configuration of a windows machine for test.
- NSClinet++
- Setup IP 10.0.1.119
- With a password
- Starts service
- Nagios server pre-requisites
- Edit the main Nagios config file with “nano /usr/local/nagios/etc/nagios.cfg”
- Remove the leading Hash (#) sign from the following line in the main configuration file: #cfg_file=/usr/local/nagios/etc/objects/windows.cfg
Code snippet of the windows configuration
Define host {
Use windows-server
Host-name Jonas PC
Alias Jonas Desktop PC Tech Room
Address 10.0.1.113 e.g
}
This snippet tells Nagios that this host is using the windows server template
In the configuration file follows what kind service the windows machine is being monitored on.
E.g define service {
use generic-service
host_name Jonas PC
service_description NSClient++ Version
check_command check_nt!CLIENTVERSION
}
Add the following service definition to monitor the uptime of the Windows computer.
Because the NSClient is being password protected we need to make changes to the command.cfg file.
Nano /usr/local/nagios/etc/objects/commands.cfg
define command{
command_name check_nt
command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -s NSClient password -v $ARG1$ $ARG2$
}
But before we restart Nagios the documentation gives us the code for see if the config file is AOKAY. To verify configuration
nagios -v /etc/nagios3/nagios.cfg
Restart the Nagios
At the moment there is nothing that is working and I am trying to get it all to work.
Saturday night I could see my PC in the Nagios map. But both the localhost “Nagios server” and windows pc was down with error 127 – missing a plug-in. So now it is Sunday evening and I’m still trying to get to work.
But if all fails I have an option of install a older version that is already are compiled with Debian.
At the moment it looks like I got a big pile of work in front of me. But if the older version will work (i´m on it now) and the configuration goes as it should. Then I will try to add my home router to the Nagios, A Apple airport extreme.
I´m not behind yet, but I am very close.
More of the Nagios HELL – Week two
Found out that the nagios that is in the repository was not that old, version 3.4.1 from may last year. The install vent fine and went on with the configuration. To my surprise the files that I needed to change was not there as the documentation said. I have no idea where these files are now.
So Monday I decided to start again and see how it went. The problem by adding a user was still there.
Trying to add a user to my nagios installment. And this is the outcome: root@raspberrypi:~# adduser nagios adduser: The group `nagios’ already exists.
Asked I our Fb group and got a fast reply back. Here I was told I could use.
useradd -m -g nagios -s /bin/bash Nagios
Rest of the installation with the guide is going well.
Some problems with apt-get install nagios-plugins nagios-snmp-plugins
First run it was not complete and had to use –miss-fixing
It did not work
Foundt out how to get the apt-get install Nagios version to work. Like this:
- apt-get update
- apt-get upgrade (now the RPI is up to date but might take some time)
- apt-get install nagios
It will ask you for an password for nagiosadmin.
Now all done You can login to http://ip-of- server/nagios3 using nagiosadmin and the password you issued.
If you have encountered some Nagios installations before, be aware the files you need to use are not in the usual spots as described on Nagios.org
/etc/nagios3 – this is your primary folder where e.g. commands.cfg resides.
/etc/nagios3/conf.d/ – this is the folder for all your config files. I used these for the basic monitoring tasks.
/etc/nagios-plugins – home of all the native plugins like http_check
To a restart of the Nagios. A stop command is added as well.
root@raspberrypi:~# service nagios3 restart
[….] Restarting nagios3 monitoring daemon: nagios3
. ok
root@raspberrypi:~# service nagios3 stop
[….] Stopping nagios3 monitoring daemon: nagios3
. ok
Have edit following to get this http check to work.
edit /etc/nagios-plugins/config/http.cfg
# ‘check_http’ command definition
define command{
command_name check_http
command_line /usr/lib/nagios/plugins/check_http -H ‘$HOSTADDRESS$’ -I ‘$HOSTADDRESS$’ ‘$ARG1$’
}
Then make another file for these devices, I’ve used services.cfg
define service{ use generic-service ; Inherit default values from a template host_name name-of-your-machine service_description HTTP:PORT check_command check_http!-p 10000 ;with 10000 as the port you want to monitor for http service }
hostname.cfg with following basic input to add a host
define host {
use generic-host
host_name name-of-your-machine
address IP of target machine
Then save all your work and service nagios3 restart and refresh the browser.
Have now configured it to monitor if there is a connection to my Home desktop PC and the Internet.
More of the Nagios HELL – week 3
This week I had to do a lot of studing the documentation and websites for how this command line has to be written.
Last week’s problems was “missing a –l parameter” and “permission denied”
After hours I found out that the solutions were easy and my own fault.
# ‘check_nt’ command definition
define command {
command_name check_nt
command_line /usr/lib/nagios/plugins/check_nt -H ‘$HOSTADDRESS -p 12489 -s ***** -v ‘$ARG1 $ARG2$
}
The problem was that it was missing a password parameter and a argument in this command line located ind the /plugin/config/nt.cfg.
Then the services started to light up green. This was a nice success.