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!

A command to check the status of the tape drives?

Status
Not open for further replies.

nsrwendy

Technical User
Nov 27, 2002
7
US
Hi,

I am a Unix system administrator and am responsible for backups en tape changes as well.

I normally use the 'nsrwatch' command to check in which status the tape drives are. Is there another way to check what the status of the tape drives is? In other words, is there a command that gives me the following output:
/dev/rmt/0cbn(J) dlt7000 File.0011 writing, done
/dev/rmt/1cbn(J) dlt7000 Testplant.0024 writing, done
/dev/rmt/2cbn(J) dlt7000 Unix.0001 writing, done
/dev/rmt/3cbn(J) dlt7000 File.0017 writing, done
/dev/rmt/4cbn(J) dlt7000 Unix.0010 writing, done
/dev/rmt/5cbn(J) dlt7000 File.0014 writing, done
/dev/rmt/6cbn(J) dlt7000 (none) read open error, I/O error
/dev/rmt/7cbn(J) dlt7000 (none) disabled
/dev/rmt/8cbn(J) dlt7000 (none) ejected

Can I do this with nsradmin or mminfo ?

Thanks
wendy
 
Hi

Do you want :

1 > NSR status of your tape devices
2 > system status of your tape devices

In the case 2, 605 gave you the right action but i expected you 've known before your post

In the case 1, excuse me but i've no idea, but i will search later this evening ;)
 
Hello,

I tried "mt -f ...." but that does not give me the NSR status of the tape device. I am interested in the output:
/dev/rmt/0cbn writing, done
/dev/rmt/1cbn ejected
/dev/rmt/2cbn read I/O error
etc....
So I want the NSR status of the devices.

I don't know how these values "writing,done" and "ejected" are called in NetWorker. When I use 'nsradmin -c' and I check out the NSR Devices, I cannot find a field that indicates that status. I can only find it when I use 'nsrwatch'.

The reason why I need an alternative for nsrwatch is that I want to build a script to check if all tape drives are finished with the writing process. I can't use nsrwatch in my script because it is a command that gives variable output and that makes my script hang.
When all backups are finished and all tape drives are not active anymore, then I want the script to unmount all tapes with 'nsrjb -u'.

nsrwendy
 
For the Solaris OS, there's fuser. If there's a process associated with the drive, fuser will show the process number.

fuser /dev/rmt/5stcbn (or whatever the device name is)

An example:

# fuser /dev/rmt/5stcbn
/dev/rmt/5stcbn: 2361o
# ps -ef | grep 2361
root 2361 27336 0 21:41:00 ? 62:01 /usr/sbin/nsrmmd -n 629
root 12775 12605 0 07:33:44 pts/14 0:00 grep 2361

I don't know of a way to make fuser report the process name. That takes a grep on the process number. This also won't tell you what the tape drive is doing, just that there's a nsrmmd associated with the drive.

Or, maybe the script could grep for the different NSR processes - nsrclone, nsrjb -l -M (I'm skipping the jukebox part of this command) for a mount - that tie up tape devices.


 


Have you tried to use nsrwatch with a -p option which will tell it to poll every X seconds. This might give you a easyier target to look for. Also have you tried to send the nsrwatch to a file then kill it, and look for the data you want there? That is the only thing I can think of.
 
This is quite evil, but it might put you on the track of how to accomplish it:

nsrwatch < /dev/null | grep '/dev/rmt/' > status.tmp

The file status.tmp has the text of your devices. It gives some kind of funky error message, but at least you get the text.

 

Hello Wendy!

To see these messages in nsradmin you have to turn on
the hidden options by command &quot;option hidden&quot; in nsradmin.
Then you can see alot of more details about the resources
in networker.
For the status of your devices you can use a script that
I will include below. You can modify it as you need to fit
your environment. I'm using HPUX 11.11 on my networker
server so if you are at another Unix OS you probably at least have to change the NW_BIN variable in my script.

/Regards Thomas


#!/bin/sh

NW_BIN=/opt/networker/bin
QUERY_FILE=/tmp/dev.query
DEVICE=&quot;&quot;
TYPE=&quot;&quot;
MESSAGE=&quot;&quot;
VOLUME=&quot;&quot;

echo &quot;option hidden&quot; > $QUERY_FILE
echo &quot;show name; media type; volume name; message&quot; >> $QUERY_FILE
echo &quot;print type: NSR device;&quot; >> $QUERY_FILE

$NW_BIN/nsradmin -i - <$QUERY_FILE 2>/dev/null | while read line
do
case $line in
&quot;name:&quot;*)
DEVICE=&quot;`echo $line | sed -e 's/name: //' -e 's/;//'`&quot;
;;
&quot;media type:&quot;*)
TYPE=&quot;`echo $line | sed -e 's/media type: //' -e 's/;//'`&quot;
;;
&quot;message:&quot;*)
MESSAGE=&quot;`echo $line | sed -e 's/message: //' -e 's/;//'`&quot;
;;
&quot;volume name:&quot;*)
VOLUME=&quot;`echo $line | sed -e 's/volume name: //' -e 's/;//'`&quot;
echo &quot;$DEVICE $TYPE $VOLUME $MESSAGE&quot;
;;
*)
;;
esac
done

