Ad Widget

Collapse

Pie chart country+value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pietro54
    Senior Member
    • Feb 2011
    • 112

    #1

    Pie chart country+value

    Hello zabbix guys

    this should be quite simple task, but i cannot find nowhere any solution
    Target to achive is pie chart with 2 values,
    country + number.

    When you are monitoring web server, you would like to see from where is most part of Traffic.

    This should look like:
    go to google and search: "threads country pie chart"

    eg. input look like this:
    CH:10
    US:1000
    GB:22
    etc.

    could you help?
    Last edited by pietro54; 04-11-2017, 00:11.
  • pietro54
    Senior Member
    • Feb 2011
    • 112

    #2
    Hello, is there any one who could help?

    Comment

    • Atsushi
      Senior Member
      • Aug 2013
      • 2028

      #3
      If you are using Zabbix 3.4, you may be able to realize it using item preprocessing.


      First, create items that acquire text data of each country with multiple lines.

      And prepare items of each country as child items of that item.
      For each country item, it is a method to retrieve the value of each country using regular expressions from parent items.

      ex. regexp parameters
      Code:
      CH:([0-9]+)
      US:([0-9]+)
      GB:([0-9]+)
      Last edited by Atsushi; 10-11-2017, 08:57.

      Comment

      • Atsushi
        Senior Member
        • Aug 2013
        • 2028

        #4
        Sample parent item setting.

        Code:
        Name : Base data
        Type : Zabbix agent
        Key : vfs.file.contents[/tmp/base.dat]
        Type of information : Text

        Sample child item setting.

        Code:
        Name : Switzerland value
        Type : Dependent item
        Key : test.switzerland
        Master item : Base data: vfs.file.contents[/tmp/base.dat]
        Type of information : Numeric (unsigned)
        
        Preprocessing steps
        Name : Regular expression
        Parameter : CH:([0-9]+)		\1

        Comment

        • pietro54
          Senior Member
          • Feb 2011
          • 112

          #5
          Hi,

          thanks for replay,
          i was thinking about LLD and prototype items.

          I have scripts httpcodes.sh

          that will giv me some data like this
          Code:
          {
            200: 1279276,
            206: 732,
            301: 22366,
            302: 6888,
            304: 39417,
            307: 68,
            400: 714,
            401: 1,
            403: 1384,
            404: 27249,
            406: 4964,
            410: 9495,
            412: 21,
            499: 5033,
            500: 146,
            501: 4,
            502: 6,
            503: 16,
            504: 1,
            520: 136,
            530: 5
          }
          I was wondering how should look userparameter in zabbix conf and how should look item in zabbix server.

          Comment

          • Atsushi
            Senior Member
            • Aug 2013
            • 2028

            #6
            If you use LLD to dynamically generate country-specific items, you will need the following two scripts.

            1. Script for generating country-specific list
            2. Script to retrieve values corresponding to each country

            The first script is a script that will return information for each country in the JSON format as shown in the following URL.
            Zabbix uses this script in the discovery rule.



            The second script is a script that obtains values corresponding to each country from country-specific information generated by discovery.
            Zabbix uses this script in the prototype of the item in the discovery rule.

            Since I do not know the format of the data to be input, I can not answer any more.

            Also, the feature that automatically displays discovered items on the same graph is not yet implemented.

            ZBXNEXT-927 : Allow LLD Graphs to graph an item for each discovered entity in a single graph

            Comment

            • pietro54
              Senior Member
              • Feb 2011
              • 112

              #7
              Hi,

              my output form the sctipt looks like this:

              $/usr/local/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf -t httpcode
              httpcode [t|{
              "data":[
              {
              "{#HTTPCODE}":"200",
              "{#AMOUNT}":"1774916"
              }
              ,
              {
              "{#HTTPCODE}":"206",
              "{#AMOUNT}":"1243"
              }
              ,
              {
              "{#HTTPCODE}":"301",
              "{#AMOUNT}":"34268"
              }
              ,
              {
              "{#HTTPCODE}":"302",
              "{#AMOUNT}":"10948"
              }
              ]}]

              My userparm in zabbix agent conf is like this:
              UserParameter=httpcode,python /etc/zabbix/scripts/httpcodes2.py
              My config looks like this,




              My issue looks like this



              I think the issue is itemprototype key... i was trying with {#amount} and this does`t help. I don`t have idea what to change here
              Last edited by pietro54; 13-11-2017, 20:14.

              Comment

              • Atsushi
                Senior Member
                • Aug 2013
                • 2028

                #8
                You do not want to compile by country, do you?

                You set the item key of the item prototype as follows.

                Code:
                httpcode[{#HTTPCODE}]
                However, UserParameter is not set to handle arguments.

                Can httpcodes2.py be processed by giving httpcode as an argument?
                For example, suppose that you can get the value corresponding to each httpcode by executing as follows.

                Code:
                $ python /etc/zabbix/scripts/httpcodes2.py 200
                1774916
                $
                If so, add the following settings as UserParameter.

                Code:
                UserParameter=httpcodevalue[*],python /etc/zabbix/scripts/httpcodes2.py $1
                Please set the item prototype which is the item key as follows according to it.

                Code:
                httpcodevalue[{#HTTPCODE}]

                Comment

                • pietro54
                  Senior Member
                  • Feb 2011
                  • 112

                  #9
                  Hi,

                  sorry for late response.

                  please look into this documentation, https://www.zabbix.com/documentation...evel_discovery

                  Go do bottom of this page, and please look for perl script. I was trying to do this trick exactly with this documentation, maybe for you it will be more intuitive.

                  If you won`t understood it i will have to rebuild my script...

                  Comment

                  • Atsushi
                    Senior Member
                    • Aug 2013
                    • 2028

                    #10
                    Hi pietro54,

                    Are you reading the message I wrote?
                    That perl script only performs discovery.
                    Apart from that script, you need a script to get the value of each item.

                    Comment

                    • pietro54
                      Senior Member
                      • Feb 2011
                      • 112

                      #11
                      Atsushi thanks for your pacient for me.
                      this work fine, thanks.

                      [SOLVED]

                      Comment

                      Working...