enhance indent
This commit is contained in:
parent
d69b46a826
commit
204c09548e
centreon-plugins/os
solaris/local
windows
|
@ -31,24 +31,24 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"remote" => { name => 'remote' },
|
||||
"ssh-option:s@" => { name => 'ssh_option' },
|
||||
"ssh-path:s" => { name => 'ssh_path' },
|
||||
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
||||
"timeout:s" => { name => 'timeout', default => 30 },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"command:s" => { name => 'command', default => 'format' },
|
||||
"command-path:s" => { name => 'command_path', default => '/usr/sbin' },
|
||||
"command-options:s" => { name => 'command_options', default => '2>&1 << EOF
|
||||
$options{options}->add_options(arguments => {
|
||||
'hostname:s' => { name => 'hostname' },
|
||||
'remote' => { name => 'remote' },
|
||||
'ssh-option:s@' => { name => 'ssh_option' },
|
||||
'ssh-path:s' => { name => 'ssh_path' },
|
||||
'ssh-command:s' => { name => 'ssh_command', default => 'ssh' },
|
||||
'timeout:s' => { name => 'timeout', default => 30 },
|
||||
'sudo' => { name => 'sudo' },
|
||||
'command:s' => { name => 'command', default => 'format' },
|
||||
'command-path:s' => { name => 'command_path', default => '/usr/sbin' },
|
||||
'command-options:s' => { name => 'command_options', default => '2>&1 << EOF
|
||||
0
|
||||
quit
|
||||
EOF' },
|
||||
"warning:s" => { name => 'warning', },
|
||||
"critical:s" => { name => 'critical', },
|
||||
});
|
||||
"warning:s" => { name => 'warning', },
|
||||
"critical:s" => { name => 'critical', },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
@ -57,24 +57,26 @@ sub check_options {
|
|||
$self->SUPER::init(%options);
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => $self->{option_results}->{command},
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options});
|
||||
my $stdout = centreon::plugins::misc::execute(
|
||||
output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => $self->{option_results}->{command},
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options}
|
||||
);
|
||||
my $long_msg = $stdout;
|
||||
$long_msg =~ s/\|/~/mg;
|
||||
$self->{output}->output_add(long_msg => $long_msg);
|
||||
|
@ -89,7 +91,7 @@ sub run {
|
|||
}
|
||||
|
||||
my ($exit_code) = $self->{perfdata}->threshold_check(value => $num_errors,
|
||||
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
if ($num_errors > 0) {
|
||||
$self->{output}->output_add(severity => $exit_code,
|
||||
short_msg => sprintf("Disks$disks_name are on errors."));
|
||||
|
|
|
@ -32,21 +32,21 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"remote" => { name => 'remote' },
|
||||
"ssh-option:s@" => { name => 'ssh_option' },
|
||||
"ssh-path:s" => { name => 'ssh_path' },
|
||||
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
||||
"timeout:s" => { name => 'timeout', default => 30 },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"command:s" => { name => 'command', default => 'kstat' },
|
||||
"command-path:s" => { name => 'command_path' },
|
||||
"command-options:s" => { name => 'command_options', default => '-n sys 2>&1' },
|
||||
"warning:s" => { name => 'warning', },
|
||||
"critical:s" => { name => 'critical', },
|
||||
});
|
||||
$options{options}->add_options(arguments => {
|
||||
'hostname:s' => { name => 'hostname' },
|
||||
'remote' => { name => 'remote' },
|
||||
'ssh-option:s@' => { name => 'ssh_option' },
|
||||
'ssh-path:s' => { name => 'ssh_path' },
|
||||
'ssh-command:s' => { name => 'ssh_command', default => 'ssh' },
|
||||
'timeout:s' => { name => 'timeout', default => 30 },
|
||||
'sudo' => { name => 'sudo' },
|
||||
'command:s' => { name => 'command', default => 'kstat' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-n sys 2>&1' },
|
||||
'warning:s' => { name => 'warning' },
|
||||
'critical:s' => { name => 'critical' },
|
||||
});
|
||||
|
||||
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
|
||||
$self->{hostname} = undef;
|
||||
return $self;
|
||||
|
@ -75,12 +75,14 @@ sub check_options {
|
|||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => $self->{option_results}->{command},
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options});
|
||||
my $stdout = centreon::plugins::misc::execute(
|
||||
output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => $self->{option_results}->{command},
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options}
|
||||
);
|
||||
$self->{statefile_cache}->read(statefile => 'cache_solaris_local_' . $self->{hostname} . '_' . $self->{mode});
|
||||
my $old_timestamp = $self->{statefile_cache}->get(name => 'last_timestamp');
|
||||
my $datas = {};
|
||||
|
@ -128,11 +130,13 @@ sub run {
|
|||
$self->{output}->output_add(severity => $exit_code,
|
||||
short_msg => sprintf("CPU %d %.2f%%", $cpu_number, $cpu_ratio_usetime));
|
||||
}
|
||||
$self->{output}->perfdata_add(label => 'cpu_' . $cpu_number, unit => '%',
|
||||
value => sprintf("%.2f", $cpu_ratio_usetime),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
||||
min => 0, max => 100);
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'cpu_' . $cpu_number, unit => '%',
|
||||
value => sprintf("%.2f", $cpu_ratio_usetime),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
||||
min => 0, max => 100
|
||||
);
|
||||
}
|
||||
|
||||
$self->{statefile_cache}->write(data => $datas);
|
||||
|
|
|
@ -31,18 +31,18 @@ sub new {
|
|||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
'prtdiag' => 'os::solaris::local::mode::prtdiag',
|
||||
'cpu' => 'os::solaris::local::mode::cpu',
|
||||
'fc-connected' => 'os::solaris::local::mode::fcconnected',
|
||||
'hardware-fmadm' => 'os::solaris::local::mode::fmadm',
|
||||
'analyze-disks' => 'os::solaris::local::mode::analyzedisks',
|
||||
'vx-disks' => 'os::solaris::local::mode::vxdisks',
|
||||
'svm-disks' => 'os::solaris::local::mode::svmdisks',
|
||||
'hwraidctl-status' => 'os::solaris::local::mode::hwraidctl',
|
||||
'hwsas2ircu-status' => 'os::solaris::local::mode::hwsas2ircu',
|
||||
'lom-v120-status' => 'os::solaris::local::mode::lomv120',
|
||||
'lom-v1280-status' => 'os::solaris::local::mode::lomv1280',
|
||||
);
|
||||
'prtdiag' => 'os::solaris::local::mode::prtdiag',
|
||||
'cpu' => 'os::solaris::local::mode::cpu',
|
||||
'fc-connected' => 'os::solaris::local::mode::fcconnected',
|
||||
'hardware-fmadm' => 'os::solaris::local::mode::fmadm',
|
||||
'analyze-disks' => 'os::solaris::local::mode::analyzedisks',
|
||||
'vx-disks' => 'os::solaris::local::mode::vxdisks',
|
||||
'svm-disks' => 'os::solaris::local::mode::svmdisks',
|
||||
'hwraidctl-status' => 'os::solaris::local::mode::hwraidctl',
|
||||
'hwsas2ircu-status' => 'os::solaris::local::mode::hwsas2ircu',
|
||||
'lom-v120-status' => 'os::solaris::local::mode::lomv120',
|
||||
'lom-v1280-status' => 'os::solaris::local::mode::lomv1280',
|
||||
);
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
|
|
@ -32,16 +32,16 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning-time:s" => { name => 'warning_time' },
|
||||
"critical-time:s" => { name => 'critical_time' },
|
||||
"timeout:s" => { name => 'timeout', default => 30 },
|
||||
"command:s" => { name => 'command' },
|
||||
"command-path:s" => { name => 'command_path' },
|
||||
"command-options:s" => { name => 'command_options' },
|
||||
"manage-returns:s" => { name => 'manage_returns', default => '' },
|
||||
});
|
||||
$options{options}->add_options(arguments => {
|
||||
'warning-time:s' => { name => 'warning_time' },
|
||||
'critical-time:s' => { name => 'critical_time' },
|
||||
'timeout:s' => { name => 'timeout', default => 30 },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'manage-returns:s' => { name => 'manage_returns', default => '' },
|
||||
});
|
||||
|
||||
$self->{manage_returns} = {};
|
||||
return $self;
|
||||
}
|
||||
|
@ -83,12 +83,14 @@ sub run {
|
|||
my ($self, %options) = @_;
|
||||
|
||||
my $timing0 = [gettimeofday];
|
||||
my ($stdout, $exit_code) = centreon::plugins::misc::execute(output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
command => $self->{option_results}->{command},
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
no_quit => 1);
|
||||
my ($stdout, $exit_code) = centreon::plugins::misc::execute(
|
||||
output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
command => $self->{option_results}->{command},
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
no_quit => 1
|
||||
);
|
||||
my $timeelapsed = tv_interval($timing0, [gettimeofday]);
|
||||
|
||||
my $long_msg = $stdout;
|
||||
|
@ -107,8 +109,10 @@ sub run {
|
|||
}
|
||||
|
||||
if (defined($exit_code)) {
|
||||
$self->{output}->perfdata_add(label => "code",
|
||||
value => $exit_code);
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'code',
|
||||
value => $exit_code
|
||||
);
|
||||
}
|
||||
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $timeelapsed,
|
||||
|
@ -118,11 +122,13 @@ sub run {
|
|||
short_msg => sprintf("Response time %.3fs", $timeelapsed));
|
||||
}
|
||||
|
||||
$self->{output}->perfdata_add(label => 'time', unit => 's',
|
||||
value => sprintf('%.3f', $timeelapsed),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning_time'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical_time'),
|
||||
min => 0);
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'time', unit => 's',
|
||||
value => sprintf('%.3f', $timeelapsed),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning_time'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical_time'),
|
||||
min => 0
|
||||
);
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
|
|
|
@ -32,16 +32,15 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
|
||||
"no-ps" => { name => 'no_ps', },
|
||||
"timeout:s" => { name => 'timeout', default => 50 },
|
||||
"command:s" => { name => 'command', default => 'powershell.exe' },
|
||||
"command-path:s" => { name => 'command_path' },
|
||||
"command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
"ps-exec-only" => { name => 'ps_exec_only', }
|
||||
});
|
||||
$options{options}->add_options(arguments => {
|
||||
'no-ps' => { name => 'no_ps', },
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only', }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
@ -57,11 +56,13 @@ sub run {
|
|||
|
||||
$self->{option_results}->{command_options} .= " " . $ps;
|
||||
|
||||
my ($stdout) = centreon::plugins::misc::windows_execute(output => $self->{output},
|
||||
timeout => $self->{option_results}->{timeout},
|
||||
command => $self->{option_results}->{command},
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options});
|
||||
my ($stdout) = centreon::plugins::misc::windows_execute(
|
||||
output => $self->{output},
|
||||
timeout => $self->{option_results}->{timeout},
|
||||
command => $self->{option_results}->{command},
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options}
|
||||
);
|
||||
if (defined($self->{option_results}->{ps_exec_only})) {
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => $stdout);
|
||||
|
@ -87,11 +88,13 @@ sub disco_show {
|
|||
my $ps = centreon::common::powershell::windows::liststorages::get_powershell(no_ps => $self->{option_results}->{no_ps});
|
||||
|
||||
$self->{option_results}->{command_options} .= " " . $ps;
|
||||
my ($stdout) = centreon::plugins::misc::windows_execute(output => $self->{output},
|
||||
timeout => $self->{option_results}->{timeout},
|
||||
command => $self->{option_results}->{command},
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options});
|
||||
my ($stdout) = centreon::plugins::misc::windows_execute(
|
||||
output => $self->{output},
|
||||
timeout => $self->{option_results}->{timeout},
|
||||
command => $self->{option_results}->{command},
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options}
|
||||
);
|
||||
centreon::common::powershell::windows::liststorages::disco_show($self, stdout => $stdout);
|
||||
}
|
||||
|
||||
|
@ -136,4 +139,4 @@ Filter database (only wilcard 'FileSystem' can be used. In Powershell).
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
=cut
|
||||
|
|
|
@ -37,11 +37,11 @@ sub new {
|
|||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'ntp-hostname:s' => { name => 'ntp_hostname' },
|
||||
'ntp-port:s' => { name => 'ntp_port', default => 123 },
|
||||
'warning:s' => { name => 'warning' },
|
||||
'critical:s' => { name => 'critical' },
|
||||
'timeout:s' => { name => 'timeout', default => 30 },
|
||||
'ntp-hostname:s' => { name => 'ntp_hostname' },
|
||||
'ntp-port:s' => { name => 'ntp_port', default => 123 },
|
||||
'warning:s' => { name => 'warning' },
|
||||
'critical:s' => { name => 'critical' },
|
||||
'timeout:s' => { name => 'timeout', default => 30 },
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
|
|
@ -31,13 +31,15 @@ use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold)
|
|||
sub custom_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $msg = sprintf('Reboot Pending: %s [Windows Update: %s][Component Based Servicing: %s][SCCM Client: %s][File Rename Operations: %s][Computer Name Change: %s]',
|
||||
$self->{result_values}->{RebootPending},
|
||||
$self->{result_values}->{WindowsUpdate},
|
||||
$self->{result_values}->{CBServicing},
|
||||
$self->{result_values}->{CCMClientSDK},
|
||||
$self->{result_values}->{PendFileRename},
|
||||
$self->{result_values}->{PendComputerRename});
|
||||
my $msg = sprintf(
|
||||
'Reboot Pending: %s [Windows Update: %s][Component Based Servicing: %s][SCCM Client: %s][File Rename Operations: %s][Computer Name Change: %s]',
|
||||
$self->{result_values}->{RebootPending},
|
||||
$self->{result_values}->{WindowsUpdate},
|
||||
$self->{result_values}->{CBServicing},
|
||||
$self->{result_values}->{CCMClientSDK},
|
||||
$self->{result_values}->{PendFileRename},
|
||||
$self->{result_values}->{PendComputerRename}
|
||||
);
|
||||
return $msg;
|
||||
}
|
||||
|
||||
|
@ -77,17 +79,17 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"timeout:s" => { name => 'timeout', default => 50 },
|
||||
"command:s" => { name => 'command', default => 'powershell.exe' },
|
||||
"command-path:s" => { name => 'command_path' },
|
||||
"command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
"no-ps" => { name => 'no_ps' },
|
||||
"ps-exec-only" => { name => 'ps_exec_only' },
|
||||
"warning-status:s" => { name => 'warning_status', default => '%{RebootPending} =~ /true/i' },
|
||||
"critical-status:s" => { name => 'critical_status', default => '' },
|
||||
});
|
||||
$options{options}->add_options(arguments => {
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'warning-status:s' => { name => 'warning_status', default => '%{RebootPending} =~ /true/i' },
|
||||
'critical-status:s' => { name => 'critical_status', default => '' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
@ -105,11 +107,13 @@ sub manage_selection {
|
|||
no_ps => $self->{option_results}->{no_ps});
|
||||
|
||||
$self->{option_results}->{command_options} .= " " . $ps;
|
||||
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
command => $self->{option_results}->{command},
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options});
|
||||
my ($stdout) = centreon::plugins::misc::execute(
|
||||
output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
command => $self->{option_results}->{command},
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options}
|
||||
);
|
||||
if (defined($self->{option_results}->{ps_exec_only})) {
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => $stdout);
|
||||
|
|
|
@ -31,12 +31,12 @@ sub new {
|
|||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
'cmd-return' => 'os::windows::local::mode::cmdreturn',
|
||||
'pending-reboot' => 'os::windows::local::mode::pendingreboot',
|
||||
'sessions' => 'os::windows::local::mode::sessions',
|
||||
'time' => 'os::windows::local::mode::ntp',
|
||||
'list-storages' => 'os::windows::local::mode::liststorages',
|
||||
);
|
||||
'cmd-return' => 'os::windows::local::mode::cmdreturn',
|
||||
'list-storages' => 'os::windows::local::mode::liststorages',
|
||||
'pending-reboot' => 'os::windows::local::mode::pendingreboot',
|
||||
'sessions' => 'os::windows::local::mode::sessions',
|
||||
'time' => 'os::windows::local::mode::ntp',
|
||||
);
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
|
|
@ -30,11 +30,10 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"name:s" => { name => 'name' },
|
||||
"regexp" => { name => 'use_regexp' },
|
||||
});
|
||||
$options{options}->add_options(arguments => {
|
||||
'name:s' => { name => 'name' },
|
||||
'regexp' => { name => 'use_regexp' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
@ -47,10 +46,12 @@ sub check_options {
|
|||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{result} = $self->{wsman}->request(uri => 'http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/*',
|
||||
wql_filter => 'Select Name, DisplayName, StartMode, State From Win32_Service',
|
||||
result_type => 'hash',
|
||||
hash_key => 'Name');
|
||||
$self->{result} = $self->{wsman}->request(
|
||||
uri => 'http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/*',
|
||||
wql_filter => 'Select Name, DisplayName, StartMode, State From Win32_Service',
|
||||
result_type => 'hash',
|
||||
hash_key => 'Name'
|
||||
);
|
||||
foreach my $name (sort(keys %{$self->{result}})) {
|
||||
# Get all without a name
|
||||
next if (!defined($self->{option_results}->{name}));
|
||||
|
@ -95,11 +96,12 @@ sub disco_show {
|
|||
|
||||
$self->manage_selection();
|
||||
foreach my $name (sort(keys %{$self->{result}})) {
|
||||
$self->{output}->add_disco_entry(name => $name,
|
||||
display_name => $self->{output}->to_utf8($self->{result}->{$name}->{DisplayName}),
|
||||
start_mode => $self->{result}->{$name}->{StartMode},
|
||||
state => $self->{result}->{$name}->{State}
|
||||
);
|
||||
$self->{output}->add_disco_entry(
|
||||
name => $name,
|
||||
display_name => $self->{output}->to_utf8($self->{result}->{$name}->{DisplayName}),
|
||||
start_mode => $self->{result}->{$name}->{StartMode},
|
||||
state => $self->{result}->{$name}->{State}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,4 +125,4 @@ Allows to use regexp to filter service name (with option --name).
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
=cut
|
||||
|
|
|
@ -30,14 +30,14 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning" => { name => 'warning', },
|
||||
"critical" => { name => 'critical', },
|
||||
"services:s" => { name => 'services', },
|
||||
"auto" => { name => 'auto', },
|
||||
"exclude:s" => { name => 'exclude', },
|
||||
});
|
||||
$options{options}->add_options(arguments => {
|
||||
'warning' => { name => 'warning' },
|
||||
'critical' => { name => 'critical' },
|
||||
'services:s' => { name => 'services' },
|
||||
'auto' => { name => 'auto' },
|
||||
'exclude:s' => { name => 'exclude' },
|
||||
});
|
||||
|
||||
$self->{service_rules} = {};
|
||||
$self->{wql_filter} = '';
|
||||
$self->{threshold} = 'CRITICAL';
|
||||
|
@ -97,10 +97,12 @@ sub check_options {
|
|||
sub check_auto {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{result} = $self->{wsman}->request(uri => 'http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/*',
|
||||
wql_filter => "Select Name, State From Win32_Service Where StartMode = 'Auto'",
|
||||
result_type => 'hash',
|
||||
hash_key => 'Name');
|
||||
$self->{result} = $self->{wsman}->request(
|
||||
uri => 'http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/*',
|
||||
wql_filter => "Select Name, State From Win32_Service Where StartMode = 'Auto'",
|
||||
result_type => 'hash',
|
||||
hash_key => 'Name'
|
||||
);
|
||||
foreach my $name (sort(keys %{$self->{result}})) {
|
||||
if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} ne '' && $self->{result}->{$name}->{Name} =~ /$self->{option_results}->{exclude}/) {
|
||||
$self->{output}->output_add(long_msg => "Skipping Service '" . $self->{result}->{$name}->{Name} . "'");
|
||||
|
@ -118,10 +120,12 @@ sub check_auto {
|
|||
sub check {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{result} = $self->{wsman}->request(uri => 'http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/*',
|
||||
wql_filter => 'Select Name, State From Win32_Service Where ' . $self->{wql_filter},
|
||||
result_type => 'hash',
|
||||
hash_key => 'Name');
|
||||
$self->{result} = $self->{wsman}->request(
|
||||
uri => 'http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/*',
|
||||
wql_filter => 'Select Name, State From Win32_Service Where ' . $self->{wql_filter},
|
||||
result_type => 'hash',
|
||||
hash_key => 'Name'
|
||||
);
|
||||
foreach my $name (sort(keys %{$self->{service_rules}})) {
|
||||
if (!defined($self->{result}->{$name})) {
|
||||
$self->{output}->output_add(severity => 'UNKNOWN',
|
||||
|
@ -144,7 +148,6 @@ sub check {
|
|||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{wsman} = wsman object
|
||||
$self->{wsman} = $options{wsman};
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
|
@ -201,4 +204,4 @@ Exclude some services for --auto option (Can be a regexp).
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
=cut
|
||||
|
|
|
@ -31,9 +31,9 @@ sub new {
|
|||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
'list-services' => 'os::windows::wsman::mode::listservices',
|
||||
'service' => 'os::windows::wsman::mode::service',
|
||||
);
|
||||
'list-services' => 'os::windows::wsman::mode::listservices',
|
||||
'service' => 'os::windows::wsman::mode::service',
|
||||
);
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue