# Scripts to monitor Wowza connections from MRTG and Munin

**URL:** <https://community.wowza.com/t/scripts-to-monitor-wowza-connections-from-mrtg-and-munin/34065>\
**Category:** Wowza Developer Dojo\
**Tags:** wowza-streaming-server-java-api\
**Created:** [August 5, 2010, 2:56pm UTC](https://community.wowza.com/t/scripts-to-monitor-wowza-connections-from-mrtg-and-munin/34065 "2010-08-05T14:56:31Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Georgi\_Ivanov](https://avatars.discourse-cdn.com/v4/letter/g/838e76/32.png) [@Georgi\_Ivanov](https://community.wowza.com/u/Georgi_Ivanov)\
**Post date:** [August 5, 2010, 2:56pm UTC](https://community.wowza.com/t/scripts-to-monitor-wowza-connections-from-mrtg-and-munin/34065/1 "2010-08-05T14:56:31Z")

</div>

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://community.wowza.com/t/-/59](http://community.wowza.com/t/-/59)

MRTG

Create script /root/scripts/get\_wowza\_connections.sh

```auto
#!/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 :

```auto
/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

```auto
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

```auto
#!/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/ ):

```auto
#!/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:

---

<div class="post-metadata">

**Author:** ![tuan\_phan\_van](https://avatars.discourse-cdn.com/v4/letter/t/a9a28c/32.png) [@tuan\_phan\_van](https://community.wowza.com/u/tuan_phan_van)\
**Post date:** [June 7, 2011, 1:32am UTC](https://community.wowza.com/t/scripts-to-monitor-wowza-connections-from-mrtg-and-munin/34065/2 "2011-06-07T01:32:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [June 7, 2011, 10:14am UTC](https://community.wowza.com/t/scripts-to-monitor-wowza-connections-from-mrtg-and-munin/34065/3 "2011-06-07T10:14:25Z")

</div>

JConsole/JMX quickstart guide is here:

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

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [August 23, 2011, 10:32pm UTC](https://community.wowza.com/t/scripts-to-monitor-wowza-connections-from-mrtg-and-munin/34065/4 "2011-08-23T22:32:10Z")

</div>

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](https://www.wowza.com/docs/how-to-set-up-a-command-line-interface-to-wowza-api)

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [March 1, 2012, 2:38pm UTC](https://community.wowza.com/t/scripts-to-monitor-wowza-connections-from-mrtg-and-munin/34065/5 "2012-03-01T14:38:46Z")

</div>

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](https://www.wowza.com/docs/how-to-graph-individual-values-ex-concurrent-connections-to-the-server)

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [January 5, 2013, 2:20pm UTC](https://community.wowza.com/t/scripts-to-monitor-wowza-connections-from-mrtg-and-munin/34065/6 "2013-01-05T14:20:38Z")

</div>

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](https://www.wowza.com/docs/how-to-monitor-server-connections-load-and-application-statistics)

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [January 7, 2013, 2:09pm UTC](https://community.wowza.com/t/scripts-to-monitor-wowza-connections-from-mrtg-and-munin/34065/7 "2013-01-07T14:09:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Georgi\_Ivanov](https://avatars.discourse-cdn.com/v4/letter/g/838e76/32.png) [@Georgi\_Ivanov](https://community.wowza.com/u/Georgi_Ivanov)\
**Post date:** [June 7, 2011, 12:04pm UTC](https://community.wowza.com/t/scripts-to-monitor-wowza-connections-from-mrtg-and-munin/34065/8 "2011-06-07T12:04:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Eliran\_Hayun](https://avatars.discourse-cdn.com/v4/letter/e/54ee81/32.png) [@Eliran\_Hayun](https://community.wowza.com/u/Eliran_Hayun)\
**Post date:** [August 23, 2011, 8:50pm UTC](https://community.wowza.com/t/scripts-to-monitor-wowza-connections-from-mrtg-and-munin/34065/9 "2011-08-23T20:50:56Z")

</div>

Hi,

Did someone convert the scripts to Windows?

---

<div class="post-metadata">

**Author:** ![tuan\_phan\_van](https://avatars.discourse-cdn.com/v4/letter/t/a9a28c/32.png) [@tuan\_phan\_van](https://community.wowza.com/u/tuan_phan_van)\
**Post date:** [June 16, 2011, 8:37pm UTC](https://community.wowza.com/t/scripts-to-monitor-wowza-connections-from-mrtg-and-munin/34065/10 "2011-06-16T20:37:57Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Randall\_Auriemma](https://avatars.discourse-cdn.com/v4/letter/r/85e7bf/32.png) [@Randall\_Auriemma](https://community.wowza.com/u/Randall_Auriemma)\
**Post date:** [March 1, 2012, 6:41pm UTC](https://community.wowza.com/t/scripts-to-monitor-wowza-connections-from-mrtg-and-munin/34065/11 "2012-03-01T18:41:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ekachai\_Woranut](https://avatars.discourse-cdn.com/v4/letter/e/e68b1a/32.png) [@Ekachai\_Woranut](https://community.wowza.com/u/Ekachai_Woranut)\
**Post date:** [July 26, 2012, 12:49am UTC](https://community.wowza.com/t/scripts-to-monitor-wowza-connections-from-mrtg-and-munin/34065/12 "2012-07-26T00:49:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![danny\_lau](https://avatars.discourse-cdn.com/v4/letter/d/90ced4/32.png) [@danny\_lau](https://community.wowza.com/u/danny_lau)\
**Post date:** [March 1, 2012, 4:36pm UTC](https://community.wowza.com/t/scripts-to-monitor-wowza-connections-from-mrtg-and-munin/34065/13 "2012-03-01T16:36:13Z")

</div>

> Should run same on Windows. Here is setup guide for JMX command line:
> 
> [Set up a command-line interface to the Wowza Streaming](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?

---

<div class="post-metadata">

**Author:** ![danny\_lau](https://avatars.discourse-cdn.com/v4/letter/d/90ced4/32.png) [@danny\_lau](https://community.wowza.com/u/danny_lau)\
**Post date:** [March 2, 2012, 11:16am UTC](https://community.wowza.com/t/scripts-to-monitor-wowza-connections-from-mrtg-and-munin/34065/14 "2012-03-02T11:16:22Z")

</div>

> 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:
> 
> [Wowza Streaming Engine](https://www.wowza.com/docs/how-to-graph-individual-values-ex-concurrent-connections-to-the-server)
> 
> Richard

Thanks, I got the graph in JConsole 🆒

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

---

<div class="post-metadata">

**Author:** ![lee\_lee](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@lee\_lee](https://community.wowza.com/u/lee_lee)\
**Post date:** [January 5, 2013, 11:31am UTC](https://community.wowza.com/t/scripts-to-monitor-wowza-connections-from-mrtg-and-munin/34065/15 "2013-01-05T11:31:47Z")

</div>

Hi,

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

---

<div class="post-metadata">

**Author:** ![lee\_lee](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@lee\_lee](https://community.wowza.com/u/lee_lee)\
**Post date:** [January 7, 2013, 5:22pm UTC](https://community.wowza.com/t/scripts-to-monitor-wowza-connections-from-mrtg-and-munin/34065/16 "2013-01-07T17:22:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![indra\_cyd](https://avatars.discourse-cdn.com/v4/letter/i/bc79bd/32.png) [@indra\_cyd](https://community.wowza.com/u/indra_cyd)\
**Post date:** [October 19, 2012, 1:55pm UTC](https://community.wowza.com/t/scripts-to-monitor-wowza-connections-from-mrtg-and-munin/34065/17 "2012-10-19T13:55:20Z")

</div>

this features is free?

---

<div class="post-metadata">

**Author:** ![indra\_cyd](https://avatars.discourse-cdn.com/v4/letter/i/bc79bd/32.png) [@indra\_cyd](https://community.wowza.com/u/indra_cyd)\
**Post date:** [October 20, 2012, 12:30pm UTC](https://community.wowza.com/t/scripts-to-monitor-wowza-connections-from-mrtg-and-munin/34065/18 "2012-10-20T12:30:16Z")

</div>

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