Page 1 of 1

downtime data via API not available during apply config

Posted: Wed Apr 14, 2021 9:45 am
by jweijters
Hi,

When there is an incident, like a host down, or a service down, we run a Notification to create a ticket in our servicemanagement tool. The ticket number we put back in Nagios as an acknowledgement.
Our first line support team check and tries to fix the incident, and when they do, they close the ticket in the servicemanagement tool.
When the incident is fixed, the event is OK again, and the acknowledement is automaticaly removed.

However sometimes a ticket is closed in the SM tool, however the incident is not fixed. For this we check every hour if this is the case.
We do this by using the API to request the comments "/nagiosxi/api/v1/objects/comment"

It is possible that we have systems or services in Downtime, If we have a host or service in downtime, the SM ticket should not be re-opened.
I can imagine 2nd/3rd line was forgotten to set the host or/and services in downtime due to maintenance.

We look for the downtime by requesting the downtime via the API: /nagiosxi/api/v1/objects/downtime

We found that when an apply config is running, and we request the downtime by the API, the API is not returning the correct information
What means downtime which was set before, is not active, and out script just re-opens the SM ticket.

can you look in to this?

kind regards,

Joris Weijters

Re: downtime data via API not available during apply config

Posted: Wed Apr 14, 2021 4:18 pm
by vtrac
Hi,
I tested my VM by scheduled a downtime for all my 16 services which belong to ONE host.

I used the below command to get my downtime info:

Code: Select all

 curl -k -XGET "https://x.x.x.x/nagiosxi/api/v1/objects/downtime?apikey=dmh97R0u4N76S42j3HjQSMZcPFGnWHNqk4Sqc9efVlkNIFmKCYQq2PV7qCOHfBnC&pretty=1"
Here are the outputs:

Code: Select all

