Ad Widget

Collapse

Multiple output values with custom check script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • emerzon
    Junior Member
    • Apr 2008
    • 21

    #1

    Multiple output values with custom check script

    Hello everyone,

    I wrote a custom monitoring script that will fetch values from a Oracle database using sqlplus. My question is, is there any way to output multiple values at once to Zabbix? For instance, instead of:

    # ./script.sh field_a
    value1
    # ./script.sh field_b
    value2


    using simply:

    # ./script.sh
    value1;value2


    and make zabbix handle value1 and value2 differently.

    I ask that because I am using very CPU intensive SQL queries, and it would be much CPU cheaper to fetch all the values at once.

    Any ideas?
  • nelsonab
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Sep 2006
    • 1233

    #2
    Here's what we do for CPU intensive queries involving scripts. First the script will check the age of it's local "cache" file. If the file is below an expiration threshold it will grep the file and return the value. If the file is above the threshold it will regenerate the file, grep it and then return the data. The script is general purpose and will return a value based on the command line argument. Right now our script gives us a two minute resolution irrespective of how often we check it in Zabbix.
    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

    • emerzon
      Junior Member
      • Apr 2008
      • 21

      #3
      Hello. Thanks for your suggestion. I will give it a try.

      BR,
      Emerson

      Comment

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

        #4
        Another option along this idea is to have the "cache" file generated from a cron job. You would then only need a simple script to return your values. You will also want to add a check for the age of the "cache" file, then associate a trigger with it should the "cache" file be older than a certain threshold, this way you will be alerted should the cron job fail.
        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

        Working...