qwatcher
is designed to help monitor TCP connections and diagnose buffer and connectivity issues on Linux machines related to input
and output
queues.
The idea of writing this program came to me after reading a few blog posts discussing how they faced odd connectivity issues and how it ended up being related to the send and receive queues.
Had they had this tool, they would have been able to find the root cause much faster.
-
Download and extract the file from this URL:
wget https://github.com/pouriyajamshidi/qwatcher/releases/latest/download/qwatcher.tar.gz tar xvf qwatcher.tar.gz
Optionally, you can use
Nimble
for installation https://nimble.directory/pkg/qwatcher and skip to step 3.nimble install qwatcher
-
Make it executable and if you prefer, move it to your
$PATH
:chmod +x qwatcher sudo cp qwatcher /usr/local/bin
-
Run it. There are two modes to run
qwatcher
.- Write mode. Provides two logging methods:
- Using
--db_path
to log to a database. Default path:/var/log/qwatcher.db
- Using
--log_path
to log to a text file. Default path:/var/log/qwatcher.log
- Using
- Monitor mode (default). Prints the output to the console
- Write mode. Provides two logging methods:
⚠️ Make sure to not feed a higher number than your current buffer size to the program.
In order to get the current read and write buffer sizes, run the following commands:
cat /proc/sys/net/ipv4/tcp_rmem
cat /proc/sys/net/ipv4/tcp_wmem
Let's explore all modes:
-
check every 5 seconds and log connections that surpass 100 kilobytes in send or receive queues to a database located at
/var/log/qwatcher.db
:qwatcher --recv_q=100000 --send_q=100000 --refresh=5 --db_path=/var/log/qwatcher.db
Then you can check the database. For instance, connections with
receive queue
bigger than zero:sqlite3
needs to be installed.# Open the database file: sqlite3 /var/log/qwatcher.db # Beautify sqlite output: .mode line .headers on .separator ROW "\n" # Run your query: sqlite> SELECT * FROM qwatcher WHERE receiveQ > 0;
-
Should you prefer to log the stats in a log file instead of a database as shown in step 1 use
--log_path
:qwatcher --recv_q=100000 --send_q=100000 --refresh=5 --log_path=/var/log/qwatcher.log
Then you can use tail to check the file contents:
tail -f /var/log/qwatcher.log
-
Default mode. If you want the output to be shown on the console and not log to disk, use the commands above without
--log_path
or--db_path
options:qwatcher --recv_q=100000 --send_q=100000
The default refresh interval is 10 seconds.
The sample output can be seen here
Additionally, you can use the accompanying systemd service to run qwatcher
in the background and not worry about system restarts:
sudo cp qwatcher.service /etc/systemd/system/qwatcher.service
sudo systemctl enable qwatcher.service
sudo systemctl start qwatcher.service
-h, --help : show help
--recv_q, : Minimum receive-Q to trigger alert in bytes (default: 10000)
--send_q, : Minimum send-Q to trigger alert in bytes (default: 10000)
--refresh, : Refresh interval in seconds (default: 10)
--db_path, : Path to SQLite database to log reports (default: /var/log/qwatcher.db)
--log_path, : Path to log file to log reports (default: /var/log/qwatcher.log)
-v, --version, : Show version
Please note that you cannot use
--db_path
and--log_path
at the same time.
Below output depicts the provided information for a connection:
Apart from the send and receive queues, there are additional information that can be useful to diagnose connectivity issues such as congestion window
, mss
, retransmits
and more.
This project is also hosted on Nimble.
Ubuntu server 22.04.