-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Labels
Description
Hello,
node-netstat currently does nothing if the command netstat is not found (i.e. net-tools is not installed). For example:
code source (click to view)
/**
* index.js
*/
const netstat = require('node-netstat');
netstat(
{ filter: { protocol: 'tcp' }, limit: 1 },
(data) => console.log(data)
);Commands and outputs:
node-netstat$ which netstat
netstat not found
node-netstat$ node index.js
node-netstat$ sudo pacman -S --noconfirm net-tools
resolving dependencies...
looking for conflicting packages...
Packages (1) net-tools-2.10-2
Total Installed Size: 0.51 MiB
:: Proceed with installation? [Y/n]
(1/1) checking keys in keyring [------------------------------------------------------] 100%
(1/1) checking package integrity [------------------------------------------------------] 100%
(1/1) loading package files [------------------------------------------------------] 100%
(1/1) checking for file conflicts [------------------------------------------------------] 100%
(1/1) checking available disk space [------------------------------------------------------] 100%
:: Processing package changes...
(1/1) installing net-tools [------------------------------------------------------] 100%
:: Running post-transaction hooks...
(1/1) Arming ConditionNeedsUpdate...
node-netstat$ node index.js
{
protocol: 'tcp',
local: { port: 6600, address: null },
remote: { port: NaN, address: null },
state: 'LISTEN',
pid: 1564
}
node-netstat$ which netstat
/usr/bin/netstat
This can be difficult to debug. On netstat's manual page, we have
Note
This program is obsolete. Replacement for netstat is ss. Replacement for netstat -r is ip route. Replacement for netstat -i is ip -s > link. Replacement for netstat -g is ip maddr.
so it's not uncommon for docker images and linux distributions do not ship with net-tools.
Would it be possible to simply throw an Error with a helpful message telling the user to install net-tools?
Thank you :)).
