What we know is wrong with the Nagios 2.0 docs. Post in this

I’m following the docs for 2.0 and here is what I have found so far.
nagios.sourceforge.net/docs/2_0/toc.html
nagios.sourceforge.net/docs/2_0/installing.html

  1. Last URL above incorrectly states:
    Replace htmurl with the actual url you will be using to access the HTML for the main interface and documentation (default is /nagios/)
    It should read (default is /nagios)

  2. If you are installing nagios 2.0 and don’t want to step on your current install, make sure you copy /etc/rc.d/init.d/nagios to /etc/rc.d/init.d/nagios1.2 before you install 2.0. Of course, change the nagios 2.0 install prefix to nagios2 with the ./configure --prefix=/usr/local/nagios2 switch.
    Here is my configure settings.
    ./configure --prefix=/usr/local/nagios2 --with-cgiurl=/nagios2/cgi-bin --with-htmurl=/nagios2 --with-command-group=nagcmd

To keep you current nagios 1.2 running while you test nagios2.0
cp /etc/rc.d/init.d/nagios /etc/rc.d/init.d/nagios1.2
install nagios 2.0 and after you run make install-init
cp /etc/rc.d/init.d/nagios /etc/rc.d/init.d/nagios2.0
cp /etc/rc.d/init.d/nagios1.2 /etc/rc.d/init.d/nagios
Now you have both init scripts but nagios 1.2 will be the one to autostart upon boot. Change appropriately when you are happy with 2.0.
cp /etc/rc.d/init.d/nagios2.0 /etc/rc.d/init.d/nagios and reboot.

  1. The docs say to run make all, make install, make install-init. What they don’t say is to run make install-commandmode which configures your external command file folder and make install-config which installs sample config files plus creates the nagios/etc directory.

That is the end of the install portion, now on to configuring problems.

  1. nagios.sourceforge.net/docs/2_0/installweb.html incorrectly states;
    ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin
    <Directory “/usr/local/nagios/sbin”>
    it should be:
    ScriptAlias /nagios/cgi-bin/ /usr/local/nagios/sbin/
    <Directory “/usr/local/nagios/sbin/”>

  2. Instead of editing your httpd.conf file, most apache installs now have another method of making such changes.
    /etc/httpd/ may have a folder called conf.d. In that folder are several files.
    Create a new file named nagios.conf, or in my case nagios2.conf and make the suggested changes per the docs.
    ScriptAlias /nagios2/cgi-bin/ /usr/local/nagios2/sbin/

<Directory “/usr/local/nagios2/sbin/”>
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios2/etc/htpasswd.users
Require valid-user

Alias /nagios2/ /usr/local/nagios2/share/

<Directory “/usr/local/nagios2/share/”>
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios2/etc/htpasswd.users
Require valid-user

Copy your /usr/local/nagios/etc/htpasswd.users to /usr/local/nagios2/etc/htpasswd.users and save yourself some work.
restart apache
3. The nagios.sourceforge.net/docs/2_0/cgiauth.html looks good so you should now be able to login and authenticate with no trouble. That is of course, if you followed the docs and made the above corrections.

  1. Whoops! message is what you see, but of course, we haven’t started nor even configured nagios yet.

Edited ]

This begins configuring the nagios.cfg file and preps you for configuring the object config files.

Although the docs don’t explicitely state it might be helpful for others.

  1. The out of the box sample configs can cause you trouble.
    cp nagios.cfg-sample nagios.cfg
    vi nagios.cfg
    Notice it states cfg_file=/usr/local/nagios2/etc/checkcommands.cfg and cfg_file=/usr/local/nagios2/etc/minimal.cfg
    So you would assume they want you to cp minimal.cfg-sample minimal.cfg and cp checkcommands.cfg-sample checkcommands.cfg right? Well, if you do, then you will have checkcommands like check-host-alive defined more than once. I would suggest to
    vi nagios.cfg and comment out the minimal.cfg line and uncomment the others below it.
    #cfg_file=/usr/local/nagios2/etc/minimal.cfg

