diff options
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2002-11-18 07:22:28 +0000 |
---|---|---|
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2002-11-18 07:22:28 +0000 |
commit | 57c32f34730554dcd7ccd8e0e1f9c9e40bfb325a (patch) | |
tree | 90b4133b278d178fde5eeb7a41e31a5afcfa8ef1 | |
parent | c953de7d1c4775d73e4798a09d6bc40a3e2b2815 (diff) | |
download | monitoring-plugins-57c32f34730554dcd7ccd8e0e1f9c9e40bfb325a.tar.gz |
more readable max_state() code
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@207 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r-- | plugins/utils.c | 41 |
1 files changed, 14 insertions, 27 deletions
diff --git a/plugins/utils.c b/plugins/utils.c index 10d544c4..da9ccedd 100644 --- a/plugins/utils.c +++ b/plugins/utils.c | |||
@@ -60,8 +60,8 @@ char *strpcat (char *dest, const char *src, const char *str); | |||
60 | #define max(a,b) ((a)>(b))?(a):(b) | 60 | #define max(a,b) ((a)>(b))?(a):(b) |
61 | 61 | ||
62 | /* ************************************************************************** | 62 | /* ************************************************************************** |
63 | * max_state(result, STATE_x) | 63 | * max_state(STATE_x, STATE_y) |
64 | * compares STATE_x to result and returns result if STATE_x is less than a based on the following | 64 | * compares STATE_x to STATE_y and returns result based on the following |
65 | * STATE_UNKNOWN < STATE_OK < STATE_WARNING < STATE_CRITICAL | 65 | * STATE_UNKNOWN < STATE_OK < STATE_WARNING < STATE_CRITICAL |
66 | * | 66 | * |
67 | * Note that numerically the above does not hold | 67 | * Note that numerically the above does not hold |
@@ -70,31 +70,18 @@ char *strpcat (char *dest, const char *src, const char *str); | |||
70 | int | 70 | int |
71 | max_state(int a, int b) | 71 | max_state(int a, int b) |
72 | { | 72 | { |
73 | if(a == STATE_CRITICAL){ | 73 | if (a == STATE_CRITICAL || b == STATE_CRITICAL) |
74 | return a; | 74 | return STATE_CRITICAL; |
75 | } | 75 | else if (a == STATE_WARNING || b == STATE_WARNING) |
76 | else if (a == STATE_WARNING) { | 76 | return STATE_WARNING; |
77 | 77 | else if (a == STATE_OK || b == STATE_OK) | |
78 | if (b == STATE_CRITICAL){ | 78 | return STATE_OK; |
79 | return b; | 79 | else if (a == STATE_UNKNOWN || b == STATE_UNKNOWN) |
80 | }else { | 80 | return STATE_UNKNOWN; |
81 | return a; | 81 | else if (a == STATE_DEPENDENT || b == STATE_DEPENDENT) |
82 | } | 82 | return STATE_DEPENDENT; |
83 | } | 83 | else |
84 | else if (a == STATE_OK) { | 84 | return max (a, b); |
85 | |||
86 | if ( b== STATE_CRITICAL || b == STATE_WARNING) { | ||
87 | return b; | ||
88 | }else{ | ||
89 | return a; | ||
90 | } | ||
91 | } | ||
92 | else { | ||
93 | /* a == UNKNOWN */ | ||
94 | return b; | ||
95 | } | ||
96 | |||
97 | |||
98 | } | 85 | } |
99 | 86 | ||
100 | char * | 87 | char * |