Cyberpower – power panel

root@donkey:/data/software# dpkg -i powerpanel_132_amd64.deb

root@donkey:/data/software# pwrstat -status -test

The UPS information shows as following:

Properties:
    Model Name................... CP1000PFCLCD
    Firmware Number.............. 000000000000
    Rating Voltage............... 120 V
    Rating Power................. 600 Watt

Current UPS status:
    State........................ Normal
    Power Supply by.............. Utility Power
    Utility Voltage.............. 122 V
    Output Voltage............... 122 V
    Battery Capacity............. 100 %
    Remaining Runtime............ 36 min.
    Load......................... 102 Watt(17 %)
    Line Interaction............. None
    Test Result.................. Unknown
    Last Power Event............. None

root@donkey:/data/software# pwrstat -config

Daemon Configuration:

Alarm ………………………………………. On
Hibernate …………………………………… Off

Action for Power Failure:

Delay time since Power failure ............. 60 sec.
Run script command ......................... On
Path of script command ..................... /etc/pwrstatd-powerfail.sh
Duration of command running ................ 0 sec.
Enable shutdown system ..................... On

Action for Battery Low:

Remaining runtime threshold ................ 300 sec.
Battery capacity threshold ................. 35 %.
Run script command ......................... On
Path of command ............................ /etc/pwrstatd-lowbatt.sh
Duration of command running ................ 0 sec.
Enable shutdown system ..................... On


root@donkey:/data/software# pwrstat -config

Daemon Configuration:

Alarm ………………………………………. On
Hibernate …………………………………… Off

Action for Power Failure:

Delay time since Power failure ............. 60 sec.
Run script command ......................... On
Path of script command ..................... /etc/pwrstatd-powerfail.sh
Duration of command running ................ 0 sec.
Enable shutdown system ..................... On

Action for Battery Low:

Remaining runtime threshold ................ 300 sec.
Battery capacity threshold ................. 35 %.
Run script command ......................... On
Path of command ............................ /etc/pwrstatd-lowbatt.sh
Duration of command running ................ 0 sec.
Enable shutdown system ..................... On

root@donkey:/data/software# cat /etc/pwrstatd-powerfail.sh

!/bin/sh

echo “Warning: Utility power failure has occurred for a while, system will be shutdown soon!” | wall

export RECEIPT_NAME
export RECEIPT_ADDRESS
export SENDER_ADDRESS

#

If you want to receive event notification by e-mail, you must change ‘ENABLE_EMAIL’ item to ‘yes’.

Note: After change ‘ENABLE_EMAIL’ item, you must asign ‘RECEIPT_NAME’, ‘RECEIPT_ADDRESS’, and

‘SENDER_ADDRESS’ three items as below for the correct information.

#

Enable to send e-mail

ENABLE_EMAIL=yes

Change your name at this itme.

RECEIPT_NAME=”Jeremiah Jester”

Change mail receiver address at this itme.

RECEIPT_ADDRESS=jeremiahjester@gmail.com

Change mail sender address at this itme.

SENDER_ADDRESS=root@donkey.duckdns.org

Execute the ‘pwrstatd-email.sh’ shell script

if [ $ENABLE_EMAIL = yes ]; then
/etc/pwrstatd-email.sh
fi


Plex Media Scanner cmd line Error & fix

Error:

jjest@donkey:~$ sudo /usr/lib/plexmediaserver/Plex\ Media\ Scanner –list
/usr/lib/plexmediaserver/Plex Media Scanner: error while loading shared libraries: libboost_atomic.so.1.59.0: cannot open shared object file: No such file or directory

Resolution:

root@donkey:~# LD_LIBRARY_PATH=/usr/lib/plexmediaserver
You have new mail in /var/mail/root
root@donkey:~# PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=”/var/lib/plexmediaserver/Library/Application Support”
root@donkey:~# export LD_LIBRARY_PATH=/usr/lib/plexmediaserver
root@donkey:~# export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=”/var/lib/plexmediaserver/Library/Application Support”

Fixed!

Usage:

root@donkey:~# /usr/lib/plexmediaserver/Plex\ Media\ Scanner –list