cfg_file=/usr/local/nagios2/etc/contactgroups.cfg
cfg_file=/usr/local/nagios2/etc/contacts.cfg
cfg_file=/usr/local/nagios2/etc/dependencies.cfg
cfg_file=/usr/local/nagios2/etc/escalations.cfg
cfg_file=/usr/local/nagios2/etc/hostgroups.cfg
cfg_file=/usr/local/nagios2/etc/hosts.cfg
cfg_file=/usr/local/nagios2/etc/services.cfg
cfg_file=/usr/local/nagios2/etc/timeperiods.cfg
cfg_file=/usr/local/nagios2/etc/hostextinfo.cfg
cfg_file=/usr/local/nagios2/etc/serviceextinfo.cfg

cp cgi.cfg-sample cgi.cfg
cp checkcommands.cfg-sample checkcommands.cfg
cp misccommands.cfg-sample misccommands.cfg
cp resource.cfg-sample resource.cfg
The rest of the cfg files that are not created for you, will have to be copy/paste from minimal.cfg-sample or bigger.cfg-sample to, for example, timeperiods.cfg.
Does that make sense? copy/paste? OK, I’m sure you got it.

vi nagios.cfg and change
check_external_commands=0 to a 1, unless of course, you don’t want to.
others that I personally changed from default are shown below as to how i have them set.
use_syslog=0
log_notifications=0
log_service_retries=0
log_host_retries=0
log_event_handlers=0
log_external_commands=0
log_passive_checks=0
max_service_check_spread=5 ; I haven’t tested this yet, but it seems to me, that I would want all my services checked(upon startup) within interval_length x normal_check_interval which in my case is 5 minutes.
check_for_orphaned_services=1

This ends configuring the nagios.cfg file and preps you for configuring the object config files.

I don’t know if this is stated in the docs or not, but I know another area of confusion is when people uncomment lines for things like escalations and dependencies, but leave the files blank and Nagios errors out. I can’t remember if the docs state that Nagios will error out if any of the config files to which nagios.cfg points are empty.

Just for kicks, I am
cp /usr/local/nagios/etc/checkcommands.cfg /usr/local/nagios2/etc/checkcommands.cfg
cp /usr/local/nagios/etc/contactgroups.cfg /usr/local/nagios2/etc/contactgroups.cfg
cp /usr/local/nagios/etc/contacts.cfg /usr/local/nagios2/etc/contacts.cfg
cp /usr/local/nagios/etc/dependencies.cfg /usr/local/nagios2/etc/dependencies.cfg
cp /usr/local/nagios/etc/escalations.cfg /usr/local/nagios2/etc/escalations.cfg
cp /usr/local/nagios/etc/hostgroups.cfg /usr/local/nagios2/etc/hostgroups.cfg
cp /usr/local/nagios/etc/hosts.cfg /usr/local/nagios2/etc/hosts.cfg
cp /usr/local/nagios/etc/services.cfg /usr/local/nagios2/etc/services.cfg
cp /usr/local/nagios/etc/timeperiods.cfg /usr/local/nagios2/etc/timeperiods.cfg
cp /usr/local/nagios/etc/hostextinfo.cfg /usr/local/nagios2/etc/hostextinfo.cfg
cp /usr/local/nagios/etc/serviceextinfo.cfg /usr/local/nagios2/etc/serviceextinfo.cfg
cp /usr/local/nagios/etc/resource.cfg /usr/local/nagios2/etc/resource.cfg
I had to edit resource.cfg and take out all the mysql stuff I had in there.

To save some more time, I thought we might be able to just copy the plugins over from the old to the new. Sorry, can’t do it.

cd ~/src/nagios-plugins-1.4.2
make clean
./configure --help
-./configure --prefix=/usr/local/nagios2 --with-cgiurl=/nagios2/cgi-bin
make
make install
The libexec directory has now been created for you and the plugins installed. Permissions are WRONG on the directory and files in it.
cd /usr/local/nagios2
chown -R nagios.nagios libexec/
chmod -R 775 libexec/

We are now ready to test the configs and see what directives nagios is going to puke on from copiing from 1.2 .cfg’s to 2.0 version of nagios.

