System status query script

Hi, I am trying to access and read certain lines from a configuration XML file on multiple servers (within the LAN). Fortunately the file name and path is always the same for all servers. An example extract of the file is as follows:

 <DUMMY-SMSC>false</DUMMY-SMSC> 

<DUMMY-HOST>weblogic2</DUMMY-HOST>
<SMPP_SERVER>true</SMPP_SERVER>
<SMPP_SENT_LOG_TIMER>true</SMPP_SENT_LOG_TIMER>
<CAMPAIGN_TIMER>false</CAMPAIGN_TIMER>
<CALENDAR-ACTIVE>false</CALENDAR-ACTIVE>
<OLD_PAGING>true</OLD_PAGING>
<EXPIRY-HOURS>36</EXPIRY-HOURS>

From this I want to obtain a list of true conditions for all servers and collated so each service will show what server it is running on
eg

SMPP_SERVER: server1, server3
OLD_PAGING: server1

The ultimate goal would be for the script to run continuously to provide a realtime indicator of services running. However if not feasible then a run when needed script would be the second choice.

I would welcome assistance for this from any guru out there !

Fingers crossed !
Jaz

here's a working script.
you can set it up in cron... build another script to call this one in a loop with
some sleep statements in there....

ie:

while : ; do
call_this_script
sleep 60
done

Anyway, here's the working script:

#!/bin/ksh

mkdir temp

cat << EOF |
server1
server2
server3
EOF
while read server ; do

  rcp $server:xml_config_file temp/$server

done

cd temp

cat << EOF |
SMPP_SERVER
OLD_PAGING
OTHER SERVICES
EOF
while read service ; do

  print -n "$service: "
  echo `grep -li "$service.*true" * |
    tr '\n' ,` |
    sed -e 's/,$//' -e 's/,/, /g'

done |
  tee ../log

... taking your formatting desires literally...

First, collect all the files from all the servers and save them. Go through them one after the other and compile a list of services to be available. Load this list in an array. Create a second array with corresponding subscripts consisting of empty string values.

Then go through the collected files a second time and write the server name to the second array when the respective service status is up.

Example: First step, get all the service names and create the two arrays, you end up with two arrays, looking like this:

servname[1]="service_1"
servname[2]="service_2"
servname[3]="service_3"

servhost[1]=""
servhost[2]=""
servhost[3]=""

Step two is going through the collected files and scan for service-host-relationships. If you find in the file of host1 that service_2 is up you would add "host1" to the content of $servhost[2], etc.

Last step is to go through the servname/servhost pair of arrays, and print the name of the service (from servname[]) follwoed by the list of hosts (from servhosts[]) to create the list you wanted.

I hope this helps.

bakunin