Page 2 of 3

Re: Nagios Basics

Posted: Wed Jun 18, 2014 9:49 am
by slansing
You will need to assign a proper IP/FQDNS name to the host so that it's services have a clear address to run their commands against, whatever they are. In this case, it looks like:

Code: Select all

check_proxy_education
check_proxy_google
check_proxy_irishtimes
heck_proxy_webemail
Can you share what the exact commands.cfg definition is for these commands? It's hard to tell exactly what plugin is being ran.

Re: Nagios Basics

Posted: Wed Jun 18, 2014 10:27 am
by Dave-OD
I can ping the object fine from Nagios CLI, and resolves to the correct IP.. but seems to be responding with hostname of the device i copied. Is there somewhere i need to change this?

Thanks again :)

edirlinux:~ # ping webproxy2
PING webproxy2.ad.aib.pri (10.8.1.109) 56(84) bytes of data.
64 bytes from alpwsisc2 (10.8.1.109): icmp_seq=1 ttl=59 time=1.09 ms
64 bytes from alpwsisc2 (10.8.1.109): icmp_seq=2 ttl=59 time=0.838 ms
64 bytes from alpwsisc2 (10.8.1.109): icmp_seq=3 ttl=59 time=0.745 ms
64 bytes from alpwsisc2 (10.8.1.109): icmp_seq=4 ttl=59 time=2.13 ms
64 bytes from alpwsisc2 (10.8.1.109): icmp_seq=5 ttl=59 time=0.842 ms
64 bytes from alpwsisc2 (10.8.1.109): icmp_seq=6 ttl=59 time=0.846 ms
64 bytes from alpwsisc2 (10.8.1.109): icmp_seq=7 ttl=59 time=0.839 ms
64 bytes from alpwsisc2 (10.8.1.109): icmp_seq=8 ttl=59 time=0.719 ms
64 bytes from alpwsisc2 (10.8.1.109): icmp_seq=9 ttl=59 time=0.888 ms
64 bytes from alpwsisc2 (10.8.1.109): icmp_seq=10 ttl=59 time=1.07 ms

Re: Nagios Basics

Posted: Wed Jun 18, 2014 11:48 am
by slansing
Yep, what I was asking for was the command definitions of those commands though, we need to see what they are running.

Re: Nagios Basics

Posted: Thu Jun 19, 2014 7:11 am
by Dave-OD
Here you go...



define command{
command_name check_proxy_google
command_line $USER1$/check_http -H www.google.ie $HOSTADDRESS$ -p 8080 -u http://www.google.ie/ -b somename:xxxxxxx
}


All pretty much the same.. each command i mean!!

Re: Nagios Basics

Posted: Thu Jun 19, 2014 12:49 pm
by slansing
Ahh this might be your problem, you will either need to decide if you want to have a hard coded address in your commands, or for them to dynamically pull the hostaddress to check. You will need to remove one or the other. By default, we recommend using $HOSTADDRESS$ and not hard coding addresses for your services, this way, you can assign them to whatever hosts you want and pull that information automatically, like so:

Code: Select all

define command{
command_name check_proxy_google
command_line $USER1$/check_http -H $HOSTADDRESS$ -p 8080 -u http://www.google.ie/ -b somename:xxxxxxx
}

Re: Nagios Basics

Posted: Mon Jun 30, 2014 5:09 am
by Dave-OD
slansing wrote:Ahh this might be your problem, you will either need to decide if you want to have a hard coded address in your commands, or for them to dynamically pull the hostaddress to check. You will need to remove one or the other. By default, we recommend using $HOSTADDRESS$ and not hard coding addresses for your services, this way, you can assign them to whatever hosts you want and pull that information automatically, like so:

Code: Select all

define command{
command_name check_proxy_google
command_line $USER1$/check_http -H $HOSTADDRESS$ -p 8080 -u http://www.google.ie/ -b somename:xxxxxxx
}
Hi,

Sorry only replying now, ive been on some leave.

So just to try get my head around this setup...

Are commands specified individually within each object? Or on a more global level?

Also when you say hostaddress, you mean fqdn i.e. using DNS?

Re: Nagios Basics

Posted: Mon Jun 30, 2014 9:38 am
by tmcdonald
Commands are *defined* somewhat globally but they are *assigned* on a per-object basis (or by using templates).

$HOSTADDRESS$ is a Nagios macro that will be substituted with the hosts's "address" field, which could be a FQDN, yes.

Re: Nagios Basics

Posted: Tue Jul 08, 2014 8:38 am
by Dave-OD
Thanks guys.. it looks like i have got the commands issue sorted.. :)

Basically now i have ran the same CP command mentioned earlier, to create a new copy of one of my objects, and renamed.

I can see the new objects listed in objects directory on CLI, but Nagios GUI doesnt seem to recognize them.

Other then making a copy of the file is there something else i need to do for Nagios to recognize these new objects?

I have changed the contents of the objects hostname / IP addresses etc.

Re: Nagios Basics

