How to add new service to existing Linux client

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.
Locked
sudz28
Posts: 1
Joined: Tue Mar 23, 2021 8:48 am

How to add new service to existing Linux client

Post by sudz28 »

I'm sure this is a very dumb question with a very obvious answer, yet I've been unable to find it all morning.

I am trying to learn a little Nagios in a new job, and I have a group of Linux clients that all have the "NFS Mountpoints Check" service reporting back in the GUI (showing they are all correctly mounting what is in their /etc/fstab file) - except one. For whatever reason this single Linux client shows all other service/checks, but is missing the NFS Mountpoint Check in the GUI. I've run the command locally on the client without any issue, and manually ran it from the Nagios server successfully, but I can't figure out how to get Nagios to just run it and display it as part of all the other checks it's running? I can't seem to find what is different between those that are correctly showing this check and the one that is not.
My apologies!
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: How to add new service to existing Linux client

Post by mcapra »

Are you restarting the Nagios Core daemon every time you apply configuration changes?

To answer this directly, and say "change this thing", I would need to see your entire set of Nagios object definitions.

Service objects can be associated with specific host objects in one of two ways (three if you count servicegroups but I won't get into that):
  • By defining a specific host the service object is associated with, via the host_name directive of the service object -- this is meant to reference a specific host object. This is a 1-to-1 relationship between a service definition and a host definition.
  • By defining a group of hosts the service object is associated with, via the hostgroup_name directive of the service object -- this is meant to reference a specific hostgroup object. This is a 1-to-1 relationship between a service definition and a hostgroup definition, where a hostgroup definition represents a 1-to-many relationship between the hostgroup and one or more hosts.
One way by which you could assign many of the same service definitions to several hosts, is to first group those hosts into a hostgroup, then within your service definition leverage the hostgroup_name directive. Say I've got a hostgroup that is just named "linux-hosts" like so, which contains 3 individual Linux servers:

Code: Select all


define host {
    host_name	linux-server-1
...
}    

define host {
    host_name	linux-server-2
...
}    

define host {
    host_name	linux-server-3
...
}    

define hostgroup {
    hostgroup_name  linux-hosts
    alias           These be where my Linux hosts are
    members         linux-server-1,linux-server-2,linux-server-3
    ...
}
I can attach a specific service object to all of those hosts simultaneously by simply referencing the hostgroup, rather than having 3 separate service definitions for those 3 separate hosts:

Instead of this:

Code: Select all

define service{
    host_name	linux-server-1
    service_description Check My NFS mounts
    check_command	do_my_nfs_check_command
...
}

define service{
    host_name	linux-server-2
    service_description Check My NFS mounts
    check_command	do_my_nfs_check_command
...
}

define service{
    host_name	linux-server-3
    service_description Check My NFS mounts
    check_command	do_my_nfs_check_command
...
}
We can do this:

Code: Select all

define service{
    hostgroup_name	linux-hosts
    service_description Check My NFS mounts
    check_command	do_my_nfs_check_command
...
}
So, if you're leveraging services tied to specific hosts, you need to create a new copy of the "NFS Mountpoints Check" service for the host that is missing it. If you're leveraging services tied to groups of hosts, you need to include that host in the hostgroup.
Former Nagios employee
https://www.mcapra.com/
Locked