Hi,
How about these now?
These include extra improvements to other parts of systat.
These patches create new files.
If you already applies previosly, please check and clean up new files.
Regards,
Hiro
On Sun, 4 Apr 2021 10:21:59 +
tech-lists wrote:
> Hi,
>
> On Fri, Apr 02, 2021 at 08:12:14PM -0400, Yoshihiro Ota wrote:
> >Hi,
> >
> >We do not seem to have a nice way to see current swap space usage per
> >process.
> >I updated systat to use libprocstat to obtain such infomation and display
> >along with swap devise/file stats.
>
> Unfotunately your patch gets rejected on recent stable/13 and main/14
>
> --
> J.
diff --git a/usr.bin/systat/Makefile b/usr.bin/systat/Makefile
index ca3f7ed72ce..bfbe1336d29 100644
--- a/usr.bin/systat/Makefile
+++ b/usr.bin/systat/Makefile
@@ -5,7 +5,7 @@
PROG= systat
SRCS= cmds.c cmdtab.c devs.c fetch.c iostat.c keyboard.c main.c sysput.c \
- netcmds.c netstat.c pigs.c swap.c icmp.c \
+ netcmds.c netstat.c pigs.c proc.c swap.c icmp.c \
mode.c ip.c sctp.c tcp.c zarc.c \
vmstat.c convtbl.c ifcmds.c ifstat.c
@@ -16,6 +16,6 @@ CFLAGS+= -DINET6
WARNS?= 1
-LIBADD= ncursesw m devstat kvm util
+LIBADD= ncursesw m devstat kvm util procstat
.include
diff --git a/usr.bin/systat/devs.c b/usr.bin/systat/devs.c
index b293796c2c7..87d04f989ea 100644
--- a/usr.bin/systat/devs.c
+++ b/usr.bin/systat/devs.c
@@ -426,12 +426,6 @@ dsshow2(int diskcol, int diskrow, int dn, int lc, struct statinfo *now, struct s
putlongdouble(device_busy, diskrow + 4, lc, 5, 0, 0);
}
-static void
-dsshow3(int diskcol, int diskrow, int dn, int lc, struct statinfo *now, struct statinfo *then)
-{
- dsshow2(diskcol, diskrow, dn, lc, now, then);
-}
-
void
dsshow(int maxdrives, int diskcol, int diskrow, struct statinfo *now, struct statinfo *then)
{
@@ -439,5 +433,5 @@ dsshow(int maxdrives, int diskcol, int diskrow, struct statinfo *now, struct sta
for (i = 0, lc = 0; i < num_devices && lc < maxdrives; i++)
if (dev_select[i].selected)
- dsshow3(diskcol, diskrow, i, ++lc, now, then);
+ dsshow2(diskcol, diskrow, i, ++lc, now, then);
}
diff --git a/usr.bin/systat/devs.h b/usr.bin/systat/devs.h
index cbedd844290..79a44a6c3f5 100644
--- a/usr.bin/systat/devs.h
+++ b/usr.bin/systat/devs.h
@@ -2,7 +2,7 @@
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 1998 David E. O'Brien
- * 2015 Yoshihiro Ota
+ * 2015, 2021 Yoshihiro Ota
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -34,6 +34,8 @@
#include
+#define DISKHIGHT 5
+
int dsinit(int);
void dsgetinfo(struct statinfo *);
int dscmd(const char *, const char *, int, struct statinfo *);
diff --git a/usr.bin/systat/extern.h b/usr.bin/systat/extern.h
index 6e3117bece4..322065f7931 100644
--- a/usr.bin/systat/extern.h
+++ b/usr.bin/systat/extern.h
@@ -168,6 +168,7 @@ char *sysctl_dynread(const char *, size_t *);
void sysputpage(WINDOW* , int, int, int, uint64_t, int);
void sysputspaces(WINDOW* , int, int, int);
void sysputstrs(WINDOW* , int, int, int);
+void sysputXs(WINDOW* , int, int, int);
void sysputuint64(WINDOW* , int, int, int, uint64_t, int);
void sysputwuint64(WINDOW* , int, int, int, uint64_t, int);
diff --git a/usr.bin/systat/main.c b/usr.bin/systat/main.c
index b5a19d381ad..b84351379f4 100644
--- a/usr.bin/systat/main.c
+++ b/usr.bin/systat/main.c
@@ -135,6 +135,21 @@ parse_cmd_args (int argc, char **argv)
}
+static void
+resize(int signo __unused)
+{
+
+ endwin();
+ refresh();
+ clear();
+
+ CMDLINE = LINES - 1;
+ labels();
+ display();
+ status();
+}
+
+
int
main(int argc, char **argv)
{
@@ -191,6 +206,7 @@ main(int argc, char **argv)
signal(SIGINT, die);
signal(SIGQUIT, die);
signal(SIGTERM, die);
+ signal(SIGWINCH, resize);
/*
* Initialize display. Load average appears in a one line
diff --git a/usr.bin/systat/pigs.c b/usr.bin/systat/pigs.c
index d9f3f8d4ad1..879f6548d86 100644
--- a/usr.bin/systat/pigs.c
+++ b/usr.bin/systat/pigs.c
@@ -56,13 +56,13 @@ __FBSDID("$FreeBSD$");
#include "systat.h"
#include "extern.h"
-int compar(const void *, const void *);
+static int compar(const void *, const void *);
static int nproc;
static struct p_times {
float pt_pctcpu;
struct kinfo_proc *pt_kp;
-} *pt;
+} *pt = NULL;
static intfscale;
static double lccpu;
@@ -90,7 +90,7 @@ showpigs(void)
const char *uname, *pname;
char pidname[30];
- if (pt == NULL)
+ if (nproc == 0)
return;
qsort(pt, nproc, sizeof (struct p_times), compar);
@@ -146,23 +146,20 @@ fetchpigs(void)
float ftime;
float *pctp;
struct kinfo_proc *kpp;
- static int lastnproc = 0;
+ static int maxnproc = 0;
if ((kpp = kvm_getprocs(kd, KERN_PROC_ALL, 0, )) == NULL) {
error("%s", kvm_geterr(kd));
- if (pt)
- free(pt);
+ nproc = 0;
return;
}
- if (nproc > lastnproc) {
- free(pt);
- if ((pt =
- malloc(nproc * sizeof(struct p_times))) == NULL) {
+ if (nproc >