您好,登錄后才能下訂單哦!
去年監控mongodb設置的模板,包括mongodb連接數,內存,復制延遲,是否Master的監控,下面是一些監控圖形示例
我們還有一些觸發器,比如mongodb實例是否可用,mongodb副本集的角色是否切換。
附件中是mongodb的模板文件,后臺的腳本改日再行上傳。
后臺運行腳本:
#!/bin/bash ######################################################### # mongod_stats.sh # # written by yanglixue # # 2015/07/08 # ######################################################### command_line="/opt/mongodb-linux-x86_64-3.0.7/bin/mongo" username_m="admin" password_m="password" username_c="admin" password_c="password" function get_mongo_conn() { if [ $1 == "Primary" ];then username=${username_m} password=${password_m} elif [ $1 == "Secondary" ];then username=${username_m} password=${password_m} elif [ $1 == "Config" ];then username=${username_c} password=${password_c} elif [ $1 == "Mongos" ];then username=${username_c} password=${password_c} fi command_line="${command_line} localhost:$port/admin -u$username -p$password" } case $# in 3) port=$3 get_mongo_conn $1 if [ $2 == "Repl_lag" ];then output=$(/bin/echo "db.printSlaveReplicationInfo()" |$command_line|grep "behind the primary" |awk '{print $1}'|sed 's/-//') elif [ $2 == "IsMaster" ];then o1=$(/bin/echo "db.isMaster().ismaster" |$command_line|sed -n '3p') if [ $o1 == "true" ];then output=1 elif [ $o1 == "false" ];then output=0 else output=-1 fi else output=$(/bin/echo "db.serverStatus().$2" |$command_line|sed -n '3p') fi ;; 4) port=$4 get_mongo_conn $1 output=$(/bin/echo "db.serverStatus().$2.$3" |$command_line|sed -n '3p') ;; 5) port=$5 get_mongo_conn $1 output=$(/bin/echo "db.serverStatus().$2.$3.$4" |$command_line|sed -n '3p') ;; esac #check if the output contains "NumberLong" if [[ "$output" =~ "NumberLong" ]];then echo $output|sed -n 's/NumberLong(//p'|sed -n 's/)//p' else echo $output fi
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。