exit
 
Waaauw! So many replies!!
The last days I haven't had the time to follow up on this but I will try out all the above ideas and see what I can do with them.

Thanks already. I'll give you some feedback later on.
 
SEYTHMA, I like your approach much more than my suggested 'hack'... on my particular Solaris install, my NW_BIN would be /usr/sbin/nsr
 
Hi all,

I tried some things out. Here are the results:

kcongdon
I work with Solaris so I can user 'fuser'. When the drives are not writing anything and I use fuser, the output is empty
e.g. root@t66s# fuser /dev/rmt/0cbn
/dev/rmt/0cbn:
This option might be useful. I have to investigate this further.

john7
nsrwatch -p 2 | grep '/dev/rmt' > tapedrivestatus
This command keeps on hanging and I get an empty tapedrivestatus file.

I tried to redirect the nsrwatch output to a file and to quit it then, but that quit command does not work when I build that into a script. It keeps on hanging.
Script content was:
#!/bin/ksh
nsrwatch | grep '/dev/rmt' > /em/home/xdshewe/Friday.output
quit

goony
When I enter 'nsrwatch < /dev/null | grep '/dev/rmt' > status.tmp' I get the message: &quot;getting size: No such device or address&quot; and the command is hanging until I press Ctrl C.

Now I will try SEYTHMA's suggestion.
Wendy

 


Using a -p is only a 2 second popll time, this is the default for NetWorker, make it -p 60 and give it a try.
 
John, I will try that &quot;-p 60&quot; tomorrow, I want to see the result.

Thomas, your script is the solution to my problem. I simplified it a bit because actually I only need the device name and the message. My script looks now as follows:

#!/bin/sh

QUERY_FILE=/tmp/dev.query
DEVICE=&quot;&quot;
MESSAGE=&quot;&quot;

echo &quot;show name; message&quot; >> $QUERY_FILE
echo &quot;print type: NSR device;&quot; >> $QUERY_FILE

/usr/sbin/nsradmin -i - <$QUERY_FILE 2>/dev/null | while read line
do
case $line in
&quot;name:&quot;*)
DEVICE=&quot;`echo $line | sed -e 's/name: //' -e 's/;//'`&quot;
;;
&quot;message:&quot;*)
MESSAGE=&quot;`echo $line | sed -e 's/message: //' -e 's/;//'`&quot;
echo &quot;$DEVICE $MESSAGE&quot;
;;
*)
;;
esac
done

exit


Result is:
&quot;writing, done &quot;
/dev/rmt/0cbn &quot;writing, done &quot;
/dev/rmt/1cbn &quot;writing, done &quot;
/dev/rmt/2cbn &quot;writing, done &quot;
/dev/rmt/3cbn &quot;writing, done &quot;
/dev/rmt/4cbn &quot;writing, done &quot;
/dev/rmt/5cbn disabled

While it should be:
/dev/rmt/0cbn &quot;writing, done &quot;
/dev/rmt/1cbn &quot;writing, done &quot;
/dev/rmt/2cbn &quot;writing, done &quot;
/dev/rmt/3cbn &quot;writing, done &quot;
/dev/rmt/4cbn &quot;writing, done &quot;
/dev/rmt/5cbn &quot;writing, done &quot;
/dev/rmt/6cbn disabled

Something is wrong in my version of the script. I will go over it step by step until I have it correct.

Thomas, in your original script, you had a line:
echo &quot;option hidden&quot; > $QUERY_FILE
Do I really need that?

Thanks for all your help!
 
Hello Wendy!

I'm using &quot;option hidden&quot; too see all the configuration for
the devices but if you are asking explicity for lets say
the value of the message parameter it will display that
without the need of turning option hidden on.
In other words you can remove that line in your script and
it will still give you the message for each device.

In your original posting you asked for a way of getting the
status of the drives by a command and your example showed
that you like to display DEVICE,TYPE,VOLUME and MESSAGE, that's why my script is getting these 4 values.

Since you removed a couple of lines from my original script
you are getting wrong output in your script.
If you only need the values DEVICE/MESSAGE from each device
you have to move the 'echo &quot;$DEVICE $MESSAGE&quot;' and put it
after the
DEVICE=&quot;`echo $line | sed -e 's/name: //' -e 's/;//'`&quot; line.

This is because you will first get the MESSAGE and then the DEVICE value in the loop.

/Regards Thomas

.
.
.
case $line in
&quot;name:&quot;*)
DEVICE=&quot;`echo $line | sed -e 's/name: //' -e 's/;//'`&quot;
echo &quot;$DEVICE $MESSAGE&quot;
;;
&quot;message:&quot;*)
MESSAGE=&quot;`echo $line | sed -e 's/message: //' -e 's/;//'`&quot;
;;
*)
;;
esac
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top