*New 12.1 series Release:
2020-04-17: XigmaNAS 12.1.0.4.7542 - released

*New 11.3 series Release:
2020-04-16: XigmaNAS 11.3.0.4.7538 - released!


We really need "Your" help on XigmaNAS https://translations.launchpad.net/xigmanas translations. Please help today!

Producing and hosting XigmaNAS costs money. Please consider donating for our project so that we can continue to offer you the best.
We need your support! eg: PAYPAL

[HOWTO] Install NCurses Disk Usage (embedded)

XigmaNAS Scripts and shell tips
Forum rules
Set-Up GuideFAQsForum Rules
Post Reply
ginggs
Starter
Starter
Posts: 31
Joined: 27 Jun 2012 14:30
Status: Offline

[HOWTO] Install NCurses Disk Usage (embedded)

#1

Post by ginggs »

Here is another script based on danmero's script for installing Midnight Commander.

Now updated for XigmaNAS 12.1.0.4.

NCurses Disk Usage
Ncdu is a disk usage analyzer with an ncurses interface. It is designed to find space hogs on a remote server where you don't have an entire graphical setup available, but it is a useful tool even on regular desktop systems. Ncdu aims to be fast, simple and easy to use, and should be able to run in any minimal POSIX-like environment with ncurses installed.
Image
Image
More screenshots.

Code: Select all

#!/bin/sh
# filename:     ncdu.sh
# author:       Graham Inggs
# date:         2018-05-24 ; Initial release for NAS4Free 11.1.0.4
# date:         2018-12-29 ; Updated for XigmaNAS 11.2.0.4
# date:         2019-10-29 ; Updated for XigmaNAS 12.0.0.4 (no changes)
# date:         2019-11-25 ; Updated for XigmaNAS 12.1.0.4
# purpose:      Install NCurses Disk Usage (ncdu) on XigmaNAS (embedded version).
# Note:         Check the end of the page.
#
#----------------------- Set variables ------------------------------------------------------------------
DIR=`dirname $0`;
PLATFORM=`uname -m`
RELEASE=`uname -r | cut -d- -f1`
REL_MAJOR=`echo $RELEASE | cut -d. -f1`
REL_MINOR=`echo $RELEASE | cut -d. -f2`
URL="http://distcache.freebsd.org/FreeBSD:${REL_MAJOR}:${PLATFORM}/release_${REL_MINOR}/All"
NCDUFILE="ncdu-1.14.1.txz"
#----------------------- Set Errors ---------------------------------------------------------------------
_msg() { case $@ in
  0) echo "The script will exit now."; exit 0 ;;
  1) echo "No route to server, or file do not exist on server"; _msg 0 ;;
  2) echo "Can't find ${FILE} on ${DIR}"; _msg 0 ;;
  3) echo "NCurses Disk Usage installed and ready! (ONLY USE DURING A SSH SESSION)"; exit 0 ;;
  4) echo "Always run this script using the full path: /mnt/.../directory/ncdu.sh"; _msg 0 ;;
esac ; exit 0; }
#----------------------- Check for full path ------------------------------------------------------------
if [ ! `echo $0 |cut -c1-5` = "/mnt/" ]; then _msg 4; fi
cd $DIR;
#----------------------- Download and decompress ncdu files if needed -----------------------------------
FILE=${NCDUFILE}
if [ ! -d ${DIR}/usr/local/bin ]; then
  if [ ! -e ${DIR}/${FILE} ]; then fetch ${URL}/${FILE} || _msg 1; fi
  if [ -f ${DIR}/${FILE} ]; then tar xzf ${DIR}/${FILE} || _msg 2;
    rm ${DIR}/+*; rm -R ${DIR}/usr/local/man; rm -R ${DIR}/usr/local/share; fi
  if [ ! -d ${DIR}/usr/local/bin ] ; then _msg 4; fi
