Share

Search Unix Commands/Scripts


  Help us in improving the repository. Add new commands/scripts through 'Submit Commands/Scripts ' link.





Unix Commands/Scripts for '#Aws' - 21 Commands/Scripts found

 Sample 1. Shell Script for Log4j Log Analysis and exception reporting

#!/bin/ksh

EMAIL_SUBJECT="Exceptions-Log"
EMAIL_TO="xyz@yahoo.com"
`grep "xception" Out.log >> /home/xyz/test1`
`cat /home/xyz/test1 | sed -n 's/.* ([^ ]*xception[^ ]*) .*/1/p' | awk '!x[$0]++' >> /home/xyz/test2`

`rm test3`

while read line
do
lineNum=`sed -n "/$line/,/EST/{=;q;}" Out.log`
let bl=$lineNum-5
let el=$lineNum+15
echo "*************************************************
$line
**************************************************

" >> test3
`sed -n "$bl,$el p" Out.log >> test3`
echo "


" >> test3
done < "/home/xyz/test2"

`cat test3 | /bin/mail -s $EMAIL_SUBJECT $EMAIL_TO`

   Like      Feedback     script  exception reporting script  log4j analysis script  awk


 Sample 2. Shell Scripts for Automating System Monitoring Task

#!/bin/ksh

errorSnippet=''

# ********************************************************Configuration***************************************************************
homeBench='90'
VivaBench='90'
rootBench='90'
appHomeBench='90'
idleBench='95'
logsOldBench='15'
memUsageBench='2500'
avgLoadBench='5'
EMAIL_SUBJECT="Server Health Check Report for $(hostname)"
EMAIL_TO="test@test.com"
# ************************************************************************************************************************************

dfHome=`df | sed -n '/ /home$/s/.* ([0-9][0-9]*)%.*/1/p'`
dfViva=`df | sed -n '/ /apphome/Viva$/s/.* ([0-9][0-9]*)%.*/1/p'`
dfRoot=`df | sed -n '/ /$/s/.* ([0-9][0-9]*)%.*/1/p'`
dfApphome=`df | sed -n '/ /apphome$/s/.* ([0-9][0-9]*)%.*/1/p'`
dfLogsOld=`df | sed -n '/ /localvg-logsOld$/s/.* ([0-9][0-9]*)%.*/1/p'`
memUsage=`sar -q 1 | tail -1 | awk '{ print "" $3}' | sed 's/%//g'`
avgLoad=`uptime | awk -F "$FTEXT" '{ print $2 }' | cut -d, -f3`
iostatIdle=`iostat | awk '{print $5}' | awk 'NR==4' | cut -d '.' -f1`

if [[ $dfHome -gt $homeBench ]] then
errorSnippet="Disk Usage for /home exceedeed the benchmark, Its $dfHome now";
fi
if [[ $dfViva -gt $VivaBench ]] then
errorSnippet="$errorSnippet
Disk Usage for /apphome/Viva exceedeed the benchmark, Its $dfViva now";
fi
if [[ $dfRoot -gt $rootBench ]] then
errorSnippet="$errorSnippet
Disk Usage for /(root) exceedeed the benchmark, Its $dfRoot now";
fi
if [[ $dfRoot -gt $rootBench ]] then
errorSnippet="$errorSnippet
Disk Usage for /(root) exceedeed the benchmark, Its $dfRoot now";
fi
if [[ $dfApphome -gt $appHomeBench ]] then
errorSnippet="$errorSnippet
Disk Usage for /apphome exceedeed the benchmark, Its $dfApphome now";
fi
if [[ $dfLogsOld -gt $logsOldBench ]] then
errorSnippet="$errorSnippet
Disk Usage for logs old exceedeed the benchmark, Its $dfLogsOld now";
fi
if [[ $iostatIdle -gt $idleBench ]] then
errorSnippet="$errorSnippet
Iostat idle exceedeed the benchmark, Its $iostatIdle now";
fi
if [[ $memUsage -gt $memUsageBench ]] then
errorSnippet="$errorSnippet
Memory Usage exceedeed the benchmark, Its $memUsage now";
fi
if [[ $avgLoad -gt $avgLoadBench ]] then
errorSnippet="$errorSnippet
15 minute Average Load exceedeed the benchmark, Its $avgLoad now";
fi

