Solved

Nagios adding .cfg file

Posted on 2011-03-03
27
1,045 Views
Last Modified: 2013-11-15
got Nagios 3.2.0 ( i know its old), and trying to add a new host group configuration to seperate out web servers (W3svc) from all my other servers. Everytime I try to make a change to the Nagios.cfg file to add a new object .cfg file to run, the services fail to restart.

I'm pretty much a noob on Nagios and Linux, so any answer has to be really detailed and explicit.

Thanks,
0
Comment
Question by:AHEC
  • 16
  • 10
27 Comments
 
LVL 18

Expert Comment

by:Sanga Collins
Comment Utility
what errors show up when you run the check config command?

/usr/local/bin/nagios -v /usr/local/etc/nagios/nagios.cfg
0
 
LVL 1

Author Comment

by:AHEC
Comment Utility
I don't have anything in usr/local/bin, so there's not nagios anything in there....also wouldn't the second part be -v /usr/local/nagios/etc/nagios.cfg and not etc/nagios/nagios.cfg...at least that is how my file structure is created.

anyway..i ran it verbatim and the command failed, no such file or directory or sonmething like that.
0
 
LVL 18

Expert Comment

by:Sanga Collins
Comment Utility
i used the check config command from my default settings nagios install. if the files are in different directories on your system, you can modify the path accordingly.
0
 
LVL 18

Expert Comment

by:Sanga Collins
Comment Utility
here is the command from the nagios website documentation

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
0
 
LVL 1

Author Comment

by:AHEC
Comment Utility
i ran the command /usr/local/nagios -v /usr/local/nagios/etc/nagios.cfg

and got:

/usr/local/nagios: is a directory

ok...so what??
0
 
LVL 1

Expert Comment

by:marwin79
Comment Utility
Try these commands to find the binary and config:

find / -type f -name nagios 2> /dev/null
find / -type f -name nagios.cfg 2> /dev/null

Now take the output from the first command, space, -v, space, output from second command.
0
 
LVL 1

Author Comment

by:AHEC
Comment Utility
Error: Cannot open resource file 'etc/resource.cfg' for reading!
Error in configuration file '/home/support/downloads/nagios-3.1.2/t/etc/nagios.cfg' Line 450 (Check result path is not a valid directory
Error processing Main config file!

Line 450 in that file reads
check_result_path=var/spool/checkresults

i'm getting really confused on how Nagios was installed on this server. I inherited this server and it didn't have a GUI, and I didn't have permissions to edit the nagios files...so I went thru all this trouble to install desktop, and now i'm using Alt+F2 initiating gksu nautilus to browse to the files to update configs, but where i'm browsing to is /usr/local/nagios/etc and .../etc/objects. Both of these directories have nagios.cfg, and windows.cfg and others...I've been able to edit the windows.cfg file in ...etc/objects  to add new servers and they do show up on the webpage and are being monitored.

anyway...i'm just really confused :) so thanks for the help. I'm thinking to start from scratch, but still want some help figuring this out.
0
 
LVL 18

Expert Comment

by:Sanga Collins
Comment Utility
It does look like alot of config lines are either in the wrong place or somehow corrupted. The correct line 450 for a default nagios config is:

check_result_path=/usr/local/nagios/var/spool/checkresults

Maybe environment variable PATH was setup for /usr/local/nagios/ at some point and is no longer configured correctly. That may explain the strange paths in your configs. Either way keep letting me know what errors you are getting and ill keep trying to find the correction until you are back up and running.

PS a fresh start sounds like a good idea with the default setup from the website quickstart guide.


0
 
LVL 1

Author Comment

by:AHEC
Comment Utility
I'm starting new server,....but once again...

look the instructions tell me to create the nagios user and give it a password:

/usr/sbin/useradd -m -s /bin/bash nagios

passwd nagios

I take these instructions to mean two seperate commands...so i entered

/usr/sbin/useradd -m -s /bin/bash nagios

ENTER

and then tried:

passwd <entered my own password>

Enter...this does not work there is not command passwd...

help...


0
 
LVL 18

Expert Comment

by:Sanga Collins
Comment Utility
yes they are two different commands, but the second command is

passwd nagios


as in set the passwd for the user called nagios :)
0
 
LVL 1

Author Comment

by:AHEC
Comment Utility
ok, i think i got past that part and have finished the setup, but now i get 500 internal server error when trying to log into the web interface.

I believe i may have not understood how to set a password following this command

htpasswd -c /usr/local/nagios/etc/htpasswd.user nagiosadmin

The instructions state only "remember the password you assign to this account - you'll need it later"...but i'm not a linux guy...i dont know how to do this...i wish the instructions were a bit more detailed!!!!
0
 
LVL 1

Author Comment

by:AHEC
Comment Utility
so you know how i can set a pssword for nagiosadmin account for web?
0
 
LVL 1

Author Comment

by:AHEC
Comment Utility
Nevermind...i got it...i re-ran the command and this time it actually asked me to create a password...i did not do the same the first time.
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 18

Expert Comment

