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:
parent
d3c0b24204
commit
5d5cb34f1e
@ -1,23 +1,24 @@
|
|||||||
#!/usr/bin/php
|
#!/bin/bash
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
# plugin made by Dju
|
# plugin made by Dju
|
||||||
|
# v1.1
|
||||||
# allows to monitor the mirrors number and bandwidth from Launchpad for a specific country
|
# 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
|
# 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( '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( 'CACHE_UPTIME', 3 );
|
||||||
define( 'COUNTRY', 'France' );
|
define( 'COUNTRY', 'France' );
|
||||||
|
|
||||||
|
|
||||||
function find_and_short( $str, &$html, $with_str=true )
|
function find_and_short( $str, &$html, $with_str=true )
|
||||||
{
|
{
|
||||||
$pos = strpos( $html, $str );
|
$pos = strpos( $html, $str );
|
||||||
if( $pos === false ) {
|
if( $pos === false ) {
|
||||||
throw new Exception( "error finding '$str'", 2 );
|
throw new Exception( "error finding '$str'", 2 );
|
||||||
} else {
|
} 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) );
|
$html = substr( $html, $pos + strlen($str) );
|
||||||
return $removed;
|
return $removed;
|
||||||
}
|
}
|
||||||
@ -80,11 +81,12 @@ try
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( isset($_SERVER['argv'][1]) && $_SERVER['argv'][1] != '' ) {
|
if( isset($_SERVER['argv'][1]) && $_SERVER['argv'][1] != '' ) {
|
||||||
$arg = $_SERVER['argv'][1];
|
switch( $_SERVER['argv'][1] ) {
|
||||||
if( $arg == 'autoconf' ) {
|
case 'autoconf':
|
||||||
echo "yes\n";
|
echo "yes\n";
|
||||||
exit( 0 );
|
exit( 0 );
|
||||||
} elseif( $arg == 'config' ) {
|
break;
|
||||||
|
case 'config':
|
||||||
echo "graph_title Ubuntu Mirrors in ".COUNTRY."\n";
|
echo "graph_title Ubuntu Mirrors in ".COUNTRY."\n";
|
||||||
echo "graph_category Ubuntu\n";
|
echo "graph_category Ubuntu\n";
|
||||||
echo "graph_args --base 1000 -l 0\n";
|
echo "graph_args --base 1000 -l 0\n";
|
||||||
@ -97,7 +99,8 @@ try
|
|||||||
$bwUnit = ( $CACHE == false ) ? '' : ' in '.$BW_UNIT;
|
$bwUnit = ( $CACHE == false ) ? '' : ' in '.$BW_UNIT;
|
||||||
echo "bw.label Bandwidth".$bwUnit."\n";
|
echo "bw.label Bandwidth".$bwUnit."\n";
|
||||||
exit( 0 );
|
exit( 0 );
|
||||||
} else {
|
break;
|
||||||
|
default:
|
||||||
echo "Unknown arg: ".$arg."\n";
|
echo "Unknown arg: ".$arg."\n";
|
||||||
exit( 2 );
|
exit( 2 );
|
||||||
}
|
}
|
||||||
@ -108,8 +111,8 @@ try
|
|||||||
set_cache( $MIRRORS, $BW_RATE, $BW_UNIT );
|
set_cache( $MIRRORS, $BW_RATE, $BW_UNIT );
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "nbm.value $mirrors\n";
|
echo "nbm.value ".$MIRRORS."\n";
|
||||||
echo "bw.value $bw\n";
|
echo "bw.value ".$BW_RATE."\n";
|
||||||
exit( 0 );
|
exit( 0 );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user