Skip to content

Instantly share code, notes, and snippets.

@koyhoge
Last active December 20, 2015 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koyhoge/6121093 to your computer and use it in GitHub Desktop.
Save koyhoge/6121093 to your computer and use it in GitHub Desktop.
get mongodb statuses for zabbix
#!/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