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
#!/usr/bin/perl -w | |
# Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"). You may not | |
# use this file except in compliance with the License. A copy of the License | |
# is located at | |
# | |
# http://aws.amazon.com/apache2.0/ | |
# |
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 | |
# crontab line: | |
# * * * * * <PATH_TO>/aws-scripts-mon-cron.sh | |
/opt/aws-scripts-mon/mon-put-instance-data-patch-load.pl --aws-access-key-id='AKIAxxxxxxxxxxxxxxxx' --aws-secret-key='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \ | |
--mem-util --mem-used --mem-avail --swap-util --swap-used \ | |
$(df -h -x "tmpfs" -x "devtmpfs" | sed 1d | awk '{print $6}' | sort -u | while read i; do echo -n " --disk-path=$i"; done) \ | |
--disk-space-util --disk-space-used --disk-space-avail \ | |
--load-1 --load-5 --load-15 \ | |
--from-cron |
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 | |
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | |
local_indices='/var/lib/elasticsearch/elasticsearch/nodes/0/indices' | |
# retention | |
i=14 | |
# history verification for skipped runs | |
h=10 | |
I=$i |
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
log='/var/log/log.log' | |
log_out(){ echo -e "`date +'%Y-%d-%m %H:%M:%S'` (pid $$) -- $1" >> $log; } | |
log_pipe(){ | |
[ ! -z "$1" ] && p="$1: " || p="" | |
while read data; do | |
echo -e "`date +'%Y-%d-%m %H:%M:%S'` (pid $$) -- ${p}$data" >> $log | |
done | |
} |
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
pid_file="/var/run/file.lock" | |
lock_retry_timeout=60 | |
check_lock(){ | |
if [ -e $pid_file ]; then | |
log_out log "lock file ($pid_file) found, verifying" | |
sleep 2 | |
if grep $0 /proc/`cat $pid_file`/cmdline &>/dev/null; then | |
log_out log "Script $0 is locked ($pid_file)!!!!" | |
return 1 |
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
# EC2ulz_ops | |
echo -ne "\033]0;`hostname`\007" | |
ec_key='/root/.ssh/my-keypair.pem' | |
# awscli autocomplete | |
complete -C '/usr/bin/aws_completer' aws | |
## _EC2hosts_cache - hostname completion (dynamic cahced) | |
################### | |
_EC2hosts_cache='/tmp/EC2hosts.cache' |
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 | |
# currently support server_audit only!! | |
# Requires: | |
# working awscli | |
# apt-get install lockfile-progs | |
# required monitoring: | |
# logwatch on $admin_log for the word 'ERROR' | |
# log integrity check | |
# locations: | |
# script log - /var/log/rds/rds_getlogs.log |
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: apt-get install lockfile-progs | |
# Test: /root/locktest.sh& sleep 2; /root/locktest.sh | |
lock_file='/var/run/locker' | |
# 0 for immidiate fail, see 'man lockfile-progs' for details | |
lock_retry=0 | |
lock(){ | |
lockfile-create -r $lock_retry -p $lock_file && return 0 |
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
Get instance Name tag value: | |
aws ec2 describe-tags --filters "Name=resource-id,Values=i-11111111111111111" "Name=key,Values=Name" --output text |
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
Pidstat aggregator - Aggregates statistics from pidstat by process name or username mainly for | |
feeding it to carbon through crontab. Can output stats by pid, with or without username and | |
process name. Can also output plain table of aggregations. | |
Syntax: /usr/local/bin/pidstat_aggregator.sh <operation> <aggregations> <interval> [graphite/carbon server:port] | |
operation: | |
help - This help | |
table - Print aggregation table | |
graphite - Graphite/carbon compatible metric output | |
debug - Print pre-aggregation pidstat table, table output and graphite output |
OlderNewer