summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2014-02-14 04:33:49 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2014-02-14 04:36:58 +0100
commit5ef645a7c5a61caded3dcaa7df7443e7d5c84780 (patch)
tree24ae27c684a2096448a12a881c47ffea56f0517b
parent51984eda5fac634031e291884bca5249346ceeec (diff)
downloadvserver-monitoring-5ef645a7c5a61caded3dcaa7df7443e7d5c84780.tar.gz
vserver-monitoring-5ef645a7c5a61caded3dcaa7df7443e7d5c84780.tar.bz2
vserver-monitoring-5ef645a7c5a61caded3dcaa7df7443e7d5c84780.zip
add parameter for service name
-rwxr-xr-xcheck_load15
-rwxr-xr-xcheck_mem15
2 files changed, 28 insertions, 2 deletions
diff --git a/check_load b/check_load
index 59a8554..ac2db4d 100755
--- a/check_load
+++ b/check_load
@@ -12,7 +12,8 @@ our $VERSION = '1.6';
sub init_nagios_plugin() {
my $plugin = Nagios::Plugin->new(
usage => "Usage: %s [-h|--help] [-w|--warnings=...] " .
- "[-c|--critical=...] [-d|--domain=...] [vserver-name]",
+ "[-c|--critical=...] [-d|--domain=...] " .
+ "[-s|--service=...] [vserver-name]",
version => $VERSION,
blurb => "This plugin could monitor the load of vserver guests."
);
@@ -36,6 +37,14 @@ sub init_nagios_plugin() {
label => "DOMAIN",
);
+ $plugin->add_arg(
+ spec => 's|service=s',
+ help => 'Name of the service, as defined in the config of ' .
+ 'the monitoring server. (default: ' .
+ Nagios::Plugin::Functions::get_shortname() . ')',
+ label => 'SERVICE',
+ );
+
return $plugin;
}
@@ -138,6 +147,10 @@ for my $load (qw( load1 load5 load15 )) {
}
}
+if ($n->opts->s && $n->opts->s =~ m/(\w[\w\/]*\w)/) {
+ $ENV{'NAGIOS_PLUGIN'} = $1;
+}
+
my $domain = '';
$domain = ('.' . $n->opts->d) if $n->opts->d;
diff --git a/check_mem b/check_mem
index 702273b..9909134 100755
--- a/check_mem
+++ b/check_mem
@@ -19,7 +19,8 @@ our %desc = (
sub init_nagios_plugin() {
my $plugin = Nagios::Plugin->new(
usage => "Usage: %s [-h|--help] [-w|--warnings=...] " .
- "[-c|--critical=...] [-d|--domain=...] [vserver-name]",
+ "[-c|--critical=...] [-d|--domain=...] " .
+ "[-s|--service=...] [vserver-name]",
version => $VERSION,
blurb => "This plugin could monitor the memory of vserver guests."
);
@@ -43,6 +44,14 @@ sub init_nagios_plugin() {
label => "DOMAIN",
);
+ $plugin->add_arg(
+ spec => 's|service=s',
+ help => 'Name of the service, as defined in the config of ' .
+ 'the monitoring server. (default: ' .
+ Nagios::Plugin::Functions::get_shortname() . ')',
+ label => 'SERVICE',
+ );
+
return $plugin;
}
@@ -143,6 +152,10 @@ my (%warn, %crit);
($warn{'vm'}, $warn{'rss'}, $warn{'anon'}, $warn{'vml'}) = parse_thresholds($n->opts->w);
($crit{'vm'}, $crit{'rss'}, $crit{'anon'}, $crit{'vml'}) = parse_thresholds($n->opts->c);
+if ($n->opts->s && $n->opts->s =~ m/(\w[\w\/]*\w)/) {
+ $ENV{'NAGIOS_PLUGIN'} = $1;
+}
+
my $domain = '';
$domain = ('.' . $n->opts->d) if $n->opts->d;