Template to carryout service check once every 4 seconds

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

Template to carryout service check once every 4 seconds

Postby kaushalshriyan » Fri Jul 12, 2019 9:05 am


Is there a way to create a template to carry out service check once every 4 seconds with changing check_interval in /usr/local/nagios/etc/nagios.cfg

Code: Select all
define service{
        name                            check_api_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 4 times in order to determine its final (hard) state
        check_interval              15         ; Check the service once in every 24 hours under normal conditions
        retry_interval              3         ; Re-check the service once in every 6 hours until a hard state can be determined
        contact_groups                  admins         ; Notifications get sent out to everyone in the 'admins' group
   notification_options      w,u,c,r         ; Send notifications about warning, unknown, critical, and recovery events
        notification_interval           0         ; Re-notify about service problems every hour
        notification_period             24x7         ; Notifications can be sent out at any time
        register                        0             ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!

My nagios nrpe client plugin

Code: Select all
str1=$(/usr/lib/nagios/plugins/check_http -H 'api.example.com' -S -k 'Host: api.example.com' -p 8443 -j GET -a 'username:password' -u '/services/customer/customerdata/getoperator/v5?domain=B2B&lob=Mobility&consumerTransactionId=Monitoring&consumerName=appuser&programmeName=OperatorInfo&id=9729471303&type=MSISDN&action=OperatorInfo' -e 'HTTP/1.1 200 OK' -f follow | awk '{sub(/:/,"",$2);print $2}')

if [ "$str1" == "OK" ]
    echo "OK"
       exit 0
    echo "CRITICAL"
       exit 2

Any help will be highly appreciable. Thanks in Advance.

Best Regards,

Posts: 96
Joined: Fri May 22, 2015 7:12 am

Re: Template to carryout service check once every 4 seconds

Postby mcapra » Fri Jul 12, 2019 9:30 am

I would strongly suggest creating this as a cron job or dedicated process/daemon instead, then submitting the results to Nagios Core as a passive check. Nagios Core wasn't really designed around this level of granularity.

The interval Nagios Core uses is contained in the main cfg file as interval_length. By default, Nagios Core uses 60 second intervals. If you want to get even more granular than that, you'd have to alter this **global** interval_length directive. There is no way by which you could have only one specific service override this directive.
Former Nagios employee
User avatar
Posts: 3587
Joined: Thu May 05, 2016 3:54 pm

Re: Template to carryout service check once every 4 seconds

Postby scottwilkerson » Fri Jul 12, 2019 2:15 pm

I agree with mcapra, changing the interval_length is the only way to do it HOWEVER this is going to provide a whole host of problems and would require everything else to be changed..

One thing you could do is set the following
Code: Select all
check_freshness                 1
freshness_interval                 4

But this still will likely not get down to the limit you want because the freshness checking is only triggered every 15 seconds by default
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
DevOps Engineer
Posts: 17032
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Return to Nagios Core

Who is online

Users browsing this forum: No registered users and 13 guests