misc: make the pattern matching case-insensitive
To improve the usability better use case-insensitive pattern-matching in ifstat, nstat and ss tools. Signed-off-by: Anton Danilov <littlesmilingcloud@gmail.com> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
This commit is contained in:
parent
66702fb9ba
commit
8f5a602f7a
|
|
@ -14,6 +14,13 @@ and
|
||||||
.B rtacct
|
.B rtacct
|
||||||
are simple tools to monitor kernel snmp counters and network interface statistics.
|
are simple tools to monitor kernel snmp counters and network interface statistics.
|
||||||
|
|
||||||
|
.B nstat
|
||||||
|
can filter kernel snmp counters by name with one or several specified wildcards. Wildcards are case-insensitive and can include special symbols
|
||||||
|
.B ?
|
||||||
|
and
|
||||||
|
.B *
|
||||||
|
.
|
||||||
|
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.B \-h, \-\-help
|
.B \-h, \-\-help
|
||||||
Print help
|
Print help
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ static int match(const char *id)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
for (i = 0; i < npatterns; i++) {
|
for (i = 0; i < npatterns; i++) {
|
||||||
if (!fnmatch(patterns[i], id, 0))
|
if (!fnmatch(patterns[i], id, FNM_CASEFOLD))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ static int match(const char *id)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
for (i = 0; i < npatterns; i++) {
|
for (i = 0; i < npatterns; i++) {
|
||||||
if (!fnmatch(patterns[i], id, 0))
|
if (!fnmatch(patterns[i], id, FNM_CASEFOLD))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -1670,7 +1670,7 @@ static int unix_match(const inet_prefix *a, const inet_prefix *p)
|
||||||
return 1;
|
return 1;
|
||||||
if (addr == NULL)
|
if (addr == NULL)
|
||||||
addr = "";
|
addr = "";
|
||||||
return !fnmatch(pattern, addr, 0);
|
return !fnmatch(pattern, addr, FNM_CASEFOLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int run_ssfilter(struct ssfilter *f, struct sockstat *s)
|
static int run_ssfilter(struct ssfilter *f, struct sockstat *s)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue