Bulk Remove Scheduled Downtime

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
gregbeyer
Posts: 181
Joined: Fri Sep 11, 2020 2:13 pm

Bulk Remove Scheduled Downtime

Post by gregbeyer »

Referring to viewtopic.php?t=24694&p=84272

"scroll down to the "Mass Remove Downtime" section, click on "Check All" and "Remove Downtimes".

I do not have a Mass Remove Downtime section therein. Removed from XI since 2014?
cnorell
Developer
Posts: 141
Joined: Mon Nov 27, 2017 3:08 pm

Re: Bulk Remove Scheduled Downtime

Post by cnorell »

gregbeyer,

I don't believe you can currently use incident management to remove downtime. That said, adding a mass downtime feature is on our roadmap. As always - I can't promise a release date - but keep an eye out for it in upcoming releases.

Best Regards,

Cory Norell
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
gregbeyer
Posts: 181
Joined: Fri Sep 11, 2020 2:13 pm

Re: Bulk Remove Scheduled Downtime

Post by gregbeyer »

So how can a bulk removal of scheduled downtime be accomplished? Per the OP from 2014, is there a raw SQL command do do so? When a maintenance period gets moved, there's got to be a way to alter the downtime or completely remove and start over.
sgardil
Posts: 355
Joined: Wed Aug 09, 2023 9:58 am

Re: Bulk Remove Scheduled Downtime

Post by sgardil »

gregbeyer wrote: Fri Jul 19, 2024 2:23 pm So how can a bulk removal of scheduled downtime be accomplished? Per the OP from 2014, is there a raw SQL command do do so? When a maintenance period gets moved, there's got to be a way to alter the downtime or completely remove and start over.
Hey @gregbeyer

Are these reoccurring scheduled downtimes or just one offs? If they aren't reoccurring you can try navigating to home -> incident management -> scheduled downtimes. There should be a list of the scheduled downtimes here where you can use checkboxes to remove multiple. If they are reoccurring there is a separate page however it doesn't seem theres a bulk option for this unfortunately.
gregbeyer
Posts: 181
Joined: Fri Sep 11, 2020 2:13 pm

Re: Bulk Remove Scheduled Downtime

Post by gregbeyer »

This is a one-off downtime. However, as we have thousands of hosts, and 4-6 checks per host, the downtime scheduler created 60K downtime records. No way to (reasonably) delete those using the check and delete method. So if there's not a UI method, the only hope is an SQL query to do so.

I think some way to mass delete needs prioritization for development. It's only been a known need since 2014.
cnorell
Developer
Posts: 141
Joined: Mon Nov 27, 2017 3:08 pm

Re: Bulk Remove Scheduled Downtime

Post by cnorell »

gregbeyer,

I hear you, I wish I had a better answer for you right now. When the mass downtime feature releases, you will also be able to mass remove downtime.

Best Regards,

Cory Norell
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
sgardil
Posts: 355
Joined: Wed Aug 09, 2023 9:58 am

Re: Bulk Remove Scheduled Downtime

Post by sgardil »

gregbeyer wrote: Wed Jul 24, 2024 9:01 am This is a one-off downtime. However, as we have thousands of hosts, and 4-6 checks per host, the downtime scheduler created 60K downtime records. No way to (reasonably) delete those using the check and delete method. So if there's not a UI method, the only hope is an SQL query to do so.

I think some way to mass delete needs prioritization for development. It's only been a known need since 2014.
There may theoretically be a way to get this to work in the gui but it definitely isn't the most user friendly and intuitive. If you go to the scheduled downtime page there is the ability to set the amount viewed in page to no limit. That being said this needs to be improved on as it worked once and other times it gave an endless buffering icon. You can give it a try and see if it will load for you and if it does click the checkbox to select all in the top and endlessly scroll to the bottom for the option to select remove in the with selected option. Not perfect but worth giving a shot.
snapier3
Posts: 144
Joined: Tue Apr 23, 2019 7:12 pm

Re: Bulk Remove Scheduled Downtime

Post by snapier3 »

I manage this with a combination of Python and the NagiosXI API (v1). This is by no means the complete source or meant to be a production solution.

I have a function that's called NagiosXI Generic API that submits the API request and returns the JSON results. If you follow information in the help about the API you'll get the basics of what's being done

