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:
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 !
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:
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.