PHP
Monitor Concurrent Connections from Wowza Media Server in Munin
So.. theres a professional way to do this (can be found on the Wowza Media Server forums[click]), but it requires you to bounce Wowza, which is less ideal.
Heres the hack:
First..
apt-get install php5-cli php5-curl
/etc/munin/wowzaget.php
#!/usr/bin/php
<?php
function xml2array($xml) {
$arXML=array();
$arXML['name']=trim($xml->getName());
$arXML['value']=trim((string)$xml);
$t=array();
foreach($xml->attributes() as $name => $value) $t[$name]=trim($value);
$arXML['attr']=$t;
$t=array();
foreach($xml->children() as $name => $xmlchild) $t[$name]=xml2array($xmlchild);
$arXML['children']=$t;
return($arXML);
}
function getIt($host,$user,$pass){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://".$host.":8086/connectioncounts");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $user.":".$pass);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
$xml = simplexml_load_string ($output);
$x = xml2array($xml);
return array($x["children"]["ConnectionsTotal"]["value"],$x["children"]["ConnectionsCurrent"]["value"]);
}
$x = getIt("localhost","USERNAME","PASSWORD!");
echo $x[0]." ".$x[1];
?>
/etc/munin/plugins/munin_wowza (credit goes to georgi
#!/bin/sh
case $1 in
config)
cat <<'EOM'
graph_title Wowza connections
graph_scale no
graph_category wowza
graph_vlabel connections
total_connections.label total connections
live_connections.label live connections
total_connections.draw AREA
live_connections.draw LINE1
EOM
exit 0;;
esac
cons=`/etc/munin/wowzaget.php`
tot=`echo $cons | cut -d' ' -f1`
live=`echo $cons | cut -d' ' -f2`
echo -n "total_connections.value "
echo $tot
echo -n "live_connections.value "
echo $live
Make sure you
chmod +x /etc/munin/wowzaget.php chmod +x /etc/munin/plugins/munin_wowza
And replace the username/password with those found in
/usr/local/WowzaMediaServer/admin.password
Then viola, wowza in munin.
(If you look at the script, you can also use 1 server to monitor _ALL_, but you must enable your wowza control (on port 8086) to respond to external connections (which is unsafe))