Idea to develop...maintenance file

Hi,

Having an idea but not sure where and how to start…

We are migrating to icinga client on almost all our host and thinking about something related to maintenance.

It will be very useful to simply “touch” an empty file like /maintenance and that will trigger a “schedule downtime”…

It happen often that we need to work on a machine/VM and don’t want to receive notification and spam all the team members at the same time.

You can do this with a simple curl (or equivalent) command using the API.

https://icinga.com/docs/icinga-2/latest/doc/12-icinga2-api/#schedule-downtime

Antony.

@Pooh yeah I know that, but sometime if it’s not a senior sysadmin that is doing something it’s not always easy to do the curl call.

That’s why the idea of the maintenance file come in mind.

@Pooh yeah I know that, but sometime if it’s not a senior sysadmin that is
doing something it’s not always easy to do the curl call.

Put it into a script so that anyone can use it without understanding what’s in
it.

That’s why the idea of the maintenance file come in mind.

a) set up a cron job to look for the maintenance file and run the curl script
if it’s less than 100 seconds old

b) use inotify to detect the appearance of the maintenance file and run the
curl script

Another thing I’ve done is to create a new script in /etc/init.d called
“downtime”. It accepts the usual “start” and “stop” parameters, and for a
“start” it takes the machine out of downtime in Icinga, and for “stop” it puts
it into downtime.

The “Required-Start” dependency is “$all” and the “Required-Stop” dependency
is “$network”. That makes it the last thing to run on startup (so, all
services should have been started by the time downtime ends), and one of the
first to run on shutdown, and definitely before the network disappears (so, it
puts the machine into downtime early in the shutdown process).

That way, anything which does a clean shutdown / restart / reboot of the
server automatically puts it into downtime for the duration of the restart.

Antony.

1 Like

@Pooh Can you/do you want, to share your initd script ? :wink:

It’s at #! /bin/sh### BEGIN INIT INFO# Provides: downtime# Required-St - Pastebin.com for 30 days.

This script is designed for Debian / Devuan and similar. I have no idea about
CentOS, Arch, Gentoo, or anything running systemd.

Regards,

Antony.

1 Like

I will have a look and test it under systemd and will give you the script back in you need it!