Ad Widget

Collapse

UserParameter provide numeric values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tvtue
    Member
    • Sep 2012
    • 71

    #1

    UserParameter provide numeric values

    Hello zabbix users,

    how can one get the zabbix agent to provide numeric values when using UserParamter items? I've searched the forum and found a lot of similar entries, but none of them satisfies my question.

    I've defined the following UserParameter:

    Code:
    UserParameter=ibs.echo1,echo 1
    UserParameter=ibs.echo2,echo 2.0
    If I do a --test with zabbix-agentd I get these return values:

    Code:
    root@admin:~ # zabbix-agentd --test "ibs.echo1"
    ibs.echo1                                     [t|1]
    
    root@admin:~ # zabbix-agentd --test "ibs.echo2"
    ibs.echo2                                     [t|2.0]
    The thing is: I want to get numeric values, so I can have a trend and to calculation with them.

    TIA
    timo
  • ingus.vilnis
    Senior Member
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Mar 2014
    • 908

    #2
    Hello,

    Not sure but try something like
    Code:
    UserParameter=ibs.echo1,echo 1 | awk '{print $2}'
    Best Regards,
    Ingus

    Comment

    • tvtue
      Member
      • Sep 2012
      • 71

      #3
      Originally posted by ingus.vilnis
      Hello,

      Not sure but try something like
      Code:
      UserParameter=ibs.echo1,echo 1 | awk '{print $2}'
      Best Regards,
      Ingus
      Hello Ingus,
      thank you for your reply but that results in an empty value:

      Code:
      root@admin:~ # zabbix-agentd --test "ibs.echo1"
      ibs.echo1                                     [t|]

      Comment

      • ingus.vilnis
        Senior Member
        Zabbix Certified Trainer
        Zabbix Certified SpecialistZabbix Certified Professional
        • Mar 2014
        • 908

        #4
        Maybe
        Code:
        UserParameter=ibs.echo1,echo 1 | awk '{print $1}'
        works?

        But anyways, what do you get in Zabbix frontend? Do you get any values with item key ibs.echo1 both with or without this print function?

        Best Regards,
        Ingus

        Comment

        • tvtue
          Member
          • Sep 2012
          • 71

          #5
          Originally posted by ingus.vilnis
          Maybe
          Code:
          UserParameter=ibs.echo1,echo 1 | awk '{print $1}'
          works?

          But anyways, what do you get in Zabbix frontend? Do you get any values with item key ibs.echo1 both with or without this print function?

          Best Regards,
          Ingus


          With this UserParameter
          Code:
          UserParameter=ibs.echo1,echo 1 | awk '{ print $1 }'
          I am getting this result on the shell:

          Code:
          zabbix@admin:~ $ /usr/sbin/zabbix-agentd --test ibs.echo1
          ibs.echo1                                     [t|1]
          And in the frontend I get the desired values. This is surprising! Even more, the second test UserParameter ibs.echo2 also works. I don't need to append | awk.

          Of course the upper mentioned UserParameters were only for testing. My real UserParameter is not working. It gives me red icons and the message:

          Code:
          Received value [] is not suitable for value type [Numeric (unsigned)] and data type [Decimal]
          Here is the code of it:
          Code:
          UserParameter=ibs.mbox.mailnum[*],/usr/bin/sudo -u cyrus /usr/cyrus/bin/mbexamine $1 | awk '/Number of Messages:/ {print $$4}'
          It works in the shell:
          Code:
          zabbix@admin:~ $ /usr/sbin/zabbix-agentd --test ibs.mbox.mailnum[user/ibs-blb]
          ibs.mbox.mailnum[user/ibs-blb]                [t|34]
          But it seems to provide only emtpy values on the zabbix server, "Received value [] ..."
          Last edited by tvtue; 27-06-2014, 14:23.

          Comment

          • tvtue
            Member
            • Sep 2012
            • 71

            #6
            update

            On the zabbix server, I can also do a

            Code:
            root@ibs-mngr:~ # zabbix_get -s admin-w0 -k ibs.mbox.mailnum[user/ibs-blb]
            34
            But the item is an agent active one, though.

            Comment

            • tvtue
              Member
              • Sep 2012
              • 71

              #7
              Ihave raised the debug level on the zabbix-agentd side. And I can see that indeed the values for items are empty. But I still don't understand why.

              Here is an excerpt from the log:

              Code:
              31301:20140627:143722.222 JSON before sending [{
                      "request":"agent data",
                      "data":[
                              {
                                      "host":"admin-w0.example.com",
                                      "key":"ibs.mbox.mailnum[user.desi]",
                                      "value":"",
                                      "clock":1403872637,
                                      "ns":556218351},
                              {
                                      "host":"admin-w0.example.com",
                                      "key":"ibs.mbox.mailnum[user.ibs-blb]",
                                      "value":"",
                                      "clock":1403872637,
                                      "ns":576883114},
                              ....
              31301:20140627:143722.223 JSON back [{
                      "response":"success",
                      "info":"processed: 2; failed: 33; total: 35; seconds spent: 0.000483"}]
               31301:20140627:143722.223 In check_response() response:'{
                      "response":"success",
                      "info":"processed: 2; failed: 33; total: 35; seconds spent: 0.000483"}'
               31301:20140627:143722.224 info from server: 'processed: 2; failed: 33; total: 35; seconds spent: 0.000483'
               31301:20140627:143722.224 End of check_response():SUCCEED
               31301:20140627:143722.224 OK
              Last edited by tvtue; 27-06-2014, 14:46.

              Comment

              • ingus.vilnis
                Senior Member
                Zabbix Certified Trainer
                Zabbix Certified SpecialistZabbix Certified Professional
                • Mar 2014
                • 908

                #8
                Is your zabbix user running as sudo with root rights?

                Can user zabbix normally access folder /usr/cyrus/bin/mbexamine ?

                Best Regards,
                Ingus

                Comment

                • tvtue
                  Member
                  • Sep 2012
                  • 71

                  #9
                  Originally posted by ingus.vilnis
                  Is your zabbix user running as sudo with root rights?

                  Can user zabbix normally access folder /usr/cyrus/bin/mbexamine ?

                  Best Regards,
                  Ingus
                  What do you mean by "normally"?

                  The UserParamter has sudo rights for user cyrus in it, who is allowed to run the mbexamine binary.

                  Code:
                  UserParameter=ibs.mbox.mailnum[*],/usr/bin/sudo -u cyrus /usr/cyrus/bin/mbexamine $1 | awk '/Number of Messages:/ {print $$4}'

                  Comment

                  • ingus.vilnis
                    Senior Member
                    Zabbix Certified Trainer
                    Zabbix Certified SpecialistZabbix Certified Professional
                    • Mar 2014
                    • 908

                    #10
                    I wanted to know whether you don't need additional rights or passwords to execute this function.

                    But ok, here are some more things and pointers you can check.
                    • what is your Timeout setting in zabbix_server.conf file? Set it to some 15 seconds in case the command takes long time to run.
                    • what is your Refresh unsupported items (in sec) setting in Administration -> General -> Other (from top right dropdown menu)?
                    • can't you just reduce awk '/Number of Messages:/ {print $$4}' to {print $4} ?


                    Best Regards,
                    Ingus

                    Comment

                    • tvtue
                      Member
                      • Sep 2012
                      • 71

                      #11
                      I found it, I made a mistake in a step before. /var/log/messages revealed it by showing me the actual sudo command that were beeing executed.

                      So I tested with the right parameters but zabbix-agentd was using wrong input values.

                      Thank you for your time and help!

                      timo

                      Comment

                      • worksyn
                        Junior Member
                        • Jun 2015
                        • 18

                        #12
                        Originally posted by tvtue
                        The thing is: I want to get numeric values, so I can have a trend and to calculation with them.

                        TIA
                        timo
                        so did anyone sort this out? How can i get numeric data type from UserParameter command?

                        Comment

                        • kaspars.mednis
                          Senior Member
                          Zabbix Certified Trainer
                          Zabbix Certified SpecialistZabbix Certified Professional
                          • Oct 2017
                          • 349

                          #13
                          can you be a little more specific on your problem ?

                          what are you getting now ?

                          Best regards,
                          Kaspars

                          Comment

                          • worksyn
                            Junior Member
                            • Jun 2015
                            • 18

                            #14
                            Originally posted by kaspars.mednis
                            can you be a little more specific on your problem ?

                            what are you getting now ?

                            Best regards,
                            Kaspars
                            # zabbix_agentd -t tasks[all]
                            tasks[all] [t|3]

                            my script returns numeric type, but agent treats it as text (t), I would like to have numeric type recognized by the agent.

                            Comment

                            • kaspars.mednis
                              Senior Member
                              Zabbix Certified Trainer
                              Zabbix Certified SpecialistZabbix Certified Professional
                              • Oct 2017
                              • 349

                              #15
                              Hi !
                              I have tried
                              Code:
                              zabbix_agentd -t system.run["echo 1"]
                              zabbix_agentd [26713]: Warning: Executing command 'echo 1'
                              system.run[echo 1]                            [t|1]
                              the output is text t|1
                              But if you specify item type as numeric unsigned, i think zabbix will try to transform this into integer

                              Have you tried this ?

                              Best regards,
                              Kaspars

                              Comment

                              Working...