lup-system
Version:
NodeJS library to retrieve system information and utilization.
69 lines (68 loc) • 2.86 kB
TypeScript
export type NICUtilization = {
/** Current receive link utilization (RX) in percentage (0.0-1.0) of the maximum bandwidth (speed). */
receive: number;
/** Current transmit link utilization (TX) in percentage (0.0-1.0) of the maximum bandwidth (speed). */
transmit: number;
};
export type NICInfo = {
/** Name of the network interface (e.g. lo, eth0). */
name: string;
/** Network addresses assigned to the network interface. */
addresses: {
/** Type of the address (IPv4 or IPv6). */
type: 'ipv4' | 'ipv6';
/** MAC address of the interface. */
mac: string;
/** IPv4 or IPv6 address. */
ip: string;
/** Subnet mask in CIDR notation (e.g. /24 for IPv4). */
netmask: string;
/** CIDR notation of the address. */
cidr: string | null;
/** If the address is internal (e.g. loopback). */
internal: boolean;
}[];
/** Status information about the network interface. */
status: {
/** Operational status of the interface (e.g. up, down). */
operational: 'up' | 'down' | 'dormant' | 'notpresent' | 'lowerlayerdown' | 'testing' | 'unknown';
/** If the interface is enabled in the settings. */
admin: boolean;
/** If a network cable is plugged into the interface. */
cable: boolean;
};
/** If the interface is a physical (e.g. Ethernet) or virtual (e.g. Loopback, VPN, Hyper-V) interface. */
physical: boolean;
/**
* Maximum link speed that the network interface is capable of.
* For full-duplex interfaces (default), this speed counts once for receive and once for transmit simultaneously.
* For half-duplex interfaces, this speed counts for both receive and transmit combined/shared.
*
* The speed cannot be determined for all interfaces, in which case it will be undefined.
*/
speed?: {
/** Speed in bits per second (bps). */
bits: number;
/** Speed in bytes per second (Bps). */
bytes: number;
};
/**
* Current link utilization in percentage (0.0-1.0) of the maximum bandwidth (speed).
*
* The utilization cannot be determined for all interfaces, in which case it will be undefined.
*/
utilization?: NICUtilization;
};
/** Intervall in milliseconds at which network interface utilization is computed. */
export declare let NET_COMPUTE_UTILIZATION_INTERVAL: number;
/**
* Stops the computation of network utilization.
* As soon as the getNetworkInterfaces function is called again, the computation will be restarted.
*/
export declare function stopNetworkUtilizationComputation(): void;
/**
* Returns information about the network interfaces on the system.
*
* @returns List of NICInfo objects.
*/
export declare function getNetworkInterfaces(): Promise<NICInfo[]>;