Help configure custom plugin under Nagios Core

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.
gmills
Posts: 114
Joined: Wed Jun 12, 2019 2:08 pm

Help defining plugin in Nagios Core

Post by gmills »

Hello and thank you in advance!

I have created a plugin linux shell script for checking the status of AWS cloud services. however, I am confused in defining the host for the service.

it works like this.. pass it the token URL and the api URL to check.

./check_api_cloud_service.sh -t https://a8a2ffc4-b04e-4ec1-bfed-7a51dd4 ... auth/token -s https://ims-ums-case-reporting-preprod. ... .io/health

Usage: ./check_api_cloud_service.sh -t Access_Token_URL -s Service_API_URL

the commands.cfg
# Custom plugins commands...
define command{
command_name check_api_cloud_service
command_line $USER1$/check_api_cloud_service.sh -t $ARG1$ -s $ARG2$
}

#Case reporting service
define service{
use generic-service
host_name
service_description Job MGMT Service
check_command check_api_cloud_service!https://a8a2ffc4-b04e-4ec1-bfed-7a51dd4 ... .io/health!
notifications_enabled 0
}

I do not know how to define the host definition because there really isn't a host, as it is passed as parameter?
can I define a host without an address?
sorry I'm still new to Nagios and this is my first plugin.

my plugin is attached.
Attachments
check_api_cloud_service.sh
my first plugin
(3.16 KiB) Downloaded 157 times
gmills
Posts: 114
Joined: Wed Jun 12, 2019 2:08 pm

Help configure custom plugin under Nagios Core

Post by gmills »

Hello and thank you in advance! I did also asked this question on the Plugin developement forum but not sure about response on that forum.

I have created a plugin linux shell script for checking the status of AWS cloud services. however, I am confused in defining the host for the service.

it works like this.. pass it the token URL and the api URL to check.

./check_api_cloud_service.sh -t https://a8a2ffc4-b04e-4ec1-bfed-7a51dd4 ... auth/token -s https://ims-ums-case-reporting-preprod. ... .io/health

Usage: ./check_api_cloud_service.sh -t Access_Token_URL -s Service_API_URL

the commands.cfg
# Custom plugins commands...
define command{
command_name check_api_cloud_service
command_line $USER1$/check_api_cloud_service.sh -t $ARG1$ -s $ARG2$
}

#Case reporting service
define service{
use generic-service
host_name
service_description Job MGMT Service
check_command check_api_cloud_service!https://a8a2ffc4-b04e-4ec1-bfed-7a51dd4 ... .io/health!
notifications_enabled 0
}

I do not know how to define the host or service definitions because there really isn't a host, as it is passed as parameter?
can I define a host without an address? can you suggest how I can achieve this? thank you !!

sorry I'm still new to Nagios ( always finding something I don't know about ) and this is my first plugin.

my plugin is attached.
Attachments
check_api_cloud_service.sh
my custom plugin
(3.16 KiB) Downloaded 155 times
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Help defining plugin in Nagios Core

Post by scottwilkerson »

You need to create a host definition, even if it is a dummy host that is going to hold these services.

All services need to be assigned to a host

You could use localhost if you have that defined already
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: Help configure custom plugin under Nagios Core

Post by lmiltchev »

This is how you define a host:

https://assets.nagios.com/downloads/nag ... .html#host

If you had a host config as such:

Code: Select all

define host {
	host_name	myhost
	...
}
then you service config would be:

Code: Select all

#Case reporting service
define service{
use generic-service
host_name	myhost
service_description Job MGMT Service
check_command check_api_cloud_service!https://a8a2ffc4-b04e-4ec1-bfed-7a51dd408725-uaa.run.aws-usw02-pr.ice.io/oauth/token!https://ims-ums-job-management-preprod.run.aws-usw02-pr.ice.io/health!
notifications_enabled 0
}
Be sure to check out our Knowledgebase for helpful articles and solutions!
gmills
Posts: 114
Joined: Wed Jun 12, 2019 2:08 pm

Re: Help configure custom plugin under Nagios Core

Post by gmills »

thank you! let me give this a try.
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: Help configure custom plugin under Nagios Core

Post by lmiltchev »

Sure, let us know if you have any further questions.
Be sure to check out our Knowledgebase for helpful articles and solutions!
gmills
Posts: 114
Joined: Wed Jun 12, 2019 2:08 pm

Re: Help configure custom plugin under Nagios Core

Post by gmills »

hey, I'm sorry, I'm just getting back to my Nagios, was pulled off for a bit.

looks like I still need your help :). thank you

I am able to get the host defined and is on the Nagios Web console. but, I can't get services associated with the new host. I know I'm doing something wrong.

