Skip to content

Instantly share code, notes, and snippets.

@xymor
Created January 21, 2019 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xymor/c759e5accc5ca2b73c6d5e68a4eae086 to your computer and use it in GitHub Desktop.
Save xymor/c759e5accc5ca2b73c6d5e68a4eae086 to your computer and use it in GitHub Desktop.
Monitor your OpLog using AWS Cloudwatch
#!/bin/bash
JSON=`mongo --quiet -u root -p pass --authenticationDatabase admin --eval "JSON.stringify(db.getReplicationInfo())" database.com.br:27017/local`
TIMEDIFF=`echo $JSON | jq '.timeDiffHours'`
echo $TIMEDIFF
aws cloudwatch put-metric-data --region sa-east-1 --metric-name MongoTimeDiffHours --namespace Midas --value "`echo $TIMEDIFF`" --timestamp `date -u "+%Y-%m-%dT%H:%M:%SZ"`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment