1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-11-28 00:39:23 +02:00

package/wprobe: {enhancement} make printing attributes optional. A delay interval (-d option) of 0 (zero) dumps the data once then exit. (closes #8107)

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@24892 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
acoul 2011-01-03 16:37:07 +00:00
parent 25b18586e6
commit 441ac131a2

View File

@ -149,8 +149,10 @@ static int usage(const char *prog)
#endif #endif
"\n" "\n"
"Options:\n" "Options:\n"
" -a: Print attributes\n"
" -c: Only apply configuration\n" " -c: Only apply configuration\n"
" -d: Delay between measurement dumps (in milliseconds, default: 1000)\n" " -d: Delay between measurement dumps (in milliseconds, default: 1000)\n"
" A value of 0 (zero) prints once and exits; useful for scripts\n"
" -f: Dump contents of layer 2 filter counters during measurement\n" " -f: Dump contents of layer 2 filter counters during measurement\n"
" -F <file>: Apply layer 2 filters from <file>\n" " -F <file>: Apply layer 2 filters from <file>\n"
" -h: This help text\n" " -h: This help text\n"
@ -205,13 +207,14 @@ static void show_filter(void *arg, const char *group, struct wprobe_filter_item
static void loop_measurement(struct wprobe_iface *dev, bool print_filters, unsigned long delay) static void loop_measurement(struct wprobe_iface *dev, bool print_filters, unsigned long delay)
{ {
while (1) { do {
usleep(delay * 1000);
wprobe_update_links(dev); wprobe_update_links(dev);
wprobe_dump_data(dev); wprobe_dump_data(dev);
if (print_filters) if (print_filters)
wprobe_dump_filters(dev, simple_mode ? show_filter_simple : show_filter, NULL); wprobe_dump_filters(dev, simple_mode ? show_filter_simple : show_filter, NULL);
usleep(delay * 1000);
} }
while (delay);
} }
static void set_filter(struct wprobe_iface *dev, const char *filename) static void set_filter(struct wprobe_iface *dev, const char *filename)
@ -342,6 +345,7 @@ int main(int argc, char **argv)
CMD_PROXY, CMD_PROXY,
} cmd = CMD_NONE; } cmd = CMD_NONE;
const char *filter = NULL; const char *filter = NULL;
bool print_attributes = false;
bool print_filters = false; bool print_filters = false;
unsigned long delay = 1000; unsigned long delay = 1000;
int interval = -1; int interval = -1;
@ -373,8 +377,11 @@ int main(int argc, char **argv)
argv++; argv++;
argc--; argc--;
while ((ch = getopt(argc, argv, "cd:fF:hi:msp:")) != -1) { while ((ch = getopt(argc, argv, "acd:fF:hi:msp:")) != -1) {
switch(ch) { switch(ch) {
case 'a':
print_attributes = true;
break;
case 'c': case 'c':
cmd = CMD_CONFIG; cmd = CMD_CONFIG;
break; break;
@ -430,8 +437,10 @@ int main(int argc, char **argv)
wprobe_apply_config(dev); wprobe_apply_config(dev);
} }
if (cmd != CMD_CONFIG) if (cmd != CMD_CONFIG) {
show_attributes(dev); if (print_attributes)
show_attributes(dev);
}
if (cmd == CMD_MEASURE) if (cmd == CMD_MEASURE)
loop_measurement(dev, print_filters, delay); loop_measurement(dev, print_filters, delay);