Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drives called the same identifying

Status
Not open for further replies.

maxcrook

Programmer
Jan 25, 2001
210
GB
I have several drives each one however is called either
RMT1_B or RMT1_C (they are both the same drive but shared in a library) when RMT1_B is in use RMT1_C shows as polling.

If however both drives are polling i need to be made aware.Therefore how do I identify that both drives are polling - therefore broken!

If the same drive is polling and a grep is performed i will get the following:
RMT1_B Polling
RMT1_C Polling

Ive tried to do a count but stumble at the first hurdle as it only counts one instance of each which it will do as they are both uniquely named!

Hope this makes sense !!






 
how do you check to see if a drive is polling?


Kind Regards
Duncan
 
Its done via TSM so the command is
q dr
the output is then written to a file like below, i then grep out all the things i dont need as below:

q dr > temp_work_file_qdr
cat temp_work_file_qdr | awk '{print $2,$4}' |grep Polling > temp_inuse_work_file_qdr

cat temp_inuse_work_file_qdr |awk '{print $1}' > inuse_work_file_qdr

The following is then in the file inuse_work_file_qdr

RMT1_B
RMT1_C
RMT2_B
RMT2_C
etc
 
can you show the output before you clean it up?


Kind Regards
Duncan
 
Yes the output is:

Library Name Drive Name Device Type On-Line
------------ ------------ ----------- ----------LIBMGR01_B RMT1_B 3592 Polling
LIBMGR02_C RMT1_C 3592 Polling
 
would something like this help...

Code:
[b]#!/usr/bin/perl[/b]

chomp (@drives = <DATA>);

foreach (@drives) {
  s/_(B|C)$/_B&C/;
  $drives{"$_"}++;
}

while (($key, $value) = each %drives) {
  print "$key => $value\n";
}

__DATA__
RMT3_B
RMT1_B
RMT1_C
RMT2_B
RMT2_C
RMT4_C

outputs:-
RMT4_B&C => 1
RMT2_B&C => 2
RMT1_B&C => 2
RMT3_B&C => 1



Kind Regards
Duncan
 
It would but the DATA (in your script) changes each time.It is never the same drive that stops.

Will give this a go though and try reading in the file containing the drives that are polling.
 
don't worry about the __DATA__ bit - it's just because i haven't got any to work with!

i could run a shell command and stuff that data into the array - and work from there


Kind Regards
Duncan
 
you can execute a shell command either by:-

Code:
@result = `shell cmd here...`;

you must use BACKTICKS - not single speech marks


Kind Regards
Duncan
 
Ive now got the following:

cat temp_work_file_qdr|grep Polling|awk '{print $2,$4}' > with_BC
cat with_BC |awk -F'_' '{print $1}' > without_BC

for i in `cat without_BC`
do
printf "%s %4d \n" "$i" `grep $i without_BC|sort|uniq|wc -l` >> MaxCount
done

The files contain the data below:

with_BC:
RMT1_B Polling
RMT2_C Polling
RMT2_B Polling
RMT13_B Polling
without_BC
RMT1
RMT2
RMT2
RMT13

I want to count the amount of times that each RMT is displayed - as there are 2 in with_BC the file MaxCount should contain:

RMT1 1
RMT2 2
RMT13 1

But the for part doesnt work !!!
 
i'm afraid i am a Perl programmer:-

Code:
#!/usr/bin/perl

chomp (@drives = <DATA>);

foreach (@drives) {
  $drives{"$_"}++;
}

while (($key, $value) = each %drives) {
  print "$key => $value\n";
}

__DATA__
RMT1
RMT2
RMT2
RMT13


Kind Regards
Duncan
 
Something like this ?
q dr | awk '
/Polling/{d=$2;sub(/_.*/,"",d);++n[d]}
END{for(i in n)printf "%s\t%4d\n",i,n}
' > MaxCount

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Holy sh1t ! Thats totally genius.
Worked first time.....

Thanks everyone for help - finally got there !!!!

THANKS
 
i reckon shell scripting is his first language ;-)


Kind Regards
Duncan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top