Ad Widget

Collapse

mod_status apache monitoring

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • btoovey
    Junior Member
    • Sep 2007
    • 16

    #1

    mod_status apache monitoring

    The stuff that was out there for this kinda sucked real bad. So I modded it a bit so it didnt suck as much, but it still reaks of ass.

    Feel free to post problems i will modd it.

    Brian

    Add this to agentd.conf:

    Code:
    UserParameter=apache.total_accesses,~zabbix/bin/apache2.pl http://127.0.0.1 0
    UserParameter=apache.total_kbytes,~zabbix/bin/apache2.pl http://127.0.0.1 1
    UserParameter=apache.cpuload,~zabbix/bin/apache2.pl http://127.0.0.1 2
    UserParameter=apache.uptime,~zabbix/bin/apache2.pl http://127.0.0.1 3
    UserParameter=apache.reqpersec,~zabbix/bin/apache2.pl http://127.0.0.1 4
    UserParameter=apache.bytespersec,~zabbix/bin/apache2.pl http://127.0.0.1 5
    UserParameter=apache.bytesperreq,~zabbix/bin/apache2.pl http://127.0.0.1 6
    UserParameter=apache.busyservers,~zabbix/bin/apache2.pl http://127.0.0.1 7
    UserParameter=apache.idleservers,~zabbix/bin/apache2.pl http://127.0.0.1 8
    UserParameter=apache.scoreboard,~zabbix/bin/apache2.pl http://127.0.0.1 9
    And this is apache2.pl:

    Code:
    [root@bb-nj1-mon-web-1 bin]# cat /var/lib/zabbix/bin/apache2.pl 
    #!/usr/bin/perl 
    my $host = $ARGV[0];
    my $cmd = 'curl -A "mozilla/4.0 (compatible; cURL 7.10.5-pre2; Linux 2.4.20)" -m 12 -s -L -k -b /tmp/bbapache_cookiejar.curl -c /tmp/bbapache_cookiejar.curl -H "Pragma: no-cache" -H "Cache-control: no-cache" -H "Connection: close" "'.$host.'/server-status?auto"';
    my $server_status = qx($cmd);
    #print $server_status;
    
    my @apache_checks;
    
    $apache_checks[0] = $1 if ($server_status =~ /Total\ Accesses:\ ([\d|\.]+)/ig)||0;
    $apache_checks[1] = $1 if ($server_status =~ /Total\ kBytes:\ ([\d|\.]+)/gi);
    $apache_checks[2] = $1 if ($server_status =~ /CPULoad:\ ([\d|\.]+)/gi);
    $apache_checks[3] = $1 if ($server_status =~ /Uptime:\ ([\d|\.]+)/gi);
    $apache_checks[4] = $1 if ($server_status =~ /ReqPerSec:\ ([\d|\.]+)/gi);
    $apache_checks[5] = $1 if ($server_status =~ /BytesPerSec:\ ([\d|\.]+)/gi);
    $apache_checks[6] = $1 if ($server_status =~ /BytesPerReq:\ ([\d|\.]+)/gi);
    $apache_checks[7] = $1 if ($server_status =~ /BusyWorkers:\ ([\d|\.]+)/gi);
    $apache_checks[8] = $1 if ($server_status =~ /IdleWorkers:\ ([\d|\.]+)/gi);
    $apache_checks[9] = $1 if ($server_status =~ /Scoreboard:\ ([A-Z_]+)/gi);
    print "$apache_checks[$ARGV[1]]";
    exit(0);
    Attached Files
  • odium4u
    Junior Member
    • Sep 2008
    • 20

    #2
    Very nice.

    Comment

    • elvar
      Senior Member
      • Feb 2008
      • 226

      #3
      Originally posted by btoovey
      The stuff that was out there for this kinda sucked real bad. So I modded it a bit so it didnt suck as much, but it still reaks of ass.

      Feel free to post problems i will modd it.

      Brian

      Add this to agentd.conf:

      Code:
      UserParameter=apache.total_accesses,~zabbix/bin/apache2.pl http://127.0.0.1 0
      UserParameter=apache.total_kbytes,~zabbix/bin/apache2.pl http://127.0.0.1 1
      UserParameter=apache.cpuload,~zabbix/bin/apache2.pl http://127.0.0.1 2
      UserParameter=apache.uptime,~zabbix/bin/apache2.pl http://127.0.0.1 3
      UserParameter=apache.reqpersec,~zabbix/bin/apache2.pl http://127.0.0.1 4
      UserParameter=apache.bytespersec,~zabbix/bin/apache2.pl http://127.0.0.1 5
      UserParameter=apache.bytesperreq,~zabbix/bin/apache2.pl http://127.0.0.1 6
      UserParameter=apache.busyservers,~zabbix/bin/apache2.pl http://127.0.0.1 7
      UserParameter=apache.idleservers,~zabbix/bin/apache2.pl http://127.0.0.1 8
      UserParameter=apache.scoreboard,~zabbix/bin/apache2.pl http://127.0.0.1 9
      And this is apache2.pl:

      Code:
      [root@bb-nj1-mon-web-1 bin]# cat /var/lib/zabbix/bin/apache2.pl 
      #!/usr/bin/perl 
      my $host = $ARGV[0];
      my $cmd = 'curl -A "mozilla/4.0 (compatible; cURL 7.10.5-pre2; Linux 2.4.20)" -m 12 -s -L -k -b /tmp/bbapache_cookiejar.curl -c /tmp/bbapache_cookiejar.curl -H "Pragma: no-cache" -H "Cache-control: no-cache" -H "Connection: close" "'.$host.'/server-status?auto"';
      my $server_status = qx($cmd);
      #print $server_status;
      
      my @apache_checks;
      
      $apache_checks[0] = $1 if ($server_status =~ /Total\ Accesses:\ ([\d|\.]+)/ig)||0;
      $apache_checks[1] = $1 if ($server_status =~ /Total\ kBytes:\ ([\d|\.]+)/gi);
      $apache_checks[2] = $1 if ($server_status =~ /CPULoad:\ ([\d|\.]+)/gi);
      $apache_checks[3] = $1 if ($server_status =~ /Uptime:\ ([\d|\.]+)/gi);
      $apache_checks[4] = $1 if ($server_status =~ /ReqPerSec:\ ([\d|\.]+)/gi);
      $apache_checks[5] = $1 if ($server_status =~ /BytesPerSec:\ ([\d|\.]+)/gi);
      $apache_checks[6] = $1 if ($server_status =~ /BytesPerReq:\ ([\d|\.]+)/gi);
      $apache_checks[7] = $1 if ($server_status =~ /BusyWorkers:\ ([\d|\.]+)/gi);
      $apache_checks[8] = $1 if ($server_status =~ /IdleWorkers:\ ([\d|\.]+)/gi);
      $apache_checks[9] = $1 if ($server_status =~ /Scoreboard:\ ([A-Z_]+)/gi);
      print "$apache_checks[$ARGV[1]]";
      exit(0);

      I'm trying to get this working under Zabbix 1.8 but all I get under status for those items is "Not Supported".

      Any suggestions?

      Comment

      • elvar
        Senior Member
        • Feb 2008
        • 226

        #4
        Solved

        Well, I finally got this working and unfortunately my entire problem was the item field "Allowed Hosts"

        Really liking this so thank you very much for your scripts and template contribution!


        Cheers!

        Comment

        • avrilspirit
          Junior Member
          • May 2010
          • 5

          #5
          you have resolved your problem ?

          because i have the same problem...

          ZBX_NOTSUPPORTED

          have you an idea?

          Comment

          • bashman
            Senior Member
            • Dec 2009
            • 432

            #6
            zapache

            You can use this script:

            Code:
            #! /bin/bash
            #
            # Name: zapache
            #
            # Checks Apache activity.
            #
            #
            
            zapachever="1.1"
            rval=0
            VAR=$(wget --quiet -O - http://localhost/server-status?auto)
            
            case $1 in
            'TotalAccesses')
            	echo "$VAR"|grep "Total Accesses:"|awk '{print $3}'
            	rval=$?;;
            'TotalKBytes')
            	echo "$VAR"|grep "Total kBytes:"|awk '{print $3}'
            	rval=$?;;
            'Uptime')
            	echo "$VAR"|grep "Uptime:"|awk '{print $2}'
            	rval=$?;;
            'ReqPerSec')
            	echo "$VAR"|grep "ReqPerSec:"|awk '{print $2}'
            	rval=$?;;
            'BytesPerSec')
            	echo "$VAR"|grep "BytesPerSec:"|awk '{print $2}'
            	rval=$?;;
            'BytesPerReq')
            	echo "$VAR"|grep "BytesPerReq:"|awk '{print $2}'
            	rval=$?;;
            'BusyWorkers')
            	echo "$VAR"|grep "BusyWorkers:"|awk '{print $2}'
            	rval=$?;;
            'IdleWorkers')
            	echo "$VAR"|grep "IdleWorkers:"|awk '{print $2}'
            	rval=$?;;
            'version')
            	echo "$zapachever"
                    exit $rval;;
            *)
            	echo "zapache version: $zapachever"
                    echo "usage:"
                    echo "    $0 TotalAccesses               -- Check total accesses."
                    echo "    $0 TotalKBytes                 -- Check total KBytes."
            	echo "    $0 Uptime                      -- Check uptime."
            	echo "    $0 ReqPerSec                   -- Check requests per second."
            	echo "    $0 BytesPerSec                 -- Check Bytes per second."
            	echo "    $0 BytesPerReq                 -- Check Bytes per request."
            	echo "    $0 BusyWorkers                 -- Check busy workers."
            	echo "    $0 IdleWorkers                 -- Check idle workers."
            	echo "    $0 version                     -- Version of this script."
            	exit $rval;;
            esac
            
            if [ "$rval" -ne 0 ]; then
              	echo "ZBX_NOTSUPPORTED"
            fi
            
            exit $rval
            
            #
            # end zapache
            and just add this line to your zabbix_agentd.conf:

            Code:
            UserParameter=apache[*],/home/zabbix/bin/zapache $1
            ./zapache -h

            Code:
            zapache version: 1.1
            usage:
              ./zapache TotalAccesses               -- Check total accesses.
              ./zapache TotalKBytes                 -- Check total KBytes.
              ./zapache Uptime                      -- Check uptime.
              ./zapache ReqPerSec                   -- Check requests per second.
              ./zapache BytesPerSec                 -- Check Bytes per second.
              ./zapache BytesPerReq                 -- Check Bytes per request.
              ./zapache BusyWorkers                 -- Check busy workers.
              ./zapache IdleWorkers                 -- Check idle workers.
              ./zapache version                     -- Version of this script.
            You can add your apache items:

            Code:
            Description            Type          Key                    Type of information  Update interval  Store value  History  Trends  Applications
            Apache/TotalAccesses.  ZABBIX agent  apache[TotalAccesses]  Numeric (integer)    60               As Is        7        365     APACHE
            Apache/TotalKBytes.    ZABBIX agent  apache[TotalKBytes]    Numeric (float)      60               As Is        7        365     APACHE
            Apache/Uptime.         ZABBIX agent  apache[Uptime]         Numeric (integer)    60               As Is        7        365     APACHE
            Apache/ReqPerSec.      ZABBIX agent  apache[RecPerSec]      Numeric (float)      60               As Is        7        365     APACHE
            Apache/BytesPerSec.    ZABBIX agent  apache[BytesPerSec]    Numeric (float)      60               As Is        7        365     APACHE
            Apache/BytesPerReq.    ZABBIX agent  apache[BytesPerReq]    Numeric (float)      60               As Is        7        365     APACHE
            Apache/BusyWorkers.    ZABBIX agent  apache[BusyWorkers]    Numeric (integer)    60               As Is        7        365     APACHE
            Apache/IdleWorkers.    ZABBIX agent  apache[IdleWorkers]    Numeric (integer)    60               As Is        7        365     APACHE
            Last edited by bashman; 02-11-2010, 10:20.
            978 Hosts / 16.901 Items / 8.703 Triggers / 44 usr / 90,59 nvps / v1.8.15

            Comment

            Working...