Absolute Nagios beginner - help!

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.
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Absolute Nagios beginner - help!

Post by neworderfac33 »

Good afternoon - please speak slowly and clearly - I never touched VI before today!

I have successfully managed to install Nagios Core on a Linux server.
I have also been able to install the NSClient on two Windows servers running 2008R2 and can see it running as a service in both cases.
I have edited windows cfg and because I have two Windows servers, I have assumed (probably incorrectly) that I need two "define host" sections, which I have set up thus:
define host{
use windows-server ; Inherit default values from a template
host_name MYFIRSTSERVERID ; The name we're giving to this host
alias ; A longer name associated with (there is no alias for this server)
address 99.99.99.99 ; IP address of the host
}

define host{
use windows-server ; Inherit default values from a template
host_name MYSECONDSERVERID; The name we're giving to this host
alias ; A longer name associated with the host (there is no alias for this server either)
address 88.88.88.88 ; IP address of the host
}

I'm not sure if both these should be included in the same set of curly brackets?

Also, I have a "define hostgroup" section, which I'm pretty sure I don't need, and which I'd like to comment out.
I would have thought that the best way to do this would have been to put #s in front of each line, but VI doesn't appear to like that.

Anyway, when I try to verify the configuration file with:

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

I get:

Website: http://www.nagios.org
Reading configuration data...
Read main config file okay...
Error: Invalid hostgroup object directive 'st{'.
Error: Could not add object property in file '/usr/local/nagios/etc/objects/windows.cfg' on line 51.
Error processing object config files!

Line 51 being the "define hostgroup" line.

Sorry if these questions appear really basic, but it seems that the office Nagios expert is someone who has NEVER used Linux before. That's me, that is!

All advice gratefully received and a good weekend to all!

Pete
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Absolute Nagios beginner - help!

Post by tgriep »

Maybe there are some left over characters when you were trying to comment out the hostgroup entry. Try going back in and see if you can see whats wrong and edit the file.
If not, can you post the file?
Be sure to check out our Knowledgebase for helpful articles and solutions!
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Absolute Nagios beginner - help!

Post by ssax »

Welcome aboard Pete, we've all been there, you've come to the right place! :geek:

Please post your hostgroup config section from /usr/local/nagios/etc/objects/windows.cfg (the one you commented out) so we can see why it's failing.
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Re: Absolute Nagios beginner - help!

Post by neworderfac33 »

Good morning - thank you for your replies! :-)

As you will by now gathered, NAGIOS and LINUX are completely new to me, so this may be a long and painful process.

For argument's sake, lets assume that the two servers I need to monitor have IP addresses and names of 1.1.1.1.MYFIRSTSERVER and 2.2.2.2/MYSECONDSERVER

I'm not even sure what a hostgroup is (!), but as these two servers are newly built to test Nagios, I think it's safe to assume that they aren't grouped or linked in any way - this is why I think that the following section needs to be commented out:

define hostgroup{
st{
use windows-server
host_name MYFIRSTSERVER
alias
address 99.99.99.99
}

hostgroup_name windows-servers
alias Windows Servers
}

Also, looking at sections like:
define service{
use generic-service
host_name winserver
service_description CPU Load
check_command check_nt!CPULOAD!-l 5,80,90
}

am I correct in assuming that I'll need a similar section for each server that I need to monitor e.g.

define service{
use generic-service
host_name MYFIRSTSERVER
service_description CPU Load
check_command check_nt!CPULOAD!-l 5,80,90
}

define service{
use generic-service
host_name MYSECONDSERVER
service_description CPU Load
check_command check_nt!CPULOAD!-l 5,80,90
}

or do I need to specify both the servers within the same set of curly brackets for each service?

Thanks in advance for your help!

Pete
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Re: Absolute Nagios beginner - help!

Post by neworderfac33 »

Oh, and when I attempt to comment out the HostGroup section with hashes in VI, I get the message "W10: Warning: Changing a readonly file"

If this is supposed to be a configuration file, how come it's readonly?

See - I TOLD you it was going to be a long process! :lol:

Pete
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Absolute Nagios beginner - help!

Post by tmcdonald »

neworderfac33 wrote:I get the message "W10: Warning: Changing a readonly file"

If this is supposed to be a configuration file, how come it's readonly?
You are probably trying to edit a file with the wrong user. If the file is owned by "nagios" and you are logged in as "neworderfac33", AND the file does not have the "allow other users to edit" permissions, then you will get that message. Check the permissions with ls -l /usr/local/nagios/etc/objects/windows.cfg and post back the results.
neworderfac33 wrote:I'm not even sure what a hostgroup is (!)
It's *basically* a shorthand for a bunch of hosts. So instead of saying "I want to monitor Host A, Host B, Host C, Host D, Host E..." etc., you could put those hosts into a hostgroup and just say "I want to monitor this hostgroup".

neworderfac33 wrote:this is why I think that the following section needs to be commented out:

Code: Select all

define hostgroup{
st{
        use             windows-server
        host_name       MYFIRSTSERVER
        alias           
        address         99.99.99.99    
        }

        hostgroup_name  windows-servers
        alias           Windows Servers
        }
