Ad Widget

Collapse

using awk and $ in agentd.conf

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • riegersteve
    Member
    • Oct 2004
    • 68

    #1

    using awk and $ in agentd.conf

    here are the relevant lines from zabbix_agentd.conf



    UserParameter=descriptors.available,awk '{print $3-$1+$2}' /proc/sys/fs/file-nr
    UserParameter=descriptors.error,awk '($1-$2)>(.9*$3) {exit 1}' /proc/sys/fs/file-nr

    [root@stg2 log]# zabbix_agentd -t descriptors.available
    awk: cmd. line:1: {print -+}
    awk: cmd. line:1: ^ syntax error
    descriptors.available [m|ZBX_NOTSUPPORTED]
    [root@stg2 log]# zabbix_agentd -t descriptors.error
    awk: cmd. line:1: (-)>(.9*) {exit 1}
    awk: cmd. line:1: ^ syntax error
    awk: cmd. line:1: (-)>(.9*) {exit 1}
    awk: cmd. line:1: ^ syntax error
    awk: cmd. line:1: (-)>(.9*) {exit 1}
    awk: cmd. line:1: ^ syntax error
    awk: cmd. line:1: (-)>(.9*) {exit 1}
    awk: cmd. line:1: ^ syntax error
    descriptors.error [m|ZBX_NOTSUPPORTED]
  • raminix
    Member
    • Jun 2006
    • 37

    #2
    Originally posted by riegersteve
    here are the relevant lines from zabbix_agentd.conf



    UserParameter=descriptors.available,awk '{print $3-$1+$2}' /proc/sys/fs/file-nr
    UserParameter=descriptors.error,awk '($1-$2)>(.9*$3) {exit 1}' /proc/sys/fs/file-nr

    [root@stg2 log]# zabbix_agentd -t descriptors.available
    awk: cmd. line:1: {print -+}
    awk: cmd. line:1: ^ syntax error
    descriptors.available [m|ZBX_NOTSUPPORTED]
    [root@stg2 log]# zabbix_agentd -t descriptors.error
    awk: cmd. line:1: (-)>(.9*) {exit 1}
    awk: cmd. line:1: ^ syntax error
    awk: cmd. line:1: (-)>(.9*) {exit 1}
    awk: cmd. line:1: ^ syntax error
    awk: cmd. line:1: (-)>(.9*) {exit 1}
    awk: cmd. line:1: ^ syntax error
    awk: cmd. line:1: (-)>(.9*) {exit 1}
    awk: cmd. line:1: ^ syntax error
    descriptors.error [m|ZBX_NOTSUPPORTED]
    I was a bit intrigued by this one and why it won't work. I was able to replicate the error and could not figure out a way to get it to work directly from the conf file. Both enclosing the command in back ticks and reversing the order by catting the file to awk failed. However, you can get around this by putting together a short shell script such as:

    Code:
    #!/bin/bash
    
    ###################################################
    ## descriptors.sh
    ##
    ## Called by zabbix_agentd, takes an aergument of
    ## either "avail" or "error" and returns a value
    ###################################################
    
    ACTION=$1
    
    if [ "$ACTION" = "avail" ]
    then
    
            awk '{print $3-$1+$2}' /proc/sys/fs/file-nr
    
    elif [ "$ACTION" = "error" ]
    then
    
            awk '($1-$2)>(.9*$3) {exit 1}' /proc/sys/fs/file-nr
    
    fi
    and then call it as such:

    Code:
    UserParameter=descriptors.available,/path/to/descriptors.sh avail
    UserParameter=descriptors.error,/path/to/descriptors.sh error
    And that should do the trick.

    Comment

    • Alexei
      Founder, CEO
      Zabbix Certified Trainer
      Zabbix Certified SpecialistZabbix Certified Professional
      • Sep 2004
      • 5654

      #3
      Change

      UserParameter=descriptors.available,awk '{print $3-$1+$2}' /proc/sys/fs/file-nr
      UserParameter=descriptors.error,awk '($1-$2)>(.9*$3) {exit 1}' /proc/sys/fs/file-nr

      to

      UserParameter=descriptors.available,awk '{print $ 3-$ 1+$ 2}' /proc/sys/fs/file-nr
      UserParameter=descriptors.error,awk '($ 1-$ 2)>(.9*$ 3) {exit 1}' /proc/sys/fs/file-nr

      ZABBIX 1.1.2 won't have this problem.
      Alexei Vladishev
      Creator of Zabbix, Product manager
      New York | Tokyo | Riga
      My Twitter

      Comment

      Working...