|
@@ -144,6 +144,25 @@ double previous_value[MAX_OIDS];
|
|
|
int perf_labels = 1;
|
|
int perf_labels = 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+static char *fix_snmp_range(char *th)
|
|
|
|
|
+{
|
|
|
|
|
+ double left, right;
|
|
|
|
|
+ char *colon, *ret;
|
|
|
|
|
+ if (!(colon = strchr(th, ':')))
|
|
|
|
|
+ return th;
|
|
|
|
|
+ *colon = 0;
|
|
|
|
|
+
|
|
|
|
|
+ left = strtod(th, NULL);
|
|
|
|
|
+ right = strtod(colon + 1, NULL);
|
|
|
|
|
+ if (right >= left) {
|
|
|
|
|
+ return th;
|
|
|
|
|
+ }
|
|
|
|
|
+ ret = malloc(strlen(th) + strlen(colon + 1) + 2);
|
|
|
|
|
+ sprintf(ret, "@%s:%s", colon + 1, th);
|
|
|
|
|
+ free(th);
|
|
|
|
|
+ return ret;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
int
|
|
int
|
|
|
main (int argc, char **argv)
|
|
main (int argc, char **argv)
|
|
|
{
|
|
{
|
|
@@ -228,6 +247,10 @@ main (int argc, char **argv)
|
|
|
for (i=0; i<numoids; i++) {
|
|
for (i=0; i<numoids; i++) {
|
|
|
char *w = th_warn ? strndup(th_warn, strcspn(th_warn, ",")) : NULL;
|
|
char *w = th_warn ? strndup(th_warn, strcspn(th_warn, ",")) : NULL;
|
|
|
char *c = th_crit ? strndup(th_crit, strcspn(th_crit, ",")) : NULL;
|
|
char *c = th_crit ? strndup(th_crit, strcspn(th_crit, ",")) : NULL;
|
|
|
|
|
+ /* translate "2:1" to "@1:2" for backwards compatibility */
|
|
|
|
|
+ w = w ? fix_snmp_range(w) : NULL;
|
|
|
|
|
+ c = c ? fix_snmp_range(c) : NULL;
|
|
|
|
|
+
|
|
|
/* Skip empty thresholds, while avoiding segfault */
|
|
/* Skip empty thresholds, while avoiding segfault */
|
|
|
set_thresholds(&thlds[i],
|
|
set_thresholds(&thlds[i],
|
|
|
w ? strpbrk(w, NP_THRESHOLDS_CHARS) : NULL,
|
|
w ? strpbrk(w, NP_THRESHOLDS_CHARS) : NULL,
|