1.0.1 • Published 2 years ago
nv-file-proc v1.0.1
nv-file-proc
- several simple function to get info from /proc/.. of linux
install
- npm install nv-file-proc
usage
const x = require("nv-file-proc")
example
> await x.pids()
[
1, 2, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 18, 19, 20, 21, 22, 24, 25, 26, 27, 28,
29, 30, 31, 32, 33, 34, 35, 36, 37, 41, 42, 43,
85, 86, 87, 88, 89, 90, 96, 105, 122, 174, 175, 213,
214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225,
226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237,
238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249,
250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261,
262, 263, 264, 265,
... 76 more items
]
>
> await x.fdinfos(1)
[
_Ele { ino: 19853, path: '/proc/1/fdinfo', type: 'dir' },
_Ele {
ino: 2029548,
path: '/proc/1/fdinfo/0',
type: 'file',
data: { pos: '0', flags: '0100002', mnt_id: '24' }
},
_Ele {
ino: 2029549,
path: '/proc/1/fdinfo/1',
type: 'file',
data: { pos: '0', flags: '0100002', mnt_id: '24' }
},
_Ele {
ino: 2029556,
path: '/proc/1/fdinfo/10',
type: 'file',
data: {
pos: '0',
flags: '02000002',
mnt_id: '13',
tfd: ' 12 events'
}
},
_Ele {
ino: 2031649,
path: '/proc/1/fdinfo/100',
type: 'file',
data: { pos: '0', flags: '02004002', mnt_id: '9' }
},
......
> await x.stack(1)
[
_Ele {
ino: 2031800,
path: '/proc/1/stack',
type: 'file',
data: {
'[<0>] ep_poll+0x29c/0x3a0': undefined,
'[<0>] SyS_epoll_wait+0xc6/0xe0': undefined,
'[<0>] do_syscall_64+0x73/0x130': undefined,
'[<0>] entry_SYSCALL_64_after_hwframe+0x41/0xa6': undefined,
'[<0>] 0xffffffffffffffff': undefined
}
},
undefined
]
> await x.io()
[
_Ele {
ino: 2031146,
path: '/proc/90544/io',
type: 'file',
data: {
rchar: ' 306918',
wchar: ' 102114',
syscr: ' 616',
syscw: ' 737',
read_bytes: ' 0',
write_bytes: ' 49152',
cancelled_write_bytes: ' 0'
}
},
undefined
]
> await x.status()
[
_Ele {
ino: 2031834,
path: '/proc/90544/status',
type: 'file',
data: {
Name: 'node',
Umask: '0022',
State: 'R (running)',
Tgid: '90544',
Ngid: '0',
Pid: '90544',
PPid: '90346',
TracerPid: '0',
Uid: '0\t0\t0\t0',
Gid: '0\t0\t0\t0',
FDSize: '256',
Groups: '0 ',
NStgid: '90544',
NSpid: '90544',
NSpgid: '90544',
NSsid: '90346',
VmPeak: ' 702464 kB',
VmSize: ' 640512 kB',
VmLck: ' 0 kB',
VmPin: ' 0 kB',
VmHWM: ' 45392 kB',
VmRSS: ' 44080 kB',
RssAnon: ' 10876 kB',
RssFile: ' 33204 kB',
RssShmem: ' 0 kB',
VmData: ' 93404 kB',
VmStk: ' 132 kB',
VmExe: ' 67956 kB',
VmLib: ' 6296 kB',
VmPTE: ' 728 kB',
VmSwap: ' 0 kB',
HugetlbPages: ' 0 kB',
CoreDumping: '0',
Threads: '11',
SigQ: '0/7615',
SigPnd: '0000000000000000',
ShdPnd: '0000000000000000',
SigBlk: '0000000000000000',
SigIgn: '0000000001001000',
SigCgt: '0000000188004602',
CapInh: '0000000000000000',
CapPrm: '0000003fffffffff',
CapEff: '0000003fffffffff',
CapBnd: '0000003fffffffff',
CapAmb: '0000000000000000',
NoNewPrivs: '0',
Seccomp: '0',
Speculation_Store_Bypass: 'vulnerable',
Cpus_allowed: 'ffffffff,ffffffff,ffffffff,ffffffff',
Cpus_allowed_list: '0-127',
Mems_allowed: '00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000001',
Mems_allowed_list: '0',
voluntary_ctxt_switches: '177',
nonvoluntary_ctxt_switches: '627'
}
},
undefined
]
>
APIS
async function pids() {
async function _eng(proc_path,with_full_info) {
async function fdinfos(pid,with_full_info=false) {
async function stack(pid,with_full_info=false) {
async function io(pid,with_full_info=false) {
async function status(pid,with_full_info=false) {
LICENSE
- ISC
1.0.1
2 years ago