/usr/local/nagios2/bin/nagios -v /usr/local/nagios2/etc/nagios.cfg
Doesn’t like contact_groups in the hostgroups.cfg so remove them.
Doesn’t like gd2_image in the hostextinfo.cfg so remove/replace with statusmap_image
vi /usr/local/nagios2/etc/hostextinfo.cfg
hit esc :
then enter
%s/gd2_image/statusmap_image/g
to make a global search/replace of gd2_image with statusmap_image
In nagios 1.2 you could have gd2_image blank, but in 2.0 it appears you have to have it defined, so either comment/remove them, or define them.
So, in my case I needed to run this search/replace, since mine where all undefined.
%s/gd2_image/statusmap_image unknown.gif/g

In nagios 2.0 you can’t have host_name definitions in serviceextinfo.cfg that are not in hosts.cfg, unlike 1.2 which was forgiving in this error.

For V 2.0 hosts.cfg must have contact_groups defined for each host, max_check_attempts must be defined, check_period also.

services.cfg must have a contact_groups defined, although the verify does not complain about it. Nagios will run without it though. Note: the docs clearly show that this is required. I’m simply pointing out the differences and oddities that I notice.

That’s all I have for now. Add anything comments, corrections, etc.

yes, I pointed that out in one of my files. In V1.2 nagios didn’t care that the directive was blank, but nagios 2.0 pitched a fit.

In conclusion, if you are a first time installer of nagios, there will be only 2 or 3 items that are show stoppers. If you follow the docs and read this thread, then you should now be running nagios 2.0 with no trouble.

If converting to V2.x from V1.x or even simply attempting to use nagiostat(a rrd graphing utility that is NOT included with Nagios. i.e. not to be confused with the new nagiostats utility) there will be many macros that you need to be aware of.
Edit nagiostat file and change all occurances of:
$LASTCHECK to $LASTSERVICECHECK
$OUTPUT to $SERVICEOUTPUT
$PERFDATA to $SERVICEPERFDATA

Any scripts that you made personally, may be affected, so you should read through:
nagios.sourceforge.net/docs/2_0/macros.html

PS, remember to change your service_perfdata_command that you have defined. It should look something like this in misccomands.cfg
efine command {
command_name service-perf-data-handler
command_line /usr/local/nagios/nagiostat/nagiostat -p “$LASTSERVICECHECK$|!!|$HOSTNAME$|!!|$SERVICEDESC$|!!|$SERVICESTATE$|!!|$SERVICEOUTPUT$|!!|$SERVICEPERFDATA$”
}

I added to nagios.cfg:
cfg_file=/usr/local/nagios2/etc/servicegroups.cfg
then created the file and added directives to it, so that services can be grouped just like hosts can be.
define servicegroup{
servicegroup_name servicegroup_name
alias alias
members members
}
Instead of adding members to this file( I have over 500 fpings), I left the members directive out of the file and added the servicegroups directive to each service in services.cfg It’s much easier that way, since I have a service template for any services that have VERY VERY many hosts with the same service check.
Also, it’s easier to add “servicegroups servicegroup_name” to the services.cfg file that to add a “host,service description” to the servicegroups.cfg file This is no easy task, when you have over 1200 services".

The nagios docs show that many macro’s have been removed/replaced.
One in particular is:
$DATETIME$ from V1.x has been replaced with $LONGDATETIME$ and/or $SHORTDATETIME$
The problem is that in the notify by email command from the minimal.cfg had $LONGDATETIME$ in the command definition, and I replaced it with $SHORTDATETIME$. Having the “short” in there blew up the rest of the command output.

So, it appears to me, that the macro $SHORTDATETIME$ does not work. Will someone verify this please?

Not only that, but minimal.cfg should NOT have had the command defined such as it is below. The reason is because $OUTPUT$ is no longer valid, It has been replaced with $HOSTOUTPUT$ and/or $SERVICEOUTPUT$ WTF is this about? Doesn’t anyone check these configs before they release it as a “STABLE RELEASE?”

define command{
command_name notify-by-email
command_line /usr/bin/printf “%b” “***** Nagios ***\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $SHORTDATETIME$\n\nAdditional Info:\n\n$OUTPUT$" | /bin/mail -s " $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **” $CONTACTEMAIL$
}

