Projet

Général

Profil

Révision fd119055

IDfd119055ab30f39cc84ee3d38fe9f71eb3f07811
Parent 4b7a73e0
Enfant 9ec0760e

Ajouté par Jun Kuriyama il y a environ 13 ans

Fix usage of appname at munin symbol translation

FMS appname may include '-' chars, and was translated to '_' because
of Munin dislike this character.

But original appname is required to retrive values from getAppStats
API. So preserve original appname and translate it at only actually
needed.

Voir les différences:

plugins/network/fms_apps_rate
113 113

  
114 114
my ($host, $port, $username, $password);
115 115

  
116
sub name_filter { my ($n) = @_; $n =~ s/[^a-zA-Z0-9_]/_/g; $n }
117

  
116 118
sub get_apps {
117 119
	my @applist;
118 120
	my $ua = LWP::UserAgent->new(timeout => 30);
......
123 125
		my $apps = $1;
124 126
		while ( $apps =~ /<_[0-9]+> *([^<]*) *<\/_[0-9]+>/gi ) {
125 127
			my $appname = $1;
126
			$appname =~ s/[^a-zA-Z0-9_]/_/g;
127 128
			push(@applist, $appname);
128 129
		}
129 130
	}
......
218 219
			my @apps = get_apps();
219 220
			if ( $#apps >= 0 ) {
220 221
				foreach my $app (@apps) {
222
					my $symbol = name_filter($app);
221 223
					print <<"END_APP_CONFIG";
222
fms_app_total_$app.label $app
223
fms_app_total_$app.type DERIVE
224
fms_app_total_$app.min 0
224
fms_app_total_$symbol.label $app
225
fms_app_total_$symbol.type DERIVE
226
fms_app_total_$symbol.min 0
225 227
END_APP_CONFIG
226 228
				}
227 229
				exit 0;
......
241 243
	if ( $#apps >= 0 ) {
242 244
		my $ua = LWP::UserAgent->new(timeout => 30);
243 245
		foreach my $app (@apps) {
246
			my $symbol = name_filter($app);
244 247
			my $url = sprintf("http://%s:%d/admin/getAppStats?auser=%s\&apswd=%s\&app=%s", $host, $port, $username, $password, $app);
245 248
			my $response = $ua->request(HTTP::Request->new('GET', $url));
246 249
			if ( $response->content =~ /<data>.*<total_connects>[^0-9]*([0-9]+)[^0-9]*<\/total_connects>.*<\/data>/is ) {
247
				print("fms_app_total_$app.value $1\n");
250
				print("fms_app_total_$symbol.value $1\n");
248 251
			} else {
249 252
				print(STDERR "Failed to get total number of played streams for the \"$app\" application from the Flash Media Administration Server!\n");
250
				print("fms_app_total_$app.value U\n");
253
				print("fms_app_total_$symbol.value U\n");
251 254
			}
252 255
		}
253 256
		exit 0;

Formats disponibles : Unified diff