3: House
1: Movies
5: Photos
2: Triplex
4: TV Shows
root@donkey:~# /usr/lib/plexmediaserver/Plex\ Media\ Scanner –progress –generate -c 2
Generated new media for Triplex Common 01 20190225103159.
Generated new media for Triplex Common 01 20190225120808.
Generated new media for Triplex Common 01 20190225121139.
Generated new media for Triplex Common 01 20190225121233.
Generated new media for Triplex Common 01 20190225122931.

check home disk usage script

# cat ./check_quotas.sh

!/bin/bash

day_max_limit=30 #int
home_dir_size_limit_bytes=1000000 #int
file_size_mb=10 #int

for host in ihop1; do
while read LINE; do
username=$(echo “$LINE” | cut -f1 -d”:”)
home_path=$(echo “$LINE” | cut -f6 -d”:” | egrep ‘(home|homes)’)
if [[ -e $home_path ]]; then
home_dir_size_bytes=$(du -s ${home_path} | cut -d ‘/’ -f 1 | tr -d [[:space:]] )
home_dir_size_mb=$(expr “$(($home_dir_size_bytes/1024))”)
if [[ “$home_dir_size_bytes” -gt “$home_dir_size_limit_bytes” ]]; then
cmd=$(find $home_path -ctime +${day_max_limit} -size +${file_size_mb}M -exec du -sh {} \;)
if [[ ! -z $cmd ]]; then
echo -e “Hi $username,\n\nYou’re home directory $home_path on $host is now ${home_dir_size_mb}M. This server is intended for temporary storage and will be purge every 30 days.\n”
#echo “” #echo $username@$host:$home_path
for file in $cmd; do
echo $file;
done
echo “”
fi
fi
fi
done < /etc/passwd
done

Test SCP ciphers for improved speed

jjest@donkey:~$ for cipher in $(ssh -Q cipher localhost); do echo $cipher; scp -c “$cipher” CrashPlanSmb_6.7.2_1512021600672_5609_Linux.tgz backupsrv:~; done
3des-cbc
Unable to negotiate with 192.168.0.110 port 22: no matching cipher found. Their offer: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
lost connection
aes128-cbc
Unable to negotiate with 192.168.0.110 port 22: no matching cipher found. Their offer: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
lost connection
aes192-cbc
Unable to negotiate with 192.168.0.110 port 22: no matching cipher found. Their offer: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
lost connection
aes256-cbc
Unable to negotiate with 192.168.0.110 port 22: no matching cipher found. Their offer: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
lost connection
rijndael-cbc@lysator.liu.se
Unable to negotiate with 192.168.0.110 port 22: no matching cipher found. Their offer: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
lost connection
aes128-ctr
jjest@backupsrv’s password:
CrashPlanSmb_6.7.2_1512021600672_5609_Linux.tgz 100% 102MB 63.5MB/s 00:01
aes192-ctr
jjest@backupsrv’s password:
CrashPlanSmb_6.7.2_1512021600672_5609_Linux.tgz 100% 102MB 51.1MB/s 00:02
aes256-ctr
jjest@backupsrv’s password:
CrashPlanSmb_6.7.2_1512021600672_5609_Linux.tgz 100% 102MB 51.1MB/s 00:02
aes128-gcm@openssh.com
jjest@backupsrv’s password:
CrashPlanSmb_6.7.2_1512021600672_5609_Linux.tgz 100% 102MB 60.7MB/s 00:01
aes256-gcm@openssh.com
jjest@backupsrv’s password:
CrashPlanSmb_6.7.2_1512021600672_5609_Linux.tgz 100% 102MB 42.4MB/s 00:02
chacha20-poly1305@openssh.com
jjest@backupsrv’s password:
CrashPlanSmb_6.7.2_1512021600672_5609_Linux.tgz 100% 102MB 90.5MB/s 00:01

nagios: check_mdadm

#supports multiple mdadm arrays

root@backupsrv:~# cat /usr/local/ncpa/plugins/check_mdadm
#!/bin/bash
arrays=$(df | grep md | cut -d ‘ ‘ -f 1)
msg=””
for array in $arrays; do
state=$(sudo mdadm -D $array | grep -i “State :” | cut -d ‘:’ -f 2)
if [[ $state -ne “clean” ]]; then
msg+=”ERROR: $array is $state”
error=1
else
msg+=”OK: $array is $state”
ok=0
fi
done

echo $msg

if [[ -x $error ]]; then
exit $error
else
exit $ok
fi

root@backupsrv:~# /usr/local/ncpa/plugins/check_mdadm
OK: /dev/md127p1 is clean OK: /dev/md0p1 is clean, resyncing

nagios: check_triplex_cctv

jjest@house-nagios:~$ cat /usr/local/nagios/libexec/check_triplex_cctv
#!/bin/bash
host=$1
if [[ ! -z $host ]]; then
ssh nagios@triplex.duckdns.org “ping -c 2 $host” > /dev/null
resultant=$?
if [[ $resultant == “0” ]]; then
echo “OK – $host”
exit 0
else
echo “ERROR – $host”
exit 1
fi
else
echo “ERROR – No host value given”
exit 1
fi

Updating resolv.conf dns search

/etc/resolv.conf gets overriden by resolconf. To make domain-search to save edit interfaces file w/ dns-search

jjest@canadark:~$ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
dns-search mcis.washington.edu amc.uwmedicine.org

Virtual Box – Automating OVA’s backups

#!/bin/bash
#jjest@donkey:~$ VBoxManage list vms
#”house-plex-new” {14c956f3-79a5-447d-a1a8-4bfe091d6bed}
#”house-nagios_1″ {6b219ce4-cdbc-49c8-b899-e1e61e64b096}
#”house-ftp” {d126abb8-927d-4066-b66a-c0d52abec7c2}

date=$(date “+%Y%m%d”)
backup_path=”/data/vms/vm-backups”
for vm in $(VBoxManage list vms | cut -d ‘”‘ -f 2); do
#CREATE DIR IF NOT EXISTS
if [[ ! -d “$backup_path/$vm” ]]; then
echo “Creating $backup_path/$vm”
mkdir “$backup_path/$vm”
fi

#SHUTDOWN IF RUNNING
running_vm=$(VBoxManage list runningvms | cut -d ‘”‘ -f 2 | grep “$vm”)
if [[ “$running_vm” == “$vm” ]]; then
echo “Powering off $vm…”
VBoxManage controlvm “$vm” poweroff
else
echo “$vm already powered off…”
fi

#EXPORT OVA
if [[ ! -e “$backup_path/$vm/$vm-$date.ova” ]]; then
echo “Exporting $vm…”
VBoxManage export “$vm” -o “$backup_path/$vm/$vm-$date.ova”
else
echo “$vm-$date.ova already exists!”
fi

#POWER ON VM
echo “Powering on $vm…”
VBoxManage startvm “$vm” –type headless
done

google drive linux cli client.

https://www.fossmint.com/grive2-google-drive-client-for-linux/

Storcli for Avago/LSI Raid controllers

sudo apt-get install alien

jjest@backupsrv:~$ alien /data/software/StoreCLI/storcli_all_os/Linux/storcli-1.19.04-1.noarch.rpm
Must run as root to convert to deb format (or you may use fakeroot).
jjest@backupsrv:~$ sudo alien /data/software/StoreCLI/storcli_all_os/Linux/storcli-1.19.04-1.noarch.rpm
Warning: Skipping conversion of scripts in package storcli: postinst postrm prerm
Warning: Use the –scripts parameter to include the scripts.
storcli_1.19.04-2_all.deb generated
jjest@backupsrv:~$ sudo dpkg -i storcli_1.19.04-2_all.deb
Selecting previously unselected package storcli.
(Reading database … 216694 files and directories currently installed.)
Preparing to unpack storcli_1.19.04-2_all.deb …
Unpacking storcli (1.19.04-2) …
Setting up storcli (1.19.04-2) …
jjest@backupsrv:~$ sudo ./check-array-status.sh
Disk all good!
jjest@backupsrv:~$ cat ./check-array-status.sh
#!/bin/bash
out=$(/opt/MegaRAID/storcli/storcli64 /c0 show all | grep -e ^252 | grep -v Onln)
lines=$(echo $out | wc -l);
if [[ -z “$lines” ]]; then
if [[ $lines -gt 2 || $lines -eq 2 ]]; then
echo $out
else
OK=1
fi
else
OK=1
fi

if [ $OK == “1” ]; then
echo “Disk all good!”
fi