Ad Widget

Collapse

Creating Calculated Fields

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • emerzon
    Junior Member
    • Apr 2008
    • 21

    #1

    Creating Calculated Fields

    Hello everyone,

    I wonder if it's possible to create calculated fields, without having to collect the actual data.

    For instance:

    I have for host1 the fields value1, value2 and value3 being collected, and I would like to plot a graph with the sum of all 3.

    As I understood so far the aggregate functions do not work for that. Am I missing something?

    BR,
    Emerson
  • nelsonab
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Sep 2006
    • 1233

    #2
    Nope you're not missing anything. You'll need to create an external script that "aggregates" the values you want together and then plot that.
    RHCE, author of zbxapi
    Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
    Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

    Comment

    • rts
      Member
      • May 2007
      • 54

      #3
      What about summing between hosts? That's not easily possible via a script.

      I'd like to graph "Total widgets being used" across five servers.

      Comment

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

        #4
        Look at aggregate checks. In some cases this is what you need.
        Alexei Vladishev
        Creator of Zabbix, Product manager
        New York | Tokyo | Riga
        My Twitter

        Comment

        • rts
          Member
          • May 2007
          • 54

          #5
          Thanks Alexei. That looks to be exactly what I want. However, I can't seem to work out how to use it.

          The documentation says I should use [], whilst the PHP front end suggests (). Either way, when I create an aggregate check as follows:

          grpsum("WidgetServers","widgetapp.widgetsused","la st","0")

          I'm told "Item added", but I can't find it anywhere in the interface, nor in the DB.

          Any suggestions?

          Comment

          • rts
            Member
            • May 2007
            • 54

            #6
            Sorry to bump this, but is anyone successfully using aggregate checks

            Comment

            • nelsonab
              Senior Member
              Zabbix Certified SpecialistZabbix Certified Professional
              • Sep 2006
              • 1233

              #7
              Aggregate checks work quite well. The docs are correct, the PHP frontend is wrong...

              the format is grpfunc["group","key","func","value"]

              The double quotes and the square brackets are important. The syntax of the aggregate functions was different in previous versions of Zabbix and used parentheses and single quotes. This was a gotcha for our 1.1.6 -> 1.6 upgrade last night.
              RHCE, author of zbxapi
              Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
              Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

              Comment

              • rts
                Member
                • May 2007
                • 54

                #8
                Thanks nelsonab,

                However, I still can't get it to work. I've created an item as follows:

                grpsum["MyGrp","myapp.widgetcount","last","0]

                and am told: "Item added" in green at the top of the next page.

                However, I can never find this item.

                Am I right to add it to a template, or do I need to add it to an actual host?

                Comment

                • nelsonab
                  Senior Member
                  Zabbix Certified SpecialistZabbix Certified Professional
                  • Sep 2006
                  • 1233

                  #9
                  Originally posted by rts
                  Thanks nelsonab,

                  However, I still can't get it to work. I've created an item as follows:

                  grpsum["MyGrp","myapp.widgetcount","last","0]

                  and am told: "Item added" in green at the top of the next page.

                  However, I can never find this item.

                  Am I right to add it to a template, or do I need to add it to an actual host?
                  It may just be a copy error, but you do have the closing quote around the 0 in your server right? Also double check the syntax against the docs and the key itself after doing that make sure the item is set to enabled. Otherwise you won't see it.
                  RHCE, author of zbxapi
                  Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
                  Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

                  Comment

                  • rts
                    Member
                    • May 2007
                    • 54

                    #10
                    Thanks for pointing out that typo. I've corrected it, double checked the documentation, checked the key I'm using, and I still can't get it to actually add the item.

                    I'll try to rummage through the code tomorrow to see why it's not happening.


                    Thanks for your help

                    Comment

                    • rts
                      Member
                      • May 2007
                      • 54

                      #11
                      Good news -- I've resolved the problem. The data type chosen has to be "numeric (float)". For a reason that I haven't pinned down, the:

                      if( ($type == ITEM_TYPE_AGGREGATE) && ($value_type != ITEM_VALUE_TYPE_FLOAT))
                      {
                      error("Value type must be Float for aggregate items");
                      return FALSE;
                      }


                      in include/items.inc.php wasn't displaying the error.

                      Once I changed to float, then it worked perfectly.

                      Comment

                      Working...