Ad Widget

Collapse

UserParameter with variable substitution and $1

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • operaking
    Junior Member
    • Sep 2006
    • 2

    #1

    UserParameter with variable substitution and $1

    Hello,

    I am attempting to create a UserParameter with variable substitution.
    The command will sum memory for processes matching an expression passed to the UserParameter, for instance;
    process.mem[jboss]

    Within my command I am using the awk variable $1 to reference ps info;
    awk '{a+=$1} END {print a}'

    My full user parameter is;
    UserParameter=process.mem[*],ps -eao "vsize command" | grep $1 | awk '{a+=$1} END {print a}'

    Of course this doesn't work as Zabbix substitues all $1 variables with it's own variables. I want the first $1 to be the Zabbix supplied 'jboss' and the second $1 to be left alone as it is part of the awk awk command.

    Any ideas how to do this?
  • Alexei
    Founder, CEO
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Sep 2004
    • 5654

    #2
    ZABBIX 1.1, 1.1.1 (note space!):

    UserParameter=process.mem[*],ps -eao "vsize command" | grep $1 | awk '{a+=$ 1} END {print a}'

    In ZABBIX 1.1.2 you may use $$ to quote $:

    UserParameter=process.mem[*],ps -eao "vsize command" | grep $1 | awk '{a+=$$1} END {print a}'
    Alexei Vladishev
    Creator of Zabbix, Product manager
    New York | Tokyo | Riga
    My Twitter

    Comment

    • operaking
      Junior Member
      • Sep 2006
      • 2

      #3
      fantastic! Thanks for your great reply

      Comment

      Working...