formatBytes | ||||||||
formatBytes(bytes: string)
|
||||||||
Helper function to format bytes into human-readable form (e.g., KB, MB, GB).
This is mainly for the Windows output since
Parameters :
Returns :
string
|
parseFileSystemOutput | ||||||||
parseFileSystemOutput(output: string)
|
||||||||
Parses the output from the
Parameters :
Returns :
FileSystemInfo[]
|
getActiveConnections | ||||||||
getActiveConnections(format)
|
||||||||
Retrieves the active network connections on the system.
Parameters :
Returns :
Promise<[] | string>
|
parseNetstatOutput | ||||||||
parseNetstatOutput(output: string)
|
||||||||
Parses the output from the
Parameters :
Returns :
NetworkConnection[]
|
getCpuInfo |
getCpuInfo()
|
Asynchronously retrieves detailed CPU information, including total and per-core statistics. It gathers information like total CPU time, idle time, user/system time, and CPU usage percentages. The function provides an overall summary of the CPU, as well as core-specific data.
Returns :
Promise<CpuInfo>
A promise that resolves to an object containing detailed CPU statistics. |
getDiskUsage |
getDiskUsage()
|
Retrieves detailed disk usage data by executing a system command. Parses the output of the 'df -k' command to extract information such as filesystem type, total size, used space, available space, usage percentage, and mount point for each partition.
Returns :
[] | null
An array of disk usage information for each partition, or null in case of an error. |
parseDiskUsage | ||||||||
parseDiskUsage(output: string)
|
||||||||
Parses the output of the 'df -k' command to extract disk usage details for each partition.
Parameters :
Returns :
EnhancedDiskUsage[]
An array of parsed disk usage information. |
getLoadAverage |
getLoadAverage()
|
Retrieves the system load averages over 1, 5, and 15 minutes. The load average represents the average number of processes that are either in a runnable or uninterruptible state. It gives an indication of how busy the system is.
These values are useful for determining system load trends:
Note: On Windows systems,
Returns :
LoadAverage
An object containing the system's load averages:
|
getLogs | ||||||||||||
getLogs(path: string, keyword?: string)
|
||||||||||||
Retrieves logs from a specified file and optionally filters them by a keyword.
Parameters :
Returns :
Promise<string[]>
|
getMemoryUsage |
getMemoryUsage()
|
Asynchronously retrieves memory usage statistics, including total, free, and used memory. The function gathers system memory information and calculates the used memory by subtracting the free memory from the total memory available on the system.
Returns :
Promise<>
A promise that resolves to an object containing memory usage data with properties for total, free, and used memory. |
getNetworkInfo |
getNetworkInfo()
|
Asynchronously retrieves network interface information, including details for each network interface available on the system. The function gathers data such as the IP addresses and netmask for each network interface, facilitating network monitoring and diagnostics.
Returns :
Promise<>
A promise that resolves to an object containing network interface data. |
getOSInfo |
getOSInfo()
|
Asynchronously retrieves detailed information about the operating system. The function gathers various information such as the OS platform, release version, architecture, kernel version, hostname, home directory, uptime, memory statistics, CPU details, network interfaces, and user information.
Returns :
OSInfo
An object containing various OS information. |
getProcessInfo |
getProcessInfo()
|
Asynchronously retrieves the CPU and memory usage for the current process. The function provides detailed information about the CPU time used by the process and the memory footprint, including the Resident Set Size (RSS).
Returns :
Promise<>
A promise that resolves to an object containing CPU and memory usage data for the current process. |
getScheduledTasks |
getScheduledTasks()
|
Retrieves a list of scheduled tasks from the system and parses them into an object.
Returns :
Promise<ScheduledTasksResponse>
|
parseTasks | ||||||||
parseTasks(output: string)
|
||||||||
Parses the command output into a structured format.
Parameters :
Returns :
ScheduledTask[]
|
getServiceStatus | ||||||||
getServiceStatus(serviceName: string)
|
||||||||
Retrieves the status of a given service.
Parameters :
Returns :
Promise<ServiceStatus>
|
getSystemUptime |
getSystemUptime()
|
Asynchronously retrieves the system uptime in seconds. The function returns the total number of seconds the system has been running since the last boot, providing valuable information for system monitoring and diagnostics.
Returns :
Promise<number>
A promise that resolves to the system uptime in seconds. |
getTemperature |
getTemperature()
|
Get system temperature based on the platform. This function retrieves the temperature of the CPU or thermal zone, depending on the operating system:
Returns :
Promise<number | undefined>
Temperature in Celsius or undefined if not supported or an error occurs. |
getUserInfo |
getUserInfo()
|
Retrieves extended user information and system details.
Returns :
ExtendedUserInfo
|
logToFile | ||||||||||||
logToFile(logData: LogData, filePath: string)
|
||||||||||||
Writes log data to a specified file in JSON format.
Parameters :
Returns :
void
|
trackTime | ||||||||
trackTime(options: TrackTimeOptions)
|
||||||||
Middleware to track request/response time. This middleware logs the time taken for each request to complete and can store logs either in a file or by invoking a provided callback function to store the log data in a database.
Parameters :
|