Add more services to Nagios Core vers. 4.3.2

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.
michaelpn
Posts: 54
Joined: Fri Jul 14, 2017 12:12 am

Add more services to Nagios Core vers. 4.3.2

Post by michaelpn »

Hi,
I would like to add one service to my Nagios Core vers. 4.3.2 called "Lasernet7 (NetsShare:3288)" that is a service which is made for our employees that sends our letters digitally. This service is installed on our server where I also installed the NSclient.

How do I crate myself a service which is not a part of the Nagios service definition ?

Example from Nagios service definition: https://assets.nagios.com/downloads/nag ... tions.html

define service{
host_name linux-server
service_description check-disk-sda1
check_command check-disk!/dev/sda1
contact_groups linux-admins
}

Above as I wrote is just an example from Nagios object definitions.

But would it be written like that or what do I have to do adding a service from our server services ?
Michael Pierre
Forenede Gruppeliv
2500 Valby
Copenhagen
dwasswa

Re: Add more services to Nagios Core vers. 4.3.2

Post by dwasswa »

Hi @michaelpn,

THIS GUIDE ASSUMES YOU ARE MONITORING SERVICES ON A WINDOWS HOST SINCE YOU MENTIONED NSCLIENT

What do you want to check about the service,do you wish to check its state or...?

However,this is how you can define your service,am going to give you a quick example.

If you go to edit the windows configuration file

Code: Select all

 vi  /usr/local/nagios/etc/objects/windows.cfg
on you nagios server.

The vi command enables you to edit the file.


Go to the service definitions

Code: Select all

###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################


# Create a service for monitoring the version of NSCLient++ that is installed
# Change the host_name to match the name of the host you defined above

define service{
        use                     generic-service
        host_name               winserver
        service_description     NSClient++ Version
        check_command           check_nt!CLIENTVERSION -s "<your password from the nsclient.ini file>"
        }



# Create a service for monitoring the uptime of the server
# Change the host_name to match the name of the host you defined above

define service{
        use                     generic-service
        host_name               winserver
        service_description     Uptime
        check_command           check_nt!UPTIME -s "<your password from the nsclient.ini file>"
        }
# Create a service for monitoring CPU load
# Change the host_name to match the name of the host you defined above

define service{
        use                     generic-service
        host_name               winserver
        service_description     CPU Load
        check_command           check_nt!CPULOAD!-l 5,80,90 -s "<your password from the nsclient.ini file>"
        }



# Create a service for monitoring memory usage
# Change the host_name to match the name of the host you defined above

define service{
        use                     generic-service
        host_name               winserver
        service_description     Memory Usage
        check_command           check_nt!MEMUSE!-w 80 -c 90 -s "<your password from the nsclient.ini file>"
        }



# Create a service for monitoring C:\ disk usage
# Change the host_name to match the name of the host you defined above

define service{
        use                     generic-service
        host_name               winserver
        service_description     C:\ Drive Space
        check_command           check_nt!USEDDISKSPACE!-l c -w 80 -c 90 -s "<your password from the nsclient.ini file>"
        }



# Create a service for monitoring the W3SVC service
# Change the host_name to match the name of the host you defined above

define service{
        use                     generic-service
        host_name               winserver
        service_description     W3SVC
        check_command           check_nt!SERVICESTATE!-d SHOWALL -l W3SVC -s "<your password from the nsclient.ini file>"
        }

# Create a service for monitoring the Explorer.exe process
# Change the host_name to match the name of the host you defined above

define service{
        use                     generic-service
        host_name               winserver
        service_description     Explorer
        check_command           check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe -s "<your password from the nsclient.ini file>"
        }


In your case,if you want to monitor the state your service, this is an example of what you would do. You would add this to the bottom of this windows.cfg under services

Code: Select all

define service{
        use                     generic-service # This is just using a nagios template but can be custom 
        host_name               winserver
        service_description     <your service>
        check_command           check_nt!PROCSTATE!-d SHOWALL -l <your service>.exe -s "<your password from the nsclient.ini file>"
        }

save and close the windows.cfg file. Then restart nagios by running command

Code: Select all

service nagios restart
so that it can apply your configurations.

That was just a quick guide or example but,YES, YOU CAN CREATE YOUR OWN CUSTOM HOST AND SERVICE DEFINITIONS.

So,the documenation..https://assets.nagios.com/downloads/nag ... tions.html you looked at is accurate.
User avatar
tacolover101
Posts: 432
Joined: Mon Apr 10, 2017 11:55 am

Re: Add more services to Nagios Core vers. 4.3.2

Post by tacolover101 »

michaelpn wrote: How do I crate myself a service which is not a part of the Nagios service definition ?
all services in Nagios require service definitions. from there, you can assign a host OR a hostgroup to them.
kyang

Re: Add more services to Nagios Core vers. 4.3.2

Post by kyang »

Thanks @tacolover101!

@michaelpn, Let us know if you have any more questions.
dwasswa

Re: Add more services to Nagios Core vers. 4.3.2

Post by dwasswa »

michaelpn
Posts: 54
Joined: Fri Jul 14, 2017 12:12 am

Re: Add more services to Nagios Core vers. 4.3.2

Post by michaelpn »

Hi dwasswa,

many thanks for your answer it helped. But I have an challenge with your service definition:

first. I have separated host and host groups => windows.cfg and hostgroups.cfg so my example is for host groups service definition. Please see attachment.

# your example

define service{
use generic-service # This is just using a nagios template but can be custom
host_name winserver
service_description <your service>
check_command check_nt!PROCSTATE!-d SHOWALL -l <your service>.exe -s "<your password from the nsclient.ini file>"
}

# my example

