root / plugins / apache_apc_usage @ 8f2bcef9
Historique | Voir | Annoter | Télécharger (1,55 ko)
| 1 |
#!/usr/bin/perl |
|---|---|
| 2 |
# |
| 3 |
# Magic markers: |
| 4 |
#%# family=auto |
| 5 |
#%# capabilities=autoconf |
| 6 |
|
| 7 |
my $ret = undef; |
| 8 |
|
| 9 |
if (! eval "require LWP::UserAgent;") |
| 10 |
{
|
| 11 |
$ret = "LWP::UserAgent not found"; |
| 12 |
} |
| 13 |
|
| 14 |
my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://127.0.0.1:%d/apc_cache_usage.php?auto";
|
| 15 |
my @PORTS = exists $ENV{'ports'} ? split(' ', $ENV{'ports'}) : (80);
|
| 16 |
|
| 17 |
if ( defined $ARGV[0] and $ARGV[0] eq "autoconf" ) |
| 18 |
{
|
| 19 |
if ($ret) |
| 20 |
{
|
| 21 |
print "no ($ret)\n"; |
| 22 |
exit 1; |
| 23 |
} |
| 24 |
|
| 25 |
my $ua = LWP::UserAgent->new(timeout => 30); |
| 26 |
|
| 27 |
my @badports; |
| 28 |
foreach my $port (@PORTS) {
|
| 29 |
my $url = sprintf $URL, $port; |
| 30 |
my $response = $ua->request(HTTP::Request->new('GET',$url));
|
| 31 |
push @badports, $port unless $response->is_success and $response->content =~ /^size:/im; |
| 32 |
} |
| 33 |
if (@badports) {
|
| 34 |
print "no (apc-status)\n"; |
| 35 |
exit 1; |
| 36 |
} else {
|
| 37 |
print "yes\n"; |
| 38 |
exit 0; |
| 39 |
} |
| 40 |
} |
| 41 |
|
| 42 |
if ( defined $ARGV[0] and $ARGV[0] eq "config" ) |
| 43 |
{
|
| 44 |
print('graph_title PHP APC Cache Usage
|
| 45 |
graph_args --base 1024 -l 0 |
| 46 |
graph_vlabel bytes |
| 47 |
graph_category APC |
| 48 |
graph_order used free |
| 49 |
graph_total Total |
| 50 |
used.label Used |
| 51 |
used.draw AREA |
| 52 |
free.label Free |
| 53 |
free.draw STACK |
| 54 |
'); |
| 55 |
|
| 56 |
exit 0; |
| 57 |
} |
| 58 |
|
| 59 |
foreach my $port (@PORTS) |
| 60 |
{
|
| 61 |
my $ua = LWP::UserAgent->new(timeout => 30); |
| 62 |
my $url = sprintf $URL, $port; |
| 63 |
my $response = $ua->request(HTTP::Request->new('GET',$url));
|
| 64 |
if ($response->content =~ /used:\s+([0-9\.]+)/im) {
|
| 65 |
print "used.value $1\n"; |
| 66 |
} else {
|
| 67 |
print "used.value U\n"; |
| 68 |
} |
| 69 |
if ($response->content =~ /free:\s+([0-9\.]+)/im) {
|
| 70 |
print "free.value $1\n"; |
| 71 |
} else {
|
| 72 |
print "free.value U\n"; |
| 73 |
} |
| 74 |
} |
| 75 |
|
| 76 |
# vim:syntax=perl |
