158 lines
4.1 KiB
TypeScript
158 lines
4.1 KiB
TypeScript
export namespace cpu {
|
|
|
|
export class InfoStat {
|
|
cpu: number;
|
|
vendorId: string;
|
|
family: string;
|
|
model: string;
|
|
stepping: number;
|
|
physicalId: string;
|
|
coreId: string;
|
|
cores: number;
|
|
modelName: string;
|
|
mhz: number;
|
|
cacheSize: number;
|
|
flags: string[];
|
|
microcode: string;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new InfoStat(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.cpu = source["cpu"];
|
|
this.vendorId = source["vendorId"];
|
|
this.family = source["family"];
|
|
this.model = source["model"];
|
|
this.stepping = source["stepping"];
|
|
this.physicalId = source["physicalId"];
|
|
this.coreId = source["coreId"];
|
|
this.cores = source["cores"];
|
|
this.modelName = source["modelName"];
|
|
this.mhz = source["mhz"];
|
|
this.cacheSize = source["cacheSize"];
|
|
this.flags = source["flags"];
|
|
this.microcode = source["microcode"];
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
export namespace disk {
|
|
|
|
export class PartitionStat {
|
|
device: string;
|
|
mountpoint: string;
|
|
fstype: string;
|
|
opts: string;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new PartitionStat(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.device = source["device"];
|
|
this.mountpoint = source["mountpoint"];
|
|
this.fstype = source["fstype"];
|
|
this.opts = source["opts"];
|
|
}
|
|
}
|
|
export class UsageStat {
|
|
path: string;
|
|
fstype: string;
|
|
total: number;
|
|
free: number;
|
|
used: number;
|
|
usedPercent: number;
|
|
inodesTotal: number;
|
|
inodesUsed: number;
|
|
inodesFree: number;
|
|
inodesUsedPercent: number;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new UsageStat(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.path = source["path"];
|
|
this.fstype = source["fstype"];
|
|
this.total = source["total"];
|
|
this.free = source["free"];
|
|
this.used = source["used"];
|
|
this.usedPercent = source["usedPercent"];
|
|
this.inodesTotal = source["inodesTotal"];
|
|
this.inodesUsed = source["inodesUsed"];
|
|
this.inodesFree = source["inodesFree"];
|
|
this.inodesUsedPercent = source["inodesUsedPercent"];
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
export namespace net {
|
|
|
|
export class Addr {
|
|
ip: string;
|
|
port: number;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new Addr(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.ip = source["ip"];
|
|
this.port = source["port"];
|
|
}
|
|
}
|
|
export class ConnectionStat {
|
|
fd: number;
|
|
family: number;
|
|
type: number;
|
|
localaddr: Addr;
|
|
remoteaddr: Addr;
|
|
status: string;
|
|
uids: number[];
|
|
pid: number;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new ConnectionStat(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.fd = source["fd"];
|
|
this.family = source["family"];
|
|
this.type = source["type"];
|
|
this.localaddr = this.convertValues(source["localaddr"], Addr);
|
|
this.remoteaddr = this.convertValues(source["remoteaddr"], Addr);
|
|
this.status = source["status"];
|
|
this.uids = source["uids"];
|
|
this.pid = source["pid"];
|
|
}
|
|
|
|
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
|
if (!a) {
|
|
return a;
|
|
}
|
|
if (a.slice) {
|
|
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
|
} else if ("object" === typeof a) {
|
|
if (asMap) {
|
|
for (const key of Object.keys(a)) {
|
|
a[key] = new classs(a[key]);
|
|
}
|
|
return a;
|
|
}
|
|
return new classs(a);
|
|
}
|
|
return a;
|
|
}
|
|
}
|
|
|
|
}
|
|
|