print $errorSnippet
if [ "$errorSnippet" != "" ]; then
`echo errorSnippet | /bin/mail -s $EMAIL_SUBJECT $EMAIL_TO`
fi

   Like      Feedback     script to automate monitoring task  df  sed  sar  tail  awk  iostat  shell script if block  print  /bin/mail


 Sample 3. Get fields matching a particular string using awk

awk '/xception/ { print $1 }' source.txt >> destination.txt

   Like      Feedback     awk


 Sample 4. Print last field using awk

awk { print $NF }

   Like      Feedback     awk


Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner
 Sample 5. Install AWS CLI ( Amazon Web Service Command Line Interface ) using brew

brew install awscli

   Like      Feedback     


 Sample 6. Install AWS CLI on Linux / ubuntu

sudo apt-get install awscli

   Like      Feedback     


 Sample 7. Run df command ( check disk space usage ) using AWS CLI on AWS EC2 instance

Usage -

aws ssm send-command --document-name "AWS-RunPowerShellScript" --parameters commands=["df -a"] --targets "Key=instanceids,Values=<instanceId>"

Example -

aws ssm send-command --document-name "AWS-RunPowerShellScript" --parameters commands=["df -a"] --targets "Key=instanceids,Values= i-0981d8456ffd18wcb"

   Like      Feedback     aws cli  aws ssm  aws ssm send-command  check disk space usage on AWS instanc


 Sample 8. Get a list of files within AWS S3 bucket

aws s3 ls s3://<bucketName>

Example -

aws s3 ls s3://myBucket/bucket

   Like      Feedback     aws s3  list files within aws s3


 Sample 9. Get Summary / List of files recursively from an S3 bucket

aws s3 ls s3://mybucket --recursive --human-readable --summarize

   Like      Feedback     amazon aws s3


Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner
 Sample 10. Writes a single data record into an Amazon Kinesis stream

aws kinesis put-record --stream-name <STREAM_NAME> --partition-key <PARTITION_KEY> --data <DATA>

   Like      Feedback     Amazon AWS  AWS  Amazon Kinesis Stream  aws kinesis put-record  aws kinesis   put single record in amazon Kinesis


 Sample 11. Get information about a particular replication group

aws describe-replication-groups --replication-group-id <REPLICATION_GROUP_ID> --output text

   Like      Feedback     AWS  Amazon AWS  AWS CLI  describe-replication-groups


 Sample 12. Get Elastic Beanstalk / EC2 instance information using instance name

aws ec2 describe-instances --output text --filters "Name=tag:Name,Values=<ELASTIC_BEANSTALK_INSTANCE_NAME>"

   Like      Feedback     AWS  Amazon AWS  AWS CLI  describe-instances  Amazon EC2


 Sample 13. Get all Tag information for EC2 instance using instance name

aws ec2 describe-instances --output text --filters "Name=tag:Name,Values=<ELASTIC_BEANSTALK_INSTANCE_NAME>" | grep "TAGS"

   Like      Feedback     AWS  Amazon AWS  AWS CLI  describe-instances  Amazon EC2


 Sample 14. Get Private IP address of a EC2 / Beanstalk instance using AWS CLI

aws ec2 describe-instances --output text --filters "Name=tag:Name,Values=<ELASTIC_BEANSTALK_INSTANCE_NAME>" | grep "PRIVATEIPADDRESSES"

   Like      Feedback     AWS  Amazon AWS  AWS CLI  describe-instances  Amazon EC2


Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner
 Sample 15. Check if AWS is installed

which aws

   Like      Feedback     


 Sample 16. Get List of AWS Configuration

aws configure list

   Like      Feedback     


 Sample 17. Check if AWS has been configured properly

aws configure list | egrep "access_key|secret_key|region" | wc -l

Count of 3 means configured correctly

   Like      Feedback     


 Sample 18. Stop an EC2 instance through AWS CLI

aws ec2 stop-instances --instance-id=<EC2_INSTANCE_ID>

   Like      Feedback     


 Sample 19. Start an EC2 instance using AWS CLI

aws ec2 start-instances --instance-id=<EC2_INSTANCE_ID>

   Like      Feedback     


Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner
 Sample 20. Set a Redis field value using key and field name

or Add a new Field to a Redis Key

HSET <Key> <field> <value>

   Like      Feedback     Redis  AWS


 Sample 21. Connect to Redis using Redis CLI

redis-cli -c -h <Redis End Point> -p <Port>

   Like      Feedback     Redis  aws



Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner



comments powered by Disqus