Ad Widget

Collapse

API deleting expired maintenances

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bradenwright
    Junior Member
    • Aug 2015
    • 1

    #1

    API deleting expired maintenances

    I started using the api to put machines in maintenance mode as we do restarts, deploys or other things that I'm already notified of.

    This has worked great, only problem is that I end up having expired maintenances laying around. I would like to clean them up in an automated fashion but I haven't been able to figure out a way. I didn't see anyway to query the state for active/expired.

    And all the ideas I was coming up with would be really really messy. Any help would be much appreciated!
  • cliffennis
    Junior Member
    • May 2015
    • 15

    #2
    I do this via cron using the API. I'll pull up the code a little later today when I get into the office, but in the script I'm testing the active_till value of each maintenance object against the current time, then executing the maintenance.delete against that maintenanceid of the expired ones.

    It looks something like:

    maintenance_cleanup.pl
    Code:
    foreach my $item (@{$response->content->{result}}) {
    if ($item->{active_till} < time) {
    #do the delete stuff based on $item->{maintnenaceid}
    }
    }

    Comment

    Working...