System status query script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting System status query script
# 1  
Old 02-18-2009
Bug 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
# 2  
Old 02-18-2009
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:
Code:
while : ; do
call_this_script
sleep 60
done

Anyway, here's the working script:

Code:
#!/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...
# 3  
Old 02-18-2009
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:

Code:
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
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. What is on Your Mind?

Status of Badging System - Beta 1

Dear All, Here is the current status of the badging system: The Beta 1 phase of the new badging system is close to completion. 42 prototype badges have been "allocated" 6 prototype badge slots are held in reserve The "alert you have new badges" prototype is running and is currently... (4 Replies)
Discussion started by: Neo
4 Replies

2. Homework & Coursework Questions

Listing Live System Status

1. Edit a script named update.sh that generates status.html in your web directory: ~/public_html/. I need to write specific commands to show each specific item 2. The generated webpage should include information related to: UNIX : kernel version of ed-lab server USER : number of users on the... (13 Replies)
Discussion started by: devinj
13 Replies

3. Shell Programming and Scripting

Shell Script to execute Oracle query taking input from a file to form query

Hi, I need to query Oracle database for 100 users. I have these 100 users in a file. I need a shell script which would read this User file (one user at a time) & query database. For instance: USER CITY --------- ---------- A CITY_A B CITY_B C ... (2 Replies)
Discussion started by: DevendraG
2 Replies

4. Shell Programming and Scripting

file system status mail notifications

HI I want to get an e-mail @ my yahoo address when the file system used space gets more than 89% , & the message contents must be the outputs of df -g errpt netstat -i ??????? (3 Replies)
Discussion started by: majd_ece
3 Replies

5. Solaris

svc:/system/filesystem/local is always in maintenance status

Hello Friends, I need to change network filesystem status as online but it always seems in maintenance mode, I appreciate your any suggestion to change its state as online. shell>svcadm enable svc:/system/filesystem/local shell>svcs -l svc:/system/filesystem/local fmri ... (4 Replies)
Discussion started by: EAGL€
4 Replies

6. Shell Programming and Scripting

Hide status value from awk system command

Hi, When i use the system( ) function inside a awk, i am getting the ouput with a 0 appended in a new line. Can someone guide me to eliminate the extra line containing 0. Ex : awk -F"|" '{print system("convert.sh" $1}' The output is displayed with 0 in a new line. ... (8 Replies)
Discussion started by: muruganksk
8 Replies

7. Shell Programming and Scripting

Query Oracle tables and return values to shell script that calls the query

Hi, I have a requirement as below which needs to be done viz UNIX shell script (1) I have to connect to an Oracle database (2) Exexute "SELECT field_status from table 1" query on one of the tables. (3) Based on the result that I get from point (2), I have to update another table in the... (6 Replies)
Discussion started by: balaeswari
6 Replies

8. Infrastructure Monitoring

SNMP OID for System Status LED's

I am trying to locate the proper MIB and OID location, to determine if the system attention light is on IBM-702x servers running 5.x. Currently, we get this on our Blade Centers Management Modules at location: 1.3.6.1.4.1.2.3.51.2.2.8.2.1.1.7.xx were xx is the actual Blade number. A value of 1... (0 Replies)
Discussion started by: stamfdf
0 Replies

9. Shell Programming and Scripting

system status report script

hi i m new to this forum as well as UNIX. I've got an assignment but i don't know how can I start it. can anyone please help to tell me how can I start it? I added here few lines from my assignment. In industry, it is common for a single organisation to provide technical support for a... (0 Replies)
Discussion started by: moco
0 Replies
Login or Register to Ask a Question