diff options
-rw-r--r-- | plugins-root/check_icmp.c | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c index a9a24ee8..321612bb 100644 --- a/plugins-root/check_icmp.c +++ b/plugins-root/check_icmp.c | |||
@@ -1236,6 +1236,7 @@ finish(int sig) | |||
1236 | {"OK", "WARNING", "CRITICAL", "UNKNOWN", "DEPENDENT"}; | 1236 | {"OK", "WARNING", "CRITICAL", "UNKNOWN", "DEPENDENT"}; |
1237 | int hosts_ok = 0; | 1237 | int hosts_ok = 0; |
1238 | int hosts_warn = 0; | 1238 | int hosts_warn = 0; |
1239 | int this_status; | ||
1239 | double R; | 1240 | double R; |
1240 | 1241 | ||
1241 | alarm(0); | 1242 | alarm(0); |
@@ -1256,6 +1257,7 @@ finish(int sig) | |||
1256 | host = list; | 1257 | host = list; |
1257 | 1258 | ||
1258 | while(host) { | 1259 | while(host) { |
1260 | this_status = STATE_OK; | ||
1259 | if(!host->icmp_recv) { | 1261 | if(!host->icmp_recv) { |
1260 | /* rta 0 is ofcourse not entirely correct, but will still show up | 1262 | /* rta 0 is ofcourse not entirely correct, but will still show up |
1261 | * conspicuously as missing entries in perfparse and cacti */ | 1263 | * conspicuously as missing entries in perfparse and cacti */ |
@@ -1296,79 +1298,80 @@ finish(int sig) | |||
1296 | pl_mode=1; | 1298 | pl_mode=1; |
1297 | } | 1299 | } |
1298 | 1300 | ||
1301 | #define THIS_STATUS_WARNING this_status = (this_status <= STATE_WARNING ? STATE_WARNING : this_status) | ||
1299 | /* Check which mode is on and do the warn / Crit stuff */ | 1302 | /* Check which mode is on and do the warn / Crit stuff */ |
1300 | if (rta_mode) { | 1303 | if (rta_mode) { |
1301 | if(rta >= crit.rta) { | 1304 | if(rta >= crit.rta) { |
1305 | this_status = STATE_CRITICAL; | ||
1302 | status = STATE_CRITICAL; | 1306 | status = STATE_CRITICAL; |
1303 | host->rta_status=STATE_CRITICAL; | 1307 | host->rta_status=STATE_CRITICAL; |
1304 | } | 1308 | } |
1305 | else if(status!=STATE_CRITICAL && (rta >= warn.rta)) { | 1309 | else if(status!=STATE_CRITICAL && (rta >= warn.rta)) { |
1310 | THIS_STATUS_WARNING; | ||
1306 | status = STATE_WARNING; | 1311 | status = STATE_WARNING; |
1307 | hosts_warn++; | ||
1308 | host->rta_status=STATE_WARNING; | 1312 | host->rta_status=STATE_WARNING; |
1309 | } | 1313 | } |
1310 | else { | ||
1311 | hosts_ok++; | ||
1312 | } | ||
1313 | } | 1314 | } |
1314 | if (pl_mode) { | 1315 | if (pl_mode) { |
1315 | if(pl >= crit.pl) { | 1316 | if(pl >= crit.pl) { |
1317 | this_status = STATE_CRITICAL; | ||
1316 | status = STATE_CRITICAL; | 1318 | status = STATE_CRITICAL; |
1317 | host->pl_status=STATE_CRITICAL; | 1319 | host->pl_status=STATE_CRITICAL; |
1318 | } | 1320 | } |
1319 | else if(status!=STATE_CRITICAL && (pl >= warn.pl)) { | 1321 | else if(status!=STATE_CRITICAL && (pl >= warn.pl)) { |
1322 | THIS_STATUS_WARNING; | ||
1320 | status = STATE_WARNING; | 1323 | status = STATE_WARNING; |
1321 | hosts_warn++; | ||
1322 | host->pl_status=STATE_WARNING; | 1324 | host->pl_status=STATE_WARNING; |
1323 | } | 1325 | } |
1324 | else { | ||
1325 | hosts_ok++; | ||
1326 | } | ||
1327 | } | 1326 | } |
1328 | if (jitter_mode) { | 1327 | if (jitter_mode) { |
1329 | if(host->jitter >= crit.jitter) { | 1328 | if(host->jitter >= crit.jitter) { |
1329 | this_status = STATE_CRITICAL; | ||
1330 | status = STATE_CRITICAL; | 1330 | status = STATE_CRITICAL; |
1331 | host->jitter_status=STATE_CRITICAL; | 1331 | host->jitter_status=STATE_CRITICAL; |
1332 | } | 1332 | } |
1333 | else if(status!=STATE_CRITICAL && (host->jitter >= warn.jitter)) { | 1333 | else if(status!=STATE_CRITICAL && (host->jitter >= warn.jitter)) { |
1334 | THIS_STATUS_WARNING; | ||
1334 | status = STATE_WARNING; | 1335 | status = STATE_WARNING; |
1335 | hosts_warn++; | ||
1336 | host->jitter_status=STATE_WARNING; | 1336 | host->jitter_status=STATE_WARNING; |
1337 | } | 1337 | } |
1338 | else { | ||
1339 | hosts_ok++; | ||
1340 | } | ||
1341 | } | 1338 | } |
1342 | if (mos_mode) { | 1339 | if (mos_mode) { |
1343 | if(host->mos <= crit.mos) { | 1340 | if(host->mos <= crit.mos) { |
1341 | this_status = STATE_CRITICAL; | ||
1344 | status = STATE_CRITICAL; | 1342 | status = STATE_CRITICAL; |
1345 | host->mos_status=STATE_CRITICAL; | 1343 | host->mos_status=STATE_CRITICAL; |
1346 | } | 1344 | } |
1347 | else if(status!=STATE_CRITICAL && (host->mos <= warn.mos)) { | 1345 | else if(status!=STATE_CRITICAL && (host->mos <= warn.mos)) { |
1346 | THIS_STATUS_WARNING; | ||
1348 | status = STATE_WARNING; | 1347 | status = STATE_WARNING; |
1349 | hosts_warn++; | ||
1350 | host->mos_status=STATE_WARNING; | 1348 | host->mos_status=STATE_WARNING; |
1351 | } | 1349 | } |
1352 | else { | ||
1353 | hosts_ok++; | ||
1354 | } | ||
1355 | } | 1350 | } |
1356 | if (score_mode) { | 1351 | if (score_mode) { |
1357 | if(host->score <= crit.score) { | 1352 | if(host->score <= crit.score) { |
1353 | this_status = STATE_CRITICAL; | ||
1358 | status = STATE_CRITICAL; | 1354 | status = STATE_CRITICAL; |
1359 | host->score_status=STATE_CRITICAL; | 1355 | host->score_status=STATE_CRITICAL; |
1360 | } | 1356 | } |
1361 | else if(status!=STATE_CRITICAL && (host->score <= warn.score)) { | 1357 | else if(status!=STATE_CRITICAL && (host->score <= warn.score)) { |
1358 | THIS_STATUS_WARNING; | ||
1362 | status = STATE_WARNING; | 1359 | status = STATE_WARNING; |
1363 | score_mode++; | ||
1364 | host->score_status=STATE_WARNING; | 1360 | host->score_status=STATE_WARNING; |
1365 | } | 1361 | } |
1366 | else { | ||
1367 | hosts_ok++; | ||
1368 | } | ||
1369 | } | 1362 | } |
1363 | |||
1364 | if (this_status == STATE_WARNING) { | ||
1365 | hosts_warn++; | ||
1366 | } | ||
1367 | else if (this_status == STATE_OK) { | ||
1368 | hosts_ok++; | ||
1369 | } | ||
1370 | |||
1370 | host = host->next; | 1371 | host = host->next; |
1371 | } | 1372 | } |
1373 | |||
1374 | |||
1372 | /* this is inevitable */ | 1375 | /* this is inevitable */ |
1373 | if(!targets_alive) status = STATE_CRITICAL; | 1376 | if(!targets_alive) status = STATE_CRITICAL; |
1374 | if(min_hosts_alive > -1) { | 1377 | if(min_hosts_alive > -1) { |
@@ -1404,7 +1407,7 @@ finish(int sig) | |||
1404 | } | 1407 | } |
1405 | } | 1408 | } |
1406 | else { /* !icmp_recv */ | 1409 | else { /* !icmp_recv */ |
1407 | printf("%s:", host->name); | 1410 | printf("%s", host->name); |
1408 | /* rta text output */ | 1411 | /* rta text output */ |
1409 | if (rta_mode) { | 1412 | if (rta_mode) { |
1410 | if (status == STATE_OK) | 1413 | if (status == STATE_OK) |