fi
#----------------------- Create wrapper script to enable experimental color support ---------------------
if [ ! -e ${DIR}//usr/local/bin/ncdu.real ]; then
  mv ${DIR}/usr/local/bin/ncdu ${DIR}/usr/local/bin/ncdu.real
  cat <<'EOF' >${DIR}/usr/local/bin/ncdu
#!/bin/sh
/usr/local/bin/ncdu.real --color dark "$@"
EOF
  chmod +x ${DIR}/usr/local/bin/ncdu
fi
#----------------------- Create symlinks ----------------------------------------------------------------
for i in `ls $DIR/usr/local/bin/`
  do if [ ! -e /usr/local/bin/${i} ]; then ln -s ${DIR}/usr/local/bin/$i /usr/local/bin; fi; done
_msg 3 ; exit 0;
#----------------------- End of Script ------------------------------------------------------------------
# 1. Keep this script in its own directory.
# 2. chmod the script u+x,
# 3. Always run this script using the full path: /mnt/.../directory/ncdu.sh
# 4. You can add this script to WebGUI: Advanced: Command Scripts as a PostInit command (see 3).
# 5. To run Ncurses Disk Usage from shell type 'ncdu'.
Code also on github.

Fetch the current version:

Code: Select all

fetch https://github.com/ginggs/xigmanas-ncdu/raw/master/ncdu.sh
Last edited by ginggs on 25 Nov 2019 14:30, edited 7 times in total.

User avatar
JoseMR
Hardware & Software Guru
Hardware & Software Guru
Posts: 1124
Joined: 16 Apr 2014 04:15
Location: PR
Contact:
Status: Offline

Re: [HOWTO] Install NCurses Disk Usage (embedded)

#2

Post by JoseMR »

Very nice work, neat utility indeed, I also use "htop" and "mc-light" as well for its nice graphical stats and functionality, yet small foot print, a must have little admin tools to be included into any OS base I could say.

Regards
System: FreeBSD 12 RootOnZFS Mirror, MB: Supermicro X8SI6-F, Xeon X3450, 16GB DDR3 ECC RDIMMs.
XigmaNAS RootOnZFS
Addons at GitHub
BastilleBSD
Boot Environments Intro
Resources Home Page

ginggs
Starter
Starter
Posts: 31
Joined: 27 Jun 2012 14:30
Status: Offline

Re: [HOWTO] Install NCurses Disk Usage (embedded)

#3

Post by ginggs »

Now updated for XigmaNAS 11.2.0.4.

ginggs
Starter
Starter
Posts: 31
Joined: 27 Jun 2012 14:30
Status: Offline

Re: [HOWTO] Install NCurses Disk Usage (embedded)

#4

Post by ginggs »

JoseMR wrote:
13 Jun 2018 10:06
Very nice work, neat utility indeed, I also use "htop" and "mc-light" as well for its nice graphical stats and functionality, yet small foot print, a must have little admin tools to be included into any OS base I could say.
Thanks for mentioning htop! I've made a similar installer for it.

Northwinds
Starter
Starter
Posts: 21
Joined: 03 Sep 2014 01:51
Status: Offline

Re: [HOWTO] Install NCurses Disk Usage (embedded)

#5

Post by Northwinds »

Hi there i managed to install this manually to /mnt/pool_1/ncdu/ and then run it manually through terminal (osx) via ssh, but running it through the xigmanas gui I'm having issues.

I went to the tools menu then command and typed in ncdu and clicked execute but I get nothing?

I noticed under OneButtonInstaller (that I already had installed that it also offers an option to install it, which I tried but again I can't start it as suggested there:
"After successful installation you can use NCDU in the system console shell "

Any help please?

Thanks!
11.0.0.4.4067
x64-embedded on Intel(R) Core(TM)2 CPU 6600 @ 2.40GHz
Supermicro X7SB4/E with 2x Single-port Gigabit PCI-Express Ethernet Controllers
8GB RAM
6 x Seagate ST4000VN000 4TB NAS HDD

cookiemonster
Advanced User
Advanced User
Posts: 253
Joined: 23 Mar 2014 02:58
Location: UK
Status: Offline

Re: [HOWTO] Install NCurses Disk Usage (embedded)

#6

Post by cookiemonster »

ncdu is intended to be used over a console connection, normally ssh. One connects to the server via ssh, and then type ncdu. It launches and one navigates with the keyboard. It is not a "clickable" type of application.
Main: Xigmanas 11.2.0.4 x64-full-RootOnZFS as ESXi VM with 24GB memory.
Main Host: Supermicro X8DT3 Memory: 72GB ECC; 2 Xeon E5645 CPUs; Storage: (HBA) - LSI SAS 9211-4i with 3 SATA x 1 TB in raidZ1, 1 x 3 TB SAS drive as single stripe, 3 x 4 TB SAS drives in raidZ1.
Spare1: HP DL360 G7; 6 GB ECC RAM; 1 Xeon CPU; 5 x 500 GB disks on H210i
Backup1: HP DL380 G7; 24 GB ECC RAM; 2 Xeon E5645 CPUs; 8 x 500 GB disks on IBM M1015 flashed to LSI9211-IT

Post Reply

Return to “Scripts and shell tips”