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
112 112

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

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

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