It looks like you deleted part of a line. The st{ looks like it was part of a define host{ header. That should probably be changed to this:

Code: Select all

define host{
        use             windows-server
        host_name       MYFIRSTSERVER
        alias           
        address         99.99.99.99    
        }
define hostgroup{
        hostgroup_name  windows-servers
        alias           Windows Servers
        }
neworderfac33 wrote:Also, looking at sections like:
define service{
use generic-service
host_name winserver
service_description CPU Load
check_command check_nt!CPULOAD!-l 5,80,90
}

am I correct in assuming that I'll need a similar section for each server that I need to monitor e.g.

define service{
use generic-service
host_name MYFIRSTSERVER
service_description CPU Load
check_command check_nt!CPULOAD!-l 5,80,90
}

define service{
use generic-service
host_name MYSECONDSERVER
service_description CPU Load
check_command check_nt!CPULOAD!-l 5,80,90
}

or do I need to specify both the servers within the same set of curly brackets for each service?
You need a separate define host { ... } section for each host you will monitor, basically one for each IP. Then for services, you can either create a duplicate service definition for each host, or you can do something like this:

Code: Select all

define service{
    use generic-service
    host_name MYFIRSTSERVER, MYSECONDSERVER
    service_description CPU Load
    check_command check_nt!CPULOAD!-l 5,80,90
    }
and pass in a list of the hostnames in a comma-separated list.
Former Nagios employee
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Re: Absolute Nagios beginner - help!

Post by neworderfac33 »

That's really useful, thank you - at least now i know how to monitor more than one server! Is there a limit to the number of servers that can be added in this way?

I managed to change the permissions with a local variation of the su command that links into our AD setup, and the read-only issue has now been eliminated, thank you.

My other question at this stage relates to Hostgroups as I'm not really sure what these are or what their purpose is. If I don't think that a hostgroup exists for my particular setup, will it cause any issues to just comment out this section completely?

At the moment I'm getting the following when i attempt to verify:

Error: Could not find any host matching 'MyFirstServer' (config file '/usr/local/nagios/etc/objects/windows.cfg', starting on line 129)
Error: Failed to expand host list 'MyFirstServer' for service 'W3SVC' (/usr/local/nagios/etc/objects/windows.cfg:129)
Error processing object config files!

Line 129 is the first line of the following:

define service{
use generic-service
host_name MyFirstServer, MySecondServer
service_description W3SVC
check_command check_nt!SERVICESTATE!-d SHOWALL -l W3SVC
}

Not sure at the moment if the problem is OU/permissions related, of if my .cfg file needs further work!

Thank you for your patience.

Pete
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Re: Absolute Nagios beginner - help!

Post by neworderfac33 »

OK, here's what I have, with a few more additional service definitions not listed.

The error message I get is:
Reading configuration data...
Read main config file okay...
Error: Invalid hostgroup object directive '{'.
Error: Could not add object property in file '/usr/local/nagios/etc/objects/windows.cfg' on line 23, which is marked "XXXXX" in the listing below.

Error processing object config files!


# HOST DEFINITIONS

define host{
use windows-server
host_name MYFIRSTSERVER
alias
address 99.99.99.99
hostgroups windows-servers
}

define host{
use windows-server
host_name MYSECONDSERVER
alias
address 99.99.99.99
hostgroups windows-servers
}


# HOST GROUP DEFINITIONS

define hostgroup
{ XXXXX
hostgroup_name windows-servers
alias Windows Servers
}

#SERVICE DEFINITIONS

# Create a service for monitoring the version of NSCLient++ that is installed
define service{
use generic-service
#host_name MyFirstServer, MySecondServer
hostgroup_name windows-servers
service_description NSClient++ Version
check_command check_nt!CLIENTVERSION
}

# Create a service for monitoring the uptime of the server
define service{
use generic-service
#host_name MyFirstServer, MySecondServer
hostgroup_name windows-servers
service_description Uptime
check_command check_nt!UPTIME
}

Thanks again for your interest and patience!

Pete
Last edited by neworderfac33 on Mon Jul 27, 2015 11:13 am, edited 2 times in total.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Absolute Nagios beginner - help!

Post by tmcdonald »

peterooney wrote:Reading configuration data...
Read main config file okay...
Error: Invalid hostgroup object directive '{'.
Error: Could not add object property in file '/usr/local/nagios/etc/objects/windows.cfg' on line 23

Error processing object config files!

Code: Select all

# HOST GROUP DEFINITIONS

define hostgroup
{
hostgroup_name  windows-servers
alias           Windows Servers
}
should be

Code: Select all

# HOST GROUP DEFINITIONS

define hostgroup {
hostgroup_name  windows-servers
alias           Windows Servers
}
Also, please use code tags around command line output like I have done in my posts.
Former Nagios employee
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Re: Absolute Nagios beginner - help!

Post by neworderfac33 »

Yes, that sorted it - thank you! The configuration command is now returning no errors.
I can access information for one of my servers in the Nagios screen, but when I tried to schedule a check of the second one, I got:

Error: Could not open command file '/usr/local/nagios/var/rw/nagios.cmd' for update!

This appears to be a permissions issue on the folder containing the file, so I'm off for a Google on how to do this.

Thank you VERY much for your assistance!

By the way, is the syntax for code tags:

Open square bracket "Code" Close square bracket
Open square bracket "Code/" Close square bracket

?

Pete
Locked