Wowza Community

Scripts to monitor Wowza connections from MRTG and Munin

Hi,

Here i will post scripts to monitor total and live connections for wowza servers. This will work on Linux(or Unix ?) platforms.

Someone may find this useful.

You will need the JMX command-line interface(you can download it from this forums).

I think this is the JMX command-line tool : http://www.wowza.com/community/t/-/59

MRTG

Create script /root/scripts/get_wowza_connections.sh

#!/bin/bash
TOTALCONNS=`java -cp /root/scripts JMXCommandLine -jmx service:jmx:rmi://$1:8084/jndi/rmi://$1:8085/jmxrmi -user admin -pass jmxpassword getConnectionCounts`
LIVECONNS=`java -cp /root/scripts JMXCommandLine -jmx service:jmx:rmi://$1:8084/jndi/rmi://$1:8085/jmxrmi -user admin -pass jmxpassword getConnectionCounts _defaultVHost_:liverepeater`
echo "$TOTALCONNS"
echo "$LIVECONNS"

Be sure to replace the values for username and password .

liverepeater is the name of your live app.

Test the script :

/root/scripts/get_wowza_connections.sh 10.0.0.1

It should print two numbers : Total connections and connections to your live application.

Put this snippet in your mrtg.conf

Target[edge1.conns]: `/root/scripts/get_wowza_connections.sh 10.0.0.1`
Directory[edge1.conns]:     myhostname
Options[edge1.conns]: nopercent,growright,gauge,noinfo
Title[edge1.conns]: Open Wowza connections  -- edge1.btvcluster
PageTop[edge1.conns]: <H1>Open Wowza connections  -- edge1.btvcluster</H1>
MaxBytes[edge1.conns]: 10000
YLegend[edge1.conns]: # conns
ShortLegend[edge1.conns]: connections
LegendI[edge1.conns]:  Total Connections:
LegendO[edge1.conns]:  Live Cons
Legend1[edge1.conns]: Open Wowza connections  -- myhostname

Munin:

Create script /root/scripts/get_wowza_connections.sh

#!/bin/bash
TOTALCONNS=`java -cp /root/scripts JMXCommandLine -jmx service:jmx:rmi://$1:8084/jndi/rmi://$1:8085/jmxrmi -user admin -pass jmxpassword getConnectionCounts`
LIVECONNS=`java -cp /root/scripts JMXCommandLine -jmx service:jmx:rmi://$1:8084/jndi/rmi://$1:8085/jmxrmi -user admin -pass jmxpassword getConnectionCounts _defaultVHost_:liverepeater`
echo "$TOTALCONNS $LIVECONNS"

Create munin plugin as follows (usually in /etc/munin/plugins/ ):

#!/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=`/root/scripts/get_wowza_connections.sh 10.0.0.1`

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

Here is the result:

Hi georgi,

Your post is very helpful for me, but i can’t run it for my wowza. When i test the scrip:

sh /root/scripts/get_wowza_connections.sh 127.0.0.1

It showed:

ERROR: java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:

java.net.ConnectException: Connection refused]

ERROR: java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:

java.net.ConnectException: Connection refused]

I don’t know what’s wrong, pls help me

thanks

JConsole/JMX quickstart guide is here:

https://www.wowza.com/docs/how-to-install-and-configure-wowza-streaming-engine#jmx

Richard

Should run same on Windows. Here is setup guide for JMX command line:

https://www.wowza.com/docs/how-to-set-up-a-command-line-interface-to-wowza-api

Richard

Regarding the graphs at the top of this thread posted by “georgi”, I’m not familiar with that. You can get connection count graphs in JConsole like this:

https://www.wowza.com/docs/how-to-graph-individual-values-ex-concurrent-connections-to-the-server

Richard

Wowza EC2 AMIs used to include Cacti but do not now. We don’t support it. Take a look at these HTTPProviders that provide real-time data for Wowza

https://www.wowza.com/docs/how-to-monitor-server-connections-load-and-application-statistics

Richard

Lee,

I am not sure about the contributed scripts at the top of this thread. These HTTPProviders include current connection counts. If you want to graph that over time you can poll these at intervals and build a set to graph

Richard

Hi,

I’m guessing but i think 127.0.0.1 is not the IP where JMX is listening. If i recall u can see these settings in Server.xml

You need to configure the IP in the config file.

Hi,

Did someone convert the scripts to Windows?

Hi georgi

I have configured JMX and Jconsole,but when i run Jconsole, it doesn’t appear the image likes you, how can i get that image?

Danny, you’d have to look at the docs for MRTG or Munin, depending on which one you decide to use.

I try as below have error

root@wowza:~# /root/scripts/get_wowza_connections.sh localhost

Exception in thread “main” java.lang.NoClassDefFoundError: JMXCommandLine

Caused by: java.lang.ClassNotFoundException: JMXCommandLine

at java.net.URLClassLoader$1.run(URLClassLoader.java:202)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:190)

at java.lang.ClassLoader.loadClass(ClassLoader.java:306)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

Could not find the main class: JMXCommandLine. Program will exit.

Exception in thread “main” java.lang.NoClassDefFoundError: JMXCommandLine

Caused by: java.lang.ClassNotFoundException: JMXCommandLine

at java.net.URLClassLoader$1.run(URLClassLoader.java:202)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:190)

at java.lang.ClassLoader.loadClass(ClassLoader.java:306)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

Could not find the main class: JMXCommandLine. Program will exit.

Should run same on Windows. Here is setup guide for JMX command line:

https://www.wowza.com/docs/how-to-set-up-a-command-line-interface-to-wowza-api

Richard

I have installed mrtg and perl on my machine. However I have no idea on how to getting those graphs in windows.

Could anyone advise, please?

Regarding the graphs at the top of this thread posted by “georgi”, I’m not familiar with that. You can get connection count graphs in JConsole like this:

https://www.wowza.com/docs/how-to-graph-individual-values-ex-concurrent-connections-to-the-server

Richard

Thanks, I got the graph in JConsole :cool:

However, how if I wanna to use MRTG to plot the graph? Any suggestions on how to do so?

Hi,

How about Cacti? I’m trying to monitor the current connection through Cacti. Any help would be appreciated

Hi Richard,

What I want is to create graph about current connection (CCU) statistics for monitoring. The built-in method only provide real-time data.

Is there an easy way to achieve this? I’m trying to use munin, according to geogri tutorial but nothing work.

Lee

this features is free?

can someone help how to create graph with rrdtool?using that script?