{
    "recordcount": 16,
    "scheduleddowntime": [
        {
            "instance_id": "1",
            "instance_name": "localhost",
            "object_id": "197",
            "objecttype_id": "2",
            "host_name": "192.168.254.83-ncpa",
            "service_description": "vEthernet _Default Switch_ Bandwidth - Outbound",
            "scheduleddowntime_id": "16",
            "downtime_type": "1",
            "entry_time": "2021-04-14 16:00:39",
            "author_name": "Nagios Admin",
            "comment_data": "Testing downtime",
            "internal_downtime_id": "2",
            "triggered_by_id": "0",
            "is_fixed": "1",
            "duration": "3300",
            "scheduled_start_time": "2021-04-14 16:05:00",
            "scheduled_end_time": "2021-04-14 17:00:00",
            "was_started": "1",
            "actual_start_time": "2021-04-14 16:07:24",
            "actual_start_time_usec": "446889",
            "internal_id": "2"
        },
        {
            "instance_id": "1",
            "instance_name": "localhost",
            "object_id": "198",
            "objecttype_id": "2",
            "host_name": "192.168.254.83-ncpa",
            "service_description": "vEthernet _Default Switch_ Bandwidth - Inbound",
            "scheduleddowntime_id": "15",
            "downtime_type": "1",
            "entry_time": "2021-04-14 16:00:39",
            "author_name": "Nagios Admin",
            "comment_data": "Testing downtime",
            "internal_downtime_id": "3",
            "triggered_by_id": "0",
            "is_fixed": "1",
            "duration": "3300",
            "scheduled_start_time": "2021-04-14 16:05:00",
            "scheduled_end_time": "2021-04-14 17:00:00",
            "was_started": "1",
            "actual_start_time": "2021-04-14 16:07:24",
            "actual_start_time_usec": "452499",
            "internal_id": "3"
        },
        {
            "instance_id": "1",
            "instance_name": "localhost",
            "object_id": "187",
            "objecttype_id": "2",
            "host_name": "192.168.254.83-ncpa",
            "service_description": "User Count",
            "scheduleddowntime_id": "14",
            "downtime_type": "1",
            "entry_time": "2021-04-14 16:00:39",
            "author_name": "Nagios Admin",
            "comment_data": "Testing downtime",
            "internal_downtime_id": "4",
            "triggered_by_id": "0",
            "is_fixed": "1",
            "duration": "3300",
            "scheduled_start_time": "2021-04-14 16:05:00",
            "scheduled_end_time": "2021-04-14 17:00:00",
            "was_started": "1",
            "actual_start_time": "2021-04-14 16:07:24",
            "actual_start_time_usec": "451890",
            "internal_id": "4"
        },
        {
            "instance_id": "1",
            "instance_name": "localhost",
            "object_id": "189",
            "objecttype_id": "2",
            "host_name": "192.168.254.83-ncpa",
            "service_description": "Swap Usage",
            "scheduleddowntime_id": "13",
            "downtime_type": "1",
            "entry_time": "2021-04-14 16:00:39",
            "author_name": "Nagios Admin",
            "comment_data": "Testing downtime",
            "internal_downtime_id": "5",
            "triggered_by_id": "0",
            "is_fixed": "1",
            "duration": "3300",
            "scheduled_start_time": "2021-04-14 16:05:00",
            "scheduled_end_time": "2021-04-14 17:00:00",
            "was_started": "1",
            "actual_start_time": "2021-04-14 16:07:24",
            "actual_start_time_usec": "450924",
            "internal_id": "5"
        },
        {
            "instance_id": "1",
            "instance_name": "localhost",
            "object_id": "574",
            "objecttype_id": "2",
            "host_name": "192.168.254.83-ncpa",
            "service_description": "Process Count",
            "scheduleddowntime_id": "12",
            "downtime_type": "1",
            "entry_time": "2021-04-14 16:00:39",
            "author_name": "Nagios Admin",
            "comment_data": "Testing downtime",
            "internal_downtime_id": "6",
            "triggered_by_id": "0",
            "is_fixed": "1",
            "duration": "3300",
            "scheduled_start_time": "2021-04-14 16:05:00",
            "scheduled_end_time": "2021-04-14 17:00:00",
            "was_started": "1",
            "actual_start_time": "2021-04-14 16:07:24",
            "actual_start_time_usec": "450407",
            "internal_id": "6"
        },
        {
            "instance_id": "1",
            "instance_name": "localhost",
            "object_id": "188",
            "objecttype_id": "2",
            "host_name": "192.168.254.83-ncpa",
            "service_description": "Memory Usage",
            "scheduleddowntime_id": "11",
            "downtime_type": "1",
            "entry_time": "2021-04-14 16:00:39",
            "author_name": "Nagios Admin",
            "comment_data": "Testing downtime",
            "internal_downtime_id": "7",
            "triggered_by_id": "0",
            "is_fixed": "1",
            "duration": "3300",
            "scheduled_start_time": "2021-04-14 16:05:00",
            "scheduled_end_time": "2021-04-14 17:00:00",
            "was_started": "1",
            "actual_start_time": "2021-04-14 16:07:24",
            "actual_start_time_usec": "448919",
            "internal_id": "7"
        },
        {
            "instance_id": "1",
            "instance_name": "localhost",
            "object_id": "195",
            "objecttype_id": "2",
            "host_name": "192.168.254.83-ncpa",
            "service_description": "Local Area Connection_ 2 Bandwidth - Outbound",
            "scheduleddowntime_id": "10",
            "downtime_type": "1",
            "entry_time": "2021-04-14 16:00:39",
            "author_name": "Nagios Admin",
            "comment_data": "Testing downtime",
            "internal_downtime_id": "8",
            "triggered_by_id": "0",
            "is_fixed": "1",
            "duration": "3300",
            "scheduled_start_time": "2021-04-14 16:05:00",
            "scheduled_end_time": "2021-04-14 17:00:00",
            "was_started": "1",
            "actual_start_time": "2021-04-14 16:07:24",
            "actual_start_time_usec": "448420",
            "internal_id": "8"
        },
        {
            "instance_id": "1",
            "instance_name": "localhost",
            "object_id": "196",
            "objecttype_id": "2",
            "host_name": "192.168.254.83-ncpa",
            "service_description": "Local Area Connection_ 2 Bandwidth - Inbound",
            "scheduleddowntime_id": "9",
            "downtime_type": "1",
            "entry_time": "2021-04-14 16:00:39",
            "author_name": "Nagios Admin",
            "comment_data": "Testing downtime",
            "internal_downtime_id": "9",
            "triggered_by_id": "0",
            "is_fixed": "1",
            "duration": "3300",
            "scheduled_start_time": "2021-04-14 16:05:00",
            "scheduled_end_time": "2021-04-14 17:00:00",
            "was_started": "1",
            "actual_start_time": "2021-04-14 16:07:24",
            "actual_start_time_usec": "447350",
            "internal_id": "9"
        },
        {
            "instance_id": "1",
            "instance_name": "localhost",
            "object_id": "193",
            "objecttype_id": "2",
            "host_name": "192.168.254.83-ncpa",
            "service_description": "Local Area Connection_ 1 Bandwidth - Outbound",
            "scheduleddowntime_id": "8",
            "downtime_type": "1",
            "entry_time": "2021-04-14 16:00:39",
            "author_name": "Nagios Admin",
            "comment_data": "Testing downtime",
            "internal_downtime_id": "10",
            "triggered_by_id": "0",
            "is_fixed": "1",
            "duration": "3300",
            "scheduled_start_time": "2021-04-14 16:05:00",
            "scheduled_end_time": "2021-04-14 17:00:00",
            "was_started": "1",
            "actual_start_time": "2021-04-14 16:07:24",
            "actual_start_time_usec": "446228",
            "internal_id": "10"
        },
        {
            "instance_id": "1",
            "instance_name": "localhost",
            "object_id": "194",
            "objecttype_id": "2",
            "host_name": "192.168.254.83-ncpa",
            "service_description": "Local Area Connection_ 1 Bandwidth - Inbound",
            "scheduleddowntime_id": "7",
            "downtime_type": "1",
            "entry_time": "2021-04-14 16:00:39",
            "author_name": "Nagios Admin",
            "comment_data": "Testing downtime",
            "internal_downtime_id": "11",
            "triggered_by_id": "0",
            "is_fixed": "1",
            "duration": "3300",
            "scheduled_start_time": "2021-04-14 16:05:00",
            "scheduled_end_time": "2021-04-14 17:00:00",
            "was_started": "1",
            "actual_start_time": "2021-04-14 16:07:24",
            "actual_start_time_usec": "451378",
            "internal_id": "11"
        },
        {
            "instance_id": "1",
            "instance_name": "localhost",
            "object_id": "191",
            "objecttype_id": "2",
            "host_name": "192.168.254.83-ncpa",
            "service_description": "Ethernet 2 Bandwidth - Outbound",
            "scheduleddowntime_id": "6",
            "downtime_type": "1",
            "entry_time": "2021-04-14 16:00:39",
            "author_name": "Nagios Admin",
            "comment_data": "Testing downtime",
            "internal_downtime_id": "12",
            "triggered_by_id": "0",
            "is_fixed": "1",
            "duration": "3300",
            "scheduled_start_time": "2021-04-14 16:05:00",
            "scheduled_end_time": "2021-04-14 17:00:00",
            "was_started": "1",
            "actual_start_time": "2021-04-14 16:07:24",
            "actual_start_time_usec": "449951",
            "internal_id": "12"
        },
        {
            "instance_id": "1",
            "instance_name": "localhost",
            "object_id": "192",
            "objecttype_id": "2",
            "host_name": "192.168.254.83-ncpa",
            "service_description": "Ethernet 2 Bandwidth - Inbound",
            "scheduleddowntime_id": "5",
            "downtime_type": "1",
            "entry_time": "2021-04-14 16:00:39",
            "author_name": "Nagios Admin",
            "comment_data": "Testing downtime",
            "internal_downtime_id": "13",
            "triggered_by_id": "0",
            "is_fixed": "1",
            "duration": "3300",
            "scheduled_start_time": "2021-04-14 16:05:00",
            "scheduled_end_time": "2021-04-14 17:00:00",
            "was_started": "1",
            "actual_start_time": "2021-04-14 16:07:24",
            "actual_start_time_usec": "447874",
            "internal_id": "13"
        },
        {
            "instance_id": "1",
            "instance_name": "localhost",
            "object_id": "592",
            "objecttype_id": "2",
            "host_name": "192.168.254.83-ncpa",
            "service_description": "Disk Usage on C:\/free",
            "scheduleddowntime_id": "4",
            "downtime_type": "1",
            "entry_time": "2021-04-14 16:00:39",
            "author_name": "Nagios Admin",
            "comment_data": "Testing downtime",
            "internal_downtime_id": "14",
            "triggered_by_id": "0",
            "is_fixed": "1",
            "duration": "3300",
            "scheduled_start_time": "2021-04-14 16:05:00",
            "scheduled_end_time": "2021-04-14 17:00:00",
            "was_started": "1",
            "actual_start_time": "2021-04-14 16:07:24",
            "actual_start_time_usec": "445711",
            "internal_id": "14"
        },
        {
            "instance_id": "1",
            "instance_name": "localhost",
            "object_id": "190",
            "objecttype_id": "2",
            "host_name": "192.168.254.83-ncpa",
            "service_description": "Disk Usage on C:\/",
            "scheduleddowntime_id": "3",
            "downtime_type": "1",
            "entry_time": "2021-04-14 16:00:39",
            "author_name": "Nagios Admin",
            "comment_data": "Testing downtime",
            "internal_downtime_id": "15",
            "triggered_by_id": "0",
            "is_fixed": "1",
            "duration": "3300",
            "scheduled_start_time": "2021-04-14 16:05:00",
            "scheduled_end_time": "2021-04-14 17:00:00",
            "was_started": "1",
            "actual_start_time": "2021-04-14 16:07:24",
            "actual_start_time_usec": "449363",
            "internal_id": "15"
        },
        {
            "instance_id": "1",
            "instance_name": "localhost",
            "object_id": "573",
            "objecttype_id": "2",
            "host_name": "192.168.254.83-ncpa",
            "service_description": "Disk Usage",
            "scheduleddowntime_id": "2",
            "downtime_type": "1",
            "entry_time": "2021-04-14 16:00:39",
            "author_name": "Nagios Admin",
            "comment_data": "Testing downtime",
            "internal_downtime_id": "16",
            "triggered_by_id": "0",
            "is_fixed": "1",
            "duration": "3300",
            "scheduled_start_time": "2021-04-14 16:05:00",
            "scheduled_end_time": "2021-04-14 17:00:00",
            "was_started": "1",
            "actual_start_time": "2021-04-14 16:07:24",
            "actual_start_time_usec": "445162",
            "internal_id": "16"
        },
        {
            "instance_id": "1",
            "instance_name": "localhost",
            "object_id": "186",
            "objecttype_id": "2",
            "host_name": "192.168.254.83-ncpa",
            "service_description": "CPU Usage",
            "scheduleddowntime_id": "1",
            "downtime_type": "1",
            "entry_time": "2021-04-14 16:00:39",
            "author_name": "Nagios Admin",
            "comment_data": "Testing downtime",
            "internal_downtime_id": "17",
            "triggered_by_id": "0",
            "is_fixed": "1",
            "duration": "3300",
            "scheduled_start_time": "2021-04-14 16:05:00",
            "scheduled_end_time": "2021-04-14 17:00:00",
            "was_started": "1",
            "actual_start_time": "2021-04-14 16:07:24",
            "actual_start_time_usec": "444585",
            "internal_id": "17"
        }
    ]
}


I then went ahead and did the "Apply Configuration" and "also ran the "curl" command during the running of "Apply config" and the results are the same.

One thing to NOTE is that during the "Apply Configuration" process, Nagios do get restarted. If your system is large or slow, your "curl" command might be hung during the "Apply Config" process.


Best Regards,
Vinh