# Create a service for monitoring the LASERNET 7 (NetsShare:3288) of the DOCPOINT server
# Change the host_name to match the name of the host you defined above

define service {
use generic-service
host_name DOCPOINT
service_description Lasernet Print Cature 7
check_command check_nt!PROCSTATE!-d SHOWALL -l Lasernet Print Capture 7
}



define service {
use generic-service
host_name DOCPOINT
service_description Lasernet 7 HandleMails:3289
check_command check_nt!PROCSTATE!-d SHOWALL -l Lasernet 7 HandleMails:3289
}

# the above example get following answer from Nagios:

DOCPOINT

Lasernet 7 HandleMails:3289

CRITICAL 09-27-2017 15:12:44 0d 4h 21m 14s 3/3 Lasernet: not running

Lasernet Print Cature 7

CRITICAL 09-27-2017 15:12:57 0d 4h 11m 1s 3/3 Lasernet: not running

# and from the log file:

[1506502964] SERVICE ALERT: DOCPOINT;Lasernet 7 HandleMails:3289;CRITICAL;HARD;3;Lasernet: not running

[1506503337] SERVICE ALERT: DOCPOINT;Lasernet Print Cature 7;CRITICAL;SOFT;1;Lasernet: not running


why ?

I have issue the service "uptime" or "NSClient++" but I think these are also include to commands.cfg. I have attachments you can look at. Maybe it gives you better view:)

- ofcourse I have conrolled that the to services are running on the server :)
Attachments
lasernet Docpoint.odt
(373.69 KiB) Downloaded 218 times
hostgroups.odt
(269.63 KiB) Downloaded 208 times
Michael Pierre
Forenede Gruppeliv
2500 Valby
Copenhagen
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Add more services to Nagios Core vers. 4.3.2

Post by scottwilkerson »

These examples are for processes (sorry dwassa said <your service>.exe)

they would be used for processes.

For services the check_command should look like this

Code: Select all

check_command check_nt!SERVICESTATE!-d SHOWALL -l 'Lasernet Print Capture 7'
Note I also wrapped the service in quotes which will be required
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
dwasswa

Re: Add more services to Nagios Core vers. 4.3.2

Post by dwasswa »

Thanks @scottwilkerson,

Sorry about the mistake @michaelpn,

Code: Select all

<your services>.exe
was a mistake its

Code: Select all

<process>.exe
is the correct one.

What @scottwilkersonmentioned

Code: Select all

check_command check_nt!SERVICESTATE!-d SHOWALL -l 'Lasernet Print Capture 7'
is the correct one for service.


Let me know if you have any questions
michaelpn
Posts: 54
Joined: Fri Jul 14, 2017 12:12 am

Re: Add more services to Nagios Core vers. 4.3.2

Post by michaelpn »

Hi dwasswa,

excellent it works for Lasernet Capture 7 which is a local Service on the Server :)

# my example:
define service {
use generic-service
host_name DOCPOINT
service_description Lasernet Print Cature 7
check_command check_nt!SERVICESTATE!-d SHOWALL -l 'Lasernet Print Capture 7'
}

But for the two others:

# my exeample:
define service {
use generic-service
host_name DOCPOINT
service_description Lasernet 7 NetsShare 3288
check_command check_nt!SERVICESTATE!-d SHOWALL -l 'Lasernet 7 NetsShare:3288'
}

define service {
use generic-service
host_name DOCPOINT
service_description Lasernet 7 HandleMails:3289
check_command check_nt!SERVICESTATE!-d SHOWALL -l 'Lasernet 7 HandleMails:3289'
}

I get this answer:

# my example:

DOCPOINT


Lasernet 7 HandleMails:3289

UNKNOWN 09-28-2017 14:02:44 0d 5h 24m 21s 3/3 Failed to open service Lasernet 7 HandleMails:3289: 1060: The specified service does not exist as an installed service.

Lasernet 7 NetsShare 3288

UNKNOWN 09-28-2017 13:59:20 0d 5h 11m 45s 3/3 Failed to open service Lasernet 7 NetsShare:3288: 1060: The specified service does not exist as an installed service.

The above two examples have a user and a password connected to there service:

Please see the attachment:)

Do I need to an user and password for the "check_command" ?
Attachments
docp account.JPG
Michael Pierre
Forenede Gruppeliv
2500 Valby
Copenhagen
dwasswa

Re: Add more services to Nagios Core vers. 4.3.2

Post by dwasswa »

Hi @michaelpn,

Am glad the solution i gave you worked.

So,for the other two

Code: Select all

define service {
use generic-service
host_name DOCPOINT
service_description Lasernet 7 NetsShare 3288
check_command check_nt!SERVICESTATE!-d SHOWALL -l 'Lasernet 7 NetsShare:3288'
}

define service {
use generic-service
host_name DOCPOINT
service_description Lasernet 7 HandleMails:3289
check_command check_nt!SERVICESTATE!-d SHOWALL -l 'Lasernet 7 HandleMails:3289'
}

you are getting the unknown error because of the

Code: Select all

host_name DOCPOINT
is the same for all three.

So, all you need to do is change host_name for the other two for example, instead of DOCPOINT to

Code: Select all

host_name DOCPOINT_NetsShare 3288
and

Code: Select all

host_name DOCPOINT_HandleMails:3289
Could be anything you want,doesnt have to be the same as in my example;just create host_name that makes sense to you that you can easily remember.

After changing them,just save and close the config file and restart nagios to apply those updates.

For the authentication(username and password),that is something you have to do on on the host on which they are running and in your case windows.

So, just make sure they are already authenticated running and all nagios does is to perform timely checks active or passive and should send you a notification if something goes wrong.

Let me know if you have any questions.
Locked