| 1 | #!/usr/local/bin/perl | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | |||
| 5 | use Getopt::Std; | ||
| 6 | use Time::Local; | ||
| 7 | |||
| 8 | my %opts; | ||
| 9 | getopts('dtscvM:', \%opts); | ||
| 10 | |||
| 11 | if ($opts{'v'}) { | ||
| 12 | $opts{'c'} = $opts{'t'} = $opts{'s'} = 1; | ||
| 13 | } | ||
| 14 | |||
| 15 | |||
| 16 | use NBU; | ||
| 17 | NBU->debug($opts{'d'}); | ||
| 18 | |||
| 19 | my $master; | ||
| 20 | if ($opts{'M'}) { | ||
| 21 | $master = NBU::Host->new($opts{'M'}); | ||
| 22 | } | ||
| 23 | else { | ||
| 24 | my @masters = NBU->masters; $master = $masters[0]; | ||
| 25 | } | ||
| 26 | |||
| 27 | foreach my $stu (NBU::StorageUnit->list($master)) { | ||
| 28 | NBU::Drive->populate($stu->host) | ||
| 29 | unless (!defined($stu->host)); | ||
| 30 | } | ||
| 31 | |||
| 32 | for my $robot (NBU::Robot->farm) { | ||
| 33 | next unless (defined($robot)); | ||
| 34 | print "Robot ".$robot->id; | ||
| 35 | print " controlled from ".$robot->host->name if (defined($robot->host)); | ||
| 36 | print "\n"; | ||
| 37 | for my $drive (sort {$a->robotDriveIndex <=> $b->robotDriveIndex} $robot->drives) { | ||
| 38 | print " ".($drive->down ? "v" : "^"); | ||
| 39 | printf(" %2u", $drive->robotDriveIndex); | ||
| 40 | printf(" %-8s", $drive->name); | ||
| 41 | printf(" (%2u)", $drive->id) if ($opts{'v'}); | ||
| 42 | if ($opts{'t'}) { | ||
| 43 | if ($drive->busy) { | ||
| 44 | print " (".$drive->mount->volume->id.")"; | ||
| 45 | } | ||
| 46 | else { | ||
| 47 | print " ( )"; | ||
| 48 | } | ||
| 49 | } | ||
| 50 | print " SN:".$drive->serialNumber if ($opts{'s'}); | ||
| 51 | print " Cleaned: ".substr(localtime($drive->lastCleaned), 4) if ($opts{'c'}); | ||
| 52 | print ": ".$drive->comment if ($opts{'v'}); | ||
| 53 | |||
| 54 | print "\n"; | ||
| 55 | } | ||
| 56 | } |