I made new templates
TEMPLATE.cfg
define host {

name cloud-hosting ; The name of this host template
use generic-host ; This template inherits other values from the generic-host template
check_period 24x7 ; By default, Linux hosts are checked round the clock
check_interval 5 ; Actively check the host every 5 minutes
retry_interval 1 ; Schedule host check retries at 1 minute intervals
max_check_attempts 10 ; Check each Linux host 10 times (max)
check_command check-host-alive ; Default command to check Linux hosts
notification_period workhours ; Linux admins hate to be woken up, so we only notify during the day
; Note that the notification_period variable is being overridden from
; the value that is inherited from the generic-host template!
notification_interval 60 ; Resend notifications every 2 hours
notification_options d,u,r ; Only send notifications for specific host states
contact_groups cloud-group ; Notifications get sent to the admins by default
register 0 ; DON'T REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
}

SERVICE TEMPLATE
define service {

name generic-cloud-service ; The 'name' of this service template
active_checks_enabled 1 ; Active service checks are enabled
passive_checks_enabled 1 ; Passive service checks are enabled/accepted
parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major performance problems)
obsess_over_service 1 ; We should obsess over this service (if necessary)
check_freshness 0 ; Default is to NOT check service 'freshness'
notifications_enabled 1 ; Service notifications are enabled
event_handler_enabled 1 ; Service event handler is enabled
flap_detection_enabled 1 ; Flap detection is enabled
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across program restarts
retain_nonstatus_information 1 ; Retain non-status information across program restarts
is_volatile 0 ; The service is not volatile
check_period 24x7 ; The service can be checked at any time of the day
max_check_attempts 3 ; Re-check the service up to 3 times in order to determine its final (hard) state
check_interval 10 ; Check the service every 10 minutes under normal conditions
retry_interval 2 ; Re-check the service every two minutes until a hard state can be determined
contact_groups cloud-group ; Notifications get sent out to everyone in the 'admins' group
notification_options c,r ; Send notifications about warning, unknown, critical, and recovery events
notification_interval 60 ; Re-notify about service problems every hour
notification_period 24x7 ; Notifications can be sent out at any time
register 0 ; DON'T REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
}

define service {

name local-cloud-service ; The name of this service template
use generic-cloud-service ; Inherit default values from the generic-service definition
max_check_attempts 4 ; Re-check the service up to 4 times in order to determine its final (hard) state
check_interval 5 ; Check the service every 5 minutes under normal conditions
retry_interval 1 ; Re-check the service every minute until a hard state can be determined
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
}

HOSTS.cfg

define host{
name cloud-box ; Name of this template
use cloud-hosting ; Inherit default values
check_period 24x7
check_interval 5
retry_interval 1
max_check_attempts 10
check_command check-host-alive
notification_period 24x7
notification_interval 30
notification_options d,r
contact_groups cloud-group
process_perf_data 1
retain_nonstatus_information 0
register 0 ; DONT REGISTER THIS - ITS A TEMPLATE
}

define host{
use cloud-box ; Inherit default values from a template
host_name api-hosting ; The name we're giving to this server
alias API Services server ; A longer name for the server
address 127.0.0.1 ; dummy ping
}

The HOST is a dummy, the plugin calls AWS AZure cloud environments.

SERVICES.cfg
#Job reporting service
define service{
use local-cloud-service
host_name api-hosting
service_description Job MGMT Service
check_command check_api_cloud_service!https://a8a2ffc4-b04e-4ec1-bfed-7a51dd4 ... .io/health!
notifications_enabled 0
}
#Case reporting service
define service{
use local-cloud-service
host_name api-hosting
service_description Case Reporting Service
check_command check_api_cloud_service!https://a8a2ffc4-b04e-4ec1-bfed-7a51dd4 ... .io/health!
notifications_enabled 0
}

With this I can not get the services associated with the Host? what am I doing wrong? thank you!!!
gmills
Posts: 114
Joined: Wed Jun 12, 2019 2:08 pm

Re: Help configure custom plugin under Nagios Core

Post by gmills »

logs show the host api-hosting is OK.

Making callbacks (type 1)...
[1582056154.379889] [008.0] [pid=29279] ** Timed Event ** Type: EVENT_HOST_CHECK, Run Time: Tue Feb 18 15:02:34 2020
[1582056154.379893] [008.0] [pid=29279] ** Host Check Event ==> Host: 'api-hosting', Options: 0, Latency: 0.000327 sec
[1582056154.379901] [001.0] [pid=29279] run_scheduled_host_check()
[1582056154.379904] [016.0] [pid=29279] Attempting to run scheduled check of host 'api-hosting': check options=0, latency=0.000327
[1582056154.379948] [2320.2] [pid=29279] Raw Command Input: $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5
[1582056154.379951] [2320.2] [pid=29279] Expanded Command Output: $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5

Using Ping to localhost 127.0.0.1
gmills
Posts: 114
Joined: Wed Jun 12, 2019 2:08 pm

Re: Help configure custom plugin under Nagios Core

Post by gmills »

I'm getting error indicating no services available for this host, but, I think they are configured?


API-Services Group (API-Services)
Host Status Services Actions
api-hosting UP No matching services
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Help configure custom plugin under Nagios Core

Post by scottwilkerson »

Is SERVICES.cfg added as an included file in your nagios.cfg?
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked