Ad Widget

Collapse

Maintenance mode from CLI

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dpbaker57
    Member
    • Aug 2010
    • 33

    #1

    Maintenance mode from CLI

    We are monitoring many websites and their servers. During a software release we also include windows patching. Our software releases are almost completely scripted, in Windows batch files most of the time. Our Zabbix server runs Linux. I figure I can use the Cygwin ssh client with keys to be able to run a shell script on the Zabbix host to disable the monitors affected by the software release.

    What I need is help on how to build the shell script to disable, or preferably place in maintenance mode, the monitors while the release is happening. Of course I will need a script to undo this at the end of the release.
  • ghoz
    Senior Member
    • May 2011
    • 204

    #2
    you are looking for for zabcon, it's a command line addon that uses the zabbix API.
    however, I'm not sure it handles maintenance mode...

    Comment

    • nelsonab
      Senior Member
      Zabbix Certified SpecialistZabbix Certified Professional
      • Sep 2006
      • 1233

      #3
      In zabcon you will need to use the raw.api call:

      Code:
      raw.api maintenance.create hostids=1234,5678 name="Weekly Maintenance" maintenance_type=1 timeperiods={timeperiod_type=3 start_time=82800 period=7200 every=1 dayofweek=6}
      I haven't tested the above, but I adapted the example. That should create a maintenance window which runs every Saturday at 2300 for two hours. Unfortunately the documentation is a little light in this area.
      RHCE, author of zbxapi
      Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
      Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

      Comment

      • nicolassd
        Junior Member
        • Jul 2011
        • 2

        #4
        Hi Nelson

        I test with this:
        raw api maintenance.create hostids=10176 name="Test Maintenance" maintenance_type=1 timeperiods={timeperiod_type=0 start_time=82800 period=7200}

        Result:
        Unexpected parameter "="

        please you would have some other example?


        Thank you.

        Nicolas.

        Comment

        Working...