App-Icli
view release on metacpan or search on metacpan
config_data => {
object_file => '/var/cache/icinga/objects.cache',
status_file => '/var/lib/icinga/status.dat',
command_file => '/var/lib/icinga/rw/icinga.cmd',
},
module_name => 'App::Icli',
license => 'unrestricted',
requires => {
'perl' => '5.10.0',
'Carp' => 0,
'DateTime' => 0,
'DateTime::Format::Strptime' => 0,
'DateTime::TimeZone' => 0,
'Getopt::Long' => 0,
'List::MoreUtils' => 0,
'POSIX' => 0,
'Term::ANSIColor' => 0,
'Term::Size' => 0,
},
script_files => 'bin/',
sign => 1,
test_types => {
author => '.at',
App::Icli 0.48 - Fri Jun 13 2014
* New dependencies: DateTime, DateTime::Format::Strptime, DateTime::TimeZone
* NOT BACKWARDS COMPATIBLE: Add -a/--action option to invoke generic
actions on selected services. This replaces -a/--acknowledge with
-aa/ -a acknowledge, -r/--recheck with -ar / -a recheck and
-u/--force-recheck wiht -aR / -a force_recheck
* add -ad / -a downtime option to schedule host/service downtimes
* Also show service downtimes when using -ld, improve its output
* Show service comments when using -vvv
* Rename package to App::Icli to avoid CPAN namespace conflicts
icli 0.47 - Thu May 29 2014
}
},
"configure" : {
"requires" : {
"Module::Build" : "0.4"
}
},
"runtime" : {
"requires" : {
"Carp" : "0",
"DateTime" : "0",
"DateTime::Format::Strptime" : "0",
"DateTime::TimeZone" : "0",
"Getopt::Long" : "0",
"List::MoreUtils" : "0",
"POSIX" : "0",
"Term::ANSIColor" : "0",
"Term::Size" : "0",
"perl" : "v5.10.0"
}
}
},
"provides" : {
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
name: App-Icli
provides:
App::Icli:
file: lib/App/Icli.pm
version: 0.48
requires:
Carp: 0
DateTime: 0
DateTime::Format::Strptime: 0
DateTime::TimeZone: 0
Getopt::Long: 0
List::MoreUtils: 0
POSIX: 0
Term::ANSIColor: 0
Term::Size: 0
perl: v5.10.0
version: 0.48
icli - Icinga Command Line Interface
Requires:
* A local icinga daemon + access to some of its files
* perl v5.10 or newer with the following modules:
* DateTime
* DateTime::Format::Strptime
* DateTime::TimeZone
* List::MoreUtils
* Term::Size
Installation:
> perl Build.PL
> ./Build
> sudo ./Build install
You can then run 'man icli' for more information.
## License: WTFPL <http://sam.zoy.org/wtfpl>
## 0. You just DO WHAT THE FUCK YOU WANT TO.
use strict;
use warnings;
use 5.010;
no if $] >= 5.018, warnings => 'experimental::smartmatch';
use App::Icli::ConfigData;
use Carp qw(croak);
use DateTime;
use DateTime::Format::Strptime;
use DateTime::TimeZone;
use Getopt::Long qw/:config bundling/;
use List::MoreUtils qw(any firstval);
use POSIX qw(strftime);
use Term::ANSIColor;
use Term::Size;
our $VERSION = '0.48';
my ( $cache, $config, $data, $extra );
my $config_file = App::Icli::ConfigData->config('object_file');
or die( "Failed to open icinga command file ($rw_file): $!\n"
. "Set --rw-file to change it\n" );
printf $cmd_fh ( '[%d] %s', time(), $str, );
close($cmd_fh)
or warn("Failed to close $rw_file: $!\n");
}
sub action_on_host {
my ($host) = @_;
my $tz = DateTime::TimeZone->new( name => 'local' );
given ($action) {
when ('downtime') {
my ( $start, $end, $duration, $comment, @opts ) = @action_args;
my $strp = DateTime::Format::Strptime->new(
pattern => '%Y-%m-%dT%H:%M:%S',
time_zone => $tz->name,
);
my $dt_start = $strp->parse_datetime($start);
my $dt_end = $strp->parse_datetime($end);
my $fixed = $duration ? 0 : 1;
my $command = 'SCHEDULE_HOST_DOWNTIME';
my $addendum = q{};
}
}
sub action_on_service {
my ( $host, $service ) = @_;
if ( not have_service( $host, $service ) ) {
return;
}
my $tz = DateTime::TimeZone->new( name => 'local' );
given ($action) {
when ('downtime') {
my ( $start, $end, $duration, $comment, @opts ) = @action_args;
my $strp = DateTime::Format::Strptime->new(
pattern => '%Y-%m-%dT%H:%M:%S',
time_zone => $tz->name,
);
my $dt_start = $strp->parse_datetime($start);
my $dt_end = $strp->parse_datetime($end);
my $fixed = $duration ? 0 : 1;
$duration = parse_duration($duration);
=head1 CONFIGURATION
None.
=head1 DEPENDENCIES
=over
=item * autodie (included with perl >= 5.10.1)
=item * DateTime
=item * DateTime::Format::Strptime
=item * DateTime::TimeZone
=item * Term::Size
=back
=head1 BUGS AND LIMITATIONS
It is probably not clear from the documentation when an action will operate
on hosts and when on services.
( run in 0.416 second using v1.01-cache-2.11-cpan-2b0bae70ee8 )