Ad Widget

Collapse

Calculated item - system.cpu.num

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jdb
    Junior Member
    • Nov 2015
    • 3

    #1

    Calculated item - system.cpu.num

    I am new to zabbix.
    I tried to create a calculated item using the following formula, but it keeps giving me "Cannot evaluate function "last()": item "server_host_name:system.cpu.num" does not exist"

    100*last("system.stat[cpu,pc]") / (last("system.cpu.num")/4)

    AIX/zabbix 2.2 supports system.cpu.num.

    I used zabbix_get to validate the key and I was able to get a value back
    # /usr/bin/zabbix_get -s server_host_name-k system.cpu.num
    4

    What am I doing wrong?
  • ingus.vilnis
    Senior Member
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Mar 2014
    • 908

    #2
    Hello and welcome to Zabbix forums!

    Calculated items return results only when the formula is correct and contains items with exactly the same syntax as defined on the hosts.

    The error message already is telling you a lot: item "server_host_name:system.cpu.num" does not exist

    Please check if you have such item with exact key "system.cpu.num" on the host (or template level). Add the item if it does not exist and check the calculated item again after a while.

    Best Regards,
    Ingus

    Comment

    • jdb
      Junior Member
      • Nov 2015
      • 3

      #3
      Thanks for your reply Ingus.

      From what I read and correct me if I am wrong, the best way to test a key is to use the zabbix_get. If the key didn't exist it won't return a value. In my case it did.

      I tried to add the key at the client level then restart the agent. it didn't start because:
      7209212:20151125:114338.789 cannot add user parameter "system.cpu.num,lparstat -i |grep "Desired Virtual CPUs" |cut -f2 -d:": key "system.cpu.num" already exists

      Comment

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

        #4
        Hi,

        Let's try to understand what happens here.

        system.cpu.num is a standard built in item key in Zabbix. The value is obtained by Zabbix agent upon request.

        You did test the key and connection very correctly with zabbix_get and everything is fine there. Agent returned value "4" which is the number of CPUs you have on your device.

        And that is it. You don't have to touch agent and its configuration file anymore. You don't have to add system.cpu.num as user parameter to get data from agent. You get the values from other items without any additional user parameters already. Log entry key "system.cpu.num" already exists" just tells you that you cannot add user parameter with the same key as one built in item already has.

        Now let's go to the frontend part.
        You have to create a new item on your host or template with key system.cpu.num

        Once created, agent will report the number back to server automatically. No restart of agent is required. And don't set short update interval for this item since most like the number of CPUs does not change multiple times a day. Set it to update once an hour or even day otherwise it will just use space on your database.

        And now let's have a look again at your calculated item from original post.
        Now that you have "system.cpu.num" key on your host your calculated item most likely will get evaluated correctly.

        Best Regards,
        Ingus

        Comment

        • jdb
          Junior Member
          • Nov 2015
          • 3

          #5
          That fixed the issue and it started collecting data.
          I misunderstood the "does not exist" error, I thought it was talking about the key at the client level not the data from the client for that key.

          Thanks Ingus.

          Comment

          Working...