File: status

package info (click to toggle)
libafs-perl 2.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 2,244 kB
  • ctags: 268
  • sloc: perl: 5,159; ansic: 135; sh: 36; makefile: 7
file content (83 lines) | stat: -rwxr-xr-x 2,676 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/local/bin/perl -w

use blib;

use strict;
use AFS::BOS;
use POSIX qw(strftime);

my ($server, $cellname, $instance, $long, $bos);
my ($nargs, $status, $laststart, $lastexit, @instance);

die "Usage: $0 server [instances [long [cell]]]\n" if $#ARGV < 0;

$nargs    = $#ARGV;
$server   = shift;
$instance = shift if $nargs > 0;
$long     = shift if $nargs > 1;
$cellname = shift if $nargs > 2;

$long     = 0 if $nargs == 1;
#warn ">$server< >$instance< >$long< >$cellname< \n";

if (defined $instance and $instance =~ / /) { @instance = split / /, $instance; }

if ($cellname) { $bos = AFS::BOS->new($server, 0, 0, $cellname); }
else           { $bos = AFS::BOS->new($server); }
print "Error Code: $AFS::CODE\n" if ($AFS::CODE);

if (@instance)        { $status = $bos->status($long, \@instance); }
elsif ($instance)     { $status = $bos->status($long, $instance); }
elsif (defined $long) { $status = $bos->status($long); }
else                  { $status = $bos->status(); }
print "Error Code: $AFS::CODE\n" if ($AFS::CODE);

$bos->DESTROY;

if ($status) {
    foreach my $inst (keys %$status) {

        if (defined %{$status->{$inst}}) { print "Instance $inst, "; }
        else { die "failed to get instance info for \'$inst\' \n"; }

        print "currently running normally.\n" if $status->{$inst}->{status};
        print "\tAuxiliary status is: $status->{$inst}->{aux_status}\n" if $status->{$inst}->{aux_status};
        chomp($laststart = strftime('%d %b %R %Y', localtime($status->{$inst}->{procStartTime})));
        chomp($lastexit  = strftime('%d %b %R %Y', localtime($status->{$inst}->{lastAnyExit})));
        print "\tProcess last started at $laststart\n";
        print "\tLast exit at $lastexit\n";

        foreach my $val (keys %{$status->{$inst}}) {
            if ($val eq 'status') { next; }
            elsif ($val eq "aux_status") { next; }
            elsif ($val eq "command") {
                foreach (@{$status->{$inst}->{$val}}) {
                    print "\tCommand is $_\n";
                }
            }
        }
    }
}


my $Debugging = 0;

if ($Debugging) {
    print "\n\n\nDEBUG\n\n";
    if ($status) {
        foreach my $inst (keys %$status) {
            print "Instance: $inst\n";
            foreach my $val (keys %{$status->{$inst}}) {
                if ($val eq "command") {
                    print "\tKey: $val\n";
                    foreach (@{$status->{$inst}->{$val}}) {
                        print "\t\tValue: $_\n";
                    }
                }
                else {
                    print "\tKey: $val, Value: $status->{$inst}->{$val}\n";
                }
            }
        }
    }
}