version:2.6
#!/bin/bash
user="root"
pw="p3temp"
case $1 in
server )
a=`ps -ef | grep mongo |grep -v grep |wc -l`
echo $a;;
men_resident )
b=`echo "db.serverStatus().mem"| mongo admin -u$user -p$pw |grep resident | cut -d ":" -f 2 |cut -d "," -f 1| cut -d " " -f 2`
echo $b;;
mem_virtual )
c=`echo "db.serverStatus().mem"| mongo admin -u$user -p$pw |grep virtual | cut -d ":" -f 2 |cut -d "," -f 1| cut -d " " -f 2`
echo $c;;
mem_mapped )
d=`echo "db.serverStatus().mem"| mongo admin -u$user -p$pw |grep '\bmapped\b' | cut -d ":" -f 2 |cut -d "," -f 1| cut -d " " -f 2`
echo $d;;
index_accesses )
e=`echo "db.serverStatus().indexCounters"| mongo admin -u$user -p$pw | grep accesses| cut -d ":" -f 2 |cut -d "," -f1 |cut -d " " -f 2`
echo $e;;
index_hits )
f=`echi "db.serverStatus().indexCounters"|mongo admin -u$user -p$pw | grep hits| cut -d ":" -f 2 |cut -d "," -f1 |cut -d " " -f 2`
echo $f;;
index_misses )
g=`echo "db.serverStatus().indexCounters"| mongo admin -u$user -p$pw | grep misses| cut -d ":" -f 2 |cut -d "," -f1 |cut -d " " -f 2`
echo $g;;
index_resets )
h=`echo "db.serverStatus().indexCounters"| mongo admin -u$user -p$pw | grep resets | cut -d ":" -f 2 |cut -d "," -f1 |cut -d " " -f 2`
echo $h;;
index_missRatio )
i=`echo "db.serverStatus().indexCounters"| mongo admin -u$user -p$pw | grep missRatio | cut -d ":" -f 2 |cut -d "," -f1 |cut -d " " -f 2`
echo $i
network_bytesIn )
j=`echo "db.serverStatus().network"|mongo admin -u$user -p$pw | grep bytesIn | awk -F"[{}]" '{print $2}' | awk -F"[:, ]" '{print $5}'`
echo $j;;
network_bytesOut )
k=`echo "db.serverStatus().network"|mongo admin -u$user -p$pw | grep bytesIn | awk -F"[{}]" '{print $2}' | awk -F"[:, ]" '{print $10}'`
echo $k;;
network_numRequests )
l=`echo "db.serverStatus().network"|mongo admin -u$user -p$pw | grep bytesIn | awk -F"[{}]" '{print $2}' | awk -F"[:, ]" '{print $15}'`
echo $l;;
connections_current )
a1=`echo "db.serverStatus().connections" | mongo admin -uroot -pp3temp | grep current | awk -F"[:, ]" '{print $5}'`
echo $a1;;
connections_available )
a2=`echo "db.serverStatus().connections" | mongo admin -uroot -pp3temp | grep current | awk -F"[:, ]" '{print $10}'`
echo $a2;;
connections_NumberLong )
a3=`echo "db.serverStatus().connections" | mongo admin -uroot -pp3temp | grep current | awk -F"[:, ()]" '{print $16}'`
echo $a3;;
esac
exit 0