-
Notifications
You must be signed in to change notification settings - Fork 2
/
wowza.pl
executable file
·67 lines (58 loc) · 1.41 KB
/
wowza.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/perl
#Woza Media server statistics script
#Tadas Ustinavicius 2014.05.21
use XML::Simple;
use LWP;
use warnings;
use strict;
my $host="";
my $user="";
my $password="";
my $command="";
my $argument_nr=1;
foreach my $ar(@ARGV) {
#rint $ar;
if ( $ar eq "-h" ) {
$host=$ARGV[$argument_nr];
}
if ( $ar eq "-u" ) {
$user=$ARGV[$argument_nr];
}
if ( $ar eq "-p" ) {
$password=$ARGV[$argument_nr];
}
if ( $ar eq "-c" ) {
$command=$ARGV[$argument_nr];
}
++$argument_nr;
}
if ($host eq "" or $user eq "" or $password eq "" or $command eq ""){
print "Missing command line parameters\n";
exit;
}
my $ua = LWP::UserAgent->new;
$ua->credentials( "$host:8086","Wowza Media Systems", $user=>$password );
my $response = $ua->get("http://$host:8086/connectioncounts/");
my $xml_string= $response->decoded_content;
my $simple = XML::Simple->new();
my $data = $simple->XMLin($xml_string);
sub validate{
my ($bps)= @_;
if ($bps =~ /E/){
my @values = split('E', $bps);
$bps=$values[0]*(10**$values[1]);
}
my $result = sprintf("%.2f", $bps);
return $bps;
}
my $result="";
if ($command eq "outbps"){
$result=validate($data->{'MessagesOutBytesRate'});
}
if ($command eq "inbps"){
$result=validate($data->{'MessagesInBytesRate'});
}
if ($command eq "conn"){
$result=$data->{'VHost'}->{'ConnectionsCurrent'};
}
print $result;