summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 71b0aaf)
raw | patch | inline | side by side (parent: 71b0aaf)
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Fri, 31 Oct 2003 04:20:34 +0000 (04:20 +0000) | ||
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Fri, 31 Oct 2003 04:20:34 +0000 (04:20 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@755 f882894a-f735-0410-b71e-b25c423dba1c
plugins/check_load.c | patch | blob | history |
diff --git a/plugins/check_load.c b/plugins/check_load.c
index 275d0ad6ae7493cdd9c271742236a426101dc68a..ba942c5c21c0acbdc0527f7a6f86f351520c2272 100644 (file)
--- a/plugins/check_load.c
+++ b/plugins/check_load.c
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
char input_buffer[MAX_INPUT_BUFFER];
char *tmp_ptr;
# else
- int result;
char input_buffer[MAX_INPUT_BUFFER];
# endif
#endif
# endif
#endif
+
if ((la1 < 0.0) || (la5 < 0.0) || (la15 < 0.0)) {
#if HAVE_GETLOADAVG==1
printf (_("Error in getloadavg()\n"));
#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;
}