summaryrefslogtreecommitdiffstats
path: root/plugins/check_snmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_snmp.c')
-rw-r--r--plugins/check_snmp.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index 9839d6e..afc568b 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -152,7 +152,7 @@ state_data *previous_state;
152double *previous_value; 152double *previous_value;
153size_t previous_size = OID_COUNT_STEP; 153size_t previous_size = OID_COUNT_STEP;
154int perf_labels = 1; 154int perf_labels = 1;
155 155char* ip_version = "";
156 156
157static char *fix_snmp_range(char *th) 157static char *fix_snmp_range(char *th)
158{ 158{
@@ -576,6 +576,9 @@ main (int argc, char **argv)
576 len = sizeof(perfstr)-strlen(perfstr)-1; 576 len = sizeof(perfstr)-strlen(perfstr)-1;
577 strncat(perfstr, show, len>ptr-show ? ptr-show : len); 577 strncat(perfstr, show, len>ptr-show ? ptr-show : len);
578 578
579 if (type)
580 strncat(perfstr, type, sizeof(perfstr)-strlen(perfstr)-1);
581
579 if (warning_thresholds) { 582 if (warning_thresholds) {
580 strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1); 583 strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1);
581 strncat(perfstr, warning_thresholds, sizeof(perfstr)-strlen(perfstr)-1); 584 strncat(perfstr, warning_thresholds, sizeof(perfstr)-strlen(perfstr)-1);
@@ -588,8 +591,6 @@ main (int argc, char **argv)
588 strncat(perfstr, critical_thresholds, sizeof(perfstr)-strlen(perfstr)-1); 591 strncat(perfstr, critical_thresholds, sizeof(perfstr)-strlen(perfstr)-1);
589 } 592 }
590 593
591 if (type)
592 strncat(perfstr, type, sizeof(perfstr)-strlen(perfstr)-1);
593 strncat(perfstr, " ", sizeof(perfstr)-strlen(perfstr)-1); 594 strncat(perfstr, " ", sizeof(perfstr)-strlen(perfstr)-1);
594 } 595 }
595 } 596 }
@@ -680,6 +681,8 @@ process_arguments (int argc, char **argv)
680 {"offset", required_argument, 0, L_OFFSET}, 681 {"offset", required_argument, 0, L_OFFSET},
681 {"invert-search", no_argument, 0, L_INVERT_SEARCH}, 682 {"invert-search", no_argument, 0, L_INVERT_SEARCH},
682 {"perf-oids", no_argument, 0, 'O'}, 683 {"perf-oids", no_argument, 0, 'O'},
684 {"ipv4", no_argument, 0, '4'},
685 {"ipv6", no_argument, 0, '6'},
683 {0, 0, 0, 0} 686 {0, 0, 0, 0}
684 }; 687 };
685 688
@@ -697,7 +700,7 @@ process_arguments (int argc, char **argv)
697 } 700 }
698 701
699 while (1) { 702 while (1) {
700 c = getopt_long (argc, argv, "nhvVOt:c:w:H:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:N:L:U:a:x:A:X:", 703 c = getopt_long (argc, argv, "nhvVO46t:c:w:H:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:N:L:U:a:x:A:X:",
701 longopts, &option); 704 longopts, &option);
702 705
703 if (c == -1 || c == EOF) 706 if (c == -1 || c == EOF)
@@ -922,6 +925,13 @@ process_arguments (int argc, char **argv)
922 case 'O': 925 case 'O':
923 perf_labels=0; 926 perf_labels=0;
924 break; 927 break;
928 case '4':
929 break;
930 case '6':
931 xasprintf(&ip_version, "udp6:");
932 if(verbose>2)
933 printf("IPv6 detected! Will pass \"udp6:\" to snmpget.\n");
934 break;
925 } 935 }
926 } 936 }
927 937
@@ -1127,6 +1137,7 @@ print_help (void)
1127 1137
1128 printf (UT_HELP_VRSN); 1138 printf (UT_HELP_VRSN);
1129 printf (UT_EXTRA_OPTS); 1139 printf (UT_EXTRA_OPTS);
1140 printf (UT_IPv46);
1130 1141
1131 printf (UT_HOST_PORT, 'p', DEFAULT_PORT); 1142 printf (UT_HOST_PORT, 'p', DEFAULT_PORT);
1132 1143
@@ -1197,8 +1208,9 @@ print_help (void)
1197 printf (" %s\n", _("Separates output on multiple OID requests")); 1208 printf (" %s\n", _("Separates output on multiple OID requests"));
1198 1209
1199 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 1210 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
1211 printf (" %s\n", _("NOTE the final timeout value is calculated using this formula: timeout_interval * retries + 5"));
1200 printf (" %s\n", "-e, --retries=INTEGER"); 1212 printf (" %s\n", "-e, --retries=INTEGER");
1201 printf (" %s\n", _("Number of retries to be used in the requests")); 1213 printf (" %s%i\n", _("Number of retries to be used in the requests, default: "), DEFAULT_RETRIES);
1202 1214
1203 printf (" %s\n", "-O, --perf-oids"); 1215 printf (" %s\n", "-O, --perf-oids");
1204 printf (" %s\n", _("Label performance data with OIDs instead of --label's")); 1216 printf (" %s\n", _("Label performance data with OIDs instead of --label's"));
@@ -1245,5 +1257,5 @@ print_usage (void)
1245 printf ("[-C community] [-s string] [-r regex] [-R regexi] [-t timeout] [-e retries]\n"); 1257 printf ("[-C community] [-s string] [-r regex] [-R regexi] [-t timeout] [-e retries]\n");
1246 printf ("[-l label] [-u units] [-p port-number] [-d delimiter] [-D output-delimiter]\n"); 1258 printf ("[-l label] [-u units] [-p port-number] [-d delimiter] [-D output-delimiter]\n");
1247 printf ("[-m miblist] [-P snmp version] [-N context] [-L seclevel] [-U secname]\n"); 1259 printf ("[-m miblist] [-P snmp version] [-N context] [-L seclevel] [-U secname]\n");
1248 printf ("[-a authproto] [-A authpasswd] [-x privproto] [-X privpasswd]\n"); 1260 printf ("[-a authproto] [-A authpasswd] [-x privproto] [-X privpasswd] [-4|6]\n");
1249} 1261}