OPNsense Forum

English Forums => Tutorials and FAQs => Topic started by: brad.edmondson on November 17, 2019, 01:36:44 am

Title: Install htop process monitor
Post by: brad.edmondson on November 17, 2019, 01:36:44 am
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:
Code: [Select]
# opnsense-code tools ports src
Switch source to current version:
Code: [Select]
# cd /usr/src
# git checkout stable/21.1

install dependencies:
Code: [Select]
#  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:
Code: [Select]
# 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:
Code: [Select]
# opnsense-code tools src
attempt to update ports tree:
Code: [Select]
#  opnsense-code portsthat 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*:
Code: [Select]
# pkg query --all '%o %R' | grep -v '\ OPNsense$'
sysutils/htop unknown-repository
net/arping unknown-repository

Remove each non-OpnSense-precompiled package, e.g.:
Code: [Select]
# cd /usr/ports/sysutils/htop && make deinstall && make clean
Code: [Select]
# cd /usr/ports/net/arping && make deinstall && make clean
Remove the ports tree entirely:
Code: [Select]
# rm -rf /usr/ports/
Fetch the ports tree anew:
Code: [Select]
# opnsense-code ports
Switch source to current version:
Code: [Select]
# 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):
Code: [Select]
#  pkg install autoconf automake libtool

Install htop:
Code: [Select]
# cd /usr/ports/sysutils/htop
# make install clean

After that, htop is working beautifully again! Thanks OpnSense team!
Title: Re: Install htop process monitor
Post by: franco on November 19, 2019, 09:31:50 am
Hi Brad,

Thanks for the writeup! :)


Cheers,
Franco
Title: Re: Install htop process monitor
Post by: robvanhooren on November 24, 2019, 12:03:22 am
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
Code: [Select]
make install clean instead, to keep things tidy  :)
Title: Re: Install htop process monitor
Post by: warhawk8080 on June 25, 2020, 09:35:11 am
No longer works on OPNsense 20.1.7

Code: [Select]
--- 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
Code: [Select]
# cd /usr/src
# git checkout stable/20.1

working now very well  Thanks!!!!!
Title: Re: Install htop process monitor
Post by: genesysguy on March 30, 2021, 10:24:41 pm
How would you go about removing ports and src to free the disk space back up?
Title: Re: Install htop process monitor
Post by: brad.edmondson on March 30, 2021, 11:17:47 pm
Quote
How 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.
Title: Re: Install htop process monitor
Post by: levifig on June 15, 2023, 05:09:21 pm
23.1.9 here and these are the steps I needed to run to install htop:

Code: [Select]
$ 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+.
Title: Re: Install htop process monitor
Post by: franco on June 16, 2023, 08:05:31 am
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
Title: Re: Install htop process monitor
Post by: Dimi3 on June 16, 2023, 10:46:51 am
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.

Title: Re: Install htop process monitor
Post by: cookiemonster on June 16, 2023, 11:01:33 am
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.