Ad Widget

Collapse

Automatic graph of all LLD items per host

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • screeble
    Member
    • Dec 2011
    • 34

    #16
    I had the same issue in this line . The changing $url variable helped me.
    Check yours one and try once again.

    Comment

    • pietro54
      Senior Member
      • Feb 2011
      • 112

      #17
      Hi,
      it was very good clue,
      Im using proxy... so when i try: get http://127... i was getting error.
      That was the problem.
      Thank you.


      ---EDIT---

      Hello again,
      script is working, but im not able to see graphs,
      im getting: Graph created: WIN Volume "ALL" bytes/sec stack
      (ofc i read this text will be allways, even if graphs wont be created)
      My question is where to find error message or something like that,
      I was searching in agent log and server log, still nothing.
      Last edited by pietro54; 20-09-2012, 09:46.

      Comment

      • mmarkwitzz
        Senior Member
        • Jan 2011
        • 106

        #18
        Sorry for the late reply.

        The script has no error checking whatsoever - I made it for myself and did not think I would need it since I could debug any errors myself.

        First things first
        - if the script outputs a list of hosts for which it _says_ it created graphs than that's a good sign, your template name is written correctly
        - if the script does _not_ output the list of items added to each graph, you either have a regex problem (check it again) or there are actually no discovered items for those hosts. In general, check to see if your LLD template is functioning as intended and your hosts have discovered items. Only after you have confirmed discovered items exist, blame the script.

        As a side note, zabbix cannot create empty graphs. They need to have at least one item. So if the script says "ok, i created a graph, but I found no items to add to it", it will LIE.

        There is no log you can check, not one that will help you anyway. The script sends JSON requests to the php file you specified in $url and it receives a JSON with the result. The script _never_ checks the result, through.

        EDIT: If you edit the script, you will find a "sub sendjson" function. The function calls curl with some json parameters and stores the result received from zabbix in variable $res. You can add a line above "# find start of json" with something like :
        Code:
        print $res."\n\n";
        This will print all of the available info. It will be very messy, however, lots of text.
        Last edited by mmarkwitzz; 20-09-2012, 10:57.

        Comment

        • mmarkwitzz
          Senior Member
          • Jan 2011
          • 106

          #19
          A typical script output should look something like this:

          HOST: host1 (10088)
          Graph created: IO read on "ALL"
          Added item "IO read on host1"
          Added item "IO write on host1"
          HOST: host2 (10100)
          Graph created: IO read on "ALL"
          HOST: host3 (10124)
          Graph created: IO read on "ALL"


          In this particular scenario, the script identified 3 hosts that are linked to the specified $template. Then it used the regex to add matched items (not necessary LLD items) to each graph. For host1, it matched 2 items and added them. For host2 or host3 there were no items matched, so none were added to the graph. As zabbix cannot create empty graphs, the graphs were not created.

          Why were no items matched on host2 and host3? Check the hosts - do you see any items? Maybe there is a problem with the discovery process for that host.

          There is a second script included in the package that only checks the $regex and prints all items matched by the $regex for each host linked to $template. Use this after you have confirmed that hosts do have discovered items, to test your regexes.

          Comment

          • pietro54
            Senior Member
            • Feb 2011
            • 112

            #20
            Hm...
            I got headrush
            Please explain me step by step.
            1st I should create discovery rule to template "windows"
            2nd I should add ittems to discovery rule?
            3rd i should start your script?

            Sorry im asking, but this is first time when i try to use regexp.


            ---EDIT---

            It looks like this:
            HOST: host_name (100100000010118)
            Graph created: WIN Volume "ALL" bytes/sec stack
            HOST: host_name (100100000010120)
            Graph created: WIN Volume "ALL" bytes/sec stack
            HOST: host_name (100100000010121)
            Graph created: WIN Volume "ALL" bytes/sec stack
            HOST: host_name (100100000010148)
            Graph created: WIN Volume "ALL" bytes/sec stack
            HOST: host_name (100100000010119)
            Graph created: WIN Volume "ALL" bytes/sec stack
            second script output looks like this:

            Low disk space on C: (100100000024554)
            Low disk space on D: (100100000024555)
            Low disk space on E: (100100000024575)
            Low disk space on F: (100100000024586)
            Memory load (100100000024553)
            Procesor load is to high (100100000024556)
            Process ntp (100100000024552)
            Too many processes (100100000024549)
            Total memory (100100000024551)
            uptime (100100000024550)
            Zabbix Agent is alive (100100000024548
            Last edited by pietro54; 20-09-2012, 15:25.

            Comment

            • Slash
              Member
              • May 2011
              • 64

              #21
              Thank you for your script, it's extremely useful! I'm using it to have nice graph of DB servers with all DB sizes, used connections, etc.

              One thing I noticed is that your script doesn't work over https, so I had to open zabbix over http and limit http to localhost to secure it.

              Just wanted to let you know that so the next one to use your script will know!

              Comment

              • mmarkwitzz
                Senior Member
                • Jan 2011
                • 106

                #22
                Originally posted by Slash
                Thank you for your script, it's extremely useful! I'm using it to have nice graph of DB servers with all DB sizes, used connections, etc.

                One thing I noticed is that your script doesn't work over https, so I had to open zabbix over http and limit http to localhost to secure it.

                Just wanted to let you know that so the next one to use your script will know!
                Glad to hear you find it useful.
                The https issue might be related to cURL. This is a little linux utility the script uses to send and receive json requests over http. I have no ideea if cURL supports https, but my guess it that it doesn't.

                Comment

                • ke_sheng_jie
                  Member
                  • Aug 2011
                  • 40

                  #23
                  Thanks!

                  Very useful script. I wish Zabbix had this functionality built-in.

                  Comment

                  • prostrelov
                    Senior Member
                    • May 2012
                    • 115

                    #24
                    Thx for the script.
                    Tryed it on OpenSuse Zabbix 2.0.5 Virtual machine (.vmx)

                    yast JSON-perl
                    nano lld_all_graph.pl
                    Code:
                    use warnings;
                    $regexes[0] = 'i:stat.in:FastEthernet0/1*';
                    $regexes[1] = '';
                    cp lld_all_graph.pl /usr/share/zabbix
                    cp list_items.pl /usr/share/zabbix
                    dos2unix lld_all_graph.pl
                    dos2unix list_items.pl
                    ./lld_all_graph.pl

                    unexpected end of string while parsing JSON string, at character offset 3 (before "olor: #000000; backg...") at line 64

                    I tryed to find color #000000 in lld_all_graph.pl but there is no such color there.
                    Last edited by prostrelov; 15-02-2013, 12:17.

                    Comment

                    • gug42
                      Junior Member
                      • Apr 2009
                      • 18

                      #25
                      Hello,

                      Do you think that this script is the answser to my question/need :


                      Thank you !

                      Regards,

                      Comment

                      • WarBull
                        Junior Member
                        • Feb 2012
                        • 26

                        #26
                        Help me please - which parameter i can to create in Template?

                        #$regexes[0] = '^WIN\sVolume\s.*\sbytes/sec\swrite';
                        #$regexes[1] = '^WIN\sVolume\s.*\sbytes/sec\sread';
                        # $regexes[0] = '^IO\sread\son\s';
                        # $regexes[1] = '^WIN\sVolume\s".*"\sbytes/sec\sread';

                        $regexes[0] = 'i:stat.in:FastEthernet0/1*';
                        $regexes[1] = '';

                        I can see in command line that Graph is create, but i cannot see any new graphs in Web interface!
                        And in run list_items.pl - i see all in terminal mode. I uncomment print string - in first i have error:

                        "Missing items for graph \"WIN Volume \"ALL\" bytes\/sec stack\"
                        This error if
                        $regexes[0] = '^WIN\sVolume\s.*\sbytes/sec\swrite';
                        $regexes[1] = '^WIN\sVolume\s.*\sbytes/sec\sread';

                        ******************************************
                        OC on Server is Windows 2003
                        Help me plaese about key in template and $regexes[0]

                        Comment

                        • MiZde
                          Junior Member
                          • May 2013
                          • 3

                          #27
                          Hello,

                          thank you for this script, it seems to be very usefull. But I can´t make it work.
                          What have I done:
                          chmod +x lld_all_graph.pl
                          chmod +x list_items.pl
                          dos2unix lld_all_graph.pl
                          dos2unix list_items.pl

                          If I tried to execute script lld_all_graph.pl, I got:
                          Code:
                          JSON text must be an object or array (but found number, string, true, false or null, use allow_nonref to allow this) at ./lld_all_graph.pl line 63
                          If I put
                          Code:
                          $json = $json->allow_nonref([$enable])
                          to the header, I got:
                          Code:
                          syntax error at ./lld_all_graph.pl line 20, near ")
                          
                          
                          # load a json string from a file
                          sub loadjson
                          "
                          syntax error at ./lld_all_graph.pl line 33, near "$result
                          }"
                          syntax error at ./lld_all_graph.pl line 51, near "}"
                          syntax error at ./lld_all_graph.pl line 69, near "}"
                          syntax error at ./lld_all_graph.pl line 94, near "$dec_out
                          }"
                          syntax error at ./lld_all_graph.pl line 128, near "}"
                          syntax error at ./lld_all_graph.pl line 161, near "$dec_out
                          }"
                          syntax error at ./lld_all_graph.pl line 198, near "}"
                          syntax error at ./lld_all_graph.pl line 235, near "}"
                          syntax error at ./lld_all_graph.pl line 266, near "}"
                          ./lld_all_graph.pl has too many errors.
                          I use Centos 6.4, Zabbix 2.0.6, php-5.3.3-22.el6.x86_64, perl-5.10.1-130.el6_4.x86_64, perl-JSON-2.15-5.el6.noarch.

                          What shall I do to make it work?
                          Thank you for any help you can provide.

                          MiZde
                          Last edited by MiZde; 20-05-2013, 03:13.

                          Comment

                          • angel_of_devil
                            Junior Member
                            • Sep 2011
                            • 29

                            #28
                            Originally posted by MiZde
                            Hello,

                            thank you for this script, it seems to be very usefull. But I can´t make it work.
                            What have I done:
                            chmod +x lld_all_graph.pl
                            chmod +x list_items.pl
                            dos2unix lld_all_graph.pl
                            dos2unix list_items.pl

                            If I tried to execute script lld_all_graph.pl, I got:
                            Code:
                            JSON text must be an object or array (but found number, string, true, false or null, use allow_nonref to allow this) at ./lld_all_graph.pl line 63
                            If I put
                            Code:
                            $json = $json->allow_nonref([$enable])
                            to the header, I got:
                            Code:
                            syntax error at ./lld_all_graph.pl line 20, near ")
                            
                            
                            # load a json string from a file
                            sub loadjson
                            "
                            syntax error at ./lld_all_graph.pl line 33, near "$result
                            }"
                            syntax error at ./lld_all_graph.pl line 51, near "}"
                            syntax error at ./lld_all_graph.pl line 69, near "}"
                            syntax error at ./lld_all_graph.pl line 94, near "$dec_out
                            }"
                            syntax error at ./lld_all_graph.pl line 128, near "}"
                            syntax error at ./lld_all_graph.pl line 161, near "$dec_out
                            }"
                            syntax error at ./lld_all_graph.pl line 198, near "}"
                            syntax error at ./lld_all_graph.pl line 235, near "}"
                            syntax error at ./lld_all_graph.pl line 266, near "}"
                            ./lld_all_graph.pl has too many errors.
                            I use Centos 6.4, Zabbix 2.0.6, php-5.3.3-22.el6.x86_64, perl-5.10.1-130.el6_4.x86_64, perl-JSON-2.15-5.el6.noarch.

                            What shall I do to make it work?
                            Thank you for any help you can provide.

                            MiZde
                            Check your
                            - password
                            - URL

                            Comment

                            • jensd
                              Junior Member
                              • Dec 2014
                              • 1

                              #29
                              I found this post with Google. Sorry for the bump but I had to adjust the following for the script to work with Zabbix 2.4:

                              Line 42:
                              $res = `curl -s -i -X POST -H $header -d '$data' $url`;
                              ->
                              $res = `curl -s -i -X POST -H "Content-Type: application/json" -d '$data' $url`;

                              Line 57:
                              $data = '{ "jsonrpc": "2.0", "method": "user.authenticate", "params": { "user": "'.$user.'", "password": "'.$password.'" }, "id": 0, "auth": null }';
                              ->
                              $data = '{ "jsonrpc": "2.0", "method": "user.login", "params": { "user": "'.$user.'", "password": "'.$password.'" }, "id": 0, "auth": null }';

                              Comment

                              • Slash
                                Member
                                • May 2011
                                • 64

                                #30
                                Originally posted by jensd
                                I found this post with Google. Sorry for the bump but I had to adjust the following for the script to work with Zabbix 2.4:

                                Line 42:
                                $res = `curl -s -i -X POST -H $header -d '$data' $url`;
                                ->
                                $res = `curl -s -i -X POST -H "Content-Type: application/json" -d '$data' $url`;

                                Line 57:
                                $data = '{ "jsonrpc": "2.0", "method": "user.authenticate", "params": { "user": "'.$user.'", "password": "'.$password.'" }, "id": 0, "auth": null }';
                                ->
                                $data = '{ "jsonrpc": "2.0", "method": "user.login", "params": { "user": "'.$user.'", "password": "'.$password.'" }, "id": 0, "auth": null }';
                                Interesting, I didn't notice that the script didn't work anymore on zabbix 2.4, your fix is welcome

                                If you use this script, you may be interested in ad-hoc graph, which are new in zabbix 2.4 and extremely powerfull: http://blog.zabbix.com/zabbix-2-4-fe...c-graphs/3766/

                                Comment

                                Working...