Ad Widget

Collapse

More Apache Monitoring

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gpmidi
    Member
    • Aug 2009
    • 62

    #1

    More Apache Monitoring

    I've created a script to monitor Apache using it's status page. What's different about this script is that it uses zabbix_sender to send all of the values at once. It also only fetches the page once. This reduces the load on Apache, on Zabbix, and the script. It works with ExtendedStatus both on and off. It also takes a number of arguments to adjust it to your environment.

    Script

    Zabbix Import File

    SVN Trunk

    Feel free to contact me with suggestions, improvements, or problems. My email is paul at gpmidi dot net.

    -Paul
  • fering
    Junior Member
    • Nov 2009
    • 11

    #2
    Script location ?

    I just started using Zabbix can you please explain to me how to add teh script
    the xml import was easy

    Comment

    • gpmidi
      Member
      • Aug 2009
      • 62

      #3
      Example and Help

      Originally posted by fering
      I just started using Zabbix can you please explain to me how to add teh script
      the xml import was easy
      Run the script with --help to see all of it's options. A simple example is shown below:

      /usr/bin/python /path/to/script/ZabbixApacheUpdater.py -c my.hostname.com -z zabbix.server.com

      Edit: There is also a readme file here. If the readme file doesn't include enough information please let me know and I'll update it.
      Last edited by gpmidi; 05-02-2010, 17:50. Reason: Adding more information.

      Comment

      • ericgearhart
        Senior Member
        • Jan 2009
        • 115

        #4
        This is awesome!

        I have to try this out.... grabbing all the values at once was absolutely one of the things I was kicking myself about trying to figure out! I knew how to do it in Cacti but didn't know how to do this in Zabbix

        This is awesome When I get time I will definitely try this out

        Comment

        • gpmidi
          Member
          • Aug 2009
          • 62

          #5
          Updated Wiki

          Updated the wiki with my script and a good how-to of it.

          Comment

          • FireMail
            Junior Member
            • Mar 2010
            • 13

            #6
            hi,

            i did it like its written in the wiki, calling your script by hand gives me the following output:
            MONITORING zabbix_scripts # ./fetch.py -z MONITORING -o TS -c MONITORING
            zabbix_sender [18975]: DEBUG: Answer [{
            "response":"success",
            "info":"Processed 0 Failed 20 Total 20 Seconds spent 0.000511"}]
            Info from server: "Processed 0 Failed 20 Total 20 Seconds spent 0.000511"
            sent: 20; skipped: 0; total: 20
            the server TS has your new template assigned and i created the graph by hand showing bytes per sec and requests per sec. sadly it doesnt store any information from that server or displays that in the graphs.

            any ideas?
            thanks in advance

            Comment

            • Piavlo
              Junior Member
              • Feb 2010
              • 8

              #7
              Hi,

              On thing I don't like in your method, is the need for cron job.
              Maybe instead of cron job on the agent, it's better if zabbix
              server send single passive check which will execute the fetch.py script?

              Alex

              Comment

              • gpmidi
                Member
                • Aug 2009
                • 62

                #8
                More Info

                Originally posted by FireMail
                hi,

                i did it like its written in the wiki, calling your script by hand gives me the following output:

                the server TS has your new template assigned and i created the graph by hand showing bytes per sec and requests per sec. sadly it doesnt store any information from that server or displays that in the graphs.

                any ideas?
                thanks in advance
                What is the name of the host that you attached the Apache template to? My first guess at what is happening is that you are sending the data to Zabbix with the data being attached to the host "MONITORING". If the name of the host you attached the template to is not "MONITORING" then Zabbix won't accept the data.

                -Paul
                Last edited by gpmidi; 11-03-2010, 16:15. Reason: Added more details

                Comment

                • gpmidi
                  Member
                  • Aug 2009
                  • 62

                  #9
                  Thoughts

                  Originally posted by Piavlo
                  Hi,

                  On thing I don't like in your method, is the need for cron job.
                  Maybe instead of cron job on the agent, it's better if Zabbix
                  server send single passive check which will execute the fetch.py script?

                  Alex

                  I thought about running it that way but I ended up going with cron for a couple of reasons:

                  1) Cron is uber-stable. It is practically guaranteed to run.

                  2) It's easier to configure it in cron than it is to set the script path in Zabbix. However if you are monitoring large numbers of hosts the Zabbix config method is more scalable.

                  3) It's the standard way of running something periodically in *nix.

                  That said there are some advantages to running it via Zabbix:

                  1) You can run it more frequently than once per minute.

                  2) You can centrally control it for many hosts

                  3) It's more Zabbix-ey

                  Perhaps we should add an option to the wiki that describes how to setup the script to be run via Zabbix. We could even use macros for the configuration...

                  Thoughts?

                  -Paul

                  Comment

                  • FireMail
                    Junior Member
                    • Mar 2010
                    • 13

                    #10
                    Originally posted by gpmidi
                    What is the name of the host that you attached the Apache template to? My first guess at what is happening is that you are sending the data to Zabbix with the data being attached to the host "MONITORING". If the name of the host you attached the template to is not "MONITORING" then Zabbix won't accept the data.

                    -Paul
                    i thought by using "-o TS" it attaches it to TS? what parameter needs to be changed to attach it to TS?

                    Comment

                    • FireMail
                      Junior Member
                      • Mar 2010
                      • 13

                      #11
                      Originally posted by gpmidi
                      Thoughts?
                      imho i would go the zabbix-way, since mixing stuff from zabbix and outside zabbix can lead into more work while upgrading or maintaining the monitoring system.

                      Comment

                      • gpmidi
                        Member
                        • Aug 2009
                        • 62

                        #12
                        Both

                        Originally posted by FireMail
                        i thought by using "-o TS" it attaches it to TS? what parameter needs to be changed to attach it to TS?
                        The -o option indicates what host the Apache status page should be pulled from. The -c option indicates what host the logs should be attached to. In practice -o and -c should almost always be set to the same thing. Although if you run the script locally you may use -o 127.0.0.1 and -c myhostname.domain.com.

                        -Paul

                        Comment

                        • FireMail
                          Junior Member
                          • Mar 2010
                          • 13

                          #13
                          Originally posted by gpmidi
                          The -o option indicates what host the Apache status page should be pulled from. The -c option indicates what host the logs should be attached to. In practice -o and -c should almost always be set to the same thing. Although if you run the script locally you may use -o 127.0.0.1 and -c myhostname.domain.com.

                          -Paul
                          ok fine with me
                          MONITORING zabbix_scripts # ./fetch.py -z MONITORING -o TS -c TS
                          zabbix_sender [24376]: DEBUG: Answer [{
                          "response":"success",
                          "info":"Processed 0 Failed 20 Total 20 Seconds spent 0.000496"}]
                          Info from server: "Processed 0 Failed 20 Total 20 Seconds spent 0.000496"
                          sent: 20; skipped: 0; total: 20
                          should i worry about the "failed 20" from the server info?
                          It also doesnt add anything to the graph and when i look at the elements:
                          status: not supported
                          error: ZBX_NOTSUPPORTED


                          do you need any more information?

                          Comment

                          • gpmidi
                            Member
                            • Aug 2009
                            • 62

                            #14
                            Originally posted by FireMail
                            ok fine with me

                            should i worry about the "failed 20" from the server info?
                            It also doesnt add anything to the graph and when i look at the elements:
                            status: not supported
                            error: ZBX_NOTSUPPORTED


                            do you need any more information?
                            It failing to send anything is bad. That means that the Zabbix server refused the data for some reason. When I was writing it I found that my problem was almost always the hostname being sent up with the data being wrong. Or the item I was sending up wasn't being monitored.
                            -Paul

                            Comment

                            • Akao
                              Junior Member
                              • Mar 2010
                              • 15

                              #15
                              file "/etc/zabbix/zabbixApacheUpdater.py", line 222, in ? data=parse(data=data)
                              file "/etc/zabbix/zabbixApacheUpdater.py", line 75, in parse for (key,val) in csvobj:
                              ValueError: need more than 1 value to unpack

                              Anyone had this error?

                              I executed:

                              /usr/bin/python /etc/zabbix/ZabbixApacheUpdater.py -c 192.168.200.21 - z 192.168.200.10

                              One is the zabbix server and the another one is the host that i want to control apache.

                              Comment

                              Working...