Ad Widget

Collapse

Apache hits/s

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hardtofi
    Member
    • Jan 2008
    • 32

    #1

    Apache hits/s

    Hi all,

    I've just started testing which one to use of Zabbix and Zenoss. While testing among other things I'm trying to make nice graphs of the apache hits per s. To me this means "current avg", that is (hits since last check)/(time since last check), or (total hits now - total hits at last check)/(uptime now - uptime at last check).

    Is there any way of doing these checks, that depends on previous data?

    Thanks in advance
    Jon
  • alixen
    Senior Member
    • Apr 2006
    • 474

    #2
    Hi,

    I think you can try to use :
    - analog in a shell script to analyse apache log and get the value (analog + awk/grep )
    - extensions of the zabbix agentd

    Regards,
    http://www.alixen.fr/zabbix.html

    Comment

    • hardtofi
      Member
      • Jan 2008
      • 32

      #3
      Originally posted by alixen
      Hi,

      I think you can try to use :
      - analog in a shell script to analyse apache log and get the value (analog + awk/grep )
      - extensions of the zabbix agentd

      Regards,
      Thanks for the suggestion but I see three problems with this suggestion:
      - Not robust/scalable
      - Hard to maintain when adding more hosts
      - Potentially very slow with apache access logs being GBs or at least a few hundred MBs large

      One possible way of doing it might be:
      Have a script started by agentd doing:
      1. If no status file, create one with current hits total + epochs when being ran + return 0
      2. If status file and hits total > hits total in file, server restarted overwrite with current values and return 0
      3. Else return (hits now - hits in file) / (time now - time in file)

      It's just that this feels hackish and potentially fragile (depending on the status file) and the server has access to the data (and it's really needed for any useful actions/time calculation) I was hoping there is such calculation in Zabbix?

      Comment

      • Hichhiker
        Member
        • Nov 2004
        • 45

        #4
        Erm, apache has "mod_status" for that sort of thing and somewhere on this forum is a perl script that parses response of mod_status and sends it to a zabbix server. You can run the script via cron or control it via zabbix server using a passive check to execute it.

        Search "Cookbook" forum for things like this, but here is what I am refering to:



        Note, I needed to tweak the scripts mentioned above to make them work with apache 2.2, but they were minor tweaks.... maybe I should post there the tweaks...

        HTH

        -HH

        Comment

        • Hichhiker
          Member
          • Nov 2004
          • 45

          #5
          Posted my edits here

          -HH

          Comment

          • hardtofi
            Member
            • Jan 2008
            • 32

            #6
            Originally posted by Hichhiker
            Erm, apache has "mod_status" for that sort of thing and somewhere on this forum is a perl script that parses response of mod_status and sends it to a zabbix server. You can run the script via cron or control it via zabbix server using a passive check to execute it.

            -HH
            Thanks for the reply Hitchhiker but no, unless I misunderstood the post that script isn't that what I'm after.

            To explain the problem again:
            apache mod_status shows bytes/s, hits/s etc, but it's all based on the uptime. Lets say we have had apache running for ten hours and hits/s reports 10. That's (according to me) a pretty worthless figure when checking SLA and/or monitoring a server. That only means "there has been 360 000 requests since apache was restarted" what I need to know is if it was 359 999 the last second and 1 hit 9 hours ago or if we're having a nice even flow.

            To check this I need to know "how many hits where there at the last check" and "how long uptime was there at my last check". Then I can calculate the number of hits per s during the last interval.

            Making a custom script doing that wouldn't be too much of a problem, except for the need of having one file (or some custom db) per host saving the last data point for calculation but I'd prefer a well tested way, like using Zabbix variables or something; "When gathering this data point you need to have a diff from the previous using the formula ' (apache.hits.current - apache.hits.previous) / (apache.uptime.current - apache.uptime.previous)'.

            I think I can sum up my rambling to a fairly simple question:
            Is there a (sane, scalable) way, through an API call, zabbix client/server communication or db call to fetch previous data points that doesn't force me to know which of my gazillion vhosts im working on? Like:
            UserParameter=apache.thisvhost.avghits,myscript.pl apache.thisvhost.totalhits apache.thisvhost.uptime
            (where apache.totalhits and apache.uptime are the previous values)

            Comment

            • mikecrowe
              Member
              • Dec 2007
              • 34

              #7
              Here's what I use:

              UserParameter=apache.hitspersec,BASE=`date +%d/%b/%Y:%H:%M --date "now -1 minutes"`;HITS=`grep $BASE /var/log/apache2/access_log | wc -l`; echo "scale=1; $HITS / 60.0" | bc

              Comment

              • bashman
                Senior Member
                • Dec 2009
                • 432

                #8
                I just want to add:

                If you don't want a perl script to parse "mod_status", you can use zapache:

                978 Hosts / 16.901 Items / 8.703 Triggers / 44 usr / 90,59 nvps / v1.8.15

                Comment

                Working...