From 5e27699aff4ae6df1aae0026c784e56c1bbdccef Mon Sep 17 00:00:00 2001 From: "liuting.0xffff" Date: Tue, 4 Jul 2023 18:05:04 +0800 Subject: [PATCH] add NRCORE/NRSIGKILL for container --- deviate.c | 1 + showgeneric.c | 8 ++++++++ showlinux.c | 4 +++- showlinux.h | 2 ++ showprocs.c | 26 ++++++++++++++++++++++++++ 5 files changed, 40 insertions(+), 1 deletion(-) diff --git a/deviate.c b/deviate.c index 2aa360e..96ae753 100644 --- a/deviate.c +++ b/deviate.c @@ -312,6 +312,7 @@ deviattask(struct tstat *curtpres, unsigned long ntaskpres, devstat->gen.excode |= ~(INT_MAX); strcpy(devstat->gen.cmdline, prestat.gen.cmdline); + strcpy(devstat->gen.container, prestat.gen.container); devstat->cpu.curcpu = -1; diff --git a/showgeneric.c b/showgeneric.c index 3eb5510..7d4bbd6 100644 --- a/showgeneric.c +++ b/showgeneric.c @@ -2586,6 +2586,14 @@ accumulate(struct tstat *curproc, struct tstat *curstat) curstat->gpu.nrgpus++; } } + } else { + if (curproc->gen.excode & 0xff) + { + if (curproc->gen.excode & 0x80) + curstat->gen.nthrslpi++; // coredump + else if ((curproc->gen.excode & 0x7f) == 9 ) + curstat->gen.nthrslpu++; // sigkill + } } } diff --git a/showlinux.c b/showlinux.c index 1dd4b9e..e0b7ef5 100644 --- a/showlinux.c +++ b/showlinux.c @@ -439,6 +439,8 @@ proc_printdef *allprocpdefs[]= &procprt_S, &procprt_COMMAND_LINE, &procprt_NPROCS, + &procprt_NRSIGKILL, + &procprt_NRCORE, &procprt_RDDSK, &procprt_WRDSK, &procprt_CWRDSK, @@ -1331,7 +1333,7 @@ priphead(int curlist, int totlist, char *showtype, char *showorder, make_proc_prints(totconts, MAXITEMS, "NPROCS:10 SYSCPU:9 USRCPU:9 VSIZE:6 " "RSIZE:8 PSIZE:8 LOCKSZ:3 SWAPSZ:5 RDDSK:7 CWRDSK:7 " - "RNET:6 SNET:6 SORTITEM:10 CID:10", + "RNET:6 SNET:6 NRSIGKILL:8 NRCORE:8 SORTITEM:10 CID:10", "built-in totconts"); } diff --git a/showlinux.h b/showlinux.h index a24b3d0..e95352d 100644 --- a/showlinux.h +++ b/showlinux.h @@ -470,6 +470,8 @@ extern proc_printdef procprt_CGRMEMMAX; extern proc_printdef procprt_CGRMEMMAXR; extern proc_printdef procprt_CGRSWPMAX; extern proc_printdef procprt_CGRSWPMAXR; +extern proc_printdef procprt_NRSIGKILL; +extern proc_printdef procprt_NRCORE; //extern char *procprt_NRDDSK_ae(struct tstat *, int, int); diff --git a/showprocs.c b/showprocs.c index 19151db..51c51b9 100644 --- a/showprocs.c +++ b/showprocs.c @@ -186,6 +186,8 @@ char *procprt_CGRSWPMAX_e(struct tstat *, int, int); char *procprt_CGRSWPMAXR_a(struct tstat *, int, int); char *procprt_CGRSWPMAXR_e(struct tstat *, int, int); char *procprt_SORTITEM_ae(struct tstat *, int, int); +char *procprt_NRSIGKILL_ae(struct tstat *, int, int); +char *procprt_NRCORE_ae(struct tstat *, int, int); static char *columnhead[] = { @@ -2528,3 +2530,27 @@ procprt_SORTITEM_ae(struct tstat *curstat, int avgval, int nsecs) proc_printdef procprt_SORTITEM = // width is dynamically defined! { 0, "SORTITEM", procprt_SORTITEM_ae, procprt_SORTITEM_ae, 4}; +/***************************************************************/ +char * +procprt_NRSIGKILL_ae(struct tstat *curstat, int avgval, int nsecs) +{ + static char buf[10]; + + val2valstr(curstat->gen.nthrslpu, buf, 6, 0, 0); // pid abused as proc counter + return buf; +} + +proc_printdef procprt_NRSIGKILL = // width is dynamically defined! + {"NRSIGKILL", "NRSIGKILL", procprt_NRSIGKILL_ae, procprt_NRSIGKILL_ae, 4}; +/***************************************************************/ +char * +procprt_NRCORE_ae(struct tstat *curstat, int avgval, int nsecs) +{ + static char buf[10]; + + val2valstr(curstat->gen.nthrslpi, buf, 6, 0, 0); // pid abused as proc counter + return buf; +} + +proc_printdef procprt_NRCORE = // width is dynamically defined! + {"NRCORE", "NRCORE", procprt_NRCORE_ae, procprt_NRCORE_ae, 4}; \ No newline at end of file