Ad Widget

Collapse

Check value using Zabbix Agent

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MarcoUK
    Junior Member
    • Oct 2021
    • 26

    #1

    Check value using Zabbix Agent

    I have configured on my server this zabbix-agent parameter:
    Code:
    cat /etc/zabbix/zabbix_agentd.conf.d/userparameter.conf
    UserParameter=verify-download.failures, /usr/share/monitoring/bin/verify.sh /usr/share/monitoring/FILES/download-status
    where:
    Code:
    #!/bin/sh
    # run from Zabbix agent, used to verify output status
    echo $(cat "$1")
    and
    Code:
    cat /usr/share/monitoring/FILES/download-status
    1
    From another script I write this value, where 1 is error the file is not downloaded, and 0 is OK the file is downloaded

    On my Zabbix server, I created this item:
    Code:
    Name: download verify
    Type: Zabbix agent
    Key: verify-download.failures
    and if I click on test I receive the correct result (I tried to change manually the value in the file /usr/share/monitoring/FILES/download-status and read correctly the values)

    Now I'm trying to create trigger alert, and I set in this way:
    Code:
    Name: download alert
    Severity: High
    Expression: {server01.mydomain.com:verify-download.failures.last()} = 0
    but when the value in /usr/share/monitoring/FILES/download-status is 1 from this trigger I receive always 0

    Where is I wrong?
  • MarcoUK
    Junior Member
    • Oct 2021
    • 26

    #2
    Originally posted by cyber
    Why do you have Userparameter for this at all? Why not use "vfs.file.contents" item? or "vfs.file.regmatch" etc...

    You trigger condition says to trigger when 0, whats the problem?
    Thanks for your reply, if I set 0 it works correctly.


    To be honest my scope is to check every 5 minutes if the file is wonloaded from S3, and the file if it's downloaded have this name: filename.txt-HH:MM-BST
    is there a easy way to check it?

    Comment

    • MarcoUK
      Junior Member
      • Oct 2021
      • 26

      #3
      Originally posted by cyber
      nope... there is no options to enter hours/minutes into filenames... So you are going in right direction with a script checking it and writing result into logfile. but you don't need a UserParameter to read that logfile...
      You could also use a trapper item and send value directly from checking script with zabbix_sender

      Set your expression to "...= 1" and it should trigger when you receive 1 as item value...
      Thanks for your reply.
      I created a script that use a zabbix_sender to send info to tripper.
      My script is:
      Code:
      # $1 is a parameter passed by argument when I call this script, in my test is TEST1
      ....
      FILE=/opt/folder/file.txt
      
      if [[ -e ${FILE} ]]; then
          result="OK: File exist"
      else
          result="Error Download: no file exist"
      fi
      
      zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k $1_download.failures.trapper -o "$result"

      This is my tripper:
      Code:
      Name: File verify trapper
      Type: Zabbix trapper
      Key: TEST1_download.failures.trapper
      Type of information: Text
      This is my trigger:
      Code:
      Name: File download error
      Expression: {server.mydomain.com:TEST1_download.failures.trappe r.regexp("^(Error Download)")}=1
      and this is the response if I run manually the zabbix_sender:
      Code:
      zabbix_sender -vv -c /etc/zabbix/zabbix_agentd.conf -k TEST1_download.failures.trapper -o "Error Download: no file exist"
      zabbix_sender [747852]: DEBUG: answer [{"response":"success","info":"processed: 1; failed: 0; total: 1; seconds spent: 0.000072"}]
      Response from "10.234.16.23:10051": "processed: 1; failed: 0; total: 1; seconds spent: 0.000072"
      sent: 1; skipped: 0; total: 1
      But I don't receive an alert on trigger.
      Last edited by MarcoUK; 21-10-2021, 15:15.

      Comment

      • cyber
        Senior Member
        Zabbix Certified SpecialistZabbix Certified Professional
        • Dec 2006
        • 4807

        #4
        Why do you have Userparameter for this at all? Why not use "vfs.file.contents" item? or "vfs.file.regmatch" etc...
        You trigger condition says to trigger when 0, whats the problem?...

        Comment

        • cyber
          Senior Member
          Zabbix Certified SpecialistZabbix Certified Professional
          • Dec 2006
          • 4807

          #5
          nope... there is no options to enter hours/minutes into filenames... So you are going in right direction with a script checking it and writing result into logfile. but you don't need a UserParameter to read that logfile...
          You could also use a trapper item and send value directly from checking script with zabbix_sender
          Set your expression to "...= 1" and it should trigger when you receive 1 as item value...

          Comment

          • cyber
            Senior Member
            Zabbix Certified SpecialistZabbix Certified Professional
            • Dec 2006
            • 4807

            #6
            Key: TEST1_download.failures.trapper
            But in manual run you are usingFILE1_download.failures.trapper
            Your trigger expression is OK. I did set up exact same here, your script et al ... works like a charm..
            add that -vv option to script and see does it work ok? There must be some little thing somewhere you have missed ..

            Comment

            Working...