Subscribed unsubscribe Subscribe Subscribe

Mackerel blog #mackerelio

The Official Blog of Mackerel

Auto host retirement and status change; automation for cold standby systems and auto scale

For those organizations with auto scale-like dynamic host fluctuation or cold standby systems, it’s necessary to deal with retirement and status changes each time. Automatization of these processes up until now meant having to implement individual API calls for handling retirement and status changes in the boot script, but now with mackerel-agent v0.20.0, these processes will be done just by writing them in the settings file.

The following is an explanation of how this is done.

Automatic retirement of host upon OS shutdown

When using auto-scale for instance, you may at some point want to have hosts be retired automatically.

If you have done a package installation, simply by appending one line to the environment variable settings file for init script, automatic host retirement can be easily implemented.

If the environment variable settings file is from the yum/rpm package it will be located here /etc/sysconfig/mackerel-agent, and if it is from the deb/apt package it will be located here /etc/default/mackerel-agent.

Please make the assignment as shown below.

AUTO_RETIREMENT=1

By making this assignment, upon shutdown (more specifically /etc/init.d/mackerel-agent stop) the host will automatically be retired.

Caution Even if you have manually typed /etc/init.d/mackerel-agent stop, if the above assignment has already been made, the host will be retired. If you want to, say, update the agent to the latest version or start/stop the agent, please use /etc/init.d/mackerel-agent reload.

If you didn’t do a package install, there is a subcommand for retirement called mackerel-agent retire [-force], so please try using this command to create an automatic retirement mechanism.

Automatic status update upon host boot up and shut down

If you have a prepared cold standby system, you may want that host’s status to be automatically changed to working when it’s turned on and poweroff when it’s off.

This can be implemented by making the following designations in the mackerel-agent settings file.

# /etc/mackerel-agent/mackerel-agent.conf
[host_status]
on_start = "working"
on_stop  = "poweroff"

We hope this will make managing your cold standby system with Mackerel even easier.

As for host_status, four different statuses may be assigned: working, standby, maintenance, and poweroff. Designate the statuses that fit the needs of your particular use case for more flexible customization.


For more information please refer to the mackerel-agent specifications documentation.