Last active
December 20, 2015 11:09
-
-
Save koyhoge/6121093 to your computer and use it in GitHub Desktop.
get mongodb statuses for zabbix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
opt_host=localhost | |
opt_port=27017 | |
while getopts "h:p:" flag; do | |
case $flag in | |
h) opt_host="$OPTARG";; | |
p) opt_port="$OPTARG";; | |
esac | |
done; | |
shift $(( $OPTIND - 1 )) | |
case $# in | |
0) attr="";; | |
1) attr=".$1";; | |
2) attr=".$1.$2";; | |
3) attr=".$1.$2.$3";; | |
esac | |
echo "db.serverStatus()$attr" | mongo --host $opt_host --port $opt_port --quiet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment