Skip to content
Snippets Groups Projects
Commit a170ad2d authored by neophenix's avatar neophenix
Browse files

Allow setting an absent => X config param for file checks. If set will return...

Allow setting an absent => X config param for file checks.  If set will return all the metrics the module normally would, but with their integer values set to whatever you defined for absent.  present will still = 0 and text values will be undef
parent ca7be253
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,13 @@ This module retrieves metrics on a single file such as file age and file size.
The check name specifies which file to monitor.
=item absent
Normally if the file is absent you will get back a single present = 0 metric.
If absent is set you will instead get back all of the metrics, strings will be
null and integers will be whatever value you set for absent (present will still
be 0).
=back
=head1 METRICS
......@@ -84,9 +91,30 @@ sub handler {
if (!@statinfo) {
# File is missing
return {
"present" => [0, "i"]
my $ret = {};
if ( defined $config->{absent} ) {
$ret = {
"present" => [0, "i"],
"permissions" => [undef, "s"],
"hardlinks" => [$config->{absent},"i"],
"uid" => [undef,"s"],
"gid" => [undef,"s"],
"size" => [$config->{absent},"i"],
"atime" => [$config->{absent},"i"],
"mtime" => [$config->{absent},"i"],
"ctime" => [$config->{absent},"i"],
"aage" => [$config->{absent},"i"],
"mage" => [$config->{absent},"i"],
"cage" => [$config->{absent},"i"]
};
}
else {
$ret = {
"present" => [0, "i"]
};
}
return $ret;
} else {
my $now = time;
return {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment