| 1 | package Xymon::Plugin::Server; | ||||||||||||
| 2 | |||||||||||||
| 3 | 7 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 7 | ▶ | use warnings FATAL => 'all'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | |||||||||||||
| 6 | 7 | ▶ | use Carp; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | |||||||||||||
| 8 | =head1 NAME | ||||||||||||
| 9 | |||||||||||||
| 10 | Xymon::Plugin::Server - Xymon Server side plugin helper | ||||||||||||
| 11 | |||||||||||||
| 12 | =head1 VERSION | ||||||||||||
| 13 | |||||||||||||
| 14 | Version 0.03 | ||||||||||||
| 15 | |||||||||||||
| 16 | =cut | ||||||||||||
| 17 | |||||||||||||
| 18 | 7 | our $VERSION = '0.03'; | |||||||||||
| 19 | |||||||||||||
| 20 | |||||||||||||
| 21 | =head1 DESCRIPTION | ||||||||||||
| 22 | |||||||||||||
| 23 | Xymon::Plugin::Server package contains some useful modules to write | ||||||||||||
| 24 | Xymon plugin executed in server side. | ||||||||||||
| 25 | |||||||||||||
| 26 | =over | ||||||||||||
| 27 | |||||||||||||
| 28 | =item Xymon::Plugin::Server::Status | ||||||||||||
| 29 | |||||||||||||
| 30 | Status reporter | ||||||||||||
| 31 | |||||||||||||
| 32 | =item Xymon::Plugin::Server::Devmon | ||||||||||||
| 33 | |||||||||||||
| 34 | Data generator in devmon style | ||||||||||||
| 35 | |||||||||||||
| 36 | =item Xymon::Plugin::Server::Dispatch | ||||||||||||
| 37 | |||||||||||||
| 38 | Dispatcher | ||||||||||||
| 39 | |||||||||||||
| 40 | =back | ||||||||||||
| 41 | |||||||||||||
| 42 | Check example directory to see how to each modules. | ||||||||||||
| 43 | |||||||||||||
| 44 | |||||||||||||
| 45 | =head1 SUBROUTINES/METHODS | ||||||||||||
| 46 | |||||||||||||
| 47 | =head2 home | ||||||||||||
| 48 | |||||||||||||
| 49 | Get Xymon/Hobbit home directory. | ||||||||||||
| 50 | This is a class method. call like this: | ||||||||||||
| 51 | |||||||||||||
| 52 | my $home = Xymon::Plugin::Server->home; | ||||||||||||
| 53 | |||||||||||||
| 54 | =cut | ||||||||||||
| 55 | |||||||||||||
| 56 | 39 | ▶ | sub home { | ||||||||||
|
Subroutine
home: called CC=6 SCAR=29.3
Pod
documented
| |||||||||||||
| 57 | 39 | ▶ | return $ENV{XYMONHOME} if (defined($ENV{XYMONHOME})); # xymn 4.3 | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 58 | 18 | ▶ | return $ENV{BBHOME} if (defined($ENV{BBHOME})); # xymn 4.2 | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 59 | |||||||||||||
| 60 | 0 | ▶ | if (defined($ENV{HOME})) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 61 | 0 | my $xyhome = "$ENV{HOME}/server"; | |||||||||||
| 62 | |||||||||||||
| 63 | 0 | ▶ | return $xyhome if (-f "$xyhome/etc/hosts.cfg"); # xymon 4.3 | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 64 | 0 | ▶ | return $xyhome if (-f "$xyhome/etc/bb-hosts"); # xymon 4.2 | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 65 | } | ||||||||||||
| 66 | |||||||||||||
| 67 | 0 | croak "environment variable BBHOME/XYMONHOME is not set."; | |||||||||||
| 68 | } | ||||||||||||
| 69 | |||||||||||||
| 70 | =head2 version | ||||||||||||
| 71 | |||||||||||||
| 72 | Guess Xymon version and returns resulst as ARRAYREF like [major, minor]. | ||||||||||||
| 73 | |||||||||||||
| 74 | This is a class method. call like this: | ||||||||||||
| 75 | |||||||||||||
| 76 | my $ver = Xymon::Plugin::Server->version; | ||||||||||||
| 77 | |||||||||||||
| 78 | =cut | ||||||||||||
| 79 | |||||||||||||
| 80 | 16 | ▶ | sub version { | ||||||||||
|
Subroutine
version: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||
| 81 | 16 | my $xyhome = __PACKAGE__->home; | |||||||||||
| 82 | |||||||||||||
| 83 | 16 | ▶ | return [4, 3] if (-f "$xyhome/etc/hosts.cfg"); # xymon 4.3 | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 84 | |||||||||||||
| 85 | 8 | return [4, 2]; | |||||||||||
| 86 | } | ||||||||||||
| 87 | |||||||||||||
| 88 | =head2 display_hosts | ||||||||||||
| 89 | |||||||||||||
| 90 | Guess display hosts and returns ARRAY. | ||||||||||||
| 91 | |||||||||||||
| 92 | This is a class method. call like this: | ||||||||||||
| 93 | |||||||||||||
| 94 | my @hosts = Xymon::Plugin::Server->display_hosts; | ||||||||||||
| 95 | |||||||||||||
| 96 | =cut | ||||||||||||
| 97 | |||||||||||||
| 98 | 23 | ▶ | sub display_hosts { | ||||||||||
|
Subroutine
display_hosts: called CC=4 SCAR=21.7
Pod
documented
| |||||||||||||
| 99 | 23 | ▶ | my $display = $ENV{'BBDISP'} || '127.0.0.1'; | ||||||||||
|
Condition50%1/2
$ENV{'BBDISP'} || '127.0.0.1'
MC/DC0%0/1
$ENV{'BBDISP'} || '127.0.0.1'
$ENV{'BBDISP'}
Truth table50%1/2
A
A= $ENV{'BBDISP'}
| |||||||||||||
| 100 | |||||||||||||
| 101 | 23 | ▶ | return $display if ($display ne '0.0.0.0'); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 102 | |||||||||||||
| 103 | 0 | my $multi_display = $ENV{'BBDISPLAYS'}; | |||||||||||
| 104 | 0 | ▶ | if (defined($multi_display)) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 105 | 0 | return split(/\s+/, $multi_display); | |||||||||||
| 106 | } | ||||||||||||
| 107 | |||||||||||||
| 108 | 0 | return $display; | |||||||||||
| 109 | } | ||||||||||||
| 110 | |||||||||||||
| 111 | =head1 AUTHOR | ||||||||||||
| 112 | |||||||||||||
| 113 | Toshimitsu FUJIWARA, C<< <tttfjw at gmail.com> >> | ||||||||||||
| 114 | |||||||||||||
| 115 | =head1 BUGS | ||||||||||||
| 116 | |||||||||||||
| 117 | Please report any bugs or feature requests to C<bug-xymon-plugin-server at rt.cpan.org>, or through | ||||||||||||
| 118 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Xymon-Plugin-Server>. I will be notified, and then you'll | ||||||||||||
| 119 | automatically be notified of progress on your bug as I make changes. | ||||||||||||
| 120 | |||||||||||||
| 121 | |||||||||||||
| 122 | |||||||||||||
| 123 | |||||||||||||
| 124 | =head1 SUPPORT | ||||||||||||
| 125 | |||||||||||||
| 126 | You can find documentation for this module with the perldoc command. | ||||||||||||
| 127 | |||||||||||||
| 128 | perldoc Xymon::Plugin::Server | ||||||||||||
| 129 | |||||||||||||
| 130 | |||||||||||||
| 131 | You can also look for information at: | ||||||||||||
| 132 | |||||||||||||
| 133 | =over 4 | ||||||||||||
| 134 | |||||||||||||
| 135 | =item * About Xymon | ||||||||||||
| 136 | |||||||||||||
| 137 | L<http://xymon.sourceforge.net/> | ||||||||||||
| 138 | |||||||||||||
| 139 | =item * About RRDTool | ||||||||||||
| 140 | |||||||||||||
| 141 | L<http://oss.oetiker.ch/rrdtool/> | ||||||||||||
| 142 | |||||||||||||
| 143 | =item * RT: CPAN's request tracker (report bugs here) | ||||||||||||
| 144 | |||||||||||||
| 145 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Xymon-Plugin-Server> | ||||||||||||
| 146 | |||||||||||||
| 147 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||
| 148 | |||||||||||||
| 149 | L<http://annocpan.org/dist/Xymon-Plugin-Server> | ||||||||||||
| 150 | |||||||||||||
| 151 | =item * CPAN Ratings | ||||||||||||
| 152 | |||||||||||||
| 153 | L<http://cpanratings.perl.org/d/Xymon-Plugin-Server> | ||||||||||||
| 154 | |||||||||||||
| 155 | =item * Search CPAN | ||||||||||||
| 156 | |||||||||||||
| 157 | L<http://search.cpan.org/dist/Xymon-Plugin-Server/> | ||||||||||||
| 158 | |||||||||||||
| 159 | =back | ||||||||||||
| 160 | |||||||||||||
| 161 | |||||||||||||
| 162 | =head1 ACKNOWLEDGEMENTS | ||||||||||||
| 163 | |||||||||||||
| 164 | |||||||||||||
| 165 | =head1 LICENSE AND COPYRIGHT | ||||||||||||
| 166 | |||||||||||||
| 167 | Copyright 2013 Toshimitsu FUJIWARA. | ||||||||||||
| 168 | |||||||||||||
| 169 | This program is free software; you can redistribute it and/or modify it | ||||||||||||
| 170 | under the terms of the the Artistic License (2.0). You may obtain a | ||||||||||||
| 171 | copy of the full license at: | ||||||||||||
| 172 | |||||||||||||
| 173 | L<http://www.perlfoundation.org/artistic_license_2_0> | ||||||||||||
| 174 | |||||||||||||
| 175 | Any use, modification, and distribution of the Standard or Modified | ||||||||||||
| 176 | Versions is governed by this Artistic License. By using, modifying or | ||||||||||||
| 177 | distributing the Package, you accept this license. Do not use, modify, | ||||||||||||
| 178 | or distribute the Package, if you do not accept this license. | ||||||||||||
| 179 | |||||||||||||
| 180 | If your Modified Version has been derived from a Modified Version made | ||||||||||||
| 181 | by someone other than you, you are nevertheless required to ensure that | ||||||||||||
| 182 | your Modified Version complies with the requirements of this license. | ||||||||||||
| 183 | |||||||||||||
| 184 | This license does not grant you the right to use any trademark, service | ||||||||||||
| 185 | mark, tradename, or logo of the Copyright Holder. | ||||||||||||
| 186 | |||||||||||||
| 187 | This license includes the non-exclusive, worldwide, free-of-charge | ||||||||||||
| 188 | patent license to make, have made, use, offer to sell, sell, import and | ||||||||||||
| 189 | otherwise transfer the Package with respect to any patent claims | ||||||||||||
| 190 | licensable by the Copyright Holder that are necessarily infringed by the | ||||||||||||
| 191 | Package. If you institute patent litigation (including a cross-claim or | ||||||||||||
| 192 | counterclaim) against any party alleging that the Package constitutes | ||||||||||||
| 193 | direct or contributory patent infringement, then this Artistic License | ||||||||||||
| 194 | to you shall terminate on the date that such litigation is filed. | ||||||||||||
| 195 | |||||||||||||
| 196 | Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER | ||||||||||||
| 197 | AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. | ||||||||||||
| 198 | THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||||||||||||
| 199 | PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY | ||||||||||||
| 200 | YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR | ||||||||||||
| 201 | CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR | ||||||||||||
| 202 | CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, | ||||||||||||
| 203 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||||||||
| 204 | |||||||||||||
| 205 | |||||||||||||
| 206 | =cut | ||||||||||||
| 207 | |||||||||||||
| 208 | 7 | 1; # End of Xymon::Plugin::Server | |||||||||||