Install htop process monitor

Started by brad.edmondson, November 17, 2019, 01:36:44 AM

Previous topic - Next topic
November 17, 2019, 01:36:44 AM Last Edit: March 08, 2022, 06:02:52 AM by brad.edmondson
The classic top process monitor just doesn't cut it for me. I prefer htop, with processor & memory graphs, sorting options (including tree), and commands/keys called out in the UI (see attached).



You can install htop on Opnsense from the FreeBSD ports tree. Note that this takes up a lot of space; 3gb for me (1.2gb for ports, 1.7gb for src). On *Opnsense 21.1.2*, I had to do the following:

grab the ports tree, plus tools and source to compile from it:
# opnsense-code tools ports src

Switch source to current version:

# cd /usr/src
# git checkout stable/21.1


install dependencies:

#  pkg install autoconf automake libtool


I installed these as part of troubleshooting the htop install process (I tried resolving the build errors , so I'm not sure whether they would be automatically installed if you skip this step. If you try it out, let me know!)

Install htop:

# cd /usr/ports/sysutils/htop
# make install clean






2021-02-23 Update: changed make command to "make install clean" and updated source tree for v21.1: "# git checkout stable/21.1". Validated this works for me as of 2021-02-23 on OPNsense 21.1.2.



2022-03-07 Update: After upgrading to OpnSense 22.1, htop was still installed, but would not launch (this is expected due to library version changes). To get htop working again, I had to remove and reinstall it per the following:

update sources for tools and src repos:
# opnsense-code tools src

attempt to update ports tree:
#  opnsense-code ports
that didn't work for me, dying halfway through with a git error about "invalid distance" "too far back" for one of the objects.

Instead, I uninstalled all previous ports and removed the ports tree under /usr/ports. List installed ports by asking pkg to tell us which installed packages do not come from the OpnSense repository (those that do end with the repo string " OPNsense" so grep -v functions as a logical *not*:
# pkg query --all '%o %R' | grep -v '\ OPNsense$'
sysutils/htop unknown-repository
net/arping unknown-repository


Remove each non-OpnSense-precompiled package, e.g.:
# cd /usr/ports/sysutils/htop && make deinstall && make clean
# cd /usr/ports/net/arping && make deinstall && make clean

Remove the ports tree entirely:
# rm -rf /usr/ports/

Fetch the ports tree anew:
# opnsense-code ports

Switch source to current version:

# cd /usr/src
# git checkout stable/22.1


install dependencies if needed (if not needed, pkg will just let you know they're already the latest version):

#  pkg install autoconf automake libtool


Install htop:

# cd /usr/ports/sysutils/htop
# make install clean


After that, htop is working beautifully again! Thanks OpnSense team!

Hi Brad,

Thanks for the writeup! :)


Cheers,
Franco

lft is also nice to have (/usr/ports/net/lft)
looks like mtr's available by default, lft's not.
hrrrrumph.  :(

ps @brad -- suggest doing make install clean instead, to keep things tidy  :)

June 25, 2020, 09:35:11 AM #3 Last Edit: June 25, 2020, 09:43:28 AM by warhawk8080
No longer works on OPNsense 20.1.7

--- usage.o ---
cc  -pipe -DHARDENEDBSD -fPIE -fPIC -fsanitize=safe-stack -fstack-protector-all -fno-strict-aliasing -DHARDENEDBSD -DNEEDS_BOOL_TYPEDEF -DHASTASKS -DHAS_PAUSE_SBT -DHAS_DUP2 -DHAS_CLOSEFROM -DHASEFFNLINK=i_effnlink -DHASF_VNODE -DHAS_FILEDESCENT -DHAS_TMPFS -DHASWCTYPE_H -DHASSBSTATE -DHAS_KVM_VNODE -DHAS_UFS1_2 -DHAS_NO_IDEV -DHAS_VM_MEMATTR_T -DNEEDS_DEVICE_T -DHAS_CDEV2PRIV -DHAS_NO_SI_UDEV -DHAS_SYS_SX_H -DHASFUSEFS -DHAS_ZFS -DHAS_V_LOCKF -DHAS_LOCKF_ENTRY -DHAS_NO_6PORT -DHAS_NO_6PPCB -DNEEDS_BOOLEAN_T -DHAS_SB_CCC -DHAS_FDESCENTTBL -DFREEBSDV=11000 -DHASFDESCFS=2 -DHASPSEUDOFS -DHASNULLFS -DHASIPv6 -DHASUTMPX -DHAS_STRFTIME -DLSOF_VSTR=\"11.2-RELEASE-p20-HBSD\" -I/usr/src/sys -O2 -c usage.c -o usage.o
--- dnode2.o ---
1 warning and 1 error generated.
*** [dnode2.o] Error code 1

make[3]: stopped in /usr/obj/usr/ports/sysutils/lsof/work/lsof-4.93.2
1 error

make[3]: stopped in /usr/obj/usr/ports/sysutils/lsof/work/lsof-4.93.2
*** [dnode2.o] Error code 2

make[2]: stopped in /usr/obj/usr/ports/sysutils/lsof/work/lsof-4.93.2
--- lib/liblsof.a ---
A failure has been detected in another branch of the parallel make

make[3]: stopped in /usr/obj/usr/ports/sysutils/lsof/work/lsof-4.93.2/lib
*** [lib/liblsof.a] Error code 2

make[2]: stopped in /usr/obj/usr/ports/sysutils/lsof/work/lsof-4.93.2
2 errors

make[2]: stopped in /usr/obj/usr/ports/sysutils/lsof/work/lsof-4.93.2
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/sysutils/lsof
*** Error code 1

Stop.
make: stopped in /usr/ports/sysutils/htop





-------edit

Correction..I had to update to current distro
# cd /usr/src
# git checkout stable/20.1


working now very well  Thanks!!!!!

How would you go about removing ports and src to free the disk space back up?

March 30, 2021, 11:17:47 PM #5 Last Edit: March 08, 2022, 06:05:59 AM by brad.edmondson
QuoteHow would you go about removing ports and src to free the disk space back up?

Sorry, I don't have any experience proving out what works and what doesn't there. I just leave it since there's plenty of space on the SSD in my main OpnSense box.

If I had to guess, I'd say it's likely you can remove the dependency packages once it's compiled and installed and it'll still work, but you wouldn't be able to compile an updated version if and when that becomes necessary. I also don't know if there is an "autoremove" for unnecessary dependencies here like there is in some OS' package managers, but if I needed to figure this out I'd start by googling the same question about FreeBSD.



2022-03-08 Update: Removed HardenedBSD mention, as OpnSense' upstream is now FreeBSD 13 rather than HardenedBSD.

23.1.9 here and these are the steps I needed to run to install htop:


$ opnsense-code tools src
$ pkg install autoconf automake libtool
$ cd /usr/ports/sysutils/htop
$ make install clean


...and voilá: it works!

Thanks for the help and hope this helps anyone arriving here on 23.x+.

I'd recommend:

$ pkg install -A autoconf automake libtool

It installs these packages as automatic dependencies which clean up afterwards instead of sticking around in your system unused.


Cheers,
Franco

Would it make sense to include htop by default in OPNSense?..I also allways install it..not that is hard work to install it :), but sure is more usable than top.


mimugmail has it on his/her repo as an installable package.
So all is needed is add his repo and htop is a "#pkg install htop" away.