This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wait4(){ | |
local data_func=$1; local data_func_var=$2; local data_expect=$3; | |
local timeout=$4; local sleep_time=$5; local exit_on_timeout=${6:-0}; | |
local wait4_s=`date +%s` | |
local data_out data_prog | |
while true; do | |
# error on getting info | |
read data_out data_state <<< "`$data_func $data_func_var`" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# size units are in GB | |
# syntax: check_rds_disk.sh <1:db ident> <2:max delay> <3:warn> <4:crit> | |
# e.g: check_rds_disk.sh rds.db1 300 70 85 | |
db_name="${1/*./}" | |
# max_daly in seconds | |
max_delay=$2 | |
warn=$3 | |
crit=$4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# syntax: check_rds_cpu.sh <1:db ident> <2:max delay> <3:warn> <4:crit> | |
# e.g: check_sqs_age.sh db1 300 70 85 | |
db_name="${1/*./}" | |
# max_daly in seconds | |
max_delay=$2 | |
warn=$3 | |
crit=$4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
awscmd='aws guardduty --output json' | |
frmt='%-6s %-9s %-6s %-20s %-20s %-11s %-11s %-10s %s\n' | |
# damn aws stupid reports with utf8 | |
export LC_ALL='en_US.UTF-8' | |
map_id(){ | |
res_sed=`aws ec2 describe-instances --output json |\ | |
jq -r '.Reservations[].Instances[] | "\(.InstanceId) \(if .Tags and ([.Tags[] | select ( .Key == "Name" )] != []) then .Tags[] | select ( .Key == "Name" ) | .Value else "%" end)"' |\ | |
grep -v % | sed 1d | sort -r |\ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games | |
# Requires: | |
# jq 1.5 | |
# gawk | |
Help="Overview: | |
Based on running spot instances, on-demand prices and spot prices the script | |
calculates average spot price over a set time frame, displays lots of |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
d=${1:-3} | |
u='Shoko-sms' | |
b='/opt/omd/sites/techdrift/var/naemon/archive/naemon.log' | |
O=$( for i in `seq $d`; do | |
D=`date -d "-$i days" +%Y%m%d` | |
D2=`date -d "-$i days" +%Y.%m.%d` | |
#echo "$D2" | |
grep 'SERVICE NOTIFICATION: ' $b-$D |\ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# syntax: check_sqs_age.sh <1:queue name> <2:max delay> <3:age sec warn> <4:age sec crit> | |
# e.g: check_sqs_age.sh items 900 120 300 | |
# if (warn > crit) alert on high values and vise versa | |
queue_name=$1 | |
max_delay=$2 | |
warn=$3 | |
crit=$4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
get_regex(){ | |
awk -v R="$1" 'BEGIN {RS="\n\n"; FS="\n";} | |
{ | |
if ($1=="hoststatus {" && match($2, "^\thost_name="R)) | |
print $2 | |
};' /var/cache/nagios3/status.dat | sed "s#[\t ][\t ]*[^=]*=# #g; s# ##" | |
} | |
# output - <type=service>:<host_name>:<service_description>:<sec since last_check>:<sec since last_state_change>:<current_state> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# requires JSON.sh | |
# curl 'https://raw.githubusercontent.com/dominictarr/JSON.sh/master/JSON.sh' > /usr/local/bin/JSON.sh | |
# chmod 700 !$ | |
# requires jolokia at /opt/jolokia | |
# wget -O jolokia-jvm-1.3.7-agent.jar http://search.maven.org/remotecontent?filepath=org/jolokia/jolokia-jvm/1.3.7/jolokia-jvm-1.3.7-agent.jar | |
# mkdir /opt/jolokia | |
# mv jolokia-jvm-1.3.7-agent.jar /opt/jolokia | |
# requires jq | |
# apt-get install jq |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# tested with aws-cli/1.11.123 Python/2.7.9 Linux/3.16.0-4-amd64 botocore/1.5.86 | |
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | |
#set -x | |
family_conversion="Type Factor | |
nano 1 | |
micro 2 | |
small 4 |