Script Archive: GPS Check

!/bin/sh
 Build Header
 /bin/echo "" > /var/log/gps.log
 /bin/echo "Node: "/bin/hostname -f >> /var/log/gps.log
 /bin/echo "OS:   "/bin/uname -sr >> /var/log/gps.log
 /bin/echo "Date: "/bin/date >> /var/log/gps.log
 /bin/echo "" >> /var/log/gps.log
 /bin/ls -l /var/log/ntpstats/clockstats >> /var/log/gps.log
 /bin/echo "" >> /var/log/gps.log
 /bin/echo "Checking for GPS errors …" >> /var/log/gps.log
 /bin/echo "" >> /var/log/gps.log
 myGPSV=/usr/bin/grep ",V," /var/log/ntpstats/clockstats | /usr/bin/wc -l
 echo $myGPSV >> /var/log/gps.log
 /bin/echo "Found $myGPSV errors in the current clockstats file." >> /var/log/gps.log
 echo "" >> /var/log/gps.log
 /usr/bin/ntpq -p | /usr/bin/grep "*" >> /var/log/gps.log
 myGPSOK=/usr/local/bin/ntpq -p | /bin/grep -c "^MyBadConditionTest"
 myGPSOK=/usr/local/bin/ntpq -p | /bin/grep -c "^oGPS_NMEA"
 if [ "$myGPSOK" -ne "1" ]; then
 /bin/echo "!!! GPS CLOCK FAILURE !!!" >> /var/log/gps.log
 echo "" >> /var/log/gps.log
 /usr/local/bin/ntpq -p >> /var/log/gps.log
 /bin/cat /var/log/gps.log | /usr/bin/mailx -s "!!! GPS FAILURE !!! on hostname" root
 fi

Hits: 0

Script Archive: lunreport

!/bin/sh
 Script for matching LUNs with local device names
 Tested on Linux using open-iscsi
 Build Header
 /bin/echo "" > /var/log/lun-report.log
 /bin/echo "Node: "/bin/hostname -f >> /var/log/lun-report.log
 /bin/echo "OS:   "/bin/uname -o;/bin/uname -r >> /var/log/lun-report.log
 /bin/echo "Date: "/bin/date >> /var/log/lun-report.log
 /bin/echo "" >> /var/log/lun-report.log
 for v in /sbin/vgdisplay | /bin/grep "VG Name" | /usr/bin/awk '{print $3}';
 do
 /bin/echo "+----------" >> /var/log/lun-report.log
 /bin/echo "| "$v >> /var/log/lun-report.log;
 /bin/echo "+----------" >> /var/log/lun-report.log
 /bin/echo "" >> /var/log/lun-report.log;
 /bin/echo "Logical Volume(s): " >> /var/log/lun-report.log;
 /sbin/vgdisplay -v $v | /bin/grep "LV Name" | /usr/bin/awk '{print $3}' >> /var/log/lun-report.log
 /bin/echo "" >> /var/log/lun-report.log;
 /bin/df -h | /bin/grep Filesystem | /usr/bin/awk '{print $1"(s):"}' >> /var/log/lun-report.log;
 for m in /bin/mount | /bin/grep $v | /usr/bin/awk '{print $3}';
 do
 /bin/echo -n $m >> /var/log/lun-report.log;
 /bin/df -h $m | /bin/grep -v dev | /bin/grep -v Filesystem | /usr/bin/awk '{print "\t\tSize: "$1"\tUsed: "$2"\tAvail: "$3}' >> /var/log/lun-report.log;
 /bin/echo "" >> /var/log/lun-report.log
 done
 /bin/echo "LUN / Dev Pair(s):" >> /var/log/lun-report.log;
 for d in /sbin/vgdisplay -v $v | /bin/grep "PV Name" | /usr/bin/awk '{print $3}' | /bin/sed 's/^.\{5\}//g';
 do
 mdadm breaks this by listing md devices in vgdisplay
 /bin/ls -l /dev/disk/by-path | /bin/grep $d | /usr/bin/awk '{print $9"\t"$10"\t"$11}' >> /var/log/lun-report.log;
 /bin/ls -l /dev/disk/by-path | /usr/bin/awk '{print $9"\t"$10"\t"$11}' >> /var/log/lun-report.log;
 /bin/ls -l /dev/disk/by-path | /bin/grep $d >> /var/log/lun-report.log;
 /bin/echo "TEST!";
 /bin/echo $d;
 done
 /bin/echo "" >> /var/log/lun-report.log;
 done
 Send email notification
 /bin/cat /var/log/lun-report.log | /usr/bin/mailx email@mail.com -s "lunreport.sh: /bin/date +%m%d%Y:%H%M.%S"

Hits: 0

clamscan

Updated script to scan linux servers for viruses.

!/bin/bash
 Test log with Infected files
 LOGFILE="/var/log/clamav/malware_detected.log";
 LOGFILE="/var/log/clamav/clamav-$(/bin/date +'%Y-%m-%d').log";
 EMAIL_TO="you@yourdomain.com";
 Need to build an email header to know which system is scanned.
 Gmail gateway is overwriting from line when it forwards the email.
 HEADER_OS_LEVEL="$(/bin/uname -a)";
 HEADER_DATE="$(/bin/date)";
 > /var/log/clamav/freshclam.log
 /usr/bin/freshclam
Test clamscan
 /usr/bin/clamscan -ri /root/* > "$LOGFILE";
 /usr/bin/clamscan -ri --exclude-dir=/sys/* / > "$LOGFILE";
 get the value of "Infected lines"
 MALWARE=$(/bin/cat "$LOGFILE" | /bin/grep Infected | /usr/bin/cut -d" " -f3);
 if the value is not equal to zero, send an email with the log file attached
 if [ "$MALWARE" -ne "0" ];then
 /bin/echo " " > /var/log/clamav/EMAIL.MSG;
 /bin/echo "OS: $HEADER_OS_LEVEL" >> /var/log/clamav/EMAIL.MSG;
 /bin/echo "Date: $HEADER_DATE" >> /var/log/clamav/EMAIL.MSG;
 /bin/echo " " >> /var/log/clamav/EMAIL.MSG;
 /bin/echo "Freshclam Status:" >> /var/log/clamav/EMAIL.MSG;
 /bin/cat /var/log/clamav/freshclam.log >> /var/log/clamav/EMAIL.MSG;
 /bin/echo " " >> /var/log/clamav/EMAIL.MSG;
 /bin/echo "Log File: $LOGFILE" >> /var/log/clamav/EMAIL.MSG;
 /bin/cat "$LOGFILE" >> /var/log/clamav/EMAIL.MSG;
 /bin/cat /var/log/clamav/EMAIL.MSG | /usr/bin/mail -s "ClamAV Alert" "$EMAIL_TO";
 fi
 exit 0

Hits: 1

Passbox

usage: passbox [action]

Passbox – command line password manager utility

ACTIONS

add-field Update an existing entry to add additional fields to
delete Remove an entry from the password database
get Get a particular password entry by it’s name
generate Generate a new random password
new Prompt to create a new passbox entry
remove-field Update an existing entry to remove additional fields
search Search the password database for a particular string, returns all matching entries
update Update an existing entry in the password database

Hits: 1