Posts here are mostly step-by-step guides on how to replicate something I have set up in the past. Read over my About page to see how I show commands/output and read the disclaimer.
I do not have Nagios 4.x on any production boxes yet, but I want to keep track on how this is working on Ubuntu 12.04. Apparently Nagios Core wasn’t well tested for Debian systems if at all. But in any case, it can be installed with a couple modifications.
This guide is going to be very similar to my guide on Nagios 3.x.
I will refer to this server with the hostname s10-nagios. Change at will, but adjust the commands accordingly.
Demo Video
Base OS Installation
Install Ubuntu Server 12.04. If you are provisioning a VM, a 24GB drive will be plenty.
Set a root password. Yeah, it’s best to use sudo for the one-off commands. But sometimes being root is just easier.
[user]$ sudo passwd root
Be sure we are on the latest updates:
[root]$ apt-get update [root]$ apt-get dist-upgrade
Some basic reminders: Set account passwords, bash prompts, etc.
Nagios & Plugins Install
Prepare the Nagios User & Group
[root]$ useradd -m -s /bin/bash nagios [root]$ passwd nagios
Create the group needed for submitting commands from the web.
[root]$ groupadd nagcmd [root]$ usermod -a -G nagcmd nagios [root]$ usermod -a -G nagcmd www-data
Download / Extract Archives
[root]$ cd ~ [root]$ wget http://downloads.sourceforge.net/project/nagios/nagios-4.x/nagios-4.0.6/nagios-4.0.6.tar.gz [root]$ tar -xzvf nagios-4.0.6.tar.gz [root]$ wget https://www.nagios-plugins.org/download/nagios-plugins-1.5.tar.gz [root]$ tar -xzvf nagios-plugins-1.5.tar.gz
By the way, both of those tar command were without referencing the docs.
Compile and Install Nagios
Install some required packages.
[root]$ apt-get install libgd2-xpm-dev apache2 php5
[root]$ cd ~/nagios-4.0.6 [root]$ ./configure --with-command-group=nagcmd [root]$ make all
After the compiling is complete, the following options are presented:
– make install – This installs the main program, CGIs, and HTML files – make install-init – This installs the init script in /etc/init.d – make install-commandmode – This installs and configures permissions on the directory for holding the external command file – make install-config – This installs SAMPLE config files in /usr/local/nagios/etc You’ll have to modify these sample files before you can use Nagios. Read the HTML documentation for more info on doing this. Pay particular attention to the docs on object configuration files, as they determine what/how things get monitored! – make install-webconf – This installs the Apache config file for the Nagios web interface – make install-exfoliation – This installs the Exfoliation theme for the Nagios web interface – make install-classicui – This installs the classic theme for the Nagios web interface
I ran the following installations:
[root]$ make install [root]$ make install-init [root]$ make install-commandmode [root]$ make install-config [root]$ make install-webconf
Check out the output from this last command:
[root]$ make install-webconf /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf /usr/bin/install: cannot create regular file ‘/etc/httpd/conf.d/nagios.conf’: No such file or directory make: *** [install-webconf] Error 1
Silly Nagios installer, this is a Debian box! Let’s install this Apache2 config manually.
[root]$ /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/conf.d/nagios.conf
Don’t attempt to start Nagios yet.
Compile and Install Nagios Plugins
We first need to install some prerequisites.
[root]$ apt-get install libnet-snmp-perl libperl5.14 libpq5 libradius1 libsensors4 libsnmp-base libsnmp15 libtalloc2 libtdb1 libwbclient0 samba-common samba-common-bin smbclient snmp whois libmysqlclient15-dev libssl-dev
Now install it
[root]$ cd ~/nagios-plugins-1.5 [root]$ ./configure --with-nagios-user=nagios --with-nagios-group=nagios [root]$ make [root]$ make install
NRPE Plugin Make & Install
Note the steps below carefully. DO NOT run “make install”. All we want to do is copy out the check_nrpe plugin, which is apparently not included in the original plugin pack.
[root]$ cd ~ [root]$ wget http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.14/nrpe-2.14.tar.gz [root]$ tar -xzvf nrpe-2.14.tar.gz [root]$ cd nrpe-2.14 [root]$ ./configure --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/x86_64-linux-gnu [root]$ make
Instead of installing this whole package, we just want the plugin exec.
[root]$ cp src/check_nrpe /usr/local/nagios/libexec/
Configuration
Create the Apache login credentials.
[root]$ htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Configure your Nagios services / hosts. For now, I recommend that you only setup a couple service checks for localhost
while we build out the rest of the configuration.
BONUS TIP: Bash Alias
Create this bash alias to make it easier to run checks. For the rest of this guide, I will use the command nverify
to run a check assuming that you created this alias.
[root]$ vim ~/.bash_aliases
alias nverify="/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg"
Don’t forget to log out and then back in to this box to see the new alias.
Check the configuration.
[root]$ nverify
Hold your breath & start the services.
[root]$ service apache2 restart [root]$ service nagios start
This is the part that doesn’t seem to be compatible with Debian systems. When I attempt to start the service, I see this:
[root]$ service nagios start /etc/init.d/nagios: 20: .: Can't open /etc/rc.d/init.d/functions
There is an issue with the init script, and there is a thread that discusses this issue. I will use the fix posted by a member of the Nagios team. That post is located here.
[root]$ vim /etc/init.d/nagios
Delete the contents of the file, and paste in the code from the above mentioned post.
I also had to install daemon for this to work.
[root]$ apt-get install daemon
Now try to start the service again to see some more welcome output:
[root]$ service nagios start * is not running $Starting nagios:
Configure service to run at startup:
[root]$ ln -s /etc/init.d/nagios /etc/rc2.d/S20nagios
Checkpoint One
- Reboot
s10-nagios
- Verify that the service automatically started. Correct any startup config issues.
- Attempt to navigate to
http://s10-nagios/nagios
from a computer on the same LAN. - Login using credentials previously specified.
Nagiosgraph
Install some more prerequisites.
[root]$ apt-get install libcgi-pm-perl librrds-perl libgd-gd2-perl
Download and extract the files.
[root]$ cd ~
[root]$ wget http://downloads.sourceforge.net/project/nagiosgraph/nagiosgraph/1.4.4/nagiosgraph-1.4.4.tar.gz [root]$ tar -xzvf nagiosgraph-1.4.4.tar.gz [root]$ cd nagiosgraph-1.4.4
Verify that we have a working environment.
[root]$ ./install.pl --check-prereq
If everything looks good, continue with the install. I think it’s best to keep everything separate from the Nagios install to make upgrades easier.
[root]$ ./install.pl --layout standalone --prefix /usr/local/nagiosgraph
Most of the questions should be left at the default, except the last few. Questions that are not default are emphasized.
Destination directory (prefix)? [/usr/local/nagiosgraph] Location of configuration files (etc-dir)? [/usr/local/nagiosgraph/etc] Location of executables? [/usr/local/nagiosgraph/bin] Location of CGI scripts? [/usr/local/nagiosgraph/cgi] Location of documentation (doc-dir)? [/usr/local/nagiosgraph/doc] Location of examples? [/usr/local/nagiosgraph/examples] Location of CSS and JavaScript files? [/usr/local/nagiosgraph/share] Location of utilities? [/usr/local/nagiosgraph/util] Location of state files (var-dir)? [/usr/local/nagiosgraph/var] Location of RRD files? [/usr/local/nagiosgraph/var/rrd] Location of log files (log-dir)? [/usr/local/nagiosgraph/var] Path of log file? [/usr/local/nagiosgraph/var/nagiosgraph.log] Path of CGI log file? [/usr/local/nagiosgraph/var/nagiosgraph-cgi.log] URL of CGI scripts? [/nagiosgraph/cgi-bin] URL of CSS file? [/nagiosgraph/nagiosgraph.css] URL of JavaScript file? [/nagiosgraph/nagiosgraph.js] Path of Nagios performance data file? [/tmp/perfdata.log] URL of Nagios CGI scripts? [/nagios/cgi-bin] username or userid of Nagios user? [nagios] username or userid of web server user? [www-data] Modify the Nagios configuration? [n] y Path of Nagios configuration file? [/usr/local/nagios/etc/nagios.cfg] Path of Nagios commands file? /usr/local/nagios/etc/objects/commands.cfg Modify the Apache configuration? [n] y
Restart some services.
[root]$ service apache2 restart [root]$ service nagios restart
Graphs can now be accessed here: http://s10-nagios/nagiosgraph/cgi-bin/show.cgi
Template Hacks…err…Integration
The graphs can be integrated into the templates with a couple hacks. They are a bit cringeworthy, but they work.
To activate the pop-up graphs that we will include later, create this file.
[root]$ vim /usr/local/nagios/share/ssi/common-header.ssi
<script type="text/javascript" src="/nagiosgraph/nagiosgraph.js"></script>
To include icons for a specific service, you will need this line in your service definition:
action_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&geom=1000x200' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='/nagiosgraph/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$
I also have a special graph saved for ping tests. I use this to show RTA and packet loss. We are going to utilize both actionurl
and notesurl
for this.
action_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&db=pl,data&db=pl,warn&db=pl,crit&geom=1000x200' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='/nagiosgraph/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&db=pl,data&db=pl,warn&db=pl,crit notes_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&db=rta,data&db=rta,warn&db=rta,crit&geom=1000x200' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='/nagiosgraph/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&db=rta,data&db=rta,warn&db=rta,crit
Since we make use of the notes icon, lets give it the graph icon as well.
[root]$ mv /usr/local/nagios/share/images/notes.gif /usr/local/nagios/share/images/notes.bak.gif [root]$ cp /usr/local/nagios/share/images/action.gif /usr/local/nagios/share/images/notes.gif
Go into your host configuration files and add the graph templates to your service definitions. Only add them to services that are returning performance data.
Here are some example services you can change in the default configuration files.
[root]$ vim /usr/local/nagios/etc/objects/localhost.cfg
Delete the service definition for Current Load
and replace with this.
define service { use local-service host_name localhost service_description Current Load check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0 action_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&geom=1000x200' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='/nagiosgraph/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$ }
Delete the service definition for Ping
and replace with this.
define service { use local-service host_name localhost service_description PING check_command check_ping!100.0,20%!500.0,60% action_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&db=pl,data&db=pl,warn&db=pl,crit&geom=1000x200' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='/nagiosgraph/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&db=pl,data&db=pl,warn&db=pl,crit notes_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&db=rta,data&db=rta,warn&db=rta,crit&geom=1000x200' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='/nagiosgraph/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&db=rta,data&db=rta,warn&db=rta,crit }
Check and restart Nagios.
[root]$ nverify [root]$ service nagios restart
Now reload your Nagios homepage to see the graph icons.
Checkpoint Two
You may have to let Nagios run for about 30 minutes to give the graphs a chance to collect some data.
- Navigate to
http://s10-nagios/nagios
from a computer on the same LAN. - Login using credentials previously specified.
- View the services page, and note that ping and other services should have graph icons next to them.
- Mouseover the icons, confirm that graphs are popping up.
- Click on the icons, verify that you are being led to the page that shows graphs.
Monitoring Nagios / MRTG
So you now have Nagios running to ensure all your servers and gadgets are running as expected. But…how do you know that Nagios is healthy? We should monitor that too! We are going to use MRTG to graph stats about how Nagios is running.
[root]$ apt-get install mrtg
Copy the default config file for Nagios stats.
[root]$ cp ~/nagios-4.0.6/sample-config/mrtg.cfg /usr/local/nagios/etc/ [root]$ mkdir /usr/local/nagios/share/stats
Configure the working directory.
[root]$ vim /usr/local/nagios/etc/mrtg.cfg
Add this to the top.
WorkDir: /usr/local/nagios/share/stats
Make the initial run.
[root]$ env LANG=C mrtg /usr/local/nagios/etc/mrtg.cfg
Configure the HTML page.
[root]$ indexmaker /usr/local/nagios/etc/mrtg.cfg --output=/usr/local/nagios/share/stats/index.html
Create a scheduled cron job to keep the status up to date.
[root]$ vim /etc/cron.d/nagiostats
*/5 * * * * root env LANG=C /usr/bin/mrtg /usr/local/nagios/etc/mrtg.cfg
Checkpoint Three
You may have to let Nagios run for about 30 minutes to give the graphs a chance to collect some data.
- Navigate to
http://s10-nag-01/nagios/stats/
from a computer on the same LAN. - Verify that you see a bunch of pretty graphs.
Nagios Template Tweaks
There are several additions / tweaks that are recommended for a more efficient experience.
Set the default page to the services detail page (may want to limit results or show a different page on a large installation)
[root]$ vim /usr/local/nagios/share/index.php
Find where $corewindow
is defined, and change it to something more useful.
$corewindow="cgi-bin/status.cgi?host=all&limit=0";
Also lets add some links to the sidebar – specifically the graphs.
[root]$ vim /usr/local/nagios/share/side.php
Add this section wherever you see fit.
<div class="navsection"> <div class="navsectiontitle">External Tools</div> <div class="navsectionlinks"> <ul class="navsectionlinks"> <li><a href="/nagios/stats" target="<?php echo $link_target;?>">Nagiostats</a></li> <li><a href="/nagiosgraph/cgi-bin/show.cgi" target="<?php echo $link_target;?>">Nagiosgraph</a></li> </ul> </div> </div>
Conclusion
You now have a working base Nagios install. Now you are off to build your service checks, find more plugins, and tweak your alerts. I can almost feel your anticipation!
Epic! Thanks for taking the time to post.
On the step called “To include icons for a specific service, you will need this line in your service definition: ”
How and where do you do this?
Sorry, I’m a complete ubuntu/linux noob.
That line goes in the service definition. You can add this to any service that passes performance data, like ping.
See this page for more of a detailed explanation on what
action_url
can do.Which service definition? Can you give me an example of how you did it in your setup? For example…
1. Open this with this
2. Add this line here
etc etc.
Thanks…so far your notes are spot on.
Hi Bill – I updated the article with a couple example service definitions. See the section that starts with “Here are some example services you can change in the default configuration files.”
Thanks Andrew that was a big help. I tried adding the action_url lines to Current Load, Current Users, and a few others and when I click on the graph, page loads but I have errors….for example, Current Load shows:
Day, Week, Month, Year all show this in red….
opening ‘/usr/local/nagiosgraph/var/rrd/localhost/Current%20Load___pl.rrd’: No such file or directory.
Did I forget to add something from your instructions?
I really appreciate all your help on this…if you lived in Central Florida, I’d be taking you to World of Beer!
That message means that the Round Robin Databases have not been created yet. That could be caused from a couple different reasons.
– 1st reason can be simply time. The databases are not created until Nagios checks a service and saves the performance data. So once you install Nagiosgraph and restart Nagios, you need to wait for the service checks to run at least once for the graph to be initialized.
– 2nd reason could be incorrect Nagios configuration. Take a peak at
/usr/local/nagios/etc/nagios.cfg
and/usr/local/nagios/etc/objects/commands.cfg
to verify that the Nagiosgraph installer added lines to the end of those files.Lines are there, I’ll just wait and see what comes up…thanks a million Andrew.
Do you have any other Nagios tutorials beyond this?
I do have more Nagios-specific articles that will be posted…eventually. 🙂 I’m glad this one is helpful.
Hmm..still same problem…any ideas Andrew?
Ok, let’s try to follow the data through. First, confirm you have services passing performance data. From the Nagios services page, click on a service (like Ping or Current Load), and make sure there is data in the Performance Data Section.
Next, check to see the file that sits between Nagios and Nagiosgraph.
What this command is doing is watching the contents of this file and automatically updating the screen. If you are only using the default config, there are not many checks happening. So you should only see a line or two appear, and then clear out over a few minutes. This file is a cache where the performance data is stored before being processed by Nagiosgraph.
If this file doesn’t exist or is not ever showing any contents, check /usr/local/nagios/etc/nagios.cfg and verify Nagiosgraph updated the settings. You should see this at the end of the file:
If you are seeing the file size increase, and never clear out, service_perfdata_file_processing_command may not be functioning. Check /usr/local/nagios/etc/objects/commands.cfg and verify this is at the end of the file:
You can also try to run /usr/local/nagiosgraph/bin/insert.pl manually.
Still not working? Check to see if the databases are being created:
You should see a directory for each host passing performance data.
If you are still having trouble, please post the contents of /usr/local/nagios/etc/nagios.cfg and /usr/local/nagios/etc/objects/commands.cfg. Please paste those file into something like pastebin.com and post the links back here. Also, let me know if you have a different setup than what I used in this article, like a different version of Ubuntu.
Let me know the results.
hi andrew, thanks for this great tutorial.. i have a problem though with nagiosgraph:
i get this error message when accessing showconfig.cgi
cannot load ngshared.pm
not found in any of these locations:
/etc/nagiosgraph
/etc/perl
/usr/local/lib/perl/5.14.2
/usr/local/share/perl/5.14.2
/usr/lib/perl5
/usr/share/perl5
/usr/lib/perl/5.14
/usr/share/perl/5.14
/usr/local/lib/site_perl
any help woule be much appreciated!
Something may not have installed correctly. Check out this command I ran on my test machine:
I see the mentioned file in the source folder and the installed location. See if you can find them there. If not, I would run the
install.pl
command again. Verify that you are specifying the--prefix
.did the install with the prefix still the same error with ngshared.pm
although ngshared.pm is located on both places where you mentioned it:
/root/nagiosgraph-1.4.4/etc/ngshared.pm
/usr/local/nagiosgraph/etc/ngshared.pm
Thanks!
also when i access http://localhost/nagiosgraph/cgi-bin/show.cgi
it shows “Internal Server Error”
Ok, lets zoom out a little. Which OS are you attempting to install this on? And is this a fresh install?
If you are getting server error pages, trigger that error again, and check the Apache log file for more details:
If that doesn’t turn up anything, view the file located at
/usr/local/nagiosgraph/cgi/show.cgi
, around line 11. See what directory is in the ‘use lib’ setting and make sure ngshared.pm is in that directory.Also as I’m writing this, I wonder if something like SELinux is getting in your way.
Andrew i will try the steps again on a new install since i’m just setting it up as a vm.. will let you know of any update, i guess too many tutorials i read messed things up.. happy holidays man!
Thx. This is a good post!
hey, thanks for your great guide!
just one little thing: “~/nagios-4.0.1/sample-config/mrtg.cfg” doesn’t exist but i think you mean “~/nagios-4.0.1/sample-config/mrtg.cfg.in”
😉
The .in files are some sort of template. The config files are generated from this template after running this step:
If I list that directory after that step, I see both files:
Look at the contents or both mrtg.cfg and mrtg.cfg.in. The files ending with .in shows variables like @localstatedir@, and the equivalent config file shows the value after the configure run.
Thank you for the tutorial. It was very informative and thorough, it was also nice that you went further by doing some of your own tweaks. I have a request though, think you can do a tutorial for nconf\NRDP\NSClient++
-thanks again
I have been following other tutorials on line and yours is the best by far, THANKS!
I have one issue and I’m hoping you can help me with. this error is coming up:
check_mrtgtraf: Unable to open MRTG log file
This is from the status information for monitoring port bandwidth.
I am running an Ubuntu VM with nagios 4.02.
I have read other threads about this issue and some are saying to install MRTG again but it is working fine.
Anything that can explain this will help.
Thanks
Hi Chris – can you paste in the command that you have for check_mrtgtraf?
I might as well put all the status errors on this post, I checked and the IP is correct, the snmp community string is also correct but I cant seem to get anything to come up.
Does the model of the equipment I’m monitoring matter?
Status for Port 1 Link Status – Unknown:
# Monitor Port 1 status via SNMP
define service{
use generic-service ; Inherit values from a template
host_name Core-Wh-SW
service_description Port 1 Link Status
check_command check_snmp!-C snmp_community -o ifOperStatus.1 -r 1 -m RFC1213-MIB
}
Status for Port 1 Bandwidth Usage – Unknown:
# Monitor bandwidth via MRTG logs
define service{
use generic-service ; Inherit values from a template
host_name Core-Wh-SW
service_description Port 1 Bandwidth Usage
check_command check_local_mrtgtraf!/var/lib/mrtg/192.168.200.2_1.log!AVG!1000000,1000000!5000000,5000000!10
}
Status for Uptime – Critical:
# Monitor uptime via SNMP
define service{
use generic-service ; Inherit values from a template
host_name Core-Wh-SW
service_description Uptime
check_command check_snmp!-C snmp_community -o sysUpTime.0
action_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&geom=1000×200′ onMouseOver=’showGraphPopup(this)’ onMouseOut=’hideGraphPopup()’ rel=’/nagiosgraph/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$
}
Thanks for taking a look.
I see the check_command is pointing to /var/lib/mrtg/192.168.200.2_1.log
In this directory there is no 192.168.200.2_1.log?
Yup, first I would make sure that file path to the log file is correct.
Then, see exactly what command is being ran for “check_local_mrtgtraf”. From the Nagios web interface, left side, click on “Configuration” at the bottom of the list. Select “Commands” and hit Continue. See what the shell command is for check_local_mrtgtraf and replicate that in an SSH session. You might be able to get some more insight as to the error output that way.
check_local_mrtgtraf = $USER1$/check_mrtgtraf -F $ARG1$ -a $ARG2$ -w $ARG3$ -c $ARG4$ -e $ARG5$
I put in the command and received this error:
bash: $/check_mrtgtraf: No such file or directory
$USER1$ points to the plugins directory. To see the path, refer to the file /usr/local/nagios/etc/resource.cfg where $USER1$ is defined. Most likely though, it points to /usr/local/nagios/libexec
So the fill path to the executable is /usr/local/nagios/libexec/check_mrtgtraf but you have arguments. So based on your previous posts, it would look something like this:
/usr/local/nagios/libexec/check_mrtgtraf -F /var/lib/mrtg/192.168.200.2_1.log -a AVG -w 1000000,1000000 -c 5000000,5000000 -e 10
So run that command on your machine, and see if you still get the “file not found” message. If you do, tell me the output of this:
tail /var/lib/mrtg/192.168.200.2_1.log
This is the output of the commands:
lab@ubuntu:/$ sudo /usr/local/nagios/libexec/check_mrtgtraf -F /var/lib/mrtg/192.168.200.2_1.log -a AVG -w 1000000,1000000 -c 5000000,5000000 -e 10
check_mrtgtraf: Unable to open MRTG log file
Usage check_mrtgtraf -F -a -w
-c [-e expire_minutes]
lab@ubuntu:/$ sudo tail /var/lib/mrtg/192.168.200.2_1.log tail: cannot open `/var/lib/mrtg/192.168.200.2_1.log’ for reading: No such file or directory
Yup, that log file you are referring to doesn’t exist. How did you get the path of that log file? If you followed a procedure publicly available, can you link to it?
Are you asking about the procedure I used to install Nagios? I used your set up, which took me a lot farther than other sites.
The path I got from the Nagios web interface, left side I clicked on “Configuration”. Selected “Commands” and hit Continue. I found the command here under check_local_mrtgtraf.
I haven’t used this plugin before, but it seems that check_local_mrtgtraf scans existing log files. Something else has to put them there. MRTG in this article is configured to monitor the Nagios installation only, not switches. There has to be some other setup done by you to enable MRTG to query your switches. This article I found describes creating a configuration file using cfgmaker, and then adding that to the crontab to poll the switch and write that data to a log file. Is this what you are looking for?
Yes, I will give this a try.
Thanks for all of your help.
Great post thanks!
I am also a bit green and am wondering how to move forward from here. We have a bunch of stores that connect to our main office over IPSEC. We want to mainly monitor the router for any downtime at each store. Eg Router A 10.10.1.1, Router B 10.10.2.1, Router C 10.10.3.1 etc.
We just want to see if the connection goes down for any reason and then track history etc, so maybe a simple Ping? How do I add these to monitor.
Thanks,
I would do something like this: http://pastebin.com/5Xz0EpQw
Create a hostgroup, assign a Ping service to that hostgroup, and then create a host for each router. That way you could have graphs with ping times and outages should they ever happen.
Perfect, thanks; everything is now up an running. I am trying to find a way to monitor both the Internal IP’s and External IP’s. Therefore showing if the IPSEC is going down or the Internet as a whole. Wondering if they can be monitored together or do I need to make separate files for the Internal to the External addresses.
I came across this: http://exchange.nagios.org/directory/Plugins/Others/check_multiaddr/details. Great for monitoring Multiple Addresses, but only seems to check one at a time and doesnt really show you which one is down.
Newbie alert !
[root]$ vim ~/.bash_aliases
Cannot create an alias. Please elaborate the process to create the alis in Ubuntu Server 12.0.1.
Thank YOu
I figured out the above reported problem but after configuring the nagiosgraph, when i access it through the webconsole i see below error.
No data in rrd directory /usr/local/nagiosgraph/var/rrd
Please help
Regards
Abdul Wajid
The graph data doesn’t build until the service checks run a couple times. If you still don’t see anything after 20 minutes, double check to make sure the install parameters were entered correctly for the Nagiosgraph installation. Refer to my demo video about 14 minutes in to see what I’m talking about.
A good way to test that would be to take a peak at your Nagios configuration.
If you don’t see the nagiosgraph configuration at the end of that file, then something went wrong in the installation.
Thank you very much. I was able to see the graph but mouseover function is not happening for me.
Any idea?
Make sure you created the file
/usr/local/nagios/share/ssi/common-header.ssi
with content mentioned in the article. Also make sure you have the appropriateaction_url
in the service definitions where you want the graph icons.I have a problem while running below command to get the information through snmp. any idea how can i fix ?
root@nagios:/usr/local/nagios/libexec# ./check_snmp -H 192.168.30.1 -C gpcc -o sysUpTimeInstance
CRITICAL – Plugin timed out while executing system call
Thank You
Are you seeing that timeout message in Nagios or when running the command directly on the command line?
Nagios has a few settings that control how long certain commands (including checks) can run. These settings are located in
/usr/local/nagios/etc/nagios.conf
.This would be your area of interest:
I tried both the ways. From Nagios as well as from the CLI. Same error messag came up on the Web Console as well.
Thanks
Interesting. So it sounds like it’s the actual plugin that’s timing out then and not the Nagios backend.
I ran this to see the help information on the plugin you are using:
I saw that there is a timeout value for this plugin:
Try running the command again specifying a larger timeout value. I modified your earlier command, only adding
-t 60
at the end:Remember that if we increase this timeout to be longer than the Nagios service check timeout, you may still need to change that as well.
Same error :
root@ubuntu:/usr/local/nagios/libexec# ./check_snmp -H 192.168.30.1 -C gpcc -o sysUpTimeInstance -t 60
CRITICAL – Plugin timed out while executing system call
Thanks
How much time does it take for you to see that message? Does it wait the 60 seconds before it times out?
Hi,
Same Error comes up. It takes round three to four minutes if i user -t switch with value 60. Another thing, if i put the wrong hostname then also it pops the same error message.
Any Clue?
Thanks
I would double-check that you have the SNMP settings correct. My best suggestion is to check the SNMP parameters and make sure that SNMP is correctly configured on the device you are querying (whatever is at 192.168.30.1).
Try to remove some variables from the problem and test only the SNMP service on your network device. Instead of using Nagios (for now), try a simple SNMP browser instead, and once you are sure SNMP is working, try it with Nagios again.
Hi,
Recently I installed the nagios 4.0.5 core edition but i am unble to configure email notification, Plz explain in breif how to configure email notification in nagios4 on ununtu 12.04.
Not working!!!!!!!!!!!!
Ok, try it now.
[root]$ /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/conf.d/nagios.conf
This looks wrong in your updated 4.0.6 installation (directory does not exist – just a typo) replace it with:
[root]$ /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/conf-available/nagios.conf
I believe that is an Ubuntu 12.04 / 14.04 difference. Apache was upgraded to 2.4.7 in Ubuntu 14.04, and that changed some things like the conf directories. I will rewrite this article for Ubuntu 14.04 soon.
Not sure. You install the file at /etc/apache2/conf.d but make a link from /etc/apache2/conf-available
This does not match. But i admit I’m not an expert when it comes to Linux. However your guide helped me a lot to install it to 12.04. Now I#m on my way to get it running on 14.04.
Thanks for your work 😉
Oops, you are correct! Thanks for the note. I was attempting to modify this article to be compatible with both Ubuntu 12.04 and 14.04 before I realized the major changes in Apache. I will update that section to /etc/apache2/conf.d. Thanks!
As you add more hosts to nagios?
what is the code and where you add?
Hi Andrew, thank you so much for doing this step-by-step tutorial.
I have a little problem where after i run the “make install-webconf” i get the error message, I proceed by using the solution you gave (/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/conf.d/nagios.conf).
But neither the “install” directory under /usr/bin/ or the “apache2/conf.d” under /etc/ exists.
Ps. this is on a newly installed VM
What version of Ubuntu are you using? Ubuntu 14.04 has Apache2 config in
/etc/apache2/conf-available
. If that is the case, follow this article instead for Ubuntu 14.04.With regards to
/usr/bin/install
not being available, you may have to install thebuild-essential
package.Thank you for the quick respons Andrew
I forgot to mention that its a 14.04 machine and i changed “…/apache2/conf.d…” to “…/apache2/conf-available…” in accordance to Tobias comment on the 14th of May.
This article is targeted to Ubuntu 12.04.
If you are on Ubuntu 14.04, please refer to this guide: http://wellsie.net/p/512/
good morning
please I need your help : to install some prerequisites before installing nagios plugins
I used this cmd ” apt-get install libnet-snmp-perl libperl5.14 libpq5 libradius1 libsensors4 libsnmp-base libsnmp15 libtalloc2 libtdb1 libwbclient0 samba-common samba-common-bin smbclient snmp whois libmysqlclient15-dev libssl-dev” the result was: ” E:unable to locate package libdb1
E:unable to locate package libclient0
E:unable ti locate package smbclients”
Hi Andrew!
Excellent Tutorial! Everything is clear and well explained. I just wanted to add the fact the new Nagios 4.0.7 fixes the problem with install webconf and the error indicated is fixed so needless to replace the script. I had a question for you though. I need some help with a script to monitor game servers with metrics such as number of players and most importantly settting a threshold when a player wins a huge amount. You can get to me back through my email.
Regards
Hi there,
i ám ruuning to some problems trying to get nagiosgraph working :
root@kis13:/home/kis/nagiosgraph-1.5.2# ./install.pl –check-prereq
checking required PERL modules
Carp…1.29
CGI…3.64
Data::Dumper…2.145
Digest::MD5…2.52
File::Basename…2.84
File::Find…1.23
MIME::Base64…3.13
POSIX…1.32
RRDs…1.4007
Time::HiRes…1.9725
checking optional PERL modules
GD…2.46
Nagios::Config… ***FAIL***
checking nagios installation
found nagios exectuable at /usr/local/nagios/bin/nagios
found nagios init script at /etc/init.d/nagios
checking web server installation
found apache executable at /usr/sbin/apache2
found apache init script at /etc/init.d/apache2
please your help .
I tried to ingnore this message but then after the installation when running CPAN for the first time
I get :
Can’t call method “http” on unblessed reference at /usr/share/perl/5.18/CPAN/FirstTime.pm line 1868.