aboutsummaryrefslogtreecommitdiff
path: root/plugins/check_load.c
diff options
context:
space:
mode:
authorGravatar Karl DeBisschop <kdebisschop@users.sourceforge.net> 2003-10-31 04:20:34 +0000
committerGravatar Karl DeBisschop <kdebisschop@users.sourceforge.net> 2003-10-31 04:20:34 +0000
commitfcf3534ea29211d266338d2e7404987dd7bcf97f (patch)
treeac118a9896748cbdac0fa17c4b568f076fb85d7d /plugins/check_load.c
parent71b0aafc899fb8db32939e6c98f04951ffe9f173 (diff)
downloadmonitoring-plugins-fcf3534ea29211d266338d2e7404987dd7bcf97f.tar.gz
add perfdata
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@755 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_load.c')
-rw-r--r--plugins/check_load.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/plugins/check_load.c b/plugins/check_load.c
index 275d0ad6..ba942c5c 100644
--- a/plugins/check_load.c
+++ b/plugins/check_load.c
@@ -55,8 +55,8 @@ char *status_line;
int
main (int argc, char **argv)
{
-#if HAVE_GETLOADAVG==1
int result;
+#if HAVE_GETLOADAVG==1
double la[3] = { 0.0, 0.0, 0.0 }; /* NetBSD complains about unitialized arrays */
#else
# if HAVE_PROC_LOADAVG==1
@@ -64,7 +64,6 @@ main (int argc, char **argv)
char input_buffer[MAX_INPUT_BUFFER];
char *tmp_ptr;
# else
- int result;
char input_buffer[MAX_INPUT_BUFFER];
# endif
#endif
@@ -126,6 +125,7 @@ main (int argc, char **argv)
# endif
#endif
+
if ((la1 < 0.0) || (la5 < 0.0) || (la15 < 0.0)) {
#if HAVE_GETLOADAVG==1
printf (_("Error in getloadavg()\n"));
@@ -138,16 +138,23 @@ main (int argc, char **argv)
#endif
return STATE_UNKNOWN;
}
+
asprintf(&status_line, _("load average: %.2f, %.2f, %.2f"), la1, la5, la15);
- if ((la1 >= cload1) || (la5 >= cload5) || (la15 >= cload15)) {
- printf(_("CRITICAL - %s\n"), status_line);
- return STATE_CRITICAL;
- }
- if ((la1 >= wload1) || (la5 >= wload5) || (la15 >= wload15)) {
- printf (_("WARNING - %s\n"), status_line);
- return STATE_WARNING;
- }
- printf (_("OK - %s\n"), status_line);
+
+ if ((la1 >= cload1) || (la5 >= cload5) || (la15 >= cload15))
+ result = STATE_CRITICAL;
+ else if ((la1 >= wload1) || (la5 >= wload5) || (la15 >= wload15))
+ result = STATE_WARNING;
+ else
+ result = STATE_OK;
+
+ die (result,
+ "%s - %s|%s %s %s\n",
+ state_text (result),
+ status_line,
+ perfdata ("load1", la1, "", wload1, wload1, cload1, cload1, TRUE, 0, FALSE, 0),
+ perfdata ("load5", la5, "", wload5, wload5, cload5, cload5, TRUE, 0, FALSE, 0),
+ perfdata ("load15", la15, "", wload15, wload15, cload15, cload15, TRUE, 0, FALSE, 0));
return STATE_OK;
}