• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

README.mdH A D05-Dec-20193.3 KiB8463

dump.rsH A D31-Oct-2019477 1915

interface_stats.rsH A D27-Oct-20191.5 KiB4638

netstat.rsH A D27-Dec-20191.6 KiB5339

pressure.rsH A D12-Nov-2019260 85

ps.rsH A D31-Oct-2019834 2617

self_memory.rsH A D05-Dec-20191.8 KiB5849

README.md

1# Examples
2
3These examples can be run by running `cargo run --example example_name`
4
5## dump.rs
6
7Prints out details about the current process (the dumper itself), or a process specifed by PID
8
9## interface_stats.rs
10
11Runs continually and prints out how many bytes/packets are sent/received.  Press ctrl-c to exit the example:
12
13```
14       Interface: bytes recv                         bytes sent
15================  ====================               ====================
16 br-883c4c992deb: 823307769                0.2 kbps  1537694158               0.5 kbps
17 br-d73af6e6d094: 9137600399               0.9 kbps  2334717319               0.4 kbps
18         docker0: 2938964881               0.6 kbps  19291691656             11.4 kbps
19 docker_gwbridge: 1172300                  0.0 kbps  15649536                 0.0 kbps
20        enp5s0f0: 44643307888420        5599.8 kbps  1509415976135           99.0 kbps
21        enp5s0f1: 0                        0.0 kbps  0                        0.0 kbps
22              lo: 161143108162             0.4 kbps  161143108162             0.4 kbps
23     veth3154ff3: 3809619534               1.0 kbps  867529906                0.4 kbps
24     veth487bc9b: 2650532684               0.8 kbps  2992458899               0.9 kbps
25     veth8cb8ca8: 3234030733               0.7 kbps  16921098378             11.4 kbps
26     vethbadbe14: 12007615348              3.8 kbps  15583195644              5.0 kbps
27     vethc152f93: 978828                   0.0 kbps  3839134                  0.0 kbps
28     vethe481f30: 1637142                  0.0 kbps  15805768                 0.0 kbps
29     vethfac2e83: 19445827683              6.2 kbps  16194181515              5.1 kbps
30
31```
32
33## netstat.rs
34
35Prints out all open and listening TCP/UDP sockets, along with the owning process.  The
36output format is very similar to the standard `netstat` linux utility:
37
38```
39Local address              Remote address             State           Inode    PID/Program name
400.0.0.0:53                 0.0.0.0:0                  Listen          30883        1409/pdns_server
410.0.0.0:51413              0.0.0.0:0                  Listen          24263        927/transmission-da
420.0.0.0:35445              0.0.0.0:0                  Listen          21777        942/rpc.mountd
430.0.0.0:22                 0.0.0.0:0                  Listen          27973        1149/sshd
440.0.0.0:25                 0.0.0.0:0                  Listen          28295        1612/master
45```
46
47## pressure.rs
48
49Prints out CPU/IO/Memory pressure information
50
51## ps.rs
52
53Prints out all processes that share the same tty as the current terminal.  This is very similar to the standard
54`ps` utility on linux when run with no arguments:
55
56```
57  PID TTY          TIME CMD
58 8369 pty/13       4.05 bash
5923124 pty/13       0.23 basic-http-serv
6024206 pty/13       0.11 ps
61```
62
63## self_memory.rs
64
65Shows several ways to get the current memory usage of the current process
66
67```
68PID: 21867
69Memory page size: 4096
70== Data from /proc/self/stat:
71Total virtual memory used: 3436544 bytes
72Total resident set: 220 pages (901120 bytes)
73
74== Data from /proc/self/statm:
75Total virtual memory used: 839 pages (3436544 bytes)
76Total resident set: 220 pages (901120 byte)s
77Total shared memory: 191 pages (782336 bytes)
78
79== Data from /proc/self/status:
80Total virtual memory used: 3436544 bytes
81Total resident set: 901120 bytes
82Total shared memory: 782336 bytes
83```
84