Script to monitor Mongo DB processes across a cluster.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ## ## ## Script to Monitoring Mongo Process ## ## Search for all mongoX process on the cluster ## datevar=`date +"%m%d%Y"` timevar=`date +"%H%M%S"` PDATI=$datevar"_"$timevar PHOME=$HOME/scripts/monitor PLOGL=$PHOME/logs/mongomon_$PDATI.log PLOGE=$PHOME/logs/mongomon_$PDATI.err PCOMM="ps -fea | grep etc/mongo | grep -v grep | awk '{ print $8 }'" export PLOG1 PCOMM PHOME for i in `cat $HOME/scripts/cluster.cfg` do ssh $i "hostname && $PCOMM" 2> $PLOGE >> $PLOGL done cat $PLOGL | mail -s "DBSMT Mongo Cluster " email@companyname.com |
Log file result:
1 2 3 4 5 6 7 | [lusifer@node01 logs]$ more mongomon_10032018_115156.log node01 mongod 125916 1 1 Sep19 ? 03:56:42 /usr/bin/mongod -f /etc/mongod.conf --auth node02 mongod 58190 1 3 Sep19 ? 10:25:17 /usr/bin/mongod -f /etc/mongod.conf --auth node03 mongod 61171 1 3 Sep19 ? 10:23:20 /usr/bin/mongod -f /etc/mongod.conf --auth |
Note: Requires ssh passwordless login and cluster configuration file.