<--even more planning ^--Soigan--^ development, continued-->

Soigan - a Multicast XML monitoring system - development

Development

It's time to put all this thinking into action. There are a lot of things to do, so in what order should we code? Here's my plan.

Plugin

Let's write the users plugin. This returns useful information, has the added complexity of an array, and is easy to test.

There are three easy ways, as mentioned before, to get the list of users from a Unix system - w, who and users. Which should we use? users returns just the logins; who returns their tty, their login time and where they came from. w has the same, minus the where, but with what they're running instead. Let's go with who -- the "what" can be answered with another plugin.

Here's some sample output from "who" that we have to parse:

crwth      pts/1        Jun  1 08:02  (stilton)
crwth      pts/3        Jun  1 08:41  (stilton)
crwth      pts/4        Jun  3 15:41  (stilton)
The first hurdle I hit was that Java has horrible date/time parsing routines. There might be some in the libraries somewhere that can handle the date/time above, or one available on the internet, but I've just implemented my own for now. Seemed easier, and kinda fun I guess.

I broke the plugin into two parts, "soigan_who" which has the main interface that the Worker uses, and "whoentry" which knows how to parse and display each who line in various formats. Not counting the 350 lines of my "DateParser" class, which is generic to this plugin, it clocks in at 350 lines. That's not bad, considering that this is a pretty busy plugin, having to return an array of structures of mixed data (strings, ints and dates).

Here's the usage for the plugin:

% java soigan_who -h
Usage:  soigan_who -h
        soigan_who [-R|-X|-n]
        soigan_who -S [-R|-X]

-h      This help
-R      RPC-ready output [default]
-X      XML-RPC format
-n      no processing (raw output)
-S      Schema dump
As mentioned above, the -R is the default behaviour, and produces the output that an XML-RPC client might need to build its calls. The -R flag was added so it can be explicitly chosen as the output method, but isn't necessary. Here's the XML-RPC Schema:
% java soigan_who -S
string
nsd
date
1086728665972
string
who
struct
string
count
int
string
whoentries
array
struct
string
login
string
string
tty
string
string
when
date
string
from
string
end
end
end
All schemas return the hostname, the date and the name of the plugin so the Server that receives it doesn't have to remember that it asked for it. After that comes the struct that makes up the schema, and we see that it contains two items, an int called count, and an array called whoentries. The array then contains an example of its contents, which in this case is another struct, containing the six different pieces of information from who. And here's some output:
% java soigan_who 
string
nsd
date
1086728920176
string
who
struct
int
count
3
array
struct
string
login
crwth
string
tty
pts/1
date
when
1086098520000
string
from
stilton
end
struct
string
login
crwth
string
tty
pts/3
date
when
1086100860000
string
from
stilton
end
struct
string
login
crwth
string
tty
pts/4
date
when
1086298860000
string
from
stilton
end
end
end
It's sure not pleasant to look at, but a Worker will make short work of it. This is our XML schema:
% java soigan_who -X -S
<?xml version="1.0" encoding="ISO-8859-1"?>
  <methodCall>
    <methodName>schema.results</methodName>
    <params>
      <param>
        <value>nsd</value>
      </param>
      <param>
        <value><dateTime.iso8601>20040608T03:10:48</dateTime.iso8601></value>
      </param>
      <param>
        <value>who</value>
      </param>
      <param>
        <value><struct>
        <member><name>count</name><value>int</value></member>
        <member><name>whoarray</name><value>
        <array><data>
          <value><struct>
            <member>
              <name>login</name><value>string</value>
            </member><member>
              <name>tty</name><value>string</value>
            </member><member>
              <name>when</name><value>date</value>
            </member><member>
              <name>from</name><value>string</value>
            </member>
          </struct></value>
        </data></array>
        </value></member>
        </struct></value>
      </param>
    </params>
  </methodCall>
And the XML output:
% java soigan_who -X 
<?xml version="1.0" encoding="ISO-8859-1"?>
  <methodCall>
    <methodName>plugin.results</methodName>
    <params>
      <param>
        <value>nsd</value>
      </param>
      <param>
        <value><dateTime.iso8601>20040608T03:12:14</dateTime.iso8601></value>
      </param>
      <param>
        <value>who</value>
      </param>
      <param>
        <value><struct>
        <member><name>count</name><int>3</int></member>
        <member><name>whoentries</name>
        <array><data>
          <value><struct>
            <member>
              <name>login</name><value>crwth</value>
            </member><member>
              <name>tty</name><value>pts/1</value>
            </member><member>
              <name>when</name><value><dateTime.iso8601>20040601T08:02:00</dateTime.iso8601></value>
            </member><member>
              <name>from</name><value>stilton</value>
            </member>
          </struct></value>
          <value><struct>
            <member>
              <name>login</name><value>crwth</value>
            </member><member>
              <name>tty</name><value>pts/3</value>
            </member><member>
              <name>when</name><value><dateTime.iso8601>20040601T08:41:00</dateTime.iso8601></value>
            </member><member>
              <name>from</name><value>stilton</value>
            </member>
          </struct></value>
          <value><struct>
            <member>
              <name>login</name><value>crwth</value>
            </member><member>
              <name>tty</name><value>pts/4</value>
            </member><member>
              <name>when</name><value><dateTime.iso8601>20040603T15:41:00</dateTime.iso8601></value>
            </member><member>
              <name>from</name><value>stilton</value>
            </member>
          </struct></value>
        </data></array>
        </member></struct></value>
      </param>
    </params>
  </methodCall>
And finally, the only option we didn't mention, was the -n option, which lets us see what the plugin is reading for testing purposes:
% java soigan_who -n
crwth      pts/1        Jun  1 08:02  (stilton)
crwth      pts/3        Jun  1 08:41  (stilton)
crwth      pts/4        Jun  3 15:41  (stilton)
Looks good! Now we need to write a Worker that calls this plugin and makes some XML-RPC calls with the result.
<--even more planning ^--Soigan--^ development, continued-->
©2002-2017 Wayne Pearson