Once in a while you have to set a host into maintenance mode. This can be quite annoying, having to click yourself through all the screens in the Zabbix frontend. Many Zabbix admins use a so called „maintenance group“ to make it a little less annoying:
These are groups with a perpetual maintenance time, like 10+ years or so. Simply move one or more hosts into the maintenance group and it is in maintenance mode until it is moved out of this group again.
I created a set of scripts for Linux and Windows Powershell, to do this from the console/commandline.
Usage is easy peasy, as long as you did not override the detected hostname of the system, but if you did this, you will surely figure out how to apply this to the script.
You need to have a valid API user in Zabbix with access to the required API endpoints of course.
This script also uses http basic auth to login to the Zabbix server. So if you have set another auth method, adjust the script accordingly.
To configure this script, edit these to fit your needs:
—
API_URL=“https://URL/api_jsonrpc.php“
USER=“some_api_user_http_auth_username“
PASSWORD=“some_api_user_http_auth_pass“
HOSTGROUP=“name_of_maint_group“
—
Usage Linux:
Add host to maintenance group: /path/to/zbx_maint.sh ADD
Remove host from maintenance group: /path/to/zbx_maint.sh REMOVE
Usage Windows:
Add host to maintenance group: powershell.exe -File „C:\path\to\zbx_maint.ps1“ -Action ADD
Remove host from maintenance group: powershell.exe -File „C:\path\to\zbx_maint.ps1“ -Action REMOVE
Attention: These scripts use the „old“ authentication method, that is declared deprecated in Zabbix 7.0 LTS. However the „new“ auth method is broken in Zabbix since several versions ago:
[ZBX-22952] API authentication using Authorization bearer header does not work – ZABBIX SUPPORT
Download the scripts: zbx_maint.zip
Kommentare