mirror of
https://github.com/monitoring-plugins/monitoring-plugins.git
synced 2026-04-24 07:39:14 -04:00
more readable max_state() code
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@207 f882894a-f735-0410-b71e-b25c423dba1c
This commit is contained in:
parent
c953de7d1c
commit
57c32f3473
1 changed files with 14 additions and 27 deletions
|
|
@ -60,8 +60,8 @@ char *strpcat (char *dest, const char *src, const char *str);
|
|||
#define max(a,b) ((a)>(b))?(a):(b)
|
||||
|
||||
/* **************************************************************************
|
||||
* max_state(result, STATE_x)
|
||||
* compares STATE_x to result and returns result if STATE_x is less than a based on the following
|
||||
* max_state(STATE_x, STATE_y)
|
||||
* compares STATE_x to STATE_y and returns result based on the following
|
||||
* STATE_UNKNOWN < STATE_OK < STATE_WARNING < STATE_CRITICAL
|
||||
*
|
||||
* Note that numerically the above does not hold
|
||||
|
|
@ -70,31 +70,18 @@ char *strpcat (char *dest, const char *src, const char *str);
|
|||
int
|
||||
max_state(int a, int b)
|
||||
{
|
||||
if(a == STATE_CRITICAL){
|
||||
return a;
|
||||
}
|
||||
else if (a == STATE_WARNING) {
|
||||
|
||||
if (b == STATE_CRITICAL){
|
||||
return b;
|
||||
}else {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
else if (a == STATE_OK) {
|
||||
|
||||
if ( b== STATE_CRITICAL || b == STATE_WARNING) {
|
||||
return b;
|
||||
}else{
|
||||
return a;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* a == UNKNOWN */
|
||||
return 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_OK || b == STATE_OK)
|
||||
return STATE_OK;
|
||||
else if (a == STATE_UNKNOWN || b == STATE_UNKNOWN)
|
||||
return STATE_UNKNOWN;
|
||||
else if (a == STATE_DEPENDENT || b == STATE_DEPENDENT)
|
||||
return STATE_DEPENDENT;
|
||||
else
|
||||
return max (a, b);
|
||||
}
|
||||
|
||||
char *
|
||||
|
|
|
|||
Loading…
Reference in a new issue