Posted: Tue Jul 08, 2014 10:24 am
by slansing
What directory did you put them in? Have you verified your configs and restarted nagios? Did you also rename the host that you copied, or assign the services you copied to a new host? If not, you will get duplicate config errors when you run:

Code: Select all

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

Re: Nagios Basics

Posted: Tue Jul 08, 2014 10:50 am
by Dave-OD
hi.. and thanks again..

yes in same directory as all objects.. i can see the new nodes listed there..

and yes, verified and restarted service..

yes i renamed the host, and any references to old host within it.. but not done anything further with commands etc. I want the nodes to be pretty much exactly the same regarding commands etc.

Objects created and contents of each:

edirlinux:/usr/local/nagios/etc/objects # ls -lart | grep webproxy
-rwxr-xr-x 1 root root 3038 Jul 8 12:04 webproxy1.cfg
-rwxr-xr-x 1 root root 3049 Jul 8 12:06 webproxy2.cfg

edirlinux:/usr/local/nagios/etc/objects #

edirlinux:/usr/local/nagios/etc/objects # more webproxy1.cfg
define host{
use generic-host ; Name of host template
to use
host_name webproxy1
alias Websense V10000 - webproxy1 (10.8.x.x)
address 10.8.x.x
check_command check-host-alive
process_perf_data 1
max_check_attempts 10
notification_interval 120
notification_period workhours
notification_options d,u,r
}

define service{
use generic-service
host_name webproxy1
service_description http://WWW.GOOGLE.IE
is_volatile 0
check_period workhours
max_check_attempts 5
process_perf_data 1
normal_check_interval 1
retry_check_interval 1
contact_groups admins
notification_interval 120
notification_period workhours
notification_options w,u,c,r
check_command check_proxy_google
}

define service{
use generic-service
host_name webproxy2
service_description http://WWW.IRISHTIMES.COM
is_volatile 0
check_period workhours
max_check_attempts 5
normal_check_interval 1
retry_check_interval 1
process_perf_data 1
contact_groups admins
notification_interval 120
notification_period workhours
notification_options w,u,c,r
check_command check_proxy_irishtimes
}

define service{
use generic-service
host_name webproxy2
service_description WEBSENSE POLICY SERVER: BLOCK WEBEMAIL
is_volatile 0
check_period workhours
max_check_attempts 3
normal_check_interval 1
contact_groups admins
process_perf_data 1
notification_interval 30
notification_period workhours
notification_options w,u,c,r
check_command check_proxy_webemail
}

define service{
use generic-service
host_name webproxy2
service_description WEBSENSE POLICY SERVER: ALLOW EDUCATION
is_volatile 0
check_period workhours
max_check_attempts 3
normal_check_interval 1
process_perf_data 1
retry_check_interval 1
contact_groups admins
notification_interval 30
notification_period workhours
notification_options w,u,c,r
check_command check_proxy_education
}

edirlinux:/usr/local/nagios/etc/objects # more webproxy2.cfg
define host{
use generic-host ; Name of host template
to use
host_name webproxy2
alias Websense V10000 - webproxy2 (10.8.x.x)
address 10.8.x.x
check_command check-host-alive
process_perf_data 1
max_check_attempts 10
notification_interval 120
notification_period workhours
notification_options d,u,r
}

define service{
use generic-service
host_name webproxy2
service_description http://WWW.GOOGLE.IE
is_volatile 0
check_period workhours
max_check_attempts 5
process_perf_data 1
normal_check_interval 1
retry_check_interval 1
contact_groups admins
notification_interval 120
notification_period workhours
notification_options w,u,c,r
check_command check_proxy_google
}

define service{
use generic-service
host_name webproxy2
service_description http://WWW.IRISHTIMES.COM
is_volatile 0
check_period workhours
max_check_attempts 5
normal_check_interval 1
retry_check_interval 1
process_perf_data 1
contact_groups admins
notification_interval 120
notification_period workhours
notification_options w,u,c,r
check_command check_proxy_irishtimes
}

define service{
use generic-service
host_name webproxy2
service_description WEBSENSE POLICY SERVER: BLOCK WEBEMAIL
is_volatile 0
check_period workhours
max_check_attempts 3
normal_check_interval 1
contact_groups admins
process_perf_data 1
notification_interval 30
notification_period workhours
notification_options w,u,c,r
check_command check_proxy_webemail
}

define service{
use generic-service
host_name webproxy2
service_description WEBSENSE POLICY SERVER: ALLOW EDUCATION
is_volatile 0
check_period workhours
max_check_attempts 3
normal_check_interval 1
process_perf_data 1
retry_check_interval 1
contact_groups admins
notification_interval 30
notification_period workhours
notification_options w,u,c,r
check_command check_proxy_education
}

edirlinux:/usr/local/nagios/etc/objects #

I get the following error in verification logs...

Error: Could not find any host matching 'webproxy2' (config file '/usr/local/nagios331/etc/objects/webproxy2.cfg', starting on line 64)
Error: Could not expand hostgroups and/or hosts specified in service (config file '/usr/local/nagios331/etc/objects/webproxy2.cfg', starting on line 64)
Error processing object config files!