line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HV::Monitor; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
59193
|
use 5.006; |
|
1
|
|
|
|
|
3
|
|
4
|
1
|
|
|
1
|
|
10
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
5
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
6
|
1
|
|
|
1
|
|
421
|
use Module::List qw(list_modules); |
|
1
|
|
|
|
|
20450
|
|
|
1
|
|
|
|
|
281
|
|
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.2 |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '0.0.2'; |
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
|
|
|
|
|
|
|
}else { |
87
|
0
|
|
|
|
|
|
die('Failed to load backend... '.$@); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
return $loaded; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 run |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Runs the poller backend and report the results. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
If nothing is nothing is loaded, load will be called. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
my $status=$hm->run; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub run { |
104
|
0
|
|
|
0
|
1
|
|
my $self = $_[0]; |
105
|
|
|
|
|
|
|
|
106
|
0
|
0
|
|
|
|
|
if (!defined($self->{backend_mod})) { |
107
|
|
|
|
|
|
|
return { |
108
|
|
|
|
|
|
|
version=>$self->{version}, |
109
|
0
|
|
|
|
|
|
data=>{}, |
110
|
|
|
|
|
|
|
error=>1, |
111
|
|
|
|
|
|
|
errorString=>'No module loaded', |
112
|
|
|
|
|
|
|
}; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
my $to_return; |
116
|
0
|
|
|
|
|
|
eval{ $to_return=$self->{backend_mod}->run }; |
|
0
|
|
|
|
|
|
|
117
|
0
|
0
|
|
|
|
|
if ($@) { |
118
|
|
|
|
|
|
|
return { |
119
|
|
|
|
|
|
|
version=>$self->{version}, |
120
|
0
|
|
|
|
|
|
data=>{}, |
121
|
|
|
|
|
|
|
error=>1, |
122
|
|
|
|
|
|
|
errorString=>'Failed to run backend... '.$@, |
123
|
|
|
|
|
|
|
}; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
0
|
|
|
|
|
|
return $to_return; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 AUTHOR |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Zane C. Bowers-Hadley, C<< >> |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 BUGS |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
136
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
137
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 SUPPORT |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
perldoc HV::Monitor |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
You can also look for information at: |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=over 4 |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
L |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=item * CPAN Ratings |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
L |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item * Search CPAN |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
L |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=back |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
This software is Copyright (c) 2022 by Zane C. Bowers-Hadley. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
This is free software, licensed under: |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=cut |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
1; # End of HV::Monitor |