Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,12 @@ sudo make install ## optional
--timeout sets the SNMP timeout (in ms)
-m|--mode special operating mode (default,cisco,nonbulk,bintec)
Workarounds for various hardware

--legacy-perfdata restore the pre-1.4.4 performance data format
Omits checktime=, the ", of which X matched the regex" status
text, and per-interface inBitps/outBitps fields, matching the
exact output of versions before 1.4.4. Use this if you have
existing RRD/PNP4Nagios graph definitions that expect the old
field layout and would otherwise break on upgrade.

### Modes

Expand Down
28 changes: 26 additions & 2 deletions check_interfaces.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ static char *oid_vals_cisco[] = {".1.3.6.1.2.1.2.2.1.7", /* ifAdminStatus *
*/
static const char *modes[] = {"default", "cisco", "nonbulk", "bintec", NULL};

static bool legacy_perfdata_flag = false;

#ifdef DEBUG
static char *implode_result;
#endif
Expand Down Expand Up @@ -731,6 +733,14 @@ returncode_t print_output(struct configuration_struct *config, struct ifStruct *

unsigned int parsed_lastcheck = 0;

unsigned int printed_count = 0;

for (int i = 0; i < ifNumber; i++) {
if (!interfaces[i].ignore && (!interfaces[i].admin_down || config->print_all_flag)) {
printed_count++;
}
}

if (config->oldperfdatap && config->oldperfdatap[0]) {
parse_perfdata(config->oldperfdatap, oldperfdata, config->prefix, &parsed_lastcheck,
ifNumber, if_vars);
Expand Down Expand Up @@ -953,12 +963,18 @@ returncode_t print_output(struct configuration_struct *config, struct ifStruct *
}

/* now print performance data */

if (legacy_perfdata_flag) {
printf("%*s | interfaces::check_multi::plugins=%d time=%.2Lf", (int)out->len,
out->text, printed_count,
(((long double)time_value->tv_sec + ((long double)time_value->tv_usec / 1000000)) -
starttime));
} else {
printf("%*s | interfaces::check_multi::plugins=%d time=%.2Lf checktime=%ld", (int)out->len,
out->text, number_of_matched_interfaces,
out->text, printed_count,
(((long double)time_value->tv_sec + ((long double)time_value->tv_usec / 1000000)) -
starttime),
time_value->tv_sec);
}
if (uptime) {
printf(" %sdevice::check_snmp::uptime=%us", config->prefix ? config->prefix : "", uptime);
}
Expand All @@ -980,8 +996,10 @@ returncode_t print_output(struct configuration_struct *config, struct ifStruct *
} else {
printf(" %s=%llu", if_vars[8], interfaces[i].speed);
}
if (!legacy_perfdata_flag) {
printf(" %s=%llub %s=%llub", if_vars[9], interfaces[i].inbitps, if_vars[10],
interfaces[i].outbitps);
}
}
}
printf("\n%*s", (int)perf.len, perf.text);
Expand Down Expand Up @@ -1289,6 +1307,7 @@ void parse_and_check_commandline(int argc, char **argv, struct configuration_str
{"sleep", required_argument, NULL, 3},
{"retries", required_argument, NULL, 4},
{"max-repetitions", required_argument, NULL, 5},
{"legacy-perfdata", no_argument, NULL, 6},
{"version", no_argument, NULL, VERSION_OPTION},
{NULL, 0, NULL, 0}};

Expand Down Expand Up @@ -1388,6 +1407,9 @@ void parse_and_check_commandline(int argc, char **argv, struct configuration_str
case 5:
config->pdu_max_repetitions = strtol(optarg, NULL, 10);
break;
case 6:
legacy_perfdata_flag = true;
break;
case VERSION_OPTION:
print_version();
case '?':
Expand Down Expand Up @@ -1512,6 +1534,8 @@ int usage(char *progname) {
printf(" --retries\t\thow often to retry before giving up\n");
printf(" --max-repetitions\t\tsee "
"<http://www.net-snmp.org/docs/man/snmpbulkwalk.html>\n");
printf(" --legacy-perfdata\t\tuse the pre-1.4.4 perfdata format "
"(no checktime=, no \", of which X matched\", no inBitps/outBitps)\n");
printf(" --port\t\tPort (default 161)\n");
printf(" --version\t\tPrint program version\n");
printf("\n");
Expand Down