summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1bb5e1e)
raw | patch | inline | side by side (parent: 1bb5e1e)
author | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | |
Fri, 23 Nov 2007 04:18:16 +0000 (04:18 +0000) | ||
committer | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | |
Fri, 23 Nov 2007 04:18:16 +0000 (04:18 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1829 f882894a-f735-0410-b71e-b25c423dba1c
plugins/utils.c | patch | blob | history | |
plugins/utils.h | patch | blob | history |
diff --git a/plugins/utils.c b/plugins/utils.c
index 0e79fbdb5f13bb0bec9283d716ff97e10d8c06cc..88b441141c1f1dd9ddd21963767ad66ced506be1 100644 (file)
--- a/plugins/utils.c
+++ b/plugins/utils.c
return max (a, b);
}
+/* **************************************************************************
+ * max_state_alt(STATE_x, STATE_y)
+ * compares STATE_x to STATE_y and returns result based on the following
+ * STATE_OK < STATE_DEPENDENT < STATE_UNKNOWN < STATE_WARNING < STATE_CRITICAL
+ *
+ * The main difference between max_state_alt and max_state it that it doesn't
+ * allow setting a default to UNKNOWN. It will instead prioritixe any valid
+ * non-OK state.
+ ****************************************************************************/
+
+int
+max_state_alt (int a, int b)
+{
+ if (a == STATE_CRITICAL || b == STATE_CRITICAL)
+ return STATE_CRITICAL;
+ else if (a == STATE_WARNING || b == STATE_WARNING)
+ return STATE_WARNING;
+ else if (a == STATE_UNKNOWN || b == STATE_UNKNOWN)
+ return STATE_UNKNOWN;
+ else if (a == STATE_DEPENDENT || b == STATE_DEPENDENT)
+ return STATE_DEPENDENT;
+ else if (a == STATE_OK || b == STATE_OK)
+ return STATE_OK;
+ else
+ return max (a, b);
+}
+
void usage (const char *msg)
{
printf ("%s\n", msg);
diff --git a/plugins/utils.h b/plugins/utils.h
index f15a7b161de69541a59629198f622fa30e89d30e..bb99ee16499f95ae9484a8596c143d4ceed9460c 100644 (file)
--- a/plugins/utils.h
+++ b/plugins/utils.h
char *strpcat (char *, const char *, const char *);
int max_state (int a, int b);
+int max_state_alt (int a, int b);
void usage (const char *) __attribute__((noreturn));
void usage2(const char *, const char *) __attribute__((noreturn));