diff options
| -rw-r--r-- | plugins-root/check_icmp.c | 80 | ||||
| -rw-r--r-- | plugins-root/t/check_icmp.t | 5 |
2 files changed, 53 insertions, 32 deletions
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c index 303241d3..f788d428 100644 --- a/plugins-root/check_icmp.c +++ b/plugins-root/check_icmp.c | |||
| @@ -1547,46 +1547,66 @@ finish(int sig) | |||
| 1547 | while(host) { | 1547 | while(host) { |
| 1548 | if(debug) puts(""); | 1548 | if(debug) puts(""); |
| 1549 | 1549 | ||
| 1550 | if (rta_mode && host->pl<100) { | 1550 | if (rta_mode) { |
| 1551 | printf("%srta=%0.3fms;%0.3f;%0.3f;0; %srtmax=%0.3fms;;;; %srtmin=%0.3fms;;;; ", | 1551 | if (host->pl<100) { |
| 1552 | (targets > 1) ? host->name : "", | 1552 | printf("%srta=%0.3fms;%0.3f;%0.3f;0; %srtmax=%0.3fms;;;; %srtmin=%0.3fms;;;; ", |
| 1553 | host->rta / 1000, (float)warn.rta / 1000, (float)crit.rta / 1000, | 1553 | (targets > 1) ? host->name : "", |
| 1554 | (targets > 1) ? host->name : "", (float)host->rtmax / 1000, | 1554 | host->rta / 1000, (float)warn.rta / 1000, (float)crit.rta / 1000, |
| 1555 | (targets > 1) ? host->name : "", (host->rtmin < INFINITY) ? (float)host->rtmin / 1000 : (float)0); | 1555 | (targets > 1) ? host->name : "", (float)host->rtmax / 1000, |
| 1556 | (targets > 1) ? host->name : "", (host->rtmin < INFINITY) ? (float)host->rtmin / 1000 : (float)0); | ||
| 1557 | } else { | ||
| 1558 | printf("%srta=U;;;; %srtmax=U;;;; %srtmin=U;;;; ", | ||
| 1559 | (targets > 1) ? host->name : "", | ||
| 1560 | (targets > 1) ? host->name : "", | ||
| 1561 | (targets > 1) ? host->name : ""); | ||
| 1562 | } | ||
| 1556 | } | 1563 | } |
| 1557 | 1564 | ||
| 1558 | if (pl_mode) { | 1565 | if (pl_mode) { |
| 1559 | printf("%spl=%u%%;%u;%u;0;100 ", (targets > 1) ? host->name : "", host->pl, warn.pl, crit.pl); | 1566 | printf("%spl=%u%%;%u;%u;0;100 ", (targets > 1) ? host->name : "", host->pl, warn.pl, crit.pl); |
| 1560 | } | 1567 | } |
| 1561 | 1568 | ||
| 1562 | if (jitter_mode && host->pl<100) { | 1569 | if (jitter_mode) { |
| 1563 | printf("%sjitter_avg=%0.3fms;%0.3f;%0.3f;0; %sjitter_max=%0.3fms;;;; %sjitter_min=%0.3fms;;;; ", | 1570 | if (host->pl<100) { |
| 1564 | (targets > 1) ? host->name : "", | 1571 | printf("%sjitter_avg=%0.3fms;%0.3f;%0.3f;0; %sjitter_max=%0.3fms;;;; %sjitter_min=%0.3fms;;;; ", |
| 1565 | (float)host->jitter, | 1572 | (targets > 1) ? host->name : "", |
| 1566 | (float)warn.jitter, | 1573 | (float)host->jitter, |
| 1567 | (float)crit.jitter, | 1574 | (float)warn.jitter, |
| 1568 | (targets > 1) ? host->name : "", | 1575 | (float)crit.jitter, |
| 1569 | (float)host->jitter_max / 1000, (targets > 1) ? host->name : "", | 1576 | (targets > 1) ? host->name : "", |
| 1570 | (float)host->jitter_min / 1000 | 1577 | (float)host->jitter_max / 1000, (targets > 1) ? host->name : "", |
| 1571 | ); | 1578 | (float)host->jitter_min / 1000 |
| 1579 | ); | ||
| 1580 | } else { | ||
| 1581 | printf("%sjitter_avg=U;;;; %sjitter_max=U;;;; %sjitter_min=U;;;; ", | ||
| 1582 | (targets > 1) ? host->name : "", | ||
| 1583 | (targets > 1) ? host->name : "", | ||
| 1584 | (targets > 1) ? host->name : ""); | ||
| 1585 | } | ||
| 1572 | } | 1586 | } |
| 1573 | 1587 | ||
| 1574 | if (mos_mode && host->pl<100) { | 1588 | if (mos_mode) { |
| 1575 | printf("%smos=%0.1f;%0.1f;%0.1f;0;5 ", | 1589 | if (host->pl<100) { |
| 1576 | (targets > 1) ? host->name : "", | 1590 | printf("%smos=%0.1f;%0.1f;%0.1f;0;5 ", |
| 1577 | (float)host->mos, | 1591 | (targets > 1) ? host->name : "", |
| 1578 | (float)warn.mos, | 1592 | (float)host->mos, |
| 1579 | (float)crit.mos | 1593 | (float)warn.mos, |
| 1580 | ); | 1594 | (float)crit.mos); |
| 1595 | } else { | ||
| 1596 | printf("%smos=U;;;; ", (targets > 1) ? host->name : ""); | ||
| 1597 | } | ||
| 1581 | } | 1598 | } |
| 1582 | 1599 | ||
| 1583 | if (score_mode && host->pl<100) { | 1600 | if (score_mode) { |
| 1584 | printf("%sscore=%u;%u;%u;0;100 ", | 1601 | if (host->pl<100) { |
| 1585 | (targets > 1) ? host->name : "", | 1602 | printf("%sscore=%u;%u;%u;0;100 ", |
| 1586 | (int)host->score, | 1603 | (targets > 1) ? host->name : "", |
| 1587 | (int)warn.score, | 1604 | (int)host->score, |
| 1588 | (int)crit.score | 1605 | (int)warn.score, |
| 1589 | ); | 1606 | (int)crit.score); |
| 1607 | } else { | ||
| 1608 | printf("%sscore=U;;;; ", (targets > 1) ? host->name : ""); | ||
| 1609 | } | ||
| 1590 | } | 1610 | } |
| 1591 | 1611 | ||
| 1592 | host = host->next; | 1612 | host = host->next; |
diff --git a/plugins-root/t/check_icmp.t b/plugins-root/t/check_icmp.t index 4f9db868..de1d88d2 100644 --- a/plugins-root/t/check_icmp.t +++ b/plugins-root/t/check_icmp.t | |||
| @@ -12,7 +12,7 @@ my $allow_sudo = getTestParameter( "NP_ALLOW_SUDO", | |||
| 12 | "no" ); | 12 | "no" ); |
| 13 | 13 | ||
| 14 | if ($allow_sudo eq "yes" or $> == 0) { | 14 | if ($allow_sudo eq "yes" or $> == 0) { |
| 15 | plan tests => 39; | 15 | plan tests => 40; |
| 16 | } else { | 16 | } else { |
| 17 | plan skip_all => "Need sudo to test check_icmp"; | 17 | plan skip_all => "Need sudo to test check_icmp"; |
| 18 | } | 18 | } |
| @@ -57,7 +57,8 @@ $res = NPTest->testCmd( | |||
| 57 | "$sudo ./check_icmp -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100% -t 2" | 57 | "$sudo ./check_icmp -H $host_nonresponsive -w 10000ms,100% -c 10000ms,100% -t 2" |
| 58 | ); | 58 | ); |
| 59 | is( $res->return_code, 2, "Timeout - host nonresponsive" ); | 59 | is( $res->return_code, 2, "Timeout - host nonresponsive" ); |
| 60 | like( $res->output, '/100%/', "Error contains '100%' string (for 100% packet loss)" ); | 60 | like( $res->output, '/pl=100%/', "Error contains 'pl=100%' string (for 100% packet loss)" ); |
| 61 | like( $res->output, '/rta=U/', "Error contains 'rta=U' string" ); | ||
| 61 | 62 | ||
| 62 | $res = NPTest->testCmd( | 63 | $res = NPTest->testCmd( |
| 63 | "$sudo ./check_icmp -w 10000ms,100% -c 10000ms,100%" | 64 | "$sudo ./check_icmp -w 10000ms,100% -c 10000ms,100%" |
