line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Backup::Omni::Session::Monitor; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
1765
|
use Params::Validate ':all'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
241
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Backup::Omni::Class |
8
|
1
|
|
|
|
|
15
|
version => $VERSION, |
9
|
|
|
|
|
|
|
base => 'Backup::Omni::Base', |
10
|
|
|
|
|
|
|
utils => 'omni2dt trim', |
11
|
|
|
|
|
|
|
constants => 'OMNISTAT', |
12
|
|
|
|
|
|
|
constant => { |
13
|
|
|
|
|
|
|
RUNNING => '%s -session %s -status_only 2> /dev/null', |
14
|
|
|
|
|
|
|
COMMAND => '%s -session %s -detail 2> /dev/null', |
15
|
|
|
|
|
|
|
}, |
16
|
|
|
|
|
|
|
vars => { |
17
|
|
|
|
|
|
|
PARAMS => { |
18
|
|
|
|
|
|
|
-session => 1, |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
} |
21
|
1
|
|
|
1
|
|
6
|
; |
|
1
|
|
|
|
|
2
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Params::Validate::validation_options( |
24
|
|
|
|
|
|
|
on_fail => sub { |
25
|
|
|
|
|
|
|
my $params = shift; |
26
|
|
|
|
|
|
|
my $class = __PACKAGE__; |
27
|
|
|
|
|
|
|
Backup::Omni::Base::validation_exception($params, $class); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
32
|
|
|
|
|
|
|
# Public Methods |
33
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub running { |
36
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my $stat = 0; |
39
|
0
|
|
|
|
|
|
my $command = sprintf(RUNNING, OMNISTAT, $self->session); |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
my @result = `$command`; |
42
|
0
|
|
|
|
|
|
my $rc = $?; |
43
|
|
|
|
|
|
|
|
44
|
0
|
0
|
0
|
|
|
|
if ((grep(/SessionID/, @result)) && ($rc == 0)) { |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
$stat = 1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return $stat; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub object { |
55
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
my $started = 0; |
58
|
0
|
|
|
|
|
|
my $obj = undef; |
59
|
0
|
|
|
|
|
|
my $command = sprintf(COMMAND, OMNISTAT, $self->session); |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
my @result = `$command`; |
62
|
0
|
|
|
|
|
|
my $rc = $?; |
63
|
|
|
|
|
|
|
|
64
|
0
|
0
|
0
|
|
|
|
if ((grep(/Object name/, @result)) && ($rc == 0)) { |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
$obj = Backup::Omni::Session::Monitor::Object->new(); |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
foreach my $line (@result) { |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
chomp($line); |
71
|
0
|
0
|
|
|
|
|
next if ($line eq ''); |
72
|
|
|
|
|
|
|
|
73
|
0
|
0
|
|
|
|
|
if ($line =~ /Object name/) { |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
$started = 1; |
76
|
0
|
|
|
|
|
|
$self->_parse_line($obj, $line); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
} else { |
79
|
|
|
|
|
|
|
|
80
|
0
|
0
|
|
|
|
|
if ($started) { |
81
|
|
|
|
|
|
|
|
82
|
0
|
0
|
|
|
|
|
if ($line =~ /Device name/) { |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
$started = 0; |
85
|
0
|
|
|
|
|
|
last; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
$self->_parse_line($obj, $line); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
return $obj; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub device { |
104
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
my $started = 0; |
107
|
0
|
|
|
|
|
|
my $obj = undef; |
108
|
0
|
|
|
|
|
|
my $command = sprintf(COMMAND, OMNISTAT, $self->session); |
109
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
my @result = `$command`; |
111
|
0
|
|
|
|
|
|
my $rc = $?; |
112
|
|
|
|
|
|
|
|
113
|
0
|
0
|
0
|
|
|
|
if ((grep(/Object name/, @result)) && ($rc == 0)) { |
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
$obj = Backup::Omni::Session::Monitor::Device->new(); |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
foreach my $line (@result) { |
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
chomp($line); |
120
|
0
|
0
|
|
|
|
|
next if ($line eq ''); |
121
|
|
|
|
|
|
|
|
122
|
0
|
0
|
|
|
|
|
if ($line =~ /Device name/) { |
123
|
|
|
|
|
|
|
|
124
|
0
|
|
|
|
|
|
$started = 1; |
125
|
0
|
|
|
|
|
|
$self->_parse_line($obj, $line); |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
} else { |
128
|
|
|
|
|
|
|
|
129
|
0
|
0
|
|
|
|
|
if ($started) { |
130
|
|
|
|
|
|
|
|
131
|
0
|
0
|
|
|
|
|
if ($line =~ /Object name/) { |
132
|
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
|
$started = 0; |
134
|
0
|
|
|
|
|
|
last; |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
0
|
|
|
|
|
|
$self->_parse_line($obj, $line); |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
0
|
|
|
|
|
|
return $obj; |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
153
|
|
|
|
|
|
|
# Private Methods |
154
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub _parse_line { |
157
|
0
|
|
|
0
|
|
|
my $self = shift; |
158
|
0
|
|
|
|
|
|
my $obj = shift; |
159
|
0
|
|
|
|
|
|
my $line = shift; |
160
|
|
|
|
|
|
|
|
161
|
0
|
|
|
|
|
|
$line =~ m/^(.*): (.*)/; |
162
|
|
|
|
|
|
|
|
163
|
0
|
|
|
|
|
|
my $key = $1; |
164
|
0
|
|
|
|
|
|
my $value = $2; |
165
|
|
|
|
|
|
|
|
166
|
0
|
|
|
|
|
|
$key = trim($key); |
167
|
0
|
|
|
|
|
|
$key =~ s/ /_/g; |
168
|
0
|
|
|
|
|
|
$key = lc($key); |
169
|
|
|
|
|
|
|
|
170
|
0
|
|
|
|
|
|
$value = trim($value); |
171
|
0
|
0
|
|
|
|
|
$value = omni2dt($value) if ($value =~ /\w\w\w \d\d \w\w\w \d\d\d\d/); |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
# order is important here. Don't change |
174
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
|
$obj->class->accessors($key); # may cause redefination errors |
176
|
0
|
|
|
|
|
|
$obj->{$key} = $value; |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
# the following are stubs, they are filled out above in _parse_line(). |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
package Backup::Omni::Session::Monitor::Device; |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
use Backup::Omni::Class |
185
|
1
|
|
|
|
|
28
|
version => '0.01', |
186
|
|
|
|
|
|
|
base => 'Backup::Omni::Base', |
187
|
1
|
|
|
1
|
|
1474
|
; |
|
1
|
|
|
|
|
2
|
|
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
package Backup::Omni::Session::Monitor::Object; |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
use Backup::Omni::Class |
192
|
1
|
|
|
|
|
3
|
version => '0.01', |
193
|
|
|
|
|
|
|
base => 'Backup::Omni::Base', |
194
|
1
|
|
|
1
|
|
273
|
; |
|
1
|
|
|
|
|
2
|
|
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
1; |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
__END__ |