diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2020-03-04 06:12:18 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2020-03-04 06:12:18 +0000 |
commit | 9ce221b58ff8e5df3707cdf7d2272600da25a303 (patch) | |
tree | 92a2b4a6d815a95ae0639b14cb2373d5786b6eed /lib | |
parent | 26d529e6faaafa442e2b06093db1714f8f0b75bc (diff) | |
download | mangemanche-9ce221b58ff8e5df3707cdf7d2272600da25a303.tar.gz mangemanche-9ce221b58ff8e5df3707cdf7d2272600da25a303.tar.bz2 |
Add on-line documentation. Whitespace cleanup.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/App/Mangemanche.pm | 164 | ||||
-rw-r--r-- | lib/App/Mangemanche/Command.pm | 21 | ||||
-rw-r--r-- | lib/App/Mangemanche/Command/dbload.pm | 39 | ||||
-rw-r--r-- | lib/App/Mangemanche/Command/ident.pm | 7 | ||||
-rw-r--r-- | lib/App/Mangemanche/Command/inspect.pm | 11 | ||||
-rw-r--r-- | lib/App/Mangemanche/Command/ipadd.pm | 5 | ||||
-rw-r--r-- | lib/App/Mangemanche/Command/ipdel.pm | 4 | ||||
-rw-r--r-- | lib/App/Mangemanche/Command/nagios.pm | 17 | ||||
-rw-r--r-- | lib/Net/Ping903.pm | 25 |
9 files changed, 190 insertions, 103 deletions
diff --git a/lib/App/Mangemanche.pm b/lib/App/Mangemanche.pm index d719ecb..2bcbc44 100644 --- a/lib/App/Mangemanche.pm +++ b/lib/App/Mangemanche.pm | |||
@@ -20,24 +20,28 @@ sub new { | |||
20 | my $config = {}; | 20 | my $config = {}; |
21 | 21 | ||
22 | GetOptions( | 22 | GetOptions( |
23 | 'shorthelp|?' => sub { | 23 | 'shorthelp|?' => sub { |
24 | pod2usage(-input => pod_where({-inc => 1}, $class), | 24 | pod2usage(-input => pod_where({-inc => 1}, $class), |
25 | -verbose => 99, | 25 | -verbose => 99, |
26 | -sections => [qw(NAME SYNOPSIS COMMANDS)], | 26 | -sections => [qw(NAME SYNOPSIS COMMANDS)], |
27 | -exitstatus => 'NOEXIT'); | 27 | -exitstatus => 'NOEXIT'); |
28 | $class->list_commands; | 28 | $class->list_commands; |
29 | exit(EX_OK); | 29 | exit(EX_OK); |
30 | }, | 30 | }, |
31 | 'help' => sub { | 31 | 'help' => sub { |
32 | App::Mangemanche::Command::mandoc($class, basename($0)), | 32 | App::Mangemanche::Command::mandoc($class, basename($0)), |
33 | }, | ||
34 | 'usage' => sub { | ||
35 | pod2usage(-exitstatus => EX_OK, | ||
36 | -input => pod_where({-inc => 1}, $class), | ||
37 | -verbose => 0) | ||
38 | }, | 33 | }, |
39 | 'config|c=s' => \$config_file, | 34 | 'usage' => sub { |
40 | 'url|u=s' => \$url | 35 | pod2usage(-exitstatus => EX_OK, |
36 | -input => pod_where({-inc => 1}, $class), | ||
37 | -verbose => 0) | ||
38 | }, | ||
39 | 'version' => sub { | ||
40 | print "$0 version $VERSION\n"; | ||
41 | exit(EX_OK); | ||
42 | }, | ||
43 | 'config|c=s' => \$config_file, | ||
44 | 'url|u=s' => \$url | ||
41 | ) or exit(EX_USAGE); | 45 | ) or exit(EX_USAGE); |
42 | 46 | ||
43 | if ($config_file) { | 47 | if ($config_file) { |
@@ -64,7 +68,7 @@ sub new { | |||
64 | } | 68 | } |
65 | 69 | ||
66 | my $agent = new Net::Ping903($config->{baseurl}); | 70 | my $agent = new Net::Ping903($config->{baseurl}); |
67 | 71 | ||
68 | my $com = shift @ARGV; | 72 | my $com = shift @ARGV; |
69 | die "no command name\n" unless $com; | 73 | die "no command name\n" unless $com; |
70 | 74 | ||
@@ -75,7 +79,7 @@ sub new { | |||
75 | my $cmd; | 79 | my $cmd; |
76 | eval { | 80 | eval { |
77 | require $modpath; | 81 | require $modpath; |
78 | $cmd = $modname->new($com, $agent); | 82 | $cmd = $modname->new($com, $agent); |
79 | }; | 83 | }; |
80 | if ($@) { | 84 | if ($@) { |
81 | if ($@ =~ /Can't locate $modpath/) { | 85 | if ($@ =~ /Can't locate $modpath/) { |
@@ -114,33 +118,33 @@ sub list_commands { | |||
114 | print "\nAvailable commands are:\n"; | 118 | print "\nAvailable commands are:\n"; |
115 | foreach my $mod (sort | 119 | foreach my $mod (sort |
116 | map { | 120 | map { |
117 | my $name = basename($_); | 121 | my $name = basename($_); |
118 | if (exists($INC{File::Spec->catfile(@classpath,$name)})) { | 122 | if (exists($INC{File::Spec->catfile(@classpath,$name)})) { |
119 | () | 123 | () |
120 | } else { | 124 | } else { |
121 | eval { | 125 | eval { |
122 | require $_; | 126 | require $_; |
123 | }; | 127 | }; |
124 | $name =~ s/\.pm$//; | 128 | $name =~ s/\.pm$//; |
125 | $@ ? () : [$name, $_]; | 129 | $@ ? () : [$name, $_]; |
126 | } | 130 | } |
127 | } | 131 | } |
128 | map { | 132 | map { |
129 | glob File::Spec->catfile($_, @classpath, '*.pm') | 133 | glob File::Spec->catfile($_, @classpath, '*.pm') |
130 | } @INC) { | 134 | } @INC) { |
131 | 135 | ||
132 | my $s; | 136 | my $s; |
133 | open(my $fh, '>', \$s); | 137 | open(my $fh, '>', \$s); |
134 | pod2usage(-input => $mod->[1], | 138 | pod2usage(-input => $mod->[1], |
135 | -output => $fh, | 139 | -output => $fh, |
136 | -verbose => 99, | 140 | -verbose => 99, |
137 | -sections => ['NAME'], | 141 | -sections => ['NAME'], |
138 | -exitstatus => 'NOEXIT'); | 142 | -exitstatus => 'NOEXIT'); |
139 | close $fh; | 143 | close $fh; |
140 | my (undef, $descr) = split("\n", $s||''); | 144 | my (undef, $descr) = split("\n", $s||''); |
141 | unless ($descr) { | 145 | unless ($descr) { |
142 | $descr = ' ' . $mod->[0] | 146 | $descr = ' ' . $mod->[0] |
143 | } | 147 | } |
144 | print "$descr\n"; | 148 | print "$descr\n"; |
145 | } | 149 | } |
146 | } | 150 | } |
@@ -149,25 +153,121 @@ sub list_commands { | |||
149 | 153 | ||
150 | =head1 NAME | 154 | =head1 NAME |
151 | 155 | ||
152 | mangemanche - interface to B<ping903> daemon. | 156 | mangemanche - remote management interface to B<ping903> daemon. |
153 | 157 | ||
154 | =head1 SYNOPSIS | 158 | =head1 SYNOPSIS |
155 | 159 | ||
156 | B<mangemanche> | 160 | B<mangemanche> |
157 | [B<-c> I<FILE>] | 161 | [B<-c> I<FILE>] |
158 | [B<-u> I<FILE>] | 162 | [B<-u> I<FILE>] |
159 | [B<--config=>I<FILE>] | 163 | [B<--config=>I<FILE>] |
160 | [B<--url=>I<FILE>] | 164 | [B<--url=>I<FILE>] |
161 | I<COMMAND> | 165 | I<COMMAND> |
162 | I<ARG>... | 166 | I<ARG>... |
163 | 167 | ||
164 | B<mangemanche> | 168 | B<mangemanche> |
165 | [B<-?>] | 169 | [B<-?>] |
166 | [B<--help>] | 170 | [B<--help>] |
167 | [B<--usage>] | 171 | [B<--usage>] |
168 | 172 | [B<--version>] | |
173 | |||
169 | =head1 DESCRIPTION | 174 | =head1 DESCRIPTION |
170 | 175 | ||
176 | Mangemanche provides remote management facilities for the running B<ping903> | ||
177 | daemon. First non-optional argument specifies the name of the I<command> to | ||
178 | run. Arguments following it supply options and arguments to that command. | ||
179 | |||
180 | Mangemanche reads the IP address and port number of the B<ping903> management | ||
181 | socket from its configuration file, F</etc/ping903.conf>. If the file does | ||
182 | not exist, the default port (B<localhost:8080>) is used. The location of | ||
183 | both can be overridden in the command line. | ||
184 | |||
185 | If the server requests HTTP authorization, the program will look up the | ||
186 | authorization credentials in the B<.ping903.cred> file located in the | ||
187 | home directory. Refer to L<ping903.cred>(5) for a detailed description. | ||
188 | |||
171 | =head1 OPTIONS | 189 | =head1 OPTIONS |
172 | 190 | ||
173 | 191 | =over 4 | |
192 | |||
193 | =item B<-c>, B<--config=>I<FILE> | ||
194 | |||
195 | Specifies alternative configuration file to use instead of | ||
196 | F</etc/ping903.conf>. | ||
197 | |||
198 | =item B<-u>, B<--url=>I<FILE> | ||
199 | |||
200 | Sets the URL of the B<ping903> management socket. | ||
201 | |||
202 | =back | ||
203 | |||
204 | =head2 Informative options | ||
205 | |||
206 | Each of these options causes the program to display a particular piece of | ||
207 | information and exit with the zero status. Any other options and arguments | ||
208 | are ignored. | ||
209 | |||
210 | =over 4 | ||
211 | |||
212 | =item B<-?> | ||
213 | |||
214 | Displays a short option reminder and lists the available commands with | ||
215 | their short descriptions. | ||
216 | |||
217 | =item B<--help> | ||
218 | |||
219 | Displays this manual page. | ||
220 | |||
221 | =item B<--usage> | ||
222 | |||
223 | Displays a terse command line usage summary. | ||
224 | |||
< |