Sponsored Content
Top Forums Shell Programming and Scripting Apache Stats Collection Units information Post 302793001 by Shivaramakrishn on Thursday 11th of April 2013 01:19:57 PM
Old 04-11-2013
Apache Stats Collection Units information

Code:
#!/usr/bin/perl
#
## Zabbix_Apache2.pl
## Versions 2.0

#
use LWP::Simple;
use strict;
#
my($url)="http://localhost/server-status?auto";
my($server_status)=get($url);
my($total_accesses,$total_kbytes,$cpuload,$uptime, $reqpersec,$bytespersec,$bytesperreq,$busyworkers, $idleworkers,$totalworkers);
#
if (! $server_status) {
print "Can't access $url\nCheck apache configuration\n\n";
exit(1);
}
#
$total_accesses = $1 if ($server_status =~ /Total\ Accesses:\ ([\d|\.]+)/ig)||0;
$total_kbytes = $1 if ($server_status =~ /Total\ kBytes:\ ([\d|\.]+)/gi);
$cpuload = $1 if ($server_status =~ /CPULoad:\ ([\d|\.]+)/gi);
$uptime = $1 if ($server_status =~ /Uptime:\ ([\d|\.]+)/gi);
$reqpersec = $1 if ($server_status =~ /ReqPerSec:\ ([\d|\.]+)/gi);
$bytespersec = $1 if ($server_status =~ /BytesPerSec:\ ([\d|\.]+)/gi);
$bytesperreq = $1 if ($server_status =~ /BytesPerReq:\ ([\d|\.]+)/gi);
$busyworkers = $1 if ($server_status =~ /BusyWorkers:\ ([\d|\.]+)/gi);
$idleworkers = $1 if ($server_status =~ /IdleWorkers:\ ([\d|\.]+)/gi);
$totalworkers = $busyworkers + $idleworkers;
#
open (MYFILE, '>/tmp/apache_data.txt');
printf MYFILE "%i:%i:%.2f:%i:%.2f:%.2f:%.2f:%i:%i:%i\n",$total_accesses,$total_kbytes,$cpuload,$uptime,$reqpersec,$bytespersec,$bytesperreq,$busyworkers,$idleworkers,$totalworkers;
close (MYFILE); 
exit(0);


Above is a code that I found in your forums.I wanted to know if the measuring units represent exact values meaning wanted to know if some of them are in percentages?

Sample Output:
Code:
busyworkers:75 bytesperreq:2241.71 bytespersec:7634.33 CPULoad:.0853807 idleworkers:13 reqpersec:3.40558 TotalAccess:195167 totalworkers:88 Total_kbytes:427254


Last edited by Franklin52; 04-12-2013 at 03:06 AM.. Reason: Please use code tags for data and code samples
 

7 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to hide Apache Server information?

When we have a directory web page open to public, there is usually a message shows on the bottom: Apache/2.0.40 Server at www.mydomain.net Port 80 Could someone tell me how to hide the information like this web page does? http://debian.cn99.com/debian-cd/ Thanx in advance. HOUSCOUS (2 Replies)
Discussion started by: HOUSCOUS
2 Replies

2. Hardware

Units in server racks

What does the term units mean in the context of server racks, for instance 4U? It is an indication of height, so does that mean the amount of disks the rack can hold or can the rack hold multiple motherboards / processors? (8 Replies)
Discussion started by: figaro
8 Replies

3. AIX

Processsing Units and Virtual Processors.

Hi, on redhat linux 5.5 (IBM PPC) os, whenever I am running the command top, it is showing 8 cpu. Processing Units Property Current Pending Minimum 0.1 Assigned 0.8 Maximum 1 Virtual Processors Property Current Pending Minimum 1 Assigned 4 ... (1 Reply)
Discussion started by: manoj.solaris
1 Replies

4. Solaris

Strange power supply units alarms!!!

Hi folks, I encountered this alarms on a solaris server: 04/21/12 23:17:55 MNP-PGW-A_bge3 mnp 231748 Power Supply Unit 0 is faulty 04/21/12 23:17:55 MNP-PGW-A_bge3 mnp 231748 Power Supply Unit 1 is faulty 04/21/12 23:18:26 MNP-PGW-A_bge3 mnp 231822 Power Supply Unit 0 is faulty:CLEAR... (0 Replies)
Discussion started by: kimurayuki
0 Replies

5. UNIX for Dummies Questions & Answers

apache logging - show more information

is it possible to make apache log each user activity in its log file "access_log" i have a web application here that uses apache. in the apache log files, i see that it shows when requests are made to certain pages in my web application. but it doesn't show the user name of the person making... (1 Reply)
Discussion started by: SkySmart
1 Replies

6. UNIX and Linux Applications

Gnuplot Same Data Two Axes Different Units)

I'm pretty familiar with Gnuplot, but I've never actually come across a reasonable solution to this problem and I'm hoping someone can help me out! I think it's because I don't know how to pose the problem neatly, so please bare with me. Also new to the forum....so yeah... I have one data set (x... (3 Replies)
Discussion started by: TC69
3 Replies

7. UNIX Desktop Questions & Answers

Tool suggestion for collection CPU/memory Stats

Hi, We have around 1000 server (Red Hat + Suse + Parallels + Solaris-9/10/11). Every month, we generate a report for all servers for CPU and Memory utilization in 'percentage used'. This report is generated from HP Openview and frequency is every file minutes. In HP OpenView, we are picking 20... (0 Replies)
Discussion started by: solaris_1977
0 Replies
DIFF3(1)							   User Commands							  DIFF3(1)

NAME
diff3 - compare three files line by line SYNOPSIS
diff3 [OPTION]... MYFILE OLDFILE YOURFILE DESCRIPTION
Compare three files line by line. -e --ed Output unmerged changes from OLDFILE to YOURFILE into MYFILE. -E --show-overlap Output unmerged changes, bracketing conflicts. -A --show-all Output all changes, bracketing conflicts. -x --overlap-only Output overlapping changes. -X Output overlapping changes, bracketing them. -3 --easy-only Output unmerged nonoverlapping changes. -m --merge Output merged file instead of ed script (default -A). -L LABEL --label=LABEL Use LABEL instead of file name. -i Append `w' and `q' commands to ed scripts. -a --text Treat all files as text. --strip-trailing-cr Strip trailing carriage return on input. -T --initial-tab Make tabs line up by prepending a tab. --diff-program=PROGRAM Use PROGRAM to compare files. -v --version Output version info. --help Output this help. If a FILE is `-', read standard input. Exit status is 0 if successful, 1 if conflicts, 2 if trouble. AUTHOR
Written by Randy Smith. REPORTING BUGS
Report bugs to <bug-gnu-utils@gnu.org>. COPYRIGHT
Copyright (C) 2007 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. SEE ALSO
The full documentation for diff3 is maintained as a Texinfo manual. If the info and diff3 programs are properly installed at your site, the command info diff should give you access to the complete manual. diffutils 2.8.7-cvs January 2008 DIFF3(1)
All times are GMT -4. The time now is 03:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy