Ad Widget

Collapse

Command Line Arguments to User Parameters

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Azrael
    Junior Member
    • Mar 2005
    • 7

    #1

    Command Line Arguments to User Parameters

    I've recently upgraded to 1.1alpha6 and I noticed in the ChangeLog that Zabbix now supports the passing of command line arguments to user parameters? How do we use such arguments? What is an example UserParameter= line for the zabbix_agent/d.conf file?

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

    #2
    It is not documented yet.

    First, you create a flexible user parameter:

    UserParameter=lineno[*], command

    You may substitute '*' with any argument and the argument will be passed to the command untouched:

    lineno[/] will be trasformed to 'command /'
    lineno[/tmp] will be transformed to 'command /tmp'

    Though I'm concerned about security and usability of this solution. Perhaps I'll rewrite it to pass parameter in an environment variable.
    Alexei Vladishev
    Creator of Zabbix, Product manager
    New York | Tokyo | Riga
    My Twitter

    Comment

    • Azrael
      Junior Member
      • Mar 2005
      • 7

      #3
      Awesome stuff.

      Do you think at some point you'll change it so the argument is more flexible, as in it isn't just appended to the end of the command? Maybe something where you can specify the location of the argument with $1 or whatever... and support for more than one argument?

      Yeah security can definitely be a big issue here. Perhaps wait till a better authentication system is in place between the agents and the server? As well as encryption?

      Great work btw. I look forward to the official 1.1 release.

      -Azrael
      Last edited by Azrael; 01-03-2005, 13:54.

      Comment

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

        #4
        Originally posted by Azrael
        Do you think at some point you'll change it so the argument is more flexible, as in it isn't just appended to the end of the command? Maybe something where you can specify the location of the argument with $1 or whatever... and support for more than one argument?
        Actually I'd like arguments to be passed as environment variables, like $1. Then I could implement multi-parameters, so something[a,b,c] will be translated to command $1 $2 $3, where $1=a, $2=b, $3=c.
        Alexei Vladishev
        Creator of Zabbix, Product manager
        New York | Tokyo | Riga
        My Twitter

        Comment

        • mdeavila
          Junior Member
          • Mar 2005
          • 12

          #5
          Possible to pass multiple values to a UserParameter in 1.1alpha7?

          Can I pass multiple values to a UserParameter defined in the agentd config file?

          I want to specify a key like this on the zabbix server side,

          apmonitor[cee272,cee27b,submitted]

          In the agetnd config file I have a UserParameter defined as

          UserParameter=apmonitor[*],apmonitor

          The goal is to invoke the command

          apmonitor cee272 cee27b submitted

          Is this doable in 1.1alpha7?

          thanks,

          Miguel DeAvila

          Comment

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

            #6
            ZABBIX will invoke apmonitor cee272,cee27b,submitted in your case. It is up-to your script to parse command line arguments.

            Alternatively you may use apmonitor[cee272 cee27b submitted] to get rid of commas.
            Alexei Vladishev
            Creator of Zabbix, Product manager
            New York | Tokyo | Riga
            My Twitter

            Comment

            • mdeavila
              Junior Member
              • Mar 2005
              • 12

              #7
              Trouble passing command-line parameters in to an agent in 1.1alpha7

              I've defined an item on the zabbix server using the key

              apmonitor[cee272 cee27b submitted]

              On the agent side, I've defined a UserParameter,

              UserParameter=apmonitor[*],apmonitor

              In the agent log I see the following message,

              001537:20050322:144108 Got line:apmonitor[cee272 cee27b submitted]
              001537:20050322:144111 Sending back:ZBX_NOTSUPPORTED

              I'm trying to determine why. I can run the agent from the command line as the zabbix user,

              laverne init.d # su - zabbix
              zabbix@laverne zabbix $ apmonitor cee272 cee27b submitted
              4027

              Any suggestions how I can determine why the agentd is sending back ZBX_NOTSUPPORTED?

              thanks,

              Miguel

              Comment

              • mdeavila
                Junior Member
                • Mar 2005
                • 12

                #8
                solved

                The trouble was that command-line arguments are passed to the UserParameter script as a single argument.

                In the UserParameter script I was expecting to process the 3 args as $1, $2, and $3. Instead, the args are passed to the script as "arg1 arg2 arg3".

                I altered my script so that it accepted a single argument and then parsed it into 3 separate values.

                Comment

                • richlv
                  Senior Member
                  Zabbix Certified Trainer
                  Zabbix Certified SpecialistZabbix Certified Professional
                  • Oct 2005
                  • 3112

                  #9
                  Originally posted by Alexei
                  It is not documented yet.

                  First, you create a flexible user parameter:

                  UserParameter=lineno[*], command
                  ...
                  Though I'm concerned about security and usability of this solution. Perhaps I'll rewrite it to pass parameter in an environment variable.
                  well, it seems to be rewritten/changed
                  it now works as i tried to describe in http://www.zabbix.com/forum/showpost...3&postcount=22
                  Zabbix 3.0 Network Monitoring book

                  Comment

                  Working...