Skip to content

Instantly share code, notes, and snippets.

@mansurali901
Created March 29, 2019 16:44
Show Gist options
  • Save mansurali901/aab8739f09504df936089fbcc7d9dc5f to your computer and use it in GitHub Desktop.
Save mansurali901/aab8739f09504df936089fbcc7d9dc5f to your computer and use it in GitHub Desktop.
#!/bin/bash
MONGOD=`ps aux |grep mongod |grep -v grep |awk '{print $2}'`
MONGOCOUNT=`ps aux |grep mongod |grep -v grep |awk '{print $2}'|wc -l`
mail_func () {
echo $MONGOD > /tmp/email
mail -s "Mongo is not running " [email protected] < /tmp/email
}
if [ $MONGOCOUNT -eq '1' ];
then
echo "[`date`] : Mongo is Running with PID $MONGOD" >> /tmp/mongo.log
else
echo "[`date`] : Mongo is not running" >> /tmp/mongo.log
mail_func
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment