2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

small bug fixed in v1.1

This commit is contained in:
Dju 2010-09-04 02:47:04 +02:00 committed by Steve Schnepp
parent d3c0b24204
commit 5d5cb34f1e

View File

@ -1,23 +1,24 @@
#!/usr/bin/php
#!/bin/bash
<?php
# plugin made by Dju
# v1.1
# allows to monitor the mirrors number and bandwidth from Launchpad for a specific country
# saves the results in cache and connects to launchpad website every 3 hours
# the country constant it=s the name of he country, as it appears on the launchpad page (bold, on a gray background)
define( 'URL', 'https://launchpad.net/ubuntu/+cdmirrors' );
define( 'CACHE_FILE', '/var/lib/munin/plugin-state/ubuntu_mirrors.txt' );
define( 'CACHE_FILE', 'ubuntu_mirrors.txt' );
define( 'CACHE_UPTIME', 3 );
define( 'COUNTRY', 'France' );
function find_and_short( $str, &$html, $with_str=true )
{
$pos = strpos( $html, $str );
if( $pos === false ) {
throw new Exception( "error finding '$str'", 2 );
} else {
$removed = ( $with_str==true ) ? substr( $html, 0, $pos+strlen($str) ) : substr( $html, 0, $pos );
$removed = ( $with_str == true ) ? substr( $html, 0, $pos+strlen($str) ) : substr( $html, 0, $pos );
$html = substr( $html, $pos + strlen($str) );
return $removed;
}
@ -80,11 +81,12 @@ try
}
if( isset($_SERVER['argv'][1]) && $_SERVER['argv'][1] != '' ) {
$arg = $_SERVER['argv'][1];
if( $arg == 'autoconf' ) {
switch( $_SERVER['argv'][1] ) {
case 'autoconf':
echo "yes\n";
exit( 0 );
} elseif( $arg == 'config' ) {
break;
case 'config':
echo "graph_title Ubuntu Mirrors in ".COUNTRY."\n";
echo "graph_category Ubuntu\n";
echo "graph_args --base 1000 -l 0\n";
@ -97,7 +99,8 @@ try
$bwUnit = ( $CACHE == false ) ? '' : ' in '.$BW_UNIT;
echo "bw.label Bandwidth".$bwUnit."\n";
exit( 0 );
} else {
break;
default:
echo "Unknown arg: ".$arg."\n";
exit( 2 );
}
@ -108,8 +111,8 @@ try
set_cache( $MIRRORS, $BW_RATE, $BW_UNIT );
}
echo "nbm.value $mirrors\n";
echo "bw.value $bw\n";
echo "nbm.value ".$MIRRORS."\n";
echo "bw.value ".$BW_RATE."\n";
exit( 0 );
}