Wejn s.r.o.

Solving complicated IT problems is our hobby.

Making Wowza LoadBalancer's serverInfoXML Pretty

Working with Wowza Media Server was always a breeze for us. We’re geeks. We are friends with Java, we dream in XML and we love commandline tools.

But sometimes it’s nice to have the machines talk nice to us.

If you run Wowza with LoadBalancer on, you’ve no doubt saw the stock serverInfoXML file:

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
<LoadBalancerServerInfo>
  <LoadBalancerServer>
      <connectCount>13</connectCount>
      <status>RUNNING</status>
      <redirectCount>1</redirectCount>
      <lastMessage>1 seconds 203 milliseconds</lastMessage>
      <redirect>10.0.0.13</redirect>
      <serverId>77bbaa55-1234-5678-9012-34567890abcd</serverId>
  </LoadBalancerServer>
  <LoadBalancerServer>
      <connectCount>14</connectCount>
      <status>RUNNING</status>
      <redirectCount>0</redirectCount>
      <lastMessage>685 milliseconds</lastMessage>
      <redirect>10.0.0.14</redirect>
      <serverId>77bbaa55-1234-5678-9012-34567890abce</serverId>
  </LoadBalancerServer>
  <LoadBalancerServer>
      <connectCount>15</connectCount>
      <status>RUNNING</status>
      <redirectCount>0</redirectCount>
      <lastMessage>313 milliseconds</lastMessage>
      <redirect>10.0.0.15</redirect>
      <serverId>77bbaa55-1234-5678-9012-34567890abcf</serverId>
  </LoadBalancerServer>
</LoadBalancerServerInfo>

and maybe you thought along the lines: “Wouldn’t it be nice if it was a tad more readable?”

We did, too.

That’s why we made a small tweak that makes Wowza LoadBalancer’s serverInfoXML pretty not just to machines (machines love XML) but also to humans.

Contrast the XML above with this screenshot:

And not only it’s more readable; the page will even auto-refresh every 20 seconds for you.

If you’re interested in this module, download binary release of the module that does this. The release file contains *.jar file and documentation how to use it (which is our standard of delivering custom modules). Installation of the module should be a breeze for any seasoned Wowza admin.

You can also get the source package or see the code on github.

And now, how it’s done – the plain XML generated by Wowza’s LoadBalancer is enhanced with embedded XSLT stylesheet.

In effect, the abovementioned XML ends up looking like this:

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
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="#stylesheet"?>
<!DOCTYPE LoadBalancerServerInfo [
  <!ATTLIST xsl:stylesheet id ID #REQUIRED>
]>
<LoadBalancerServerInfo>
  <xsl:stylesheet id="stylesheet" version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <html><body>
      <h1>Wowza Edge Status</h1>
        <table border="1">
          <tr bgcolor="#bbddff">
            <th>Node</th><th>GUID</th><th>Status</th>
            <th>Connections</th><th>Redirects</th>
            <th>Last Msg</th>
          </tr>
          <xsl:for-each
              select="LoadBalancerServerInfo/LoadBalancerServer">
            <tr>
              <td><xsl:value-of select="redirect"/></td>
              <td><xsl:value-of select="serverId"/></td>
              <td><xsl:value-of select="status"/></td>
              <td><xsl:value-of select="connectCount"/></td>
              <td><xsl:value-of select="redirectCount"/></td>
              <td><xsl:value-of select="lastMessage"/></td>
            </tr>
          </xsl:for-each>
        </table>
      </body></html>
    </xsl:template>
  </xsl:stylesheet>
  <LoadBalancerServer>
    <connectCount>13</connectCount>
    <status>RUNNING</status>
    <redirectCount>1</redirectCount>
    <lastMessage>1 seconds 203 milliseconds</lastMessage>
    <redirect>10.0.0.13</redirect>
    <serverId>77bbaa55-1234-5678-9012-34567890abcd</serverId>
  </LoadBalancerServer>
  <LoadBalancerServer>
    <connectCount>14</connectCount>
    <status>RUNNING</status>
    <redirectCount>0</redirectCount>
    <lastMessage>685 milliseconds</lastMessage>
    <redirect>10.0.0.14</redirect>
    <serverId>77bbaa55-1234-5678-9012-34567890abce</serverId>
  </LoadBalancerServer>
  <LoadBalancerServer>
    <connectCount>15</connectCount>
    <status>RUNNING</status>
    <redirectCount>0</redirectCount>
    <lastMessage>313 milliseconds</lastMessage>
    <redirect>10.0.0.15</redirect>
    <serverId>77bbaa55-1234-5678-9012-34567890abcf</serverId>
  </LoadBalancerServer>
</LoadBalancerServerInfo>

Which is all there is to it. Your web browser does the rest.