Ad Widget

Collapse

UserParameter with square bracket

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • stevenfoo
    Member
    • Mar 2008
    • 46

    #1

    UserParameter with square bracket

    Hi All,

    I have been trying to setup a UserParameter as following

    UserParameter=test1,ls -l | grep -v phy_dbs | awk '{print $1 "\t" $5}' | grep '^[0-9]$'

    When I run the command manually it works.

    However when I test it with /usr/local/bin/zabbix_agentd -t test1
    it return test1 [m|ZBX_NOTSUPPORTED]

    I tried to add the "\" sign, '^\[0-9\]$' ,also it does not work

    Any ideas?
  • JBo
    Senior Member
    • Jan 2011
    • 310

    #2
    Hi,

    Your ls -l has no argument.
    What directory are you trying to monitor ?

    I don't know the purpose of your parameter, but if i run:
    Code:
    ls -l | grep -v phy_dbs | awk '{print $1 "\t" $5}' | grep '^[0-9]$'
    I get nothing.

    Your UserParameter needs to return something or Zabbix will mark it as unsupported.

    Regards,
    JBo

    Comment

    • stevenfoo
      Member
      • Mar 2008
      • 46

      #3
      I replace my script with ls -l.

      Actually my script (check_tbp) data will produce something like below:


      Space Ext Link Items Percentage
      ABC_tbpsp 13 1-1 qw 20
      DEF_tbpsp 14 1-2 qw 30
      phy_dbs 16 1-3 dr 4
      JKL_tbpsp 8 2-1 fr 9

      check_tbp | grep -v phy_dbs | awk '{print $1 "\t" $5}' | grep '^[0-9]$'

      Comment

      • JBo
        Senior Member
        • Jan 2011
        • 310

        #4
        Hi,

        I tried this:
        Code:
        echo 'Space Ext Link Items Percentage
        ABC_tbpsp 13 1-1 qw 20
        DEF_tbpsp 14 1-2 qw 30
        phy_dbs 16 1-3 dr 4
        JKL_tbpsp 8 2-1 fr 9' | grep -v phy_dbs | awk '{print $1 "\t" $5}' | grep '^[0-9]$'
        That should return the result you want and I still get no result.

        I have also tried same command without last grep:
        Code:
        echo 'Space Ext Link Items Percentage
        ABC_tbpsp 13 1-1 qw 20
        DEF_tbpsp 14 1-2 qw 30
        phy_dbs 16 1-3 dr 4
        JKL_tbpsp 8 2-1 fr 9' | grep -v phy_dbs | awk '{print $1 "\t" $5}'
        and I get:
        Code:
        Space    Percentage
        ABC_tbpsp    20
        DEF_tbpsp    30
        JKL_tbpsp    9
        You have described what you do but not what you want, so it is hard to find what should be changed in your code.

        I may be wrong but I have the impression that your shell command is not doing what you want and that has nothing to do with Zabbix.

        Regards,
        JBo

        Comment

        • stevenfoo
          Member
          • Mar 2008
          • 46

          #5
          The issue is when you test it with /usr/local/bin/zabbix_agentd -t test1
          it return test1 [m|ZBX_NOTSUPPORTED]

          The below part works fine.

          check_tbp | grep -v phy_dbs | awk '{print $1 "\t" $5}'

          However if I add the below, Zabbix does not support it and return test1 [m|ZBX_NOTSUPPORTED]

          check_tbp | grep -v phy_dbs | awk '{print $1 "\t" $5}' | grep '^[0-9]$'

          Comment

          • JBo
            Senior Member
            • Jan 2011
            • 310

            #6
            Hi,

            Originally posted by stevenfoo
            The issue is when you test it with /usr/local/bin/zabbix_agentd -t test1
            it return test1 [m|ZBX_NOTSUPPORTED]

            The below part works fine.
            OK.
            Under which account are you executing this command ?
            Is check_tbp in default PATH of this user ?
            Is check_tbp in default PATH of zabbix user ?

            If you define UserParameter as:
            Code:
            UserParameter=test1,check_tbp 2>&1
            what does
            Code:
             /usr/local/bin/zabbix_agentd -t test1
            display ?

            Regards,
            JBo

            Comment

            • JBo
              Senior Member
              • Jan 2011
              • 310

              #7
              After rereading the full thread, I'm still afraid that your command
              Code:
               check_tbp | grep -v phy_dbs | awk '{print $1 "\t" $5}' | grep '^[0-9]$'
              will never return anything.
              awk '{print $1 "\t" $5}' generates lines with 2 fields separated by a tab.
              grep '^[0-9]$' will match lines that contain only a single digit.

              I don't understand how the output of awk can match the input expected by grep.

              Regards
              JBo

              Comment

              Working...