nagios -m as documented under “Using the Embedded Perl Interpreter” (page 161) does not work. It is supposed to indicate (among other things) whether the interpreter has been compiled in.

As I can see in changelog for version 2.0:
Changes since 2.0rc2 include:

  • Fix for segfault in timed event queue
    *** Removed length limitations for object vars/vals**
  • Updated config.sub and config.guess to versions from automake-1.9
  • Doc updates

but in real the limitations are still exists :frowning: not only in Web GUI, I can see in log files that output is truncated.

Nagiosmap is used to help create a hostextinfo.cfg file. Using it with nagios v1.x it would make an entry like this:
define hostextinfo {
host_name somehostname
icon_image unknown.gif
gd2_image unknown.gd2
2d_coords 3200,50
}
gd2_image is the image displayed in the status map, and corresponds to the 1.x documentation of statusmap_image.

In V1.x the above worked just fine, but in V2.x gd2_image will not be accepted and nagios won’t start. So, before you use nagiosmap in V2.x you will have to edit the nagiosmap.pl script and replace each occurrence of gd2_image with statusmap_image.

I’m adding this just in case I didn’t point it out earlier in this thread.
The .cfg-sample files installed my nagios have errors. Just one of them is this.
In the nagios.cfg-sample is this:
cfg_file=/usr/local/nagios/etc/checkcommands.cfg
cfg_file=/usr/local/nagios/etc/minimal.cfg

Problem is that check-host-alive is a command that is defined in BOTH of the above config files, so nagios will error out and not start. Use the -v option to start nagios, and you will see that it complains about check-host-alive. So, I’d suggest to get rid of the minimal config file and create your hosts services, and so on.

Your nagios.cfg should end up looking like this:
cfg_file=/usr/local/nagios/etc/checkcommands.cfg
cfg_file=/usr/local/nagios/etc/misccommands.cfg
#cfg_file=/usr/local/nagios/etc/minimal.cfg # NOTE: THIS IS COMMENTED

cfg_file=/usr/local/nagios/etc/contactgroups.cfg
cfg_file=/usr/local/nagios/etc/contacts.cfg
cfg_file=/usr/local/nagios/etc/dependencies.cfg
cfg_file=/usr/local/nagios/etc/escalations.cfg
cfg_file=/usr/local/nagios/etc/hostgroups.cfg
cfg_file=/usr/local/nagios/etc/servicegroups.cfg
cfg_file=/usr/local/nagios/etc/hosts.cfg
cfg_file=/usr/local/nagios/etc/services.cfg
cfg_file=/usr/local/nagios/etc/timeperiods.cfg
cfg_file=/usr/local/nagios/etc/hostextinfo.cfg
cfg_file=/usr/local/nagios/etc/serviceextinfo.cfg

#!/usr/bin/perl -w

open(FILEHANDLE,“hosts.cfg”);

while(){

            print;
    if ($_ =~ 'notifications_enabled') {
            print "    contact_groups          rrbcgroup ;\n";
    }

}

A simple perl script to fix your hosts.cfg file if you didn’t have contact_groups for each host, and had them in hostgroup.cfg instead. like me.

one liner like: perl test.pl > newhosts.cfg

I know a few people that had to change all their hosts, manually :?

If someone can prove me wrong, the nagios v2.x docs don’t include this when setting up web authentication.

The second step is to create a file named .htaccess in the root your CGI directory (and optionally also you HTML directory) for Nagios (usually /usr/local/nagios/sbin and /usr/local/nagios/share, respectively). The file(s) should have contents similiar to the following…

AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
require valid-user

some more things i have found…:

i copied my 1.2 config to my V2 server and had to change the following in the nagios.cfg:

line 259:

change log_passive_service_checks

to log_passive_checks

line 291:

change inter_check_delay_method

to service_inter_check_delay_method

Also, the docs state:
nagios.sourceforge.net/docs/2_0/ … l#cfg_file
Format: object_cache_file=<file_name>
Example: object_cache_file_file=/usr/local/nagios/var/objects.cache
Which should read:
Format: object_cache_file=<file_name>
Example: object_cache_file=/usr/local/nagios/var/objects.cache