by:Sanga Collins
Comment Utility
good to hear. i hope you didnt delete the old /usr/local/nagios/etc/ directory. you can use some of those old configs in the new setup of nagios.

what i like to do is create a directory /usr/local/nagios/etc/configs

and in the nagios.cfg use the setting to specify a 'configuration file directory' All my configs go in there making it easy to back up and move to new instances of nagios or when upgrading :)
0
 
LVL 1

Author Comment

by:AHEC
Comment Utility
OK, so I have a brand new build on Ubuntu 10.10 and i've installed the desktop...cuz i need it...now...in what directory are the .cfg files i need to use to add servers, etc.

my understanding is that the are in /usr/local/nagios/etc and ...etc/objects

but ...please advise
0
 
LVL 18

Accepted Solution

by:
Sanga Collins earned 500 total points
Comment Utility
this is what i do for my nagios setup. I put all the host configs in the hosts dir and then use this line in the config file.


# You can also tell Nagios to process all config files (with a .cfg
# extension) in a particular directory by using the cfg_dir
# directive as shown below:

cfg_dir=/usr/local/nagios/etc/hosts
0
 
LVL 1

Author Comment

by:AHEC
Comment Utility
if i follow the instructions and remove the # in front of
cfg_file=/usr/local/nagios/etc/objects/windows.cfg

iget error:

unexpected start of object definition in <same file i just listed above> line 46

LINE 46 IS A BLANK FCKING LINE...LOL!!!! HELP!!!!!!!
0
 
LVL 1

Author Comment

by:AHEC
Comment Utility
I'M SORRY the line 46 in windows.cfg file is

define hostgroup{

which i did not change...i only added a host and changed the services to look for the defualt hostgroup_name windows-servers

OMG>>>you know...i'm banging my head against the walls!!!
0
 
LVL 18

Expert Comment

by:Sanga Collins
Comment Utility
LOLOL i think its missing a { or } on a defenitiion before.

use the Code link below the comment window and post the whole config. ill take a look at it and see whats missing
0
 
LVL 1

Author Comment

by:AHEC
Comment Utility
If i create a directory "configs" in .../etc, and put the windows.cfg file in there...then in the nagios.cfg file i take away the # sign in front of
cfg_dir=/usr/local/nagios/etc/configs

i get the error...line 46 in the windows.cfg file, it does not like this windows.cfg file!

what am i missing...this is the file created during setup... all i did was add a host, and changed the service defenitions to look at hostgroup_name     windows-servers

0
 
LVL 1

Author Comment

by:AHEC
Comment Utility
thanks for the hint, in my host config the ending } was in line 29 along with IP address, it needed to be in line 30.

ok...i'm making headway!!!!

ok, so now that i've conquered that...here's what I want to do. I want to create a second host-group to seperate non web servers from the rest of my windows servers? first, is this the proper or logical way to do this? and secondly...how would i do this. do i just define a new .cfg file called soemthing like "windowsweb.cfg" and put it in my "configs" directory?

to me...it sounds right...but nothing has worked well for me past couple days :)

thanks for your ongoing help, do you wan't me to start a new question so you can get the points for this one already?
0
 
LVL 1

Author Comment

by:AHEC
Comment Utility
ok, so I think i got it figured out.

If i want to create a new host group, i must also edit the templates.cfg file.

I tried this on my old server without any luck...but on the new one...   :)

thanks again.
0
 
LVL 1

Author Closing Comment

by:AHEC
Comment Utility
Thanks for all your help!
0
 
LVL 18

Expert Comment

by:Sanga Collins
Comment Utility
i saw you had closed the question. wasnt sure if you got it all sorted out or still had some lingering concerns. Either way just let me know.
0
 
LVL 1

Author Comment

by:AHEC
Comment Utility
well...now i'm trying to get notifications set up...cuz this is new, and i'm no linux guy...everything is taking forever....I'm not sure I got it all setup.

I've edited the contacts.cfg file to the same it is on our current nagios server,

i ran sudo apt-get install mailutils (note: mailx failed told me to be more specific)

but i'm still not getting any notifications
0
 
LVL 18

Expert Comment

by:Sanga Collins
Comment Utility
there is a thread that was on E a couple months ago about notifications for nagios in ubuntu. i use centos for my nagios install so sendmail works right out of the box. i will see if ii can find the link to the thread and post it for you.
0
 
LVL 1

Author Comment

by:AHEC
Comment Utility
ok, thanks.

any additional .cfg file editing other than the contacts.cfg?
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article shows how to convert a multi-page PDF file into multiple image files, with one image file created for each page of the PDF. It does this by utilizing an excellent, free software package called GraphicsMagick. The solution is amazingly s…
In this article, you will read about the trends across the human resources departments for the upcoming year. Some of them include improving employee experience, adopting new technologies, using HR software to its full extent, and integrating artifi…
The viewer will learn common shortcuts with easy ways to remember them. The viewer will then learn where to find all of the keyboard shortcuts, how to create/change them, and how to speed up their workflow.
Using Adobe Premiere Pro, the viewer will learn how to set up a sequence with proper settings, importing pictures, rendering, and exporting the finished product.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now