This function takes 6 arguments and spits back the results.
The rest of the code will be a reference to this function.

Code: Select all

##NAGIOSXI GENERIC API CALL
def nagiosxiGenericAPI(resource,endpoint,modifier,method,myurl,mykey):
    #AND THEN A MIRICAL HAPPENS 
    # ~tobtieker
    url = ("https://{turl}/nagiosxi/api/v1/{resource}/{endpoint}?{modifier}&apikey={akey}".format(turl=myurl,akey=mykey,resource=resource,endpoint=endpoint,modifier=modifier)) 

    #GET
    if method == "get":
        try:
            r = requests.get(url=url,verify=False)
        except Exception as e:
            print.error("%s",e)
            r = False
    elif method == "post":
        try:
            r = requests.post(url=url,verify=False)
        except Exception as e:
            print.error("%s",e)
            r = False
    elif method == "put":
        try:
            r = requests.put(url=url,verify=False)
        except Exception as e:
            print.error("%s",e)
            r = False
    elif method == "delete":
        try:
            r = requests.delete(url=url,verify=False)
        except Exception as e:
            print.error("%s",e)
            r = False
    else:
        print.error("%s","NO METHOD PROVIDED")
        r = False

    return r
I have logic that retrieves my user API key and associates it to mykey
I have logic that inserts my server URL as myurl.
I have logic that will parse the results and create a csv of the JSON results.

--
First I pull the current downtime list using no query modifier passed to the function
resource = objects
endpoint = downtime
method = get
modifier = none
mykey
myurl

This will spit back the record count and a list of all downtime entries.

Next, In my case I create a CSV file and write the results into the file.
I should mention that if you are parsing this list that it's one of the few times that there is a mismatch in the endpoint and the data returned.

Code: Select all

#COUNT IT
ic = 0
#API RESULTS
items = r.json()
#MAKE A CSV
mycsv = open('yourfile.csv','w',newline='',encoding='utf-8')
csv_writer = csv.writer(mycsv)

#WRITE OUR DOWNTIME RESULTS INTO THE CSV
for i in item['scheduleddowntime']:
	if ic == 0:
		header = i.keys()
		csv_writer.writerow(header)
		ic+=1
	else:
		line = i.values()
		csv_writer.writerow(line)
		ic+=1


In the CSV you'll get everything that's available including the internal_id of each entry which is what we need to move to the next step of deleting the downtime using the API.

To delete a downtime is really simple we just send a DELETE with the internal_id to the SYSTEM/SCHEDULEDDOWNTIME enpoint.

Code: Select all

#Using the nagiosXIGenericAPI function

resource = system
endpoint = scheduleddowntime
method = delete
modifier = <your internal_id>
myurl
mykey

d = nagiosXIGenericAPI(resource,endpoint,modifier,myurl,mykey)
print(d)

To delete a lot of them, make a list and loop through it making a call to delete them.
This is what I'm doing and similar to how I'm bulk managing host/service comments.

--SN
gregbeyer
Posts: 181
Joined: Fri Sep 11, 2020 2:13 pm

Re: Bulk Remove Scheduled Downtime

Post by gregbeyer »

sgardil wrote: Wed Jul 24, 2024 9:24 am it worked once and other times it gave an endless buffering icon. You can give it a try and see if it will load for you and if it does click the checkbox to select all in the top and endlessly scroll to the bottom for the option to select remove in the with selected option. Not perfect but worth giving a shot.
Yep, I, too, repeatedly tried viewing "No limit" but got the endless buffer spinner. Let it run all weekend :-) The most I can do at a time is 500. But 60K / 500 means doing it 120 times . . . NOT! LOL (or I'd cry).

Thanks, snapier3, I'll try your method out. Appreciate the engagement! Just unbelievable we're punting on something like this, tho.
bbahn
Posts: 385
Joined: Thu Jan 12, 2023 5:42 pm

Re: Bulk Remove Scheduled Downtime

Post by bbahn »

Notice to those working on this here: Nagios XI will ship with a mass add/remove downtime feature in the next release!
Actively advancing awesome answers with ardent alliteration, aptly addressing all ambiguities. Amplify your acumen and avail our amicable assistance. Eagerly awaiting your astute assessments of our advice.
Post Reply