node-os-utils
Version:
Advanced cross-platform operating system monitoring utilities with TypeScript support
124 lines • 3.9 kB
TypeScript
import { BasePlatformAdapter } from '../core/platform-adapter';
import { CommandResult, SupportedFeatures } from '../types/platform';
import { ExecuteOptions } from '../types/config';
/**
* Windows 平台适配器
*
* 通过 PowerShell / WMI / Node.js 原生 API 获取系统信息
*/
export declare class WindowsAdapter extends BasePlatformAdapter {
private executor;
constructor();
/**
* 执行系统命令
*/
executeCommand(command: string, options?: ExecuteOptions): Promise<CommandResult>;
/**
* 读取文件内容
*/
readFile(path: string): Promise<string>;
/**
* 检查文件是否存在
*/
fileExists(path: string): Promise<boolean>;
/**
* 组合 Node.js 与 WMI 数据,构建 CPU 基本信息
*/
getCPUInfo(): Promise<any>;
/**
* 获取 CPU 使用率,使用采样计算
*/
getCPUUsage(): Promise<any>;
/** 获取 CPU 温度 */
getCPUTemperature(): Promise<any>;
/**
* 获取内存信息,补充物理/虚拟内存详情
*/
getMemoryInfo(): Promise<any>;
/** 获取内存使用情况 */
getMemoryUsage(): Promise<any>;
/** 获取磁盘基本信息 */
getDiskInfo(): Promise<any[]>;
/** 获取磁盘 I/O 信息 */
getDiskIO(): Promise<any>;
/** 获取磁盘使用情况 */
getDiskUsage(): Promise<any[]>;
/** 获取磁盘统计 */
getDiskStats(): Promise<any>;
/** 获取挂载点信息 */
getMounts(): Promise<any[]>;
/** 获取文件系统信息 */
getFileSystems(): Promise<any[]>;
/** 获取网络接口 */
getNetworkInterfaces(): Promise<any>;
/** 获取网络统计 */
getNetworkStats(): Promise<any>;
/** 获取网络连接 */
getNetworkConnections(): Promise<any>;
/** 获取默认网关 */
getDefaultGateway(): Promise<any>;
/** 获取进程列表 */
getProcessList(): Promise<any[]>;
/** 获取进程信息 */
getProcessInfo(pid: number): Promise<any>;
/** 获取进程列表(旧接口兼容) */
getProcesses(): Promise<any>;
/** 杀死进程 */
killProcess(pid: number, signal?: string): Promise<boolean>;
/** 获取进程打开文件 */
getProcessOpenFiles(): Promise<string[]>;
/** 获取进程环境变量 */
getProcessEnvironment(): Promise<Record<string, string>>;
/** 获取系统信息 */
getSystemInfo(): Promise<any>;
/** 获取系统负载 */
getSystemLoad(): Promise<any>;
/** 获取系统运行时间 */
getSystemUptime(): Promise<any>;
/** 获取系统用户 */
getSystemUsers(): Promise<any>;
/** 获取系统服务 */
getSystemServices(): Promise<any>;
/** 初始化支持的功能 */
protected initializeSupportedFeatures(): SupportedFeatures;
/**
* 采样 CPU 使用率
*
* 通过两次读取 Node.js os.cpus() 的累积时间片来计算 delta,从而得到整体与单核的使用率
*/
private sampleCpuUsage;
/**
* 执行 PowerShell 命令并转换 JSON
*
* @param command PowerShell 脚本片段
* @param options 执行选项,例如超时与缓冲区
*/
private executePowerShell;
/**
* 将 WMI 返回的进程信息转换为统一结构
*/
private normalizeProcess;
/**
* 将 WMI/CIM 返回的日期字符串解析为 UTC 时间戳
*/
private parseWmiDate;
/**
* 获取文件系统驱动器
*
* 优先使用 PowerShell PSDrive,失败时回退到 WMI
*/
private getFileSystemDrives;
/**
* 将对象包装为数组,防止 PowerShell 只返回单项
*/
private ensureArray;
/**
* 清洗 JSON 输出,去除 BOM 并裁剪空白
*/
private sanitizeJson;
/**
* Promise 形式的延时工具
*/
private delay;
}
//# sourceMappingURL=windows-adapter.d.ts.map