#!/usr/bin/perl
# Script to get the requests per second and the requests currently being processed from
# an Apache webserver.
# <rs@rhapsodyk.net>
# In order for this to work, you will need to have server stats enabled in Apache.
# To enable the builtin apache server-status, you will need to enable mod_status
# and have something like the following in your httpd.conf file.
# ExtendedStatus on
# <Location /server-status>
# SetHandler server-status
# Order deny,allow
# Deny from all
# Allow from localhost
# </Location>
$output = `wget -q -O- --bind-address=localhost http://www.rhapsodyk.net/server-status`;
#$output =~ /Total accesses: (.*?) /;
#print "$1 ";
$output =~ /(.*) requests?\/sec/;
print $1;
#$output =~ /(.*) requests currently being processed/;
#print $1;
Script that gets apache usage WITHOUT parsing log files
Moderators: Developers, Moderators
Hi,
I tried this script and it's working. If I run it from the command line, I see it returned two values. I setup Cacti to get 2 inputs from the command line. From the Cron Printout when I do a show output it also displays the right data. However, it seems either I'm creating the graphs incorrectly or it's not logging the data. Anyone has success with the script/graphs?
I'm new to Cacti so I may have missed something VERY simple.
Thank you.
-Mike
I tried this script and it's working. If I run it from the command line, I see it returned two values. I setup Cacti to get 2 inputs from the command line. From the Cron Printout when I do a show output it also displays the right data. However, it seems either I'm creating the graphs incorrectly or it's not logging the data. Anyone has success with the script/graphs?
I'm new to Cacti so I may have missed something VERY simple.
Thank you.
-Mike
Update...
I looked around with the rrdtool util and use "info" as the command and point it to one of the rrd file that's not working. Here's the output from one:
filename = "ping_c3640.rrd"
rrd_version = "0001"
step = 300
last_update = 1043469901
ds[ping_c3640].type = "GAUGE"
ds[ping_c3640].minimal_heartbeat = 600
ds[ping_c3640].min = 0.0000000000e+00
ds[ping_c3640].max = 2.0000000000e+03
ds[ping_c3640].last_ds = "UNKN"
ds[ping_c3640].value = 0.0000000000e+00
ds[ping_c3640].unknown_sec = 1
I'm guessing that because the .last_ds is unkn it's not logging what I need and the remaining value fields all stats "NaN". It seems to be writing to the file but not the correct data. Here's my setup for the ping:
Data Input Source:
Input String: perl <path_cacti>/scripts/ping.pl <num> <ip>
Output String: <out_ms>
I also have the 3 fields define (IP, Ping Time, Times) with out_ms being the only output field.
Data source is also setup correctly based on the included ping. I also setup the graph which works but no data is displayed due to the rrd file not having any data to graph.
Anyone run into this problem? I can graph data but so far I've only been lucky with SNMP Interfaces and creating the graph from the link available.
Appreciate any help.
-Mike
I looked around with the rrdtool util and use "info" as the command and point it to one of the rrd file that's not working. Here's the output from one:
filename = "ping_c3640.rrd"
rrd_version = "0001"
step = 300
last_update = 1043469901
ds[ping_c3640].type = "GAUGE"
ds[ping_c3640].minimal_heartbeat = 600
ds[ping_c3640].min = 0.0000000000e+00
ds[ping_c3640].max = 2.0000000000e+03
ds[ping_c3640].last_ds = "UNKN"
ds[ping_c3640].value = 0.0000000000e+00
ds[ping_c3640].unknown_sec = 1
I'm guessing that because the .last_ds is unkn it's not logging what I need and the remaining value fields all stats "NaN". It seems to be writing to the file but not the correct data. Here's my setup for the ping:
Data Input Source:
Input String: perl <path_cacti>/scripts/ping.pl <num> <ip>
Output String: <out_ms>
I also have the 3 fields define (IP, Ping Time, Times) with out_ms being the only output field.
Data source is also setup correctly based on the included ping. I also setup the graph which works but no data is displayed due to the rrd file not having any data to graph.
Anyone run into this problem? I can graph data but so far I've only been lucky with SNMP Interfaces and creating the graph from the link available.
Appreciate any help.
-Mike
I'm having some issues getting the information returned on this script to work.
http://cacti.punched.us/graph.php?graphid=75&rraid=all is what is returning. IE Blank.
However when the cron output is running I get the following
perl /roland/www/cacti//scripts/apachehits.pl 32
So data is being returned.
Here are my settings for the data source and graph.
Data Input Source
Name: Apache Statistics
Input String: perl <path_cacti>/scripts/apachehits.pl
Output String: <requests>
-Current Data Input Source Fields
Requests requests Output Yes
Data Sources
Name: apache_stats
Data Source Path: <path_rra>/apache_stats.rrd
Data Source Type: Gauge
Associated RRA's: DWMY
Heartbeat: 600
Step: 300
Minimum: 0
Maximum: 5000
Update .rrd File: No
Active: Yes
Graph Config
Title: Apache Requests Per Second
Image Format: PNG
Height: 150
Width: 500
Use Rigid Boundaries mode: Yes
Auto Scale: Yes
Use --alt-autoscale-max
Logarithmic Auto Scaling (--logarithmic): No
Auto Padding: Yes
Allow Grouping: Yes
Allow Graph Export: Yes
Upper Limit: 5000
Lower Limit: 0
Base Value: 1000
Unit Value: NULL
Unit Exponent Value: 0
Vertical Lable: Requests Per Second
Graph Items
Item #1 apache_stats AREA 8D00BA
Data Source: apache_stats
Item Group: AREA: apache_stats (AVERAGE)
Grage Item Type: Area
Consolidation Function: Average
CDEF Function: None
Value: NULL
GPRINT Options: Normal
Text Format: Requests
Insert Hard Return: No
I hope this information helps. I thank you for your assistance.
http://cacti.punched.us/graph.php?graphid=75&rraid=all is what is returning. IE Blank.
However when the cron output is running I get the following
perl /roland/www/cacti//scripts/apachehits.pl 32
So data is being returned.
Here are my settings for the data source and graph.
Data Input Source
Name: Apache Statistics
Input String: perl <path_cacti>/scripts/apachehits.pl
Output String: <requests>
-Current Data Input Source Fields
Requests requests Output Yes
Data Sources
Name: apache_stats
Data Source Path: <path_rra>/apache_stats.rrd
Data Source Type: Gauge
Associated RRA's: DWMY
Heartbeat: 600
Step: 300
Minimum: 0
Maximum: 5000
Update .rrd File: No
Active: Yes
Graph Config
Title: Apache Requests Per Second
Image Format: PNG
Height: 150
Width: 500
Use Rigid Boundaries mode: Yes
Auto Scale: Yes
Use --alt-autoscale-max
Logarithmic Auto Scaling (--logarithmic): No
Auto Padding: Yes
Allow Grouping: Yes
Allow Graph Export: Yes
Upper Limit: 5000
Lower Limit: 0
Base Value: 1000
Unit Value: NULL
Unit Exponent Value: 0
Vertical Lable: Requests Per Second
Graph Items
Item #1 apache_stats AREA 8D00BA
Data Source: apache_stats
Item Group: AREA: apache_stats (AVERAGE)
Grage Item Type: Area
Consolidation Function: Average
CDEF Function: None
Value: NULL
GPRINT Options: Normal
Text Format: Requests
Insert Hard Return: No
I hope this information helps. I thank you for your assistance.
Who is online
Users browsing this forum: No registered users and 2 guests