Skip to content
This repository has been archived by the owner on Dec 6, 2022. It is now read-only.

Commit

Permalink
Fix recognition of var name for munin plugin, give better error msg i…
Browse files Browse the repository at this point in the history
…f bad symlink is used
  • Loading branch information
gggeek committed Jun 27, 2012
1 parent 4d3413d commit c1c001f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions bin/php/muninplugin.php
Expand Up @@ -38,7 +38,7 @@
// plugin, appending graph name to the original plugin file name. The shell script
// will pass us its own filename in the 'variable' option
$variable = isset( $options['variable'] ) ? $options['variable'] : '';
$variable = preg_replace( '/$ezmuninperflogger_/', '', $variable );
$variable = preg_replace( '/^ezmuninperflogger_/', '', $variable );

// default munin range: 5 minutes
$range = $options['range'] ? $options['range'] : 60 * 5;
Expand Down Expand Up @@ -99,7 +99,12 @@

case 'fetch':
default:
if ( $variable == '' || !in_array( $variable, $ini->variable( 'GeneralSettings', 'TrackVariables' ) ) )
if ( $variable == '' )
{
$cli->output( "Error: you are using the ezmuninperflogger_ script as munin plugin. You should create symlinks named ezmuninperflogger_\$varname instead" );
$script->shutdown( -1 );
}
if ( !in_array( $variable, $ini->variable( 'GeneralSettings', 'TrackVariables' ) ) )
{
$cli->output( "Error: '$variable' is not a tracked perf. variable" );
$script->shutdown( -1 );
Expand Down

0 comments on commit c1c001f

Please sign in to comment.