Announcement

Collapse
No announcement yet.

Suggest Script linked to item

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Suggest Script linked to item

    It would be interesting, that you could add scripts related to LLD.
    For example, if we create a rule that discovers all Windows services, we can create a script to start the service that is stopped, but for that we need the service name variable.

    It is also necessary to be able to modify the timeout of the scripts, since 3 seconds is too little for several scripts.

    Thanks a lot!

    #2
    You can use your own scripts if you want.
    Examples of such scrips you can find in my templates on https://github.com/kloczek/zabbix-templates
    For example:
    1) OS Linux template uses:
    Code:
    system.run["awk 'BEGIN {print \"{\\"data\\":[\"; ORS=\"\"} {if (NR!=1) {print \",\n\"}; print \"{\\"{#DISK}\\":\\"\" $3 \"\\"}\"} END {print \"\n]}\"}' /proc/diskstats"]
    in DSK: LLD to generate list of block devices.
    2) OS Solaris uses similar item in own DSK LLD
    Code:
    system.run["iostat -x|awk 'BEGIN {print \"{\\"data\\":[\"; ORS=\"\"} {if (NR>3) {print \",\n\"}; if (NR>2) print \"{\\"{#DISK}\\":\\"\" $1 \"\\"}\"} END {print \"]}\"}'"]
    Other examples in the same template are in ZFS::L2ARC: and ZPOOL: LLDs used on generate list of L2ARC vdevs and list of ZFS pools
    3) Service MySQL template uses
    Code:
    system.run["{$MYSQL_CMD} 'show databases'|awk 'BEGIN {print \"{\\"data\\":[\"; ORS=\"\"} {if (NR>1) {print \",\n\"}; print \"{\\"{#DB}\\":\\"\" $1 \"\\"}\"} END {print \"]}\"}'"]
    to generate list of databases which needs to be monitored.

    You can adapt that way to use system.run[] with some power shell oneliners.
    http://uk.linkedin.com/pub/tomasz-k%...zko/6/940/430/
    https://kloczek.wordpress.com/
    zapish - Zabbix API SHell binding https://github.com/kloczek/zapish
    My zabbix templates https://github.com/kloczek/zabbix-templates

    Comment


      #3
      Originally posted by kloczek View Post
      You can use your own scripts if you want.
      Examples of such scrips you can find in my templates on https://github.com/kloczek/zabbix-templates
      For example:
      1) OS Linux template uses:
      Code:
      system.run["awk 'BEGIN {print \"{\\"data\\":[\"; ORS=\"\"} {if (NR!=1) {print \",\n\"}; print \"{\\"{#DISK}\\":\\"\" $3 \"\\"}\"} END {print \"\n]}\"}' /proc/diskstats"]
      in DSK: LLD to generate list of block devices.
      2) OS Solaris uses similar item in own DSK LLD
      Code:
      system.run["iostat -x|awk 'BEGIN {print \"{\\"data\\":[\"; ORS=\"\"} {if (NR>3) {print \",\n\"}; if (NR>2) print \"{\\"{#DISK}\\":\\"\" $1 \"\\"}\"} END {print \"]}\"}'"]
      Other examples in the same template are in ZFS::L2ARC: and ZPOOL: LLDs used on generate list of L2ARC vdevs and list of ZFS pools
      3) Service MySQL template uses
      Code:
      system.run["{$MYSQL_CMD} 'show databases'|awk 'BEGIN {print \"{\\"data\\":[\"; ORS=\"\"} {if (NR>1) {print \",\n\"}; print \"{\\"{#DB}\\":\\"\" $1 \"\\"}\"} END {print \"]}\"}'"]
      to generate list of databases which needs to be monitored.

      You can adapt that way to use system.run[] with some power shell oneliners.
      Thanks koloczek, but that's not what I'm looking for.
      LLD is ok, I can detect, for example, all services from windows. Also, I Can detect if It's is running or not. When, If It's stop, the trigger alert me. I'm looking for create a script for start this service from zabbix UI. In this case I need run the command "sc start {#SERVICE.NAME}". Service Name is a variable from LLD but the zabbix dosen't available this function.

      Comment

      Working...
      X