Completely missing nagios.cmd file in Ubuntu 12.04

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
psyllex
Posts: 129
Joined: Thu Dec 20, 2012 2:18 pm

Re: Completely missing nagios.cmd file in Ubuntu 12.04

Post by psyllex »

I can give it all a shot. I ran under sudo -i the entire time which did get me permissions as root the entire time. So I'm not sure that is the problem.

The output on the following command: /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg is

"Nagios Core 3.4.1
Copyright (c) 2009-2011 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 05-11-2012
License: GPL

Website: http://www.nagios.org
Reading configuration data...
Read main config file okay...
Processing object config file '/usr/local/nagios/etc/objects/commands.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/contacts.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/timeperiods.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/templates.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/localhost.cfg'...
Read object config files okay...

Running pre-flight check on configuration data...

Checking services...
Checked 8 services.
Checking hosts...
Checked 1 hosts.
Checking host groups...
Checked 1 host groups.
Checking service groups...
Checked 0 service groups.
Checking contacts...
Checked 1 contacts.
Checking contact groups...
Checked 1 contact groups.
Checking service escalations...
Checked 0 service escalations.
Checking service dependencies...
Checked 0 service dependencies.
Checking host escalations...
Checked 0 host escalations.
Checking host dependencies...
Checked 0 host dependencies.
Checking commands...
Checked 24 commands.
Checking time periods...
Checked 5 time periods.
Checking for circular paths between hosts...
Checking for circular host and service dependencies...
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors: 0"

I did restart apache2 and no go...I'm still getting a configuration error. I will wipe the server again and give it another shot; with the suggestion you made.
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Completely missing nagios.cmd file in Ubuntu 12.04

Post by sreinhardt »

I just noticed sudo stopped about half way through the list of commands and wanted to be sure that it was not run as a standard user. Since the verification of your nagios.cfg works, lets try two things and if you could post the output of the first command.

1) ps aux | grep bin/nagios

2) if there are no nagios processes listed run the previous command /usr/local/nagios/bin/nagios -g /usr/local/nagios/etc/nagios.cfg to get it started.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
psyllex
Posts: 129
Joined: Thu Dec 20, 2012 2:18 pm

Re: Completely missing nagios.cmd file in Ubuntu 12.04

Post by psyllex »

These are the results:

Code: Select all

nagios    1046  0.0  0.0  28932  1168 ?        Ssl  11:35   0:04 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
psyllex   6836  0.0  0.0  13588   872 pts/3    S+   13:30   0:00 grep --color=auto bin/nagios
But when this is the output on the following command:

Code: Select all

psyllex@psyllex-pc:~$ service nagios start
Starting nagios:CONFIG ERROR!  Start aborted.  Check your Nagios configuration.
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Completely missing nagios.cmd file in Ubuntu 12.04

Post by sreinhardt »

My honest guess, and at this point without a fresh OS that's all it is, is that that service is still a remnant from the nagios3 package instead of the install that we want. Unless I missed it, I would highly suggest like you and jsmurphy were talking about, completely start from scratch, OS and all.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
psyllex
Posts: 129
Joined: Thu Dec 20, 2012 2:18 pm

Re: Completely missing nagios.cmd file in Ubuntu 12.04

Post by psyllex »

Just reinstall Ubuntu Server 12.04. Completed a total reinstall of Nagios.

The only variations are on the:

Code: Select all

sudo apt-get install wget install build-essential apache2 php5-gd wget libgd2-xpm libgd2-xpm-dev
libapache2-mod-php5
which I split into 3 commands like I did on the previous versions.

Then on:

Code: Select all

./configure --with-nagios-group=nagios --with-command-group=nagcmd -–with-mail=/usr/bin/sendmail
I ran:

Code: Select all

./configure --with-nagios-group=nagios --with-command-group=nagcmd
and then

Code: Select all

./configure -–with-mail=/usr/bin/sendmail
Everything else was exactly like it was before. Then after receiving a "404" error after installation, I rebooted and received the following message:

Code: Select all

psyllex@psyllex-no2:/tmp$ locate nagios
/usr/share/locale-langpack/en_AU/LC_MESSAGES/nagios-plugins.mo
/usr/share/locale-langpack/en_GB/LC_MESSAGES/nagios-plugins.mo
psyllex@psyllex-no2:/tmp$ service nagios start
Starting nagios:CONFIG ERROR!  Start aborted.  Check your Nagios configuration.

And the following:

Code: Select all

psyllex@psyllex-no2:/etc$ ps aux | grep bin/nagios
nagios     896  0.0  0.0  11504  1072 ?        Ssl  14:05   0:00 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
psyllex   1408  0.0  0.0   4384   816 pts/0    S+   14:12   0:00 grep --color=auto bin/nagios

So I tried http://<my nagios ip>/nagios again after all this and "holy crap" it is up and running!!! So would you like to me completely write out the steps I took again? Just for reference. I'm not sure if anyone else is having this issue.

When I run the previous commands again I now get:

Code: Select all

root@psyllex-no2:~# ps aux | grep bin/nagios
nagios     896  0.0  0.0  11504  1104 ?        Ssl  14:05   0:00 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
root      1557  0.0  0.0   4384   812 pts/0    S+   14:22   0:00 grep --color=auto bin/nagios
root@psyllex-no2:~# service nagios start
Starting nagios:No directory, logging in with HOME=/
 done.
Which is kinda unexpected since they were run only about 3-4 minutes apart.

