Auto-downtime reboot/shutdown

Hey folks,

Anyone already play/work and automated the downtime when a host is rebooting or shutdown for maintenance ?

Instead of having to manually trigger a downtime on a host, it will be way better to have something that run at reboot/shutdown and after that, something that run at boot to remove the downtime period…

curl -k -s -u root:password -o /dev/null -H ‘Accept: application/json’ -X POST
https://icinga.server:5665/v1/actions/schedule-downtime’ -d ‘{ “type”:
“Host”, “filter”: “host.name==“rebooting.server””, “start_time”: ‘date +%s’, “end_time”: ‘date +%s -d "+1000 seconds"’, “author”: “installation
script”, “comment”: “Machine being installed / updated”, “pretty”: false }’

and then when the reboot is done:

curl -k -s -u root:password -o /dev/null -H ‘Accept: application/json’ -X POST
https://icinga.server:5665/v1/actions/remove-downtime’ -d ‘{ “type”: “Host”,
“filter”: “host.name==“rebooting.server””, “pretty”: false }’

Works for me :slight_smile:

Antony.

thanks Antony…
so the best for that it’s to create a “dummy” user that have less permission so we can use it everywhere even in “servers” at client’s site :wink:

Don’t really like the idea of having the login and password in a script :wink:

Fair point.

I run my script from an installation server which then connects to the machine
being worked on and does whatever is needed (possibly including a reboot, or
restarting services), so I trust that installation server to talk to the
Icinga server with a scripted password.

If you want the machine which is actually being worked on to send the requests
to Icinga, though, then agreed, you want either a low-priviledge user, or else
a wrapper script on the Icinga server which can only do this function, and you
call that (eg: over SSH) from the machine being worked on, with its name as a
parameter.

Then the Icinga password is only on the Icinga machine, and the wrapper script
ensures that this downtime stuff is the only thing that anyone who gets SSH
access to it can do.

Have fun :slight_smile:

Antony.

I wrote a litle eventhandler for automatic downtimes

1 Like

Carsten,

thanks but not really sure how it works… even after reading the full README :frowning:

Its simple. It is triggered by icinga eventhandler as soon the state changes from OK to DOWN, Depending on the ‘max_check_attempts’ it will trigger a downtime for the host and it services before the host reaches a ‘hard’ state.
You should only use it for hosts that go down without notice for the admins, like workstations etc.

Ohhh I see.
We will build a program for Windows and Linux then here to do something like Antony but a little bit more secure for the password :wink: