Ad Widget

Collapse

Monitoring Apache

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Hichhiker
    Member
    • Nov 2004
    • 45

    #1

    Monitoring Apache

    Active checks of apache via mod_status, triggered via a single passive check. This works for Apache 2.2 and is based on this post with slight modifications to make it work for me.


    * Uncompress zip file into ~zabbix/bin directory

    * Edit zabbix_agentd.conf to set "Hostname=" value properly and add following:

    Code:
    UserParameter=apache.all,~zabbix/bin/apache.pl http://localhost
    * Edit apache config to add something like:

    Code:
    <Location /server-status>
        SetHandler server-status
        Order deny,allow
        Deny from all
        Allow from 127.0.0.1
    #    Allow from 192.168.1.*
    </Location>
    Or something like this - make sure mod_status is enabled

    * Import the xml into zabbix server and add template to the server you are monitoring.

    HTH

    EDIT 4/8/8: Replacing download version with new files. Fixed an issue when /bin/sh is not same as /bin/bash. Added apache.dyn_hitspersec parameter which calculated hits per second on every request in addition/instead of apache.reqpersec which gives you average since Apache was started.

    -HH
    Attached Files
    Last edited by Hichhiker; 08-04-2008, 16:50.
  • marcelein
    Junior Member
    • Apr 2008
    • 21

    #2
    hi Hichhiker and thanks for the scripts and the templates
    i got some communication errors between the sender and the zabbix server i think:
    when i start the shellscript zabbix_sender.sh
    it returns me
    Code:
    test: 18: ==: unexpected operator
    send:0; failed:1; total: 1
    my hostname in the zabbix_agentd.conf ist set to localhost because i want to monitor the apache of my zabbix server

    mod_status ist availible and reachable via lynx http://localhost/server-status

    i extendet the view:
    Code:
    <IfModule mod_status.c>
    ExtendedStatus On
    <Location /server-status>
    is this recommended? (without this i got the same error with zabbix_sender.sh)

    in my zabbix interface i only got the controller data "1" for my apache

    Comment

    • Hichhiker
      Member
      • Nov 2004
      • 45

      #3
      Originally posted by marcelein
      hi Hichhiker and thanks for the scripts and the templates
      i got some communication errors between the sender and the zabbix server i think:
      when i start the shellscript zabbix_sender.sh
      it returns me
      Code:
      test: 18: ==: unexpected operator
      send:0; failed:1; total: 1
      This seems like a zabbix_sender script error. What OS are you running under? I think the problem is that the script is asking for /bin/sh even though it is expecting bash - something that is not an issue on many Linux machines but is not true on many other *nix's - so, change top line of the script to #!/bin/bash and see if this helps.


      Originally posted by marcelein
      my hostname in the zabbix_agentd.conf ist set to localhost because i want to monitor the apache of my zabbix server
      Unless your zabbix server is listed as host "localhost", hostname should be set to host name in the zabbix config - which, btw, I just noticed may not deal well with spaces :-/ - so you may need to rename your "Zabbix Server" to Zabbix_Server or something.

      Originally posted by marcelein
      mod_status ist availible and reachable via lynx http://localhost/server-status

      i extendet the view:
      Code:
      <IfModule mod_status.c>
      ExtendedStatus On
      <Location /server-status>
      is this recommended? (without this i got the same error with zabbix_sender.sh)

      in my zabbix interface i only got the controller data "1" for my apache
      Not sure about the extended view, forgot if that is enabled or not.

      Controller data will be always 1, thats normal as controller "data" item simply triggers active sending of data to the zabbix server. Once you get everything working, you will get other data in there.

      -HH

      Comment

      • marcelein
        Junior Member
        • Apr 2008
        • 21

        #4
        thanks for your fast response, Hichhiker

        i run zabbix server/agent/interface on ubuntu 7.10 server
        i will check bash tomorrow at work
        i think my hostname is something like zabbix-ubuntu if bash won't help i test it with this host

        its just a testing environment before im going to install all that stuff on a non virtual machine. so i think i wont get in trouble with hostnames anymore..

        Comment

        • marcelein
          Junior Member
          • Apr 2008
          • 21

          #5
          bash helped to work this unexpected error out,
          but the thing with the hostname doesnt helped me
          i still got:
          Code:
          send:0; failed:1; total: 1
          and no latest data on my apache items

          some snippets from my zabbix_agentd.conf (what is this zabbix_agent.conf for?)
          Code:
          Server=127.0.0.1
          Hostname=ubuntu-zabbix
          #.....
          UserParameter=apache.all,/home/zabbix/apache.pl http://localhost

          Comment

          • marcelein
            Junior Member
            • Apr 2008
            • 21

            #6
            i finally noticed that there is a differance between the hostname in the zabbix web interface and the hostname of my machine
            but there is still a
            Code:
            failed: 1;
            when i run zabbix_sender.sh
            BUT
            im receiving data, in an 60sec interval
            i think this is because i set
            Code:
            RefreshActiveChecks=60
            , in my zabbix_agentd.conf

            Comment

            • Hichhiker
              Member
              • Nov 2004
              • 45

              #7
              Actually the way this is set up is the frequency of data updates is controlled via the "Controller" item. Whatever you set that update interval to is what everything is updated at.


              As far as "Failed:1" - are you running zabbix_sender.sh by itself? That script is designed to send an item of data back to the zabbix server but it requires a bunch of command line arguments. Really you should not need it as the main "apache.pl" script calls it

              Also, I am going to edit the original post and replace the download files. I fixed the bash issue, but the big change is that I added a parameter that gets a much more usefull version of "Req per sec" parameter (original version only gets average req per sec from time apache was started, new value is calculated on check by check basis. To upgrade you should be able to simply replace the file and re-import the template.

              Comment

              • marcelein
                Junior Member
                • Apr 2008
                • 21

                #8
                ohh sorry you are right i executed zabbix_sender.sh by myself to test it

                Comment

                • marcelein
                  Junior Member
                  • Apr 2008
                  • 21

                  #9
                  i think someone sould port this solution to lighttpd or is it compatible?
                  does anybody know if there is a differance between lighttpd server status and apache server status?
                  maybe i will test that tomorrow at work and probably port that scripts to lighttpd if its not to difficult

                  Comment

                  • Hichhiker
                    Member
                    • Nov 2004
                    • 45

                    #10
                    Originally posted by marcelein
                    i think someone sould port this solution to lighttpd or is it compatible?
                    does anybody know if there is a differance between lighttpd server status and apache server status?
                    maybe i will test that tomorrow at work and probably port that scripts to lighttpd if its not to difficult
                    As I do not use lighttp that 'someone' would not be me, but as long as you can get the data somehow in text form from lighttp - you can send it to zabbix using this method. All you have to do is re-write apache.pl script to scrape from new source.

                    -HH

                    Comment

                    • marcelein
                      Junior Member
                      • Apr 2008
                      • 21

                      #11
                      got little errors in my zabbix_server.log default log level:

                      Code:
                       32682:20080521:081519 Type of received value [] is not suitable for [apache.total_accesses@server01]
                       32693:20080521:081519 Type of received value [] is not suitable for [apache.dyn_hitspersec@server01]
                       32691:20080521:081519 Type of received value [] is not suitable for [apache.total_kbytes@server01]
                       32686:20080521:081519 Type of received value [] is not suitable for [apache.cpuload@server01]
                       32682:20080521:081519 Type of received value [] is not suitable for [apache.reqpersec@server01]
                       32693:20080521:081519 Type of received value [] is not suitable for [apache.bytespersec@server01]
                       32691:20080521:081519 Type of received value [] is not suitable for [apache.bytesperreq@server01]
                       32686:20080521:081519 Type of received value [] is not suitable for [apache.busyservers@server01]
                       32683:20080521:081519 Type of received value [] is not suitable for [apache.idleservers@server01]
                      my configuration is zabbix-1.4.5 server on the monitor host and
                      agentd_host:~ # /usr/local/sbin/zabbix_agentd -V
                      ZABBIX Agent (daemon) v1.4.5 (25 March 2008)

                      acutally iam recieving data from this agent so everything is correctly configurated except apache monitor.

                      i didnt tryed to test another type like int because i wanne have accurate data as usual

                      thx for support!
                      Last edited by marcelein; 21-05-2008, 08:44.

                      Comment

                      • Hichhiker
                        Member
                        • Nov 2004
                        • 45

                        #12
                        Originally posted by marcelein
                        Code:
                        32682:20080521:081519 Type of received value [] is not suitable for [apache.total_accesses@server01]
                        32693:20080521:081519 Type of received value [] is not suitable for [apache.dyn_hitspersec@server01]
                        The [] in the error message seems to tell me that the sender is sending blank values - so I would check that mod_status is installed and configured correctly. Try just hitting the URL yourself and see if you get all the data. Cant parse it if data is not there :-)

                        See the first post on some hints on how to enable mod_status

                        -HH

                        Comment

                        • marcelein
                          Junior Member
                          • Apr 2008
                          • 21

                          #13
                          DIDNT-MATTER:/etc/apache2 # cat mod_status.conf
                          #
                          # Allow server status reports generated by mod_status,
                          # with the URL of http://servername/server-status
                          #
                          # see http://httpd.apache.org/docs-2.2/mod/mod_status.html
                          #
                          <IfModule mod_status.c>
                          <Location /server-status>
                          SetHandler server-status
                          Order deny,allow
                          Deny from all
                          Allow from localhost
                          </Location>
                          </IfModule>


                          mod_status is up and running i checked that
                          maybe its another issue and has nothing in common with your scripts.
                          zabbix Template_Linux "Apache is running" item show me that apache is not running but i can access it via http


                          btw. sorry for spammin your nice apache post..

                          with kind regards
                          Last edited by marcelein; 21-05-2008, 16:51. Reason: format

                          Comment

                          • Hichhiker
                            Member
                            • Nov 2004
                            • 45

                            #14
                            Originally posted by marcelein

                            mod_status is up and running i checked that
                            a simple way to check if it is running AND if it is accessible via the apache.pl script is via something like:

                            Code:
                            wget -O-  http://localhost/server-status?auto 2>/dev/null
                            Your output should look like this:
                            Code:
                            Total Accesses: 982163
                            Total kBytes: 14389672
                            CPULoad: .0231971
                            Uptime: 278268
                            ReqPerSec: 3.52956
                            BytesPerSec: 52952.6
                            BytesPerReq: 15002.6
                            BusyWorkers: 4
                            IdleWorkers: 14
                            Scoreboard: __CW__......._.._._._._._.._....C.__.....C._....................................................................................................................................................................................................................

                            Originally posted by marcelein
                            maybe its another issue and has nothing in common with your scripts.
                            zabbix Template_Linux "Apache is running" item show me that apache is not running but i can access it via http
                            IIRC, Template_Linux "Apache is running" checks for number of processes of httpd - if it is not seeing that, its an issue, but should not be directly connected with this.


                            Originally posted by marcelein
                            btw. sorry for spammin your nice apache post..
                            hey, no worries, thats what this forum is for.

                            -HH

                            Comment

                            • marcelein
                              Junior Member
                              • Apr 2008
                              • 21

                              #15
                              Originally posted by Hichhiker
                              a simple way to check if it is running AND if it is accessible via the apache.pl script is via something like:

                              Code:
                              wget -O-  http://localhost/server-status?auto 2>/dev/null
                              -HH
                              gives me nothing back when i execute that

                              Comment

                              Working...