line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Unicheck; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
33991
|
use 5.10.1; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
52
|
|
4
|
1
|
|
|
1
|
|
15
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
45
|
|
5
|
1
|
|
|
1
|
|
6
|
use warnings FATAL => 'all'; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
76
|
|
6
|
1
|
|
|
1
|
|
636
|
use Module::Pluggable sub_name => '_plugins', require => 1, search_path => ['App::Unicheck::Modules']; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Moo; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
App::Unicheck - Mini data collection framework! |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Version 0.04 |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
App::Unicheck is a mini framework to collect data. |
24
|
|
|
|
|
|
|
The main purpose was to provide a pluggable, easy to use systems data source with consistent interface that is independent from specific systems monitoring solutions but can still be used by them. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
On object construction all modules inside the App::Unicheck::Modules namespace are loaded and new() is called on them. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
use App::Unicheck; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# create object and load modules |
31
|
|
|
|
|
|
|
my $unicheck = App::Unicheck->new; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head2 modules |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Hash reference containing all loaded modules with module names as keys and module instances as values. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# print out loaded modules |
42
|
|
|
|
|
|
|
say for keys $unicheck->modules; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
has modules => ( |
47
|
|
|
|
|
|
|
is => 'rw' |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 METHODS |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub BUILD { |
56
|
|
|
|
|
|
|
my $self = shift; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $modules = {}; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
for my $check ($self->_plugins){ |
61
|
|
|
|
|
|
|
(my $name = $check) =~ s/App::Unicheck::Modules::(.*)/$1/; |
62
|
|
|
|
|
|
|
$modules->{$name} = $check->new; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
$self->modules($modules); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub _loaded_modules { |
69
|
|
|
|
|
|
|
my $self = shift; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
wantarray ? keys %{$self->modules} : [keys %{$self->modules}]; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 run |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Runs a check module's run() method with parameters. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
$unicheck->run($module, @params); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub run { |
83
|
|
|
|
|
|
|
my ($self, $module, @params) = @_; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
$self->modules->{$module}->run(@params) if defined $module && defined $self->modules->{$module}; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 info |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Show information on loaded modules. Calls the help() method of the modules and formats the output. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# show info of all modules |
93
|
|
|
|
|
|
|
say $unicheck->info; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# show info of specific module |
96
|
|
|
|
|
|
|
say $unicheck->info($module); |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub info { |
101
|
|
|
|
|
|
|
my ($self, $module) = @_; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# if called with out specific module get info of all modules |
104
|
|
|
|
|
|
|
my @modules = $self->_loaded_modules; |
105
|
|
|
|
|
|
|
if (defined $module && $module) { |
106
|
|
|
|
|
|
|
@modules = ($module); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
my $info = ''; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
for my $module (@modules){ |
111
|
|
|
|
|
|
|
$info .= "$module (" . $self->modules->{$module}->help->{description} . "):\n"; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
# TODO clean up ugly mess |
114
|
|
|
|
|
|
|
$info .= (' ' x 2) . "Available actions:\n"; |
115
|
|
|
|
|
|
|
my %actions = %{$self->modules->{$module}->help->{actions}}; |
116
|
|
|
|
|
|
|
while (my ($action, $data) = each %actions){ |
117
|
|
|
|
|
|
|
$info .= (' ' x 4) . "$action ($data->{description}):\n"; |
118
|
|
|
|
|
|
|
$info .= (' ' x 6) . "Formats:\n"; |
119
|
|
|
|
|
|
|
my %formats = %{$data->{formats}}; |
120
|
|
|
|
|
|
|
while (my ($k, $v) = each %formats){ |
121
|
|
|
|
|
|
|
$info .= (' ' x 8) . "$k: $v\n"; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
$info .= (' ' x 6) . "Parameters:\n"; |
124
|
|
|
|
|
|
|
my %params = %{$data->{params}}; |
125
|
|
|
|
|
|
|
while (my ($k, $v) = each %params){ |
126
|
|
|
|
|
|
|
$info .= (' ' x 8) . "$k: $v\n"; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
$info; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 AUTHOR |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Matthias Krull, C<< <> >> |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 BUGS |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
141
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
142
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Alternatively report bugs or feature requests at L. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 SUPPORT |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
perldoc App::Unicheck |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
You can also look for information at: |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=over 4 |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
L |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
L |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=item * CPAN Ratings |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
L |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=item * Search CPAN |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
L |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=item * Github |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
L |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=back |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Copyright 2013 Matthias Krull. |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
189
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
190
|
|
|
|
|
|
|
copy of the full license at: |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
L |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified |
195
|
|
|
|
|
|
|
Versions is governed by this Artistic License. By using, modifying or |
196
|
|
|
|
|
|
|
distributing the Package, you accept this license. Do not use, modify, |
197
|
|
|
|
|
|
|
or distribute the Package, if you do not accept this license. |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
200
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
201
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
204
|
|
|
|
|
|
|
mark, tradename, or logo of the Copyright Holder. |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
207
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
208
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
209
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
210
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
211
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
212
|
|
|
|
|
|
|
direct or contributory patent infringement, then this Artistic License |
213
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
216
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
217
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
218
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
219
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
220
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
221
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
222
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=cut |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
1; # End of App::Unicheck |