150 lines
4.3 KiB
TypeScript
Executable File
150 lines
4.3 KiB
TypeScript
Executable File
export namespace backend {
|
|
|
|
export class GPUProcessInfo {
|
|
pid: number;
|
|
name: string;
|
|
type: string;
|
|
vram_mb: number;
|
|
ram: number;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new GPUProcessInfo(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.pid = source["pid"];
|
|
this.name = source["name"];
|
|
this.type = source["type"];
|
|
this.vram_mb = source["vram_mb"];
|
|
this.ram = source["ram"];
|
|
}
|
|
}
|
|
export class ProcessInfo {
|
|
pid: number;
|
|
name: string;
|
|
cpu: number;
|
|
mem: number;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new ProcessInfo(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.pid = source["pid"];
|
|
this.name = source["name"];
|
|
this.cpu = source["cpu"];
|
|
this.mem = source["mem"];
|
|
}
|
|
}
|
|
export class Metrics {
|
|
cpu_percent: number;
|
|
total_mem: number;
|
|
free_mem: number;
|
|
processes: ProcessInfo[];
|
|
timestamp: number;
|
|
gpu_name?: string;
|
|
gpu_total_mem?: number;
|
|
gpu_used_mem?: number;
|
|
gpu_util_percent?: number;
|
|
gpu_processes?: GPUProcessInfo[];
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new Metrics(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.cpu_percent = source["cpu_percent"];
|
|
this.total_mem = source["total_mem"];
|
|
this.free_mem = source["free_mem"];
|
|
this.processes = this.convertValues(source["processes"], ProcessInfo);
|
|
this.timestamp = source["timestamp"];
|
|
this.gpu_name = source["gpu_name"];
|
|
this.gpu_total_mem = source["gpu_total_mem"];
|
|
this.gpu_used_mem = source["gpu_used_mem"];
|
|
this.gpu_util_percent = source["gpu_util_percent"];
|
|
this.gpu_processes = this.convertValues(source["gpu_processes"], GPUProcessInfo);
|
|
}
|
|
|
|
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
|
if (!a) {
|
|
return a;
|
|
}
|
|
if (a.slice && a.map) {
|
|
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;
|
|
}
|
|
}
|
|
export class ProcessDetail {
|
|
pid: number;
|
|
name: string;
|
|
exe: string;
|
|
cmdline: string;
|
|
cwd: string;
|
|
status: string;
|
|
username: string;
|
|
created_at: number;
|
|
parent_pid: number;
|
|
parent_name: string;
|
|
nice: number;
|
|
num_threads: number;
|
|
num_fds: number;
|
|
cpu_percent: number;
|
|
rss: number;
|
|
vms: number;
|
|
swap: number;
|
|
mem_percent: number;
|
|
read_bytes: number;
|
|
write_bytes: number;
|
|
read_ops: number;
|
|
write_ops: number;
|
|
open_files_count: number;
|
|
conn_count: number;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new ProcessDetail(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.pid = source["pid"];
|
|
this.name = source["name"];
|
|
this.exe = source["exe"];
|
|
this.cmdline = source["cmdline"];
|
|
this.cwd = source["cwd"];
|
|
this.status = source["status"];
|
|
this.username = source["username"];
|
|
this.created_at = source["created_at"];
|
|
this.parent_pid = source["parent_pid"];
|
|
this.parent_name = source["parent_name"];
|
|
this.nice = source["nice"];
|
|
this.num_threads = source["num_threads"];
|
|
this.num_fds = source["num_fds"];
|
|
this.cpu_percent = source["cpu_percent"];
|
|
this.rss = source["rss"];
|
|
this.vms = source["vms"];
|
|
this.swap = source["swap"];
|
|
this.mem_percent = source["mem_percent"];
|
|
this.read_bytes = source["read_bytes"];
|
|
this.write_bytes = source["write_bytes"];
|
|
this.read_ops = source["read_ops"];
|
|
this.write_ops = source["write_ops"];
|
|
this.open_files_count = source["open_files_count"];
|
|
this.conn_count = source["conn_count"];
|
|
}
|
|
}
|
|
|
|
}
|
|
|