FreeBSD Stuff
FreeBSD Tuning and Optimization
Package Management
To list files installed by the package rsyslog
:
pkg info -l rsyslog
Checking up on sockets
Use man netstat, or, better yet, man sockstat.
To display listening sockets:
sockstat -l
Display Partition Table in FreeBSD
# geom disk list
# geom disk list ada5
More: https://www.cyberciti.biz/faq/freebsd-hard-disk-information/
gpart
Show all the partitions:
root@nass[~]# gpart show
=> 40 61865904 ada6 GPT (30G)
40 532480 1 efi (260M)
532520 61308928 2 freebsd-zfs (29G)
61841448 24496 - free - (12M)
=> 40 11721045088 ada5 GPT (5.5T)
40 88 - free - (44K)
128 4194304 1 freebsd-swap (2.0G)
4194432 11716850696 - free - (5.5T)
root@nass[~]# gpart show ada5
=> 40 11721045088 ada5 GPT (5.5T)
40 88 - free - (44K)
128 4194304 1 freebsd-swap (2.0G)
4194432 11716850696 - free - (5.5T)
root@nass[~]# gpart delete -i 1 ada5
ada5p1 deleted
root@nass[~]# gpart show ada5
=> 40 11721045088 ada5 GPT (5.5T)
40 11721045088 - free - (5.5T)
root@nass[~]# gpart destroy ada5
ada5 destroyed
root@nass[~]# gpart show ada5
gpart: No such geom: ada5.
driveid
#!/bin/sh
echo
echo $(basename $0) - Mounted Drives on $(hostname)
cat /etc/version
date
echo
#diskinfo="$(glabel status | tail -n +2 | awk '{split($3,a,"p"); print a[1],$1}')"
diskinfo="$(glabel status | tail -n +2 | awk '{print $3,$1}')" # Temp Bug fix to accomodate botH p1/p2
echo "+========+==========================+======================+============================================+"
echo "| Device | DISK DESCRIPTION | SERIAL# | GPTID |"
echo "+========+==========================+======================+============================================+"
for d in $(echo "$diskinfo" | cut -d" " -f 1)
do
diskinf=$(diskinfo -v $d | grep '# Disk ')
diskdescription=$(echo "$diskinf" | grep '# Disk desc' | cut -d# -f 1 | xargs)
diskserialno=$(echo "$diskinf" | grep '# Disk ident' | cut -d# -f 1 | xargs)
diskgptid=$(echo "$diskinfo" | grep ^$d | cut -d" " -f 2)
printf "| %-6s | %-24s | %-20s | %-42s |\n" "$d" "$diskdescription" "$diskserialno" "$diskgptid"
echo "+--------+--------------------------+----------------------+--------------------------------------------+"
done
systemps
#!/bin/sh
# relies on sensors, nvme, hddtemp
# cleanup
rm -f /tmp/temps_????????_??????
now=$(date +"%Y%m%d_%H%M%S")
TMPFILE="/tmp/temps_$now"
adastat () {
# this emits:
# status, error, lba_low, lba_mid, lba_high, device, lba_low_exp, lba_mid_exp, lba_high_exp, sector_count, sector_count_exp
echo `camcontrol cmd $1 -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r - | awk '{print $10 " " ; }'` " " ;
}
(
#echo "To: your email address"
#echo "Subject: System Temperatures INFO"
#echo " "
echo System temperatures - `date`
echo "$(uname -nsrm), $(cat /etc/version)"
echo -n 'System load: '
uptime | sed -n -e 's/^.*load averages: //p'
# this does not work if CPU is virtualized
echo "CPUs:"
sysctl -a | egrep -E "cpu\.[0-9]+\.temp" | awk '{ print $2 }'
#echo -e 'HDDs Activity Status'
#for i in $(sysctl -n kern.disks | awk '{for (i=NF; i!=0 ; i--) if(match($i, '/ada/')) print $i }' )
#do
# echo -n $i:;adastat $i
#done
echo -e 'HDDs:'
for i in $(sysctl -n kern.disks | awk '{for (i=NF; i!=0 ; i--) if(match($i, '/ada/')) print $i }' )
do
echo $i `smartctl -a /dev/$i|awk '/Temperature_Celsius/{DevTemp=$10;} /Serial Number:/{DevSerNum=$3} END { printf "%-25s %s°C\n",DevSerNum,DevTemp }'`
done
echo
) > $TMPFILE
#sendmail -t < $TMPFILE
cat $TMPFILE