I will compile my exact steps and post them up here. I am about to try and repeat the process on my other two servers here. So hopefully it isn't a fluke. Please let me know how if there's anything else I can do to help. I need to read up on the config files at this point and then add a plugin for routers which is the eventual end point for the Nagios monitoring.
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Completely missing nagios.cmd file in Ubuntu 12.04

Post by sreinhardt »

Glad to hear its working for you! As for the service error, you probably want to look at the /etc/init.d/nagios file and be sure that it is pointing to the right config file. Otherwise it seems like you've got it working pretty great! Good luck with the other machines!
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
psyllex
Posts: 129
Joined: Thu Dec 20, 2012 2:18 pm

Re: Completely missing nagios.cmd file in Ubuntu 12.04

Post by psyllex »

As I stated before I will post up my exact steps after I finish installing on the other two machines.
Then I need to go into work and install on 14 machines. Lol.

At any rate I appreciate your time and patience.
User avatar
jsmurphy
Posts: 989
Joined: Wed Aug 18, 2010 9:46 pm

Re: Completely missing nagios.cmd file in Ubuntu 12.04

Post by jsmurphy »

That's great to hear! it will be interesting to see what you needed to do to resolve the issue :)
psyllex
Posts: 129
Joined: Thu Dec 20, 2012 2:18 pm

Re: Completely missing nagios.cmd file in Ubuntu 12.04

Post by psyllex »

INSTRUCTIONS FOR RUNNING NAGIOS 3.4.1 ON UBUNTU SERVER 12.04 L.T.S
Alright here's what I did in order to get it running.
I started with a blank Ubuntu 12.04 L.T.S Server that I only installed OpenSSH and Virtual Machine Hosts through the tasksel menu during installation.

Then I followed the instructions as such (when I put a ** by something this is where I deviated a bit from Nagios installation instructions which I will include the link to; it's also a few of the comments above this one. Maybe page 2 or something on this thread.)

**link to nagios instruction set: http://assets.nagios.com/downloads/nagi ... Source.pdf

[from command line]
sudo -i
**had to split up this install command as it wasnt' working the way it was written in the docs
sudo apt-get install wget (this is already installed but just to be careful)
(sudo isn't implicitly necessary but this is the way they wrote them so I just included it; but your running as root with the sudo -i the whole time)
sudo apt-get install build-essential
sudo apt-get install apache2 php5-gd
sudo apt-get install libgd2-xpm libgd2-xpm-dev libapache2-mod-php5


cd /tmp
wget http://prdownloads.sourceforge.net/sour ... 4.1.tar.gz
wget http://sourceforge.net/projects/nagiosp ... .15.tar.gz

useradd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios

tar zxvf nagios-3.4.1.tar.gz
tar zxvf nagios-plugins-1.4.15.tar.gz

cd nagios
**I split up the following into two commands as well, not sure why it worked this way but it did. Make sure to keep the ./configure in both.
./configure --with-nagios-group=nagios --with-command-group=nagcmd
./configure --with-mail=/usr/bin/sendmail


make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf

cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

**After all that you should see something similar to the following:
Nagios Core 3.4.1
Copyright (c) 2009-2011 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 05-11-2012
License: GPL

Website: http://www.nagios.org
Reading configuration data...
Read main config file okay...
Processing object config file '/usr/local/nagios/etc/objects/commands.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/contacts.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/timeperiods.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/templates.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/localhost.cfg'...
Read object config files okay...

Running pre-flight check on configuration data...

Checking services...
Checked 8 services.
Checking hosts...
Checked 1 hosts.
Checking host groups...
Checked 1 host groups.
Checking service groups...
Checked 0 service groups.
Checking contacts...
Checked 1 contacts.
Checking contact groups...
Checked 1 contact groups.
Checking service escalations...
Checked 0 service escalations.
Checking service dependencies...
Checked 0 service dependencies.
Checking host escalations...
Checked 0 host escalations.
Checking host dependencies...
Checked 0 host dependencies.
Checking commands...
Checked 24 commands.
Checking time periods...
Checked 5 time periods.
Checking for circular paths between hosts...
Checking for circular host and service dependencies...
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors: 0

Things look okay - No serious problems were detected during the pre-flight check



**So now you start up Nagios
/etc/init.d/nagios start

**Set a password...this may not work (it hiccuped for me a couple times) so follow the alternate instructions if you don't see "Set password" after you issue the command
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
**OR
**Alternate instructions
cd /usr/local/nagios/etc
htpasswd -c htpasswd.users nagiosadmin


cd /tmp/nagios-plugins-1.4.15
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install

ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios

**At this point you should be done and should be able to use your browser using [http://<your nagios ip>/nagios ] and everything should be running well. But for **myself it didn't work this way. So I did the following

exit

sudo reboot


wait 5-10 mins for it to restart.

**if you try these commands to check if Nagios is running you may get a positive on the first and a definite "Config error" on the service nagios start
ps aux | grep bin/nagios (to check if it's running)
service nagios start (will start nagios)


**But here I then used my browser on my windoz machine and used the command:
http://<your.nagios.server.ip>/nagios

**And at this point is was up and running like a charm
**You can run the ps aux | grep bin/nagios & service nagios start commands now and you will get positives on both of them. I have no idea why it gives negative the first run before and after rebooting but this is how I got it to work on 3 servers using these exact instructions. It may be I just didn't wait long enough. Perhaps some of the Nagios guys can give some feedback on this. Again thank you to jsmurphy & sreighardt who were a great help and very patient with me throughout this process. I will post this up in the Ubuntu forum as I saw more than a few people on there who were having trouble. So hopefully it helps everyone out. :lol:
Locked