add few comments

This commit is contained in:
Shini31 2015-07-24 15:27:20 +02:00
parent 66f2467332
commit bc9abd0e5b
3 changed files with 19 additions and 16 deletions

View File

@ -158,6 +158,7 @@ sub run {
$new_datas->{last_timestamp} = time(); $new_datas->{last_timestamp} = time();
my $old_timestamp = $self->{statefile_value}->get(name => 'last_timestamp'); my $old_timestamp = $self->{statefile_value}->get(name => 'last_timestamp');
# First execution
if (!defined($old_timestamp)) { if (!defined($old_timestamp)) {
$self->{output}->output_add(severity => 'OK', $self->{output}->output_add(severity => 'OK',
short_msg => "Buffer creation..."); short_msg => "Buffer creation...");
@ -201,15 +202,15 @@ sub run {
$write_value . $write_unit)); $write_value . $write_unit));
$self->{output}->perfdata_add(label => 'read_io', unit => 'B/s', $self->{output}->perfdata_add(label => 'read_io', unit => 'B/s',
value => sprintf("%.2f", $read_absolute_per_sec), value => sprintf("%.2f", $read_absolute_per_sec),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-read'), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-read'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-read'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-read'),
min => 0); min => 0);
$self->{output}->perfdata_add(label => 'write_io', unit => 'B/s', $self->{output}->perfdata_add(label => 'write_io', unit => 'B/s',
value => sprintf("%.2f", $write_absolute_per_sec), value => sprintf("%.2f", $write_absolute_per_sec),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-write'), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-write'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-write'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-write'),
min => 0); min => 0);
$self->{statefile_value}->write(data => $new_datas); $self->{statefile_value}->write(data => $new_datas);

View File

@ -177,6 +177,7 @@ sub run {
if (defined($self->{option_results}->{id}) || defined($self->{option_results}->{name})) { if (defined($self->{option_results}->{id}) || defined($self->{option_results}->{name})) {
while ( my ($keys,$values) = each(%{$webcontent->{State}})) { while ( my ($keys,$values) = each(%{$webcontent->{State}})) {
# Why not set a variable that contains the state?
if ($values eq 'true') { if ($values eq 'true') {
$result = $keys; $result = $keys;
$containername = $webcontent->{Name}; $containername = $webcontent->{Name};
@ -200,6 +201,7 @@ sub run {
$containername = $val->{Names}->[0]; $containername = $val->{Names}->[0];
$containername =~ s/^\///; $containername =~ s/^\///;
# Thanks to Docker API for the paused state...
if (($val->{Status} =~ m/^Up/) && ($val->{Status} =~ m/^(?:(?!Paused).)*$/)) { if (($val->{Status} =~ m/^Up/) && ($val->{Status} =~ m/^(?:(?!Paused).)*$/)) {
$result = 'Running'; $result = 'Running';
$nbrunning++; $nbrunning++;
@ -215,7 +217,7 @@ sub run {
$exit = $self->{output}->get_most_critical(status => [ $tmp_exit, $exit ]); $exit = $self->{output}->get_most_critical(status => [ $tmp_exit, $exit ]);
if (!$self->{output}->is_status(value => $tmp_exit, compare => 'OK', litteral => 1)) { if (!$self->{output}->is_status(value => $tmp_exit, compare => 'OK', litteral => 1)) {
$self->{output}->output_add(long_msg => sprintf("Containers %s is in %s state", $self->{output}->output_add(long_msg => sprintf("Containers %s is in %s state",
$containername, $result)); $containername, $result));
} }
} }
@ -224,16 +226,16 @@ sub run {
short_msg => sprintf("Some containers are in wrong state")); short_msg => sprintf("Some containers are in wrong state"));
} }
$self->{output}->perfdata_add(label => "running", $self->{output}->perfdata_add(label => "running",
value => $nbrunning, value => $nbrunning,
min => 0, min => 0,
); );
$self->{output}->perfdata_add(label => "paused", $self->{output}->perfdata_add(label => "paused",
value => $nbpaused, value => $nbpaused,
min => 0, min => 0,
); );
$self->{output}->perfdata_add(label => "exited", $self->{output}->perfdata_add(label => "exited",
value => $nbexited, value => $nbexited,
min => 0, min => 0,
); );
} }

View File

@ -187,7 +187,7 @@ __END__
=head1 MODE =head1 MODE
Check Container's image viability Check Container's image viability with a registry
=over 8 =over 8