diff options
Diffstat (limited to 'procps/nmeter.c')
-rw-r--r-- | procps/nmeter.c | 50 |
1 files changed, 45 insertions, 5 deletions
diff --git a/procps/nmeter.c b/procps/nmeter.c index 7836a90d5..ac019eb53 100644 --- a/procps/nmeter.c +++ b/procps/nmeter.c | |||
@@ -6,6 +6,40 @@ | |||
6 | * Contact me: vda.linux@googlemail.com | 6 | * Contact me: vda.linux@googlemail.com |
7 | */ | 7 | */ |
8 | 8 | ||
9 | //config:config NMETER | ||
10 | //config: bool "nmeter" | ||
11 | //config: default y | ||
12 | //config: help | ||
13 | //config: Prints selected system stats continuously, one line per update. | ||
14 | |||
15 | //applet:IF_NMETER(APPLET(nmeter, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | ||
16 | |||
17 | //kbuild:lib-$(CONFIG_NMETER) += nmeter.o | ||
18 | |||
19 | //usage:#define nmeter_trivial_usage | ||
20 | //usage: "[-d MSEC] FORMAT_STRING" | ||
21 | //usage:#define nmeter_full_usage "\n\n" | ||
22 | //usage: "Monitor system in real time" | ||
23 | //usage: "\n" | ||
24 | //usage: "\n -d MSEC Milliseconds between updates (default:1000)" | ||
25 | //usage: "\n" | ||
26 | //usage: "\nFormat specifiers:" | ||
27 | //usage: "\n %Nc or %[cN] Monitor CPU. N - bar size (default:10)" | ||
28 | //usage: "\n (displays: S:system U:user N:niced D:iowait I:irq i:softirq)" | ||
29 | //usage: "\n %[niface] Monitor network interface 'iface'" | ||
30 | //usage: "\n %m Monitor allocated memory" | ||
31 | //usage: "\n %[mf] Monitor free memory" | ||
32 | //usage: "\n %[mt] Monitor total memory" | ||
33 | //usage: "\n %s Monitor allocated swap" | ||
34 | //usage: "\n %f Monitor number of used file descriptors" | ||
35 | //usage: "\n %Ni Monitor total/specific IRQ rate" | ||
36 | //usage: "\n %x Monitor context switch rate" | ||
37 | //usage: "\n %p Monitor forks" | ||
38 | //usage: "\n %[pn] Monitor # of processes" | ||
39 | //usage: "\n %b Monitor block io" | ||
40 | //usage: "\n %Nt Show time (with N decimal points)" | ||
41 | //usage: "\n %r Print <cr> instead of <lf> at EOL" | ||
42 | |||
9 | //TODO: | 43 | //TODO: |
10 | // simplify code | 44 | // simplify code |
11 | // /proc/locks | 45 | // /proc/locks |
@@ -769,6 +803,7 @@ static void FAST_FUNC collect_info(s_stat *s) | |||
769 | 803 | ||
770 | typedef s_stat* init_func(const char *param); | 804 | typedef s_stat* init_func(const char *param); |
771 | 805 | ||
806 | // Deprecated %NNNd is to be removed, -d MSEC supersedes it | ||
772 | static const char options[] ALIGN1 = "ncmsfixptbdr"; | 807 | static const char options[] ALIGN1 = "ncmsfixptbdr"; |
773 | static init_func *const init_functions[] = { | 808 | static init_func *const init_functions[] = { |
774 | init_if, | 809 | init_if, |
@@ -792,23 +827,28 @@ int nmeter_main(int argc UNUSED_PARAM, char **argv) | |||
792 | s_stat *first = NULL; | 827 | s_stat *first = NULL; |
793 | s_stat *last = NULL; | 828 | s_stat *last = NULL; |
794 | s_stat *s; | 829 | s_stat *s; |
830 | char *opt_d; | ||
795 | char *cur, *prev; | 831 | char *cur, *prev; |
796 | 832 | ||
797 | INIT_G(); | 833 | INIT_G(); |
798 | 834 | ||
799 | xchdir("/proc"); | 835 | xchdir("/proc"); |
800 | 836 | ||
801 | if (!argv[1]) | ||
802 | bb_show_usage(); | ||
803 | |||
804 | if (open_read_close("version", buf, sizeof(buf)-1) > 0) { | 837 | if (open_read_close("version", buf, sizeof(buf)-1) > 0) { |
805 | buf[sizeof(buf)-1] = '\0'; | 838 | buf[sizeof(buf)-1] = '\0'; |
806 | is26 = (strstr(buf, " 2.4.") == NULL); | 839 | is26 = (strstr(buf, " 2.4.") == NULL); |
807 | } | 840 | } |
808 | 841 | ||
809 | // Can use argv[1] directly, but this will mess up | 842 | if (getopt32(argv, "d:", &opt_d)) |
843 | init_delay(opt_d); | ||
844 | argv += optind; | ||
845 | |||
846 | if (!argv[0]) | ||
847 | bb_show_usage(); | ||
848 | |||
849 | // Can use argv[0] directly, but this will mess up | ||
810 | // parameters as seen by e.g. ps. Making a copy... | 850 | // parameters as seen by e.g. ps. Making a copy... |
811 | cur = xstrdup(argv[1]); | 851 | cur = xstrdup(argv[0]); |
812 | while (1) { | 852 | while (1) { |
813 | char *param, *p; | 853 | char *param, *p; |
814 | prev = cur; | 854 | prev = cur; |