Skip to content

AlexGilliland/Zabbix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is provided as-is and no warranty.
This has been tested on Zabbix 4.4, 5.0 and 5.0.2

Workflow

On graceful shutdown/reboot -> Script uses zabbix_sender to send item to Zabbix -> Zabbix triggers based on the received item and an action places the server into "Maintenance Mode" group. On boot -> Startup script uses zabbix_sender to send item to Zabbix -> Zabbix

Steps

  1. Create a group called 'Maintenance Mode' Note: Document the groupid which can be found in the URL string when selecting the group within Configuration>Host Groups

  2. Create the new item with the key 'maintenance.mode' within the template of your choosing Note: I opted to use Template Module Zabbix Agent

  3. Create a trigger with the Problem Expression set to {Template Module Zabbix agent:maintenance.mode.regexp("^Entering Maintenance Mode",1)}=1 and Recovery Expression set to {Template Module Zabbix agent:maintenance.mode.count(15m,"Exiting Maintenance Mode")}>=1 and {Template Module Zabbix agent:maintenance.mode.count(#2, "Entering Maintenance Mode")}=1

  4. Copy the files from here to /usr/lib/zabbix/alertscripts/ (or where ever you store your Zabbix scripts, but if you do, you'll need to update the basedir within the script) and update the custom variables section within the .bat file to match your environment. This includes the groupid from step 1

  5. Create a new Zabbix action within Configuration>Actions Name: Enter Maintenance Mode

    Conditions: A) Trigger name containers Maintenance Mode B) Trigger name containers Enter Maintenance Mode

    Operations Tab

    Operations:
    Target list: Set this to your Zabbix host Type: Custom script
    Execute On: Zabbix server
    Commands: /usr/lib/zabbix/alertscripts/Enter-MaintenanceMode.bat {HOST.NAME}

    Recovery Operations:
    Operation Type: Remote Command
    Target list: Zabbix host
    Type: Custom Script
    Execute On: Zabbix Server
    Commands: /usr/lib/zabbix/alertscripts/Exit-MaintenanceMode.bat {HOST.NAME}

  6. Create a new Group Policy and apply to the OUs you want and set the Computer Configuration > Policies > Windows Settings > Scripts, Shutdown (Enter-MaintenanceMode.ps1) and Startup (Exit-MaintenanceMode.ps1)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published