nic-monitor¶
Monitors Linux physical NICs. The script finds physical NICs via /sys/class/net, reads vendor statistics counters via ethtool first, falling back to /proc/net/dev on failure. It supports foreground real-time refresh or background sampling to disk with phase statistics.
← Back to UCM Toolkit
Dependencies¶
- Linux,
bash,ethtool, and root or sudo privileges to read NIC statistics. - NIC CSV offline plotting:
pandas,matplotlib.
Because ethtool statistics access is required, root or sudo is typically needed:
sudo ucm-toolkit run nic-monitor fg
Foreground Mode¶
Foreground mode refreshes the terminal in real-time without writing to disk:
sudo ucm-toolkit run nic-monitor fg
sudo ucm-toolkit run nic-monitor fg 5
Parameters:
| Parameter | Default | Description |
|---|---|---|
fg [interval_sec] |
2 |
Foreground refresh interval in seconds. |
Press Ctrl+C to stop.
Background Mode¶
Background mode creates .log, .csv, and .pid files and continuously writes sampling data to CSV:
sudo ucm-toolkit run nic-monitor bg
sudo ucm-toolkit run nic-monitor bg 24 5
sudo ucm-toolkit run nic-monitor bg 24 5 --log-dir /mnt/test/net_log
sudo ucm-toolkit run nic-monitor bg 24 5 --log-dir /mnt/test/net_log --stat-cycle-seconds 600
Parameters:
| Parameter | Default | Description |
|---|---|---|
bg [duration_hours] [interval_sec] |
12 10 |
Background run duration and sampling interval. |
--log-dir PATH |
net_log in current working directory |
Output directory for logs, CSV, and PID files. |
--stat-cycle-seconds SECONDS |
3600 |
Phase statistics cycle in seconds. |
Output filename format:
Eth_Perf_Monitor_YYYYmmdd_HHMMSS.log
Eth_Perf_Monitor_YYYYmmdd_HHMMSS.csv
Eth_Perf_Monitor_YYYYmmdd_HHMMSS.pid
On background start, it checks whether a live .pid process already exists in the same --log-dir to prevent duplicate launches.
NIC Result Visualization¶
toolkit/src/nic_monitor also provides two offline visualization entry points. They are not currently registered as ucm-toolkit run top-level tools.
Python Plotting¶
Install dependencies:
python -m pip install pandas matplotlib
Generate PNG charts:
python toolkit/src/nic_monitor/visualize_traffic.py net_log/Eth_Perf_Monitor_*.csv -o net_log/charts
python toolkit/src/nic_monitor/visualize_traffic.py net_log/Eth_Perf_Monitor_*.csv -o net_log/charts -i eth0 eth1
Parameters:
| Parameter | Default | Description |
|---|---|---|
csv |
*.csv in current directory |
Input CSV files, multiple allowed. |
-o, --output |
. |
Image output directory. |
-i, --interfaces |
All NICs | Plot only specified NICs, multiple names allowed. |
Each CSV generates a subdirectory with the same name, containing PNGs for traffic timeline, utilization timeline, total traffic stacked, and statistical summary.
Browser Page¶
Can be opened directly:
toolkit/src/nic_monitor/index.html
The page supports uploading or dragging CSV files generated by nic-monitor bg and viewing interactive charts in the browser.
FAQ¶
Permission Denied¶
Run with root or sudo:
sudo ucm-toolkit run nic-monitor fg
sudo ucm-toolkit run nic-monitor bg 12 10
Also confirm that ethtool is installed on the system.