Ad Widget

Collapse

Variable item update interval (ZBXNEXT-1414)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Semiadmin
    Senior Member
    • Oct 2014
    • 1625

    #1

    Variable item update interval (ZBXNEXT-1414)

    Once I realised that I'm missing some option in Zabbix – a possibility to change an item update interval under conditions. And apparently I'm not the only (ZBXNEXT-1414).
    Say, some graph looks even, but suddenly there is an anomaly, and I’d want to reduce the update interval to see this anomaly carefully.
    The idea is to create a trigger based action, which executes a script, and this script’d change an item update interval via API.
    I'd prefer to use remote command or global script, but item macros, like {ITEM.ID1}, are supported in notifications only. So use alert script.
    The following solution is just concept. It’s a crutch, of course, but it works.

    1. Create 2 macros, {$UPDATE_FAST} and {$UPDATE_LOW} at host, template or global level, for 2 update intervals (sec).

    2. Create a script. I used py-zabbix https://github.com/blacked/py-zabbix.

    Install py-zabbix:

    pip install py-zabbix

    Script:

    #!/usr/bin/python
    import sys
    from pyzabbix import ZabbixAPI
    zapi = ZabbixAPI(url='http://localhost/zabbix/', user='API_user', password='password')
    subject = sys.argv[1]
    items = subject.split(",")
    result = zapi.item.update({'itemid': items[0], 'delay': items[1]})

    I removed from this script any logging and exception handling. You may add it as you wish or rewrite a script for use it with your favorite Zabbix API library.

    3. Copy the script to an AlertScriptsPath location. Make it executable. Create a new media type (type – script) for the script at "Administration - Media types" with parameter {ALERT.SUBJECT}. Allow this media type to user (for example, API_user).

    4. Create an action with trigger, responsive to anomaly. Targeted item must be the first item in trigger expression.
    Default subject in “operations”:
    {ITEM.ID1},{$UPDATE_FAST}
    in “Recovery operations”:
    {ITEM.ID1},{$UPDATE_LOW}
    Operation is “send message to API_user” via this new media type.

    Criticism and improvements are welcome.
    Last edited by Semiadmin; 05-06-2017, 16:16.
Working...