diff options
| author | Jishan Alam <jishanalam9128@gmail.com> | 2026-03-07 21:04:18 +0000 |
|---|---|---|
| committer | Vladimir Druzenko <vvd@FreeBSD.org> | 2026-03-07 21:14:50 +0000 |
| commit | e8f735b02d3b3890b7d8c70fc14b5ad2694ff90a (patch) | |
| tree | 00654d2369c303f57fea7b50d25f1f7ba92e7200 | |
| parent | 915575bfc112a5576cd5705ee5040145ce91592c (diff) | |
sysutils/whowatch: Update 1.4 => 1.8.6.2, take maintainership
Switch to upstream with FreeBSD support:
- https://github.com/Zedai00/whowatch/
- The new update wasn't working on FreeBSD due to Linuxisms and FreeBSD
wrong API usages.
- Overhauled the codebase in a fork and updated it to work on both
Linux and FreeBSD.
- Uses of sysctl, libprocstat, kvm etc to gather the system informations.
PR: 293113
MFH: 2026Q1
Co-authored-by: Vladimir Druzenko <vvd@FreeBSD.org>
(cherry picked from commit 55476368ccbc3863cec96779d914046a39ac5299)
| -rw-r--r-- | sysutils/whowatch/Makefile | 23 | ||||
| -rw-r--r-- | sysutils/whowatch/distinfo | 5 | ||||
| -rw-r--r-- | sysutils/whowatch/files/patch-Makefile.in | 13 | ||||
| -rw-r--r-- | sysutils/whowatch/files/patch-process.c | 11 | ||||
| -rw-r--r-- | sysutils/whowatch/files/patch-procinfo.c | 31 | ||||
| -rw-r--r-- | sysutils/whowatch/files/patch-src_sysinfo__freebsd.c | 121 | ||||
| -rw-r--r-- | sysutils/whowatch/files/patch-whowatch.c | 105 | ||||
| -rw-r--r-- | sysutils/whowatch/files/patch-whowatch.h | 27 | ||||
| -rw-r--r-- | sysutils/whowatch/pkg-descr | 13 |
9 files changed, 142 insertions, 207 deletions
diff --git a/sysutils/whowatch/Makefile b/sysutils/whowatch/Makefile index f1ccc7bad7e0..c317d3b79b4f 100644 --- a/sysutils/whowatch/Makefile +++ b/sysutils/whowatch/Makefile @@ -1,25 +1,22 @@ PORTNAME= whowatch -PORTVERSION= 1.4 -PORTREVISION= 2 +DISTVERSION= 1.8.6.2 CATEGORIES= sysutils -MASTER_SITES= http://wizard.ae.krakow.pl/~mike/download/ \ - PACKETSTORM/UNIX/IDS -MAINTAINER= ports@FreeBSD.org +MAINTAINER= jishanalam9128@gmail.com COMMENT= Displays information in real time about users currently logged on -WWW= http://wizard.ae.krakow.pl/~mike/ +WWW= https://github.com/Zedai00/whowatch/ \ + https://github.com/mtsuszycki/whowatch/ LICENSE= GPLv2 LICENSE_FILE= ${WRKSRC}/COPYING -USES= ncurses +USES= autoreconf ncurses +USE_GITHUB= yes +GH_ACCOUNT= Zedai00 GNU_CONFIGURE= yes -GNU_CONFIGURE_MANPREFIX=${PREFIX}/share -PLIST_FILES= bin/whowatch share/man/man1/${PORTNAME}.1.gz - -pre-patch: - @${FIND} ${WRKSRC} -name 'proc????.c' | ${XARGS} ${REINPLACE_CMD} -E \ - -e 's/kp_.?proc\.._/ki_/ ; s/pcred\.p_//' +PLIST_FILES= bin/whowatch \ + share/applications/whowatch.desktop \ + share/man/man1/whowatch.1.gz .include <bsd.port.mk> diff --git a/sysutils/whowatch/distinfo b/sysutils/whowatch/distinfo index 5a652d9df725..234467f6c041 100644 --- a/sysutils/whowatch/distinfo +++ b/sysutils/whowatch/distinfo @@ -1,2 +1,3 @@ -SHA256 (whowatch-1.4.tar.gz) = 221564dbdf503990e6e14803a1df0c735c61fa6069ebc56a57a8fba9ac22e4f4 -SIZE (whowatch-1.4.tar.gz) = 43084 +TIMESTAMP = 1771524150 +SHA256 (Zedai00-whowatch-1.8.6.2_GH0.tar.gz) = b496a0ac8ec1b0fd282cfe3431eee34a0a6275b9fc93d95bb9cdb65f8cd70c39 +SIZE (Zedai00-whowatch-1.8.6.2_GH0.tar.gz) = 52538 diff --git a/sysutils/whowatch/files/patch-Makefile.in b/sysutils/whowatch/files/patch-Makefile.in deleted file mode 100644 index 28e3c6ec6e86..000000000000 --- a/sysutils/whowatch/files/patch-Makefile.in +++ /dev/null @@ -1,13 +0,0 @@ ---- Makefile.in.orig 2000-06-06 18:42:04.000000000 +0800 -+++ Makefile.in 2013-11-16 21:39:43.000000000 +0800 -@@ -70,8 +70,8 @@ clean: - rm -rf ./*.o - rm -f whowatch - install: whowatch -- $(INSTALL) -m 755 whowatch $(bindir)/whowatch -- $(INSTALL) -m 644 whowatch.1 $(mandir)/man1/whowatch.1 -+ $(BSD_INSTALL_PROGRAM) whowatch $(DESTDIR)$(bindir)/whowatch -+ $(BSD_INSTALL_MAN) whowatch.1 $(DESTDIR)$(mandir)/man1/whowatch.1 - - distclean: - make clean diff --git a/sysutils/whowatch/files/patch-process.c b/sysutils/whowatch/files/patch-process.c deleted file mode 100644 index 8ab666024a78..000000000000 --- a/sysutils/whowatch/files/patch-process.c +++ /dev/null @@ -1,11 +0,0 @@ ---- process.c.orig Wed Apr 4 16:25:29 2007 -+++ process.c Wed Apr 4 16:26:49 2007 -@@ -74,7 +74,7 @@ - memset(z, 0, sizeof *z); - check_line(l); - z->line = l++; -- (struct process *) p->priv = z; -+ p->priv = z; - z->proc = p; - if (*current){ - z->next = *current; diff --git a/sysutils/whowatch/files/patch-procinfo.c b/sysutils/whowatch/files/patch-procinfo.c deleted file mode 100644 index 2f46a20b2fa5..000000000000 --- a/sysutils/whowatch/files/patch-procinfo.c +++ /dev/null @@ -1,31 +0,0 @@ ---- procinfo.c.orig -+++ procinfo.c -@@ -65,7 +65,7 @@ - int fill_kinfo(struct kinfo_proc *info, int pid) - { - int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, pid }; -- int len = sizeof *info; -+ size_t len = sizeof *info; - if(sysctl(mib, 4, info, &len, 0, 0) == -1) - return -1; - return len?0:-1; -@@ -124,7 +124,8 @@ - int get_login_pid(char *tty) - { - int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_TTY, 0}; -- int len, t, el, i, pid, cndt = -1, l; -+ int t, el, i, pid, cndt = -1, l; -+ size_t len; - struct kinfo_proc *info; - struct procinfo p; - -@@ -169,7 +170,8 @@ - int get_all_info(struct kinfo_proc **info) - { - int mib[3] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL }; -- int len, el; -+ int el; -+ size_t len; - - if(sysctl(mib, 3, 0, &len, 0, 0) == -1) - return 0; diff --git a/sysutils/whowatch/files/patch-src_sysinfo__freebsd.c b/sysutils/whowatch/files/patch-src_sysinfo__freebsd.c new file mode 100644 index 000000000000..08642fe6262a --- /dev/null +++ b/sysutils/whowatch/files/patch-src_sysinfo__freebsd.c @@ -0,0 +1,121 @@ +--- src/sysinfo_freebsd.c.orig 2026-02-19 17:57:59 UTC ++++ src/sysinfo_freebsd.c +@@ -5,10 +5,12 @@ + #include <libgeom.h> + #include <libutil.h> + #include <machine/param.h> ++#include <paths.h> + #include <stdint.h> + #include <stdio.h> + #include <stdlib.h> + #include <string.h> ++#include <sys/fcntl.h> + #include <sys/filedesc.h> + #include <sys/linker.h> + #include <sys/mount.h> +@@ -60,6 +62,25 @@ int sys_cpu_info(struct cpu_info_t *cur_cpu_info) { + return 0; + } + ++static uint64_t round1024(uint64_t val) { ++ return (val + 512) >> 10; ++} ++ ++static void sys_mem_info_print(char* name, uint64_t val, int pagesize, int isPages) { ++ uint64_t GiB, MiB, KiB, Bytes, Pages; ++ if (isPages) { ++ Pages = val; ++ Bytes = Pages * pagesize; ++ } else { ++ Bytes = val; ++ Pages = (pagesize <= 0 ? 0 : Bytes / pagesize); ++ } ++ KiB = round1024(Bytes); ++ MiB = round1024(KiB); ++ GiB = round1024(MiB); ++ println("%s|%5llu|%8llu|%11llu|%14llu|%11llu\n", name, GiB, MiB, KiB, Bytes, Pages); ++} ++ + // stole it from top + #define GETSYSCTL(name, var) getsysctl(name, &(var), sizeof(var)) + static void getsysctl(const char *name, void *ptr, size_t len) { +@@ -67,42 +88,54 @@ static void getsysctl(const char *name, void *ptr, siz + + sysctlbyname(name, ptr, &nlen, NULL, 0); + } +-static int pageshift; +-#define pagetok(size) ((size) << pageshift) + + void sys_mem_info(void) { + +- uint64_t physmem; +- int pagesize, v_free, v_active, v_inactive, v_cache, swap_total, swap_used; ++ uint64_t realmem, physmem, v_bufspace, swap_total_sysctl, swap_total = 0, swap_used = 0; ++ unsigned int pagesize, v_free, v_active, v_inactive, v_laundry, v_wire; ++ struct kvm_swap swapary[1]; ++ static kvm_t *kd = NULL; ++ int n; + +- GETSYSCTL("hw.pagesize", pagesize); +- +- pageshift = 0; +- int ps = pagesize; +- while (ps > 1) { +- pageshift++; +- ps >>= 1; ++ if (kd == NULL) { ++ kd = kvm_open(NULL, _PATH_DEVNULL, NULL, O_RDONLY, "kvm_open"); + } +- pageshift -= 10; // LOG1024 ++ if (kd != NULL) { ++ n = kvm_getswapinfo(kd, swapary, 1, 0); ++ if (n >= 0 && swapary[0].ksw_total != 0) { ++ swap_total = swapary[0].ksw_total; ++ swap_used = swapary[0].ksw_used; ++ } ++ } + ++ GETSYSCTL("hw.pagesize", pagesize); + GETSYSCTL("vm.stats.vm.v_free_count", v_free); + GETSYSCTL("vm.stats.vm.v_active_count", v_active); + GETSYSCTL("vm.stats.vm.v_inactive_count", v_inactive); +- GETSYSCTL("vm.stats.vm.v_cache_count", v_cache); +- GETSYSCTL("vm.swap_total", swap_total); +- GETSYSCTL("vm.swap_reserved", swap_used); ++ GETSYSCTL("vm.stats.vm.v_laundry_count", v_laundry); ++ GETSYSCTL("vm.stats.vm.v_wire_count", v_wire); ++ GETSYSCTL("vfs.bufspace", v_bufspace); ++ GETSYSCTL("vm.swap_total", swap_total_sysctl); ++ GETSYSCTL("hw.realmem", realmem); + GETSYSCTL("hw.physmem", physmem); + +- println("MemTotal: %llu kB\n", physmem / 1024); +- println("MemFree: %llu kB\n", pagetok(v_free)); +- println("MemAvailable: %llu kB\n", +- (uint64_t)(v_free + v_inactive + v_cache) * pagesize / 1024); +- println("Active: %llu kB\n", (uint64_t)v_active * pagesize / 1024); +- println("Inactive: %llu kB\n", (uint64_t)v_inactive * pagesize / 1024); +- println("Cached: %llu kB\n", (uint64_t)v_cache * pagesize / 1024); +- println("SwapTotal: %llu kB\n", (uint64_t)swap_total / 1024); +- println("SwapUsed: %llu kB\n", (uint64_t)swap_used / 1024); +- println("SwapFree: %llu kB\n", (uint64_t)(swap_total - swap_used) / 1024); ++ pagesize = (pagesize <= 0 ? 1 : pagesize); ++ ++ println("PageSize: %u Bytes\n", pagesize); ++ println( "Name | GiB | MiB | KiB | Bytes | Pages\n"); ++ sys_mem_info_print("RealMemTotal ", realmem, pagesize, 0); ++ sys_mem_info_print("PhysMemTotal ", physmem, pagesize, 0); ++ sys_mem_info_print("MemFree ", v_free, pagesize, 1); ++ sys_mem_info_print("MemAvailable ", v_free + v_inactive + v_laundry + v_bufspace / pagesize, pagesize, 1); ++ sys_mem_info_print("Active ", v_active, pagesize, 1); ++ sys_mem_info_print("Inactive ", v_inactive, pagesize, 1); ++ sys_mem_info_print("Laundry ", v_laundry, pagesize, 1); ++ sys_mem_info_print("Wired ", v_wire, pagesize, 1); ++ sys_mem_info_print("Buffers ", v_bufspace, pagesize, 0); ++ sys_mem_info_print("SwapTotal Real", swap_total_sysctl, pagesize, 0); ++ sys_mem_info_print("SwapTotal Phys", swap_total, pagesize, 1); ++ sys_mem_info_print("SwapUsed ", swap_used, pagesize, 1); ++ sys_mem_info_print("SwapFree ", swap_total - swap_used, pagesize, 1); + } + + long long sys_open_files() { diff --git a/sysutils/whowatch/files/patch-whowatch.c b/sysutils/whowatch/files/patch-whowatch.c deleted file mode 100644 index 9a0b00848f83..000000000000 --- a/sysutils/whowatch/files/patch-whowatch.c +++ /dev/null @@ -1,105 +0,0 @@ ---- whowatch.c.orig 2000-06-06 03:21:44.000000000 -0700 -+++ whowatch.c 2010-02-02 19:56:37.081269004 -0800 -@@ -119,21 +119,17 @@ - /* - * Create new user structure and fill it - */ --struct user_t *allocate_user(struct utmp *entry) -+struct user_t *allocate_user(struct utmpx *entry) - { - struct user_t *u; - int ppid; - u = calloc(1, sizeof *u); - if(!u) errx(1, "Cannot allocate memory."); -- strncpy(u->name, entry->ut_user, UT_NAMESIZE); -- strncpy(u->tty, entry->ut_line, UT_LINESIZE); -- strncpy(u->host, entry->ut_host, UT_HOSTSIZE); -+ strncpy(u->name, entry->ut_user, sizeof(entry->ut_user)); -+ strncpy(u->tty, entry->ut_line, sizeof(entry->ut_line)); -+ strncpy(u->host, entry->ut_host, sizeof(entry->ut_host)); - --#ifdef HAVE_UTPID - u->pid = entry->ut_pid; --#else -- u->pid = get_login_pid(u->tty); --#endif - - if((ppid = get_ppid(u->pid)) == -1) - strncpy(u->parent, "can't access", sizeof u->parent); -@@ -192,34 +188,24 @@ - */ - void read_utmp() - { -- int fd, i; -- static struct utmp entry; -+ static struct utmpx *entry; - struct user_t *u; -+ -+ while ((entry = getutxent()) != NULL) { - -- if ((fd = open(UTMP_FILE ,O_RDONLY)) == -1){ -- curses_end(); -- errx(1, "Cannot open " UTMP_FILE); -- } -- while((i = read(fd, &entry,sizeof entry)) > 0) { -- if(i != sizeof entry) errx(1, "Error reading " UTMP_FILE ); --#ifdef HAVE_USER_PROCESS -- if(entry.ut_type != USER_PROCESS) continue; --#else -- if(!entry.ut_name[0]) continue; --#endif -- u = allocate_user(&entry); -+ if(entry->ut_type != USER_PROCESS) continue; -+ u = allocate_user(entry); - print_user(u); - update_nr_users(u->parent, &u->prot, LOGIN); - how_many ++; - users_list.d_lines = how_many; - addto_list(u, users); - } -- close(fd); - wnoutrefresh(users_list.wd); - return; - } - --struct user_t* new_user(struct utmp *newone) -+struct user_t* new_user(struct utmpx *newone) - { - struct user_t *u; - u = allocate_user(newone); -@@ -246,7 +232,7 @@ - void check_wtmp() - { - struct user_t *u; -- struct utmp entry; -+ struct utmpx entry; - int i; - - while((i = read(wtmp_fd, &entry, sizeof entry)) > 0){ -@@ -256,25 +242,17 @@ - errx(1, "Error reading " WTMP_FILE ); - } - /* user just logged in */ --#ifdef HAVE_USER_PROCESS - if(entry.ut_type == USER_PROCESS) { --#else -- if(entry.ut_user[0]) { --#endif - u = new_user(&entry); - print_user(u); - wrefresh(users_list.wd); - print_info(); - continue; - } --#ifdef HAVE_DEAD_PROCESS - if(entry.ut_type != DEAD_PROCESS) continue; --#else --// if(entry.ut_line[0]) continue; --#endif - /* user just logged out */ - for_each(u, users) { -- if(strncmp(u->tty, entry.ut_line, UT_LINESIZE)) -+ if(strncmp(u->tty, entry.ut_line, sizeof(entry.ut_line))) - continue; - if (state == USERS_LIST) - delete_line(&users_list, u->line); diff --git a/sysutils/whowatch/files/patch-whowatch.h b/sysutils/whowatch/files/patch-whowatch.h deleted file mode 100644 index b0e051737708..000000000000 --- a/sysutils/whowatch/files/patch-whowatch.h +++ /dev/null @@ -1,27 +0,0 @@ ---- whowatch.h.orig 2010-02-02 19:18:34.763514932 -0800 -+++ whowatch.h 2010-02-02 19:20:44.905393020 -0800 -@@ -2,7 +2,7 @@ - #include <stdlib.h> - #include <unistd.h> - #include <fcntl.h> --#include <utmp.h> -+#include <utmpx.h> - #include <string.h> - #include <signal.h> - #include <sys/stat.h> -@@ -75,12 +75,12 @@ - { - struct user_t *next; - struct user_t *prev; -- char name[UT_NAMESIZE + 1]; /* login name */ -- char tty[UT_LINESIZE + 1]; /* tty */ -+ char name[sizeof(((struct utmpx *)0)->ut_user)]; /* login name */ -+ char tty[sizeof(((struct utmpx *)0)->ut_line)]; /* tty */ - int prot; - int pid; /* pid of login shell */ - char parent[16]; -- char host[UT_HOSTSIZE + 1]; -+ char host[sizeof(((struct utmpx *)0)->ut_host)]; - int line; - }; - diff --git a/sysutils/whowatch/pkg-descr b/sysutils/whowatch/pkg-descr index c7367b9a311b..9049660980e3 100644 --- a/sysutils/whowatch/pkg-descr +++ b/sysutils/whowatch/pkg-descr @@ -1,5 +1,8 @@ -Whowatch is an interactive who-like program that displays information about the -users currently logged on to the machine. In addition to standard information -(login name, tty, host, user's process), the type of the connection (telnet or -ssh) is shown. You can toggle display between the users' commands or idle times. -You can watch the process tree, navigate in it, and send INT and KILL signals. +Whowatch is an interactive, ncurses-based, process and users monitoring tool +which updates information in real time. It can be described as a some kind of +interactive mix of ps, pstree, lsof, w, finger and kill. You can watch +information about users currently logged on to the machine: login type - ie. +"ssh" "telnet", tty, host, idle time and command line of their current process. +You can also naviagate in processes tree, watch process details (memory, uid, +open descriptors with TCP sockets mapped on IP:port -> IP:port pair etc.). +Whowatch has support for plugins. |
