### Start nlbwmon Daemon with Various Configurations Source: https://context7.com/jow-/nlbwmon/llms.txt Demonstrates starting the nlbwmon daemon with different configurations for network interfaces, data storage, polling intervals, and accounting periods. Use the `-Z` flag to compress archive databases with gzip. ```sh nlbwmon \ -s 192.168.1.0/24 \ -s fd00::/8 \ -i 3600 \ -r 30 \ -o /var/lib/nlbwmon \ -p /usr/share/nlbwmon/protocols \ -G 6 \ -I 1 \ -Z ``` ```sh nlbwmon -s 192.168.1.0/24 -I 2024-01-01/14 -o /var/lib/nlbwmon ``` ```sh nlbwmon -s 192.168.1.0/24 -I 25 -o /var/lib/nlbwmon ``` ```sh nlbwmon -s 192.168.1.0/24 -L 500 -P -Z -o /tmp/nlbwmon ``` ```sh # Increase netlink receive buffer for high-traffic routers (requires rmem_max >= 2M) # sysctl -w net.core.rmem_max=2097152 nlbwmon -s 192.168.1.0/24 -b 2097152 -o /var/lib/nlbwmon ``` -------------------------------- ### Example UCI Configuration for nlbwmon Source: https://context7.com/jow-/nlbwmon/llms.txt An example of how to configure nlbwmon using the UCI system in OpenWrt/LEDE, specifying commit interval, refresh interval, protocol database path, and database directory. ```uci # config nlbwmon # option commit_interval '3600' # option refresh_interval '30' # option protocol_db '/usr/share/nlbwmon/protocols' # option database_dir '/var/lib/nlbwmon' ``` -------------------------------- ### Control nlbwmon Service Source: https://context7.com/jow-/nlbwmon/llms.txt These commands are used to start, stop, and enable the nlbwmon service using its init script. Enabling the service ensures it starts automatically on system boot. ```shell /etc/init.d/nlbwmon start ``` ```shell /etc/init.d/nlbwmon stop ``` ```shell /etc/init.d/nlbwmon enable # autostart on boot ``` -------------------------------- ### nlbwmon Daemon Accounting Period Configuration Source: https://github.com/jow-/nlbwmon/blob/master/README.md Define the accounting period interval. This can be set to start a new period every NN days from a specific date or on a particular day of the month. ```bash -I interval Accounting period interval. May be either in the format YYYY-MM-DD/NN, to start a new accounting period exactly every NN days, beginning at the given date, or a number specifiying the day of month at which to start the next accounting period. For example: 2017-01-17/14 # every 14 days, starting Jan 17, 2017 -2 # second to the last day of the month, e.g. 30th in March 1 # first day of the month (default) ``` -------------------------------- ### List available databases Source: https://github.com/jow-/nlbwmon/blob/master/README.md Use the 'list' command to list available databases. Select a database to read from, and specify it with the -t option. ```shell list ``` -------------------------------- ### OpenWrt/LEDE Package Feed Integration Source: https://context7.com/jow-/nlbwmon/llms.txt Instructions for adding nlbwmon as a package feed in an OpenWrt/LEDE build environment. This allows configuration via UCI. ```bash # Add to LEDE/OpenWrt build environment: cp feeds.conf.default feeds.conf echo "src-git nlbwmon https://github.com/jow-/nlbwmon.git" >> feeds.conf ./scripts/feeds update nlbwmon ./scripts/feeds install nlbwmon make menuconfig # find nlbwmon under Network > Bandwidth Monitoring ``` -------------------------------- ### nlbwmon Daemon Memory Preallocation and Compression Options Source: https://github.com/jow-/nlbwmon/blob/master/README.md Configure options for preallocating database size in memory and for gzip compressing archive databases. These settings can help manage memory usage and storage space. ```bash -P Whether to preallocate the maximum possible database size in memory. This is mainly useful for memory constrained systems which might not be able to satisfy memory allocation after longer uptime periods. Only effective in conjunction with database_limit, ignored otherwise. ``` ```bash -Z Whether to gzip compress archive databases. Compressing the database files makes accessing old data slightly slower but helps to reduce storage requirements. ``` -------------------------------- ### Configure nlbwmon Options Source: https://context7.com/jow-/nlbwmon/llms.txt These options configure the behavior of the nlbwmon daemon, including database limits, preallocation, compression, generation limits, and accounting intervals. They are typically set in a configuration file. ```shell # option database_limit '0' # option database_prealloc '0' # option database_compress '1' # option generation_limit '10' # option interval '1' # list network 'lan' # list network 'guest' ``` -------------------------------- ### Daemon Preallocate Record Slots Source: https://context7.com/jow-/nlbwmon/llms.txt Preallocate all record slots at startup when a hard cap (-L) is set. This can improve performance by avoiding dynamic allocation during runtime. ```bash nlbwmon -L 500 -P -s 192.168.0.0/24 -I 1 ``` -------------------------------- ### Add nlbwmon as a package feed Source: https://github.com/jow-/nlbwmon/blob/master/README.md Integrate the nlbwmon repository into your build environment by adding it to the feeds.conf file and updating the feeds. ```shell cp feeds.conf.default feeds.conf echo "src-git nlbwmon https://github.com/jow-/nlbwmon.git" >> feeds.conf ./scripts/feeds update nlbwmon ./scripts/feeds install nlbwmon ``` -------------------------------- ### nlbw Client Protocol and Output Formatting Source: https://github.com/jow-/nlbwmon/blob/master/README.md Specify the protocol description file and control output formatting for grouping, ordering, and numerical representation. These options customize how statistics are displayed. ```bash -p /path/to/procol-database Protocol description file, used to distinguish traffic streams by IP protocol number and port. ``` ```bash -g col[,col] Group output by the specified column. Prefix column with a - to invert order. ``` ```bash -o col[,col] Order output by the specified column. Prefix column with a - to invert order. ``` ```bash -n Use plain numbers, dont divide to get K, M, G, etc. ``` -------------------------------- ### nlbwmon Daemon Protocol and Database Retention Configuration Source: https://github.com/jow-/nlbwmon/blob/master/README.md Configure the protocol description file and the number of database generations to retain. This affects how traffic is classified and how much historical data is kept. ```bash -p /path/to/protocol-file Protocol description file, used to distinguish traffic streams by IP protocol number and port. ``` ```bash -G count Number of database generations to retain. After the limit is reached, the oldest database files are deleted. The default is 10. ``` -------------------------------- ### nlbwmon Daemon Network and Storage Configuration Source: https://github.com/jow-/nlbwmon/blob/master/README.md Specify the network subnet to monitor and the directory for storing database files. This helps in defining the scope of monitoring and data persistence. ```bash -s network Specify network subnet to monitor. ``` ```bash -o /path/to/database-folder Storage directory for the database files. ``` -------------------------------- ### nlbwmon Daemon Configuration Intervals Source: https://github.com/jow-/nlbwmon/blob/master/README.md Configure the intervals for saving in-memory databases and polling conntrack entries. These options control how frequently data is persisted and updated. ```bash -i sec Interval used to save in-memory database to file. ``` ```bash -r sec Interval used to poll the conntrack entries. ``` -------------------------------- ### Daemon Netlink Buffer Size Configuration Source: https://context7.com/jow-/nlbwmon/llms.txt Configure the Netlink receive buffer size for the nlbwmon daemon. This value must not exceed the system's `net.core.rmem_max` limit. ```bash nlbwmon -b 1048576 -s 10.0.0.0/8 -I 1 ``` -------------------------------- ### Flush In-Memory Database to Disk Source: https://context7.com/jow-/nlbwmon/llms.txt Force the nlbwmon daemon to immediately write its current in-memory database to persistent storage. Recommended before system reboots to prevent data loss. ```bash nlbw -c commit # 0 ok # In a shutdown script: nlbw -c commit && echo "nlbwmon DB flushed" || echo "flush failed" # Using a non-default socket path (if daemon was started with a custom socket) nlbw -S /run/nlbwmon-lan.sock -c commit ``` -------------------------------- ### Control nlbwmon Daemon with Signals Source: https://context7.com/jow-/nlbwmon/llms.txt Shows how to send signals to the nlbwmon daemon for operations like flushing the in-memory database to disk. SIGTERM initiates a clean shutdown, while SIGUSR1 forces a flush. ```sh # Signals: SIGTERM = clean shutdown (removes temp DB), SIGUSR1 = flush to disk kill -USR1 $(pidof nlbwmon) # flush in-memory DB to disk before reboot ``` -------------------------------- ### Daemon Gzip Compression for Archives Source: https://context7.com/jow-/nlbwmon/llms.txt Enable Gzip compression for archived databases. This reduces file size at the cost of slightly slower read operations. ```bash nlbwmon -Z -s 192.168.0.0/24 -I 1 ``` -------------------------------- ### nlbw Client Socket and Command Specification Source: https://github.com/jow-/nlbwmon/blob/master/README.md Specify the path to the Unix domain socket for the nlbw client and the command to execute. Supported commands include show, json, csv, list, and commit. ```bash -S /path/to/domain.socket Path to unix domain socket. Default is /var/run/nlbwmon.sock. This should not be required unless the daemon was instructed to use another socket path for some reason. ``` ```bash -c command Specify a command. Current commands are: show, json, csv, list, commit. See below for more information about commands. ``` -------------------------------- ### Daemon Database Commit Interval Configuration Source: https://context7.com/jow-/nlbwmon/llms.txt Set the interval for flushing the in-memory database to disk. Supports time suffixes like 's', 'm', 'h', 'd', 'w'. ```bash # save to disk every hour nlbwmon -i 1h -s 192.168.0.0/24 -I 1 # save every 30 minutes nlbwmon -i 30m -s 192.168.0.0/24 -I 1 ``` -------------------------------- ### CSV Output Configuration Source: https://context7.com/jow-/nlbwmon/llms.txt Configure CSV output with custom separators and quoting. Useful for importing data into spreadsheets or parsing with command-line tools. ```bash # Default: tab-separated with double-quote quoting (by MAC) nlbw -c csv -g mac -o mac # mac conns rx_bytes rx_pkts tx_bytes tx_pkts # 00:00:00:00:00:00 411 72968 751 61428 767 # 34:02:86:17:5e:03 598 239950465 171095 5715237 86155 ``` ```bash # No quoting, pipe separator — for simple awk/cut pipelines nlbw -c csv -g mac -o mac -q -s '|' # mac|conns|rx_bytes|rx_pkts|tx_bytes|tx_pkts # 00:00:00:00:00:00|411|72968|751|61428|767 ``` ```bash # Read a specific historical period (billing cycle starting 2017-02-01) nlbw -c csv -g mac -o mac -q -t 2017-02-01 # mac conns rx_bytes rx_pkts tx_bytes tx_pkts # 34:02:86:17:5e:03 327 117213007 83817 3366892 51560 ``` ```bash # Per-host per-protocol CSV — useful for detailed charting nlbw -c csv -g host,layer7 -o -rx_bytes ``` -------------------------------- ### Display Human-Readable Traffic Table with nlbw Client Source: https://context7.com/jow-/nlbwmon/llms.txt Queries the nlbw daemon for traffic statistics and displays them in a formatted table. The output can be grouped and sorted by various criteria. Use the `-n` flag for plain byte/packet counts, suitable for scripting. ```sh # Default view: per-host, per-protocol breakdown nlbw -c show # Fam Host ( MAC ) Layer7 Conn. > Downld. ( > Pkts. ) Upload ( Pkts. ) # IPv4 10.11.12.7 (47:e1:b9) HTTPS 111 2.99 MB ( 4.38 K) 816.77 KB ( 5.86 K) # IPv6 2001:470:527e::6666:b3ff:fe47:e1b9 (47:e1:b9) HTTP 15 296.07 KB ( 194 ) 28.67 KB ( 329 ) ``` ```sh # Group by MAC + IP family, order by connection count ascending nlbw -c show -g mac,fam -o conn # Fam MAC < Conn. Downld. ( Pkts. ) Upload ( Pkts. ) # IPv4 64:66:b3:47:e1:b9 501 3.12 MB ( 5.19 K) 905.20 KB ( 6.79 K) ``` ```sh # Group by MAC only, sort by connections descending then upload descending nlbw -c show -g mac -o -conn,-tx # MAC > Conn. Downld. ( Pkts. ) > Upload ( Pkts. ) # 64:66:b3:47:e1:b9 542 3.96 MB ( 6.38 K) 1.12 MB ( 8.16 K) ``` ```sh # Use plain byte/packet counts (no K/M/G suffixes) — useful for scripts nlbw -c show -g mac -n ``` -------------------------------- ### Write in-memory data to database file Source: https://github.com/jow-/nlbwmon/blob/master/README.md Use the 'commit' command to write data stored in memory to the database file. This is useful just before a reboot. ```shell commit ``` -------------------------------- ### Protocol Database Format Source: https://context7.com/jow-/nlbwmon/llms.txt Defines the format for the `protocols.txt` file used for layer 7 classification. Each line specifies IP protocol, destination port, and protocol name. ```text # Format: ip_proto dst_port name # ip_proto: 6=TCP, 17=UDP, 1=ICMP, 58=ICMPv6, 0=any-port wildcard 1 0 ICMP 6 22 SSH 6 80 HTTP 17 80 QUIC 6 443 HTTPS 17 443 QUIC 6 853 DNS-over-TLS 17 5353 mDNS 6 3389 Microsoft RDP 58 0 IPv6-ICMP # To disable layer7 classification (saves memory on constrained devices): # Truncate the file: echo -n > /usr/share/nlbwmon/protocols # Custom entry — track a Wireguard server on UDP/51820: # echo "17 51820 WireGuard" >> /usr/share/nlbwmon/protocols # Then send SIGUSR1 to reload: kill -USR1 $(pidof nlbwmon) ``` -------------------------------- ### Output stats in CSV format Source: https://github.com/jow-/nlbwmon/blob/master/README.md Use the 'csv' command to output statistics in CSV format. ```shell csv ``` -------------------------------- ### Read Historical Data (JSON Output) Source: https://context7.com/jow-/nlbwmon/llms.txt Query historical network data from the database in JSON format. Specify the date to retrieve data for a specific period. ```bash nlbw -c json -g mac -t 2024-02-01 # {"columns":["mac","conns","rx_bytes","rx_pkts","tx_bytes","tx_pkts"], # "data":[["34:02:86:17:5e:03",327,117213007,83817,3366892,51560], ...]} ``` -------------------------------- ### JSON Output for Raw Database Values Source: https://github.com/jow-/nlbwmon/blob/master/README.md Dumps the raw database values in JSON format. This is useful for programmatic access to the collected network data. ```bash root@jj:~# nlbw -c json ... ``` -------------------------------- ### List Available Database Periods Source: https://context7.com/jow-/nlbwmon/llms.txt Retrieve a list of all archived database periods. The dates returned can be used with the `-t` flag to query specific historical data. ```bash nlbw -c list # 2024-01-01 # 2024-02-01 # 2024-03-01 # 2024-04-01 # Then query a specific period nlbw -c show -t 2024-02-01 -g mac -o -rx_bytes ``` -------------------------------- ### Daemon Conntrack Poll Interval Configuration Source: https://context7.com/jow-/nlbwmon/llms.txt Configure how often the nlbwmon daemon polls the conntrack table. Lower values provide more real-time data but increase system load. ```bash nlbwmon -r 10 -s 192.168.0.0/24 -I 1 # poll conntrack every 10 seconds ``` -------------------------------- ### Output Traffic Data in JSON Format with nlbw Client Source: https://context7.com/jow-/nlbwmon/llms.txt Generates a JSON output containing traffic statistics, suitable for integration with other tools and dashboards. The output structure includes 'columns' and 'data' arrays. Grouping options can simplify the output by reducing the number of columns. ```sh # Full per-host/per-protocol JSON dump (default grouping) nlbw -c json # {"columns":["family","mac","ip","proto","port","conns","rx_bytes","rx_pkts","tx_bytes","tx_pkts"], # "data":[[4,"64:66:b3:47:e1:b9","10.11.12.7","TCP",443,111,3136872,4485,836372,5996], ...]} ``` ```sh # Group by MAC address only — fewer columns in output nlbw -c json -g mac # {"columns":["mac","conns","rx_bytes","rx_pkts","tx_bytes","tx_pkts"], # "data":[["64:66:b3:47:e1:b9",542,4152934,6528,1176432,8342], ...]} ``` -------------------------------- ### nlbw Client Date-Specific Data Retrieval Source: https://github.com/jow-/nlbwmon/blob/master/README.md Read data from a specified database date instead of the active one. Use the 'list' command to see available databases. ```bash -t YYYY-MM-DD Read data from the specified database, instead of the active database. Use the list command to view available databases. ``` -------------------------------- ### Show Network Traffic Source: https://github.com/jow-/nlbwmon/blob/master/README.md Displays network traffic statistics. Use flags like -g to group and -o to order the output. ```bash root@jj:~# nlbw -c show Fam Host ( MAC ) Layer7 Conn. > Downld. ( > Pkts. ) Upload ( Pkts. ) IPv4 10.11.12.7 (47:e1:b9) HTTPS 111 2.99 MB ( 4.38 K) 816.77 KB ( 5.86 K) IPv6 2001:470:527e::6666:b3ff:fe47:e1b9 (47:e1:b9) HTTPS 14 546.07 KB ( 930 ) 196.05 KB ( 932 ) IPv6 2001:470:527e::6666:b3ff:fe47:e1b9 (47:e1:b9) HTTP 15 296.07 KB ( 194 ) 28.67 KB ( 329 ) IPv4 10.11.12.167 (a3:5c:1c) HTTPS 24 210.53 KB ( 299 ) 61.86 KB ( 400 ) IPv4 10.11.12.17 (2c:97:19) HTTPS 31 163.54 KB ( 481 ) 352.28 KB ( 593 ) IPv4 10.11.12.7 (47:e1:b9) other 353 104.52 KB ( 610 ) 64.79 KB ( 709 ) IPv4 10.11.12.15 (94:59:06) HTTPS 6 49.48 KB ( 85 ) 18.36 KB ( 103 ) IPv4 10.11.12.7 (47:e1:b9) HTTP 24 14.24 KB ( 152 ) 16.89 KB ( 177 ) IPv4 10.11.12.167 (a3:5c:1c) other 15 6.03 KB ( 80 ) 5.73 KB ( 68 ) IPv4 10.11.12.17 (2c:97:19) other 11 800 B ( 16 ) 3.11 KB ( 47 ) IPv6 2001:470:527e::6666:b3ff:fe47:e1b9 (47:e1:b9) IPv6-ICMP 1 728 B ( 7 ) 5.68 KB ( 56 ) IPv4 10.11.12.17 (2c:97:19) HTTP 1 456 B ( 5 ) 450 B ( 6 ) IPv4 10.11.12.7 (47:e1:b9) ICMP 1 420 B ( 5 ) 420 B ( 5 ) IPv4 10.11.12.15 (94:59:06) other 3 228 B ( 3 ) 228 B ( 3 ) IPv6 2001:470:527e::a886:c6fc:82a4:bba9 (2c:97:19) HTTP 1 80 B ( 1 ) 144 B ( 2 ) IPv6 2001:470:527e::a886:c6fc:82a4:bba9 (00:00:00) HTTP 2 0 B ( 0 ) 0 B ( 0 ) IPv6 2001:470:527e::1 (35:88:49) HTTP 18 0 B ( 0 ) 1.64 KB ( 21 ) ``` ```bash root@jj:~# nlbw -c show -g mac,fam -o conn Fam MAC < Conn. Downld. ( Pkts. ) Upload ( Pkts. ) IPv6 74:81:14:2c:97:19 1 80 B ( 1 ) 144 B ( 2 ) IPv6 00:00:00:00:00:00 2 0 B ( 0 ) 0 B ( 0 ) IPv4 a0:99:9b:94:59:06 9 49.70 KB ( 88 ) 18.59 KB ( 106 ) IPv6 00:0d:b9:35:88:49 19 0 B ( 0 ) 1.64 KB ( 21 ) IPv6 64:66:b3:47:e1:b9 32 857.92 KB ( 1.16 K) 242.99 KB ( 1.34 K) IPv4 00:f7:6f:a3:5c:1c 39 216.57 KB ( 379 ) 67.59 KB ( 468 ) IPv4 74:81:14:2c:97:19 43 164.77 KB ( 502 ) 355.83 KB ( 646 ) IPv4 64:66:b3:47:e1:b9 501 3.12 MB ( 5.19 K) 905.20 KB ( 6.79 K) ``` ```bash root@jj:~# nlbw -c show -g mac -o -conn,-tx MAC > Conn. Downld. ( Pkts. ) > Upload ( Pkts. ) 64:66:b3:47:e1:b9 542 3.96 MB ( 6.38 K) 1.12 MB ( 8.16 K) 74:81:14:2c:97:19 44 164.85 KB ( 503 ) 355.97 KB ( 648 ) 00:f7:6f:a3:5c:1c 42 216.61 KB ( 380 ) 67.63 KB ( 469 ) 00:0d:b9:35:88:49 20 0 B ( 0 ) 1.79 KB ( 23 ) a0:99:9b:94:59:06 9 49.70 KB ( 88 ) 18.59 KB ( 106 ) 00:00:00:00:00:00 2 0 B ( 0 ) 0 B ( 0 ) ``` -------------------------------- ### Daemon Database Generations Retention Source: https://context7.com/jow-/nlbwmon/llms.txt Specify the number of database generations to keep before pruning. A value of 0 means unlimited generations are retained. ```bash nlbwmon -G 12 -s 192.168.0.0/24 -I 1 # keep 12 months of history ``` -------------------------------- ### Daemon In-Memory Records Cap Source: https://context7.com/jow-/nlbwmon/llms.txt Set a hard cap on the number of in-memory records. A value of 0 means there is no limit. ```bash nlbwmon -L 1000 -s 192.168.0.0/24 -I 1 ``` -------------------------------- ### CSV Output for Machine Reading Source: https://github.com/jow-/nlbwmon/blob/master/README.md Generates machine-readable CSV output, suitable for tools like rrdcollect. Use -g and -o flags to specify grouping and ordering. ```bash $ nlbw -c csv -g mac -o mac -q mac conns rx_bytes rx_pkts tx_bytes tx_pkts 00:00:00:00:00:00 411 72968 751 61428 767 34:02:86:17:5e:03 598 239950465 171095 5715237 86155 ac:37:43:a1:2d:47 125 284027227 205678 6451867 107297 ``` ```bash $ nlbw -t 2017-02-01 -c csv -g mac -o mac -q mac conns rx_bytes rx_pkts tx_bytes tx_pkts 00:00:00:00:00:00 157 26960 205 17878 218 34:02:86:17:5e:03 327 117213007 83817 3366892 51560 ``` -------------------------------- ### nlbw Client CSV Output Customization Source: https://github.com/jow-/nlbwmon/blob/master/README.md Customize separator, quote, and escape characters for CSV output. These options allow fine-grained control over the CSV format for compatibility with other tools. ```bash -s char Specify the separator character when using CSV format. If no argument is provided, an empty string is assumed. Currently only applies to CSV format. ``` ```bash -q char Specify the quote character when using CSV format. If no argument is provided, an empty string is assumed. Currently only applies to CSV format. ``` ```bash -e char Specify the escape character when using CSV format. If no argument is provided, an empty string is assumed. Currently only applies to CSV format. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.