line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HV::Monitor; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
72983
|
use 5.006; |
|
1
|
|
|
|
|
5
|
|
4
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
5
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
28
|
|
6
|
1
|
|
|
1
|
|
1235
|
use Module::List qw(list_modules); |
|
1
|
|
|
|
|
26451
|
|
|
1
|
|
|
|
|
399
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
HV::Monitor - A generalized module for gathering stats for a hypervisor. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Version 0.0.6 |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '0.0.6'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 SYNOPSIS |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
use HV::Monitor; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 METHODS |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head2 new |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Inits the object. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
One option is taken and that is a hash ref. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# init with the cbsd backend |
33
|
|
|
|
|
|
|
my $hm->new({backend=>'CBSD'}); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
The keys are list as below. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
- backend :: The name of the backend to use. |
38
|
|
|
|
|
|
|
Default :: CBSD |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub new { |
43
|
0
|
|
|
0
|
1
|
|
my $module = shift; |
44
|
0
|
|
|
|
|
|
my $config = shift; |
45
|
|
|
|
|
|
|
|
46
|
0
|
0
|
|
|
|
|
if ( !defined( $config->{backend} ) ) { |
47
|
0
|
|
|
|
|
|
$config->{backend} = 'CBSD'; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my $self = { |
51
|
|
|
|
|
|
|
version => 1, |
52
|
|
|
|
|
|
|
backend => $config->{backend}, |
53
|
0
|
|
|
|
|
|
}; |
54
|
0
|
|
|
|
|
|
bless $self; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
return $self; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 load |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
This loads the specified backend. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
eval{ $hm->load; }; |
64
|
|
|
|
|
|
|
if ( $@ ){ |
65
|
|
|
|
|
|
|
print "Failed to load the backend... ".$@; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub load { |
71
|
0
|
|
|
0
|
1
|
|
my $self = $_[0]; |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
my $loaded = 0; |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
my $backend_test; |
76
|
|
|
|
|
|
|
my $usable; |
77
|
|
|
|
|
|
|
my $test_string = ' |
78
|
|
|
|
|
|
|
use HV::Monitor::Backends::' . $self->{backend} . '; |
79
|
0
|
|
|
|
|
|
$backend_test=HV::Monitor::Backends::' . $self->{backend} . '->new; |
80
|
|
|
|
|
|
|
$usable=$backend_test->usable; |
81
|
|
|
|
|
|
|
'; |
82
|
0
|
|
|
|
|
|
eval($test_string); |
83
|
0
|
0
|
|
|
|
|
if ($usable) { |
84
|
0
|
|
|
|
|
|
$self->{backend_mod} = $backend_test; |
85
|
0
|
|
|
|
|
|
$loaded = 1; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
else { |
88
|
0
|
|
|
|
|
|
die( 'Failed to load backend... ' . $@ ); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
return $loaded; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 run |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Runs the poller backend and report the results. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
If nothing is nothing is loaded, load will be called. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
my $status=$hm->run; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub run { |
105
|
0
|
|
|
0
|
1
|
|
my $self = $_[0]; |
106
|
|
|
|
|
|
|
|
107
|
0
|
0
|
|
|
|
|
if ( !defined( $self->{backend_mod} ) ) { |
108
|
|
|
|
|
|
|
return { |
109
|
|
|
|
|
|
|
version => $self->{version}, |
110
|
0
|
|
|
|
|
|
data => {}, |
111
|
|
|
|
|
|
|
error => 1, |
112
|
|
|
|
|
|
|
errorString => 'No module loaded', |
113
|
|
|
|
|
|
|
}; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
my $to_return; |
117
|
0
|
|
|
|
|
|
eval { $to_return = $self->{backend_mod}->run }; |
|
0
|
|
|
|
|
|
|
118
|
0
|
0
|
|
|
|
|
if ($@) { |
119
|
|
|
|
|
|
|
return { |
120
|
|
|
|
|
|
|
version => $self->{version}, |
121
|
0
|
|
|
|
|
|
data => {}, |
122
|
|
|
|
|
|
|
error => 1, |
123
|
|
|
|
|
|
|
errorString => 'Failed to run backend... ' . $@, |
124
|
|
|
|
|
|
|
}; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
return $to_return; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 AUTHOR |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Zane C. Bowers-Hadley, C<< >> |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 BUGS |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
137
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
138
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 SUPPORT |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
perldoc HV::Monitor |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
You can also look for information at: |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=over 4 |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
L |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=item * CPAN Ratings |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
L |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=item * Search CPAN |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
L |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=back |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
This software is Copyright (c) 2022 by Zane C. Bowers-Hadley. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
This is free software, licensed under: |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=cut |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
1; # End of HV::Monitor |