diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2020-03-03 16:21:11 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2020-03-03 16:21:11 +0000 |
commit | 26d529e6faaafa442e2b06093db1714f8f0b75bc (patch) | |
tree | b59b58dad7f815386b05d414cdd7e70ffd00e056 | |
parent | bfaee2787b9e955d0f7231cbc1fa045d6d892d60 (diff) | |
download | mangemanche-26d529e6faaafa442e2b06093db1714f8f0b75bc.tar.gz mangemanche-26d529e6faaafa442e2b06093db1714f8f0b75bc.tar.bz2 |
Rename App/Ping903 to App::Mangemanche
-rw-r--r-- | lib/App/Mangemanche.pm (renamed from lib/App/Ping903.pm) | 63 | ||||
-rw-r--r-- | lib/App/Mangemanche/Command.pm (renamed from lib/App/Ping903/Command.pm) | 2 | ||||
-rw-r--r-- | lib/App/Mangemanche/Command/dbload.pm (renamed from lib/App/Ping903/Command/dbload.pm) | 6 | ||||
-rw-r--r-- | lib/App/Mangemanche/Command/ident.pm (renamed from lib/App/Ping903/Command/ident.pm) | 6 | ||||
-rw-r--r-- | lib/App/Mangemanche/Command/inspect.pm (renamed from lib/App/Ping903/Command/inspect.pm) | 6 | ||||
-rw-r--r-- | lib/App/Mangemanche/Command/ipadd.pm (renamed from lib/App/Ping903/Command/ipadd.pm) | 6 | ||||
-rw-r--r-- | lib/App/Mangemanche/Command/ipdel.pm (renamed from lib/App/Ping903/Command/ipdel.pm) | 6 | ||||
-rw-r--r-- | lib/App/Mangemanche/Command/nagios.pm (renamed from lib/App/Ping903/Command/nagios.pm) | 51 | ||||
-rwxr-xr-x | mangemanche | 4 |
9 files changed, 125 insertions, 25 deletions
diff --git a/lib/App/Ping903.pm b/lib/App/Mangemanche.pm index 2a39391..d719ecb 100644 --- a/lib/App/Ping903.pm +++ b/lib/App/Mangemanche.pm @@ -1,4 +1,4 @@ -package App::Ping903; +package App::Mangemanche; use strict; use warnings; use Getopt::Long qw(:config gnu_getopt no_ignore_case require_order); @@ -6,7 +6,7 @@ use Pod::Man; use Pod::Usage; use Pod::Find qw(pod_where); use Net::Ping903; -use App::Ping903::Command ':exit_codes'; +use App::Mangemanche::Command ':exit_codes'; use File::Basename; our $VERSION = '0.4.90'; @@ -24,10 +24,12 @@ sub new { pod2usage(-input => pod_where({-inc => 1}, $class), -verbose => 99, -sections => [qw(NAME SYNOPSIS COMMANDS)], - -exitstatus => EX_OK) + -exitstatus => 'NOEXIT'); + $class->list_commands; + exit(EX_OK); }, 'help' => sub { - App::Ping903::Command::mandoc($class, basename($0)), + App::Mangemanche::Command::mandoc($class, basename($0)), }, 'usage' => sub { pod2usage(-exitstatus => EX_OK, @@ -105,12 +107,65 @@ sub readconfig { return $config; } +sub list_commands { + my $class = shift; + my @classpath = (split(/::/, $class), 'Command'); + + print "\nAvailable commands are:\n"; + foreach my $mod (sort + map { + my $name = basename($_); + if (exists($INC{File::Spec->catfile(@classpath,$name)})) { + () + } else { + eval { + require $_; + }; + $name =~ s/\.pm$//; + $@ ? () : [$name, $_]; + } + } + map { + glob File::Spec->catfile($_, @classpath, '*.pm') + } @INC) { + + my $s; + open(my $fh, '>', \$s); + pod2usage(-input => $mod->[1], + -output => $fh, + -verbose => 99, + -sections => ['NAME'], + -exitstatus => 'NOEXIT'); + close $fh; + my (undef, $descr) = split("\n", $s||''); + unless ($descr) { + $descr = ' ' . $mod->[0] + } + print "$descr\n"; + } +} + 1; =head1 NAME +mangemanche - interface to B<ping903> daemon. + =head1 SYNOPSIS +B<mangemanche> +[B<-c> I<FILE>] +[B<-u> I<FILE>] +[B<--config=>I<FILE>] +[B<--url=>I<FILE>] +I<COMMAND> +I<ARG>... + +B<mangemanche> +[B<-?>] +[B<--help>] +[B<--usage>] + =head1 DESCRIPTION =head1 OPTIONS diff --git a/lib/App/Ping903/Command.pm b/lib/App/Mangemanche/Command.pm index bd1a85f..9857652 100644 --- a/lib/App/Ping903/Command.pm +++ b/lib/App/Mangemanche/Command.pm @@ -1,4 +1,4 @@ -package App::Ping903::Command; +package App::Mangemanche::Command; use strict; use warnings; use Getopt::Long; diff --git a/lib/App/Ping903/Command/dbload.pm b/lib/App/Mangemanche/Command/dbload.pm index 20c8ad1..c7ddf38 100644 --- a/lib/App/Ping903/Command/dbload.pm +++ b/lib/App/Mangemanche/Command/dbload.pm @@ -1,8 +1,8 @@ -package App::Ping903::Command::dbload; +package App::Mangemanche::Command::dbload; use strict; use warnings; -use parent 'App::Ping903::Command'; -use App::Ping903::Command ':exit_codes'; +use parent 'App::Mangemanche::Command'; +use App::Mangemanche::Command ':exit_codes'; use JSON; use DBI; use File::Spec; diff --git a/lib/App/Ping903/Command/ident.pm b/lib/App/Mangemanche/Command/ident.pm index 67cebd9..a871b95 100644 --- a/lib/App/Ping903/Command/ident.pm +++ b/lib/App/Mangemanche/Command/ident.pm @@ -1,8 +1,8 @@ -package App::Ping903::Command::ident; +package App::Mangemanche::Command::ident; use strict; use warnings; -use parent 'App::Ping903::Command'; -use App::Ping903::Command ':exit_codes'; +use parent 'App::Mangemanche::Command'; +use App::Mangemanche::Command ':exit_codes'; sub run { my $self = shift; diff --git a/lib/App/Ping903/Command/inspect.pm b/lib/App/Mangemanche/Command/inspect.pm index 6c4a11b..81f1049 100644 --- a/lib/App/Ping903/Command/inspect.pm +++ b/lib/App/Mangemanche/Command/inspect.pm @@ -1,8 +1,8 @@ -package App::Ping903::Command::inspect; +package App::Mangemanche::Command::inspect; use strict; use warnings; -use parent 'App::Ping903::Command'; -use App::Ping903::Command ':exit_codes'; +use parent 'App::Mangemanche::Command'; +use App::Mangemanche::Command ':exit_codes'; sub run { my $self = shift; diff --git a/lib/App/Ping903/Command/ipadd.pm b/lib/App/Mangemanche/Command/ipadd.pm index 443c052..53c48b6 100644 --- a/lib/App/Ping903/Command/ipadd.pm +++ b/lib/App/Mangemanche/Command/ipadd.pm @@ -1,8 +1,8 @@ -package App::Ping903::Command::ipadd; +package App::Mangemanche::Command::ipadd; use strict; use warnings; -use parent 'App::Ping903::Command'; -use App::Ping903::Command ':exit_codes'; +use parent 'App::Mangemanche::Command'; +use App::Mangemanche::Command ':exit_codes'; sub run { my $self = shift; diff --git a/lib/App/Ping903/Command/ipdel.pm b/lib/App/Mangemanche/Command/ipdel.pm index 45ca0d7..ef4005b 100644 --- a/lib/App/Ping903/Command/ipdel.pm +++ b/lib/App/Mangemanche/Command/ipdel.pm @@ -1,8 +1,8 @@ -package App::Ping903::Command::ipdel; +package App::Mangemanche::Command::ipdel; use strict; use warnings; -use parent 'App::Ping903::Command'; -use App::Ping903::Command ':exit_codes'; +use parent 'App::Mangemanche::Command'; +use App::Mangemanche::Command ':exit_codes'; sub run { my $self = shift; diff --git a/lib/App/Ping903/Command/nagios.pm b/lib/App/Mangemanche/Command/nagios.pm index b6c8204..7e42d01 100644 --- a/lib/App/Ping903/Command/nagios.pm +++ b/lib/App/Mangemanche/Command/nagios.pm @@ -1,8 +1,8 @@ -package App::Ping903::Command::nagios; +package App::Mangemanche::Command::nagios; use strict; use warnings; -use parent 'App::Ping903::Command'; -use App::Ping903::Command ':exit_codes'; +use parent 'App::Mangemanche::Command'; +use App::Mangemanche::Command ':exit_codes'; use File::Spec; use File::Basename; use Nagios::Config; @@ -59,4 +59,49 @@ sub check_command { } 1; +=head1 NAME +nagios - extract monitored IP addresses from the Nagios configuration + +=head1 SYNOPSIS + +B<nagios> +[B<-c> I<FILE>] +[B<-p> I<PROG>] +[B<--config=>I<FILE>] +[B<--progname=>I<PROG>] + +=head1 DESCRIPTION + +Scans Nagios configuration for services that use B<ping903q> and extracts +IP addresses of associated hosts. At the end of the run, the extracted +addresses are posted to the mutable list of IP addresses monitored by +the running B<ping903> server. + +Default nagios configuration file is F</etc/nagios/nagios.conf>. + +=head1 OPTIONS + +=over 4 + +=item B<-c>, B<--config=>I<FILE> + +Read Nagios configuration from I<FILE>. + +=item B<-p>, B<--progname=>I<PROG> + +Look for I<PROG> in addition to B<ping903q>. + +=back + +=head1 SEE ALSO + +L<ping903>, +L<mangemache>, +L<ipadd>, +L<ipdel>. + +=cut + + + diff --git a/mangemanche b/mangemanche index 3c6ee8b..db3f4a7 100755 --- a/mangemanche +++ b/mangemanche @@ -4,8 +4,8 @@ eval 'exec perl -x -S $0 ${1+"$@"}' if 0; use strict; use warnings; -use App::Ping903; -App::Ping903->new->run; +use App::Mangemanche; +App::Mangemanche->new->run; |