metrics.sh/sysmetricsd.sh

67 lines
915 B
Bash
Raw Normal View History

2015-02-19 20:15:38 +01:00
#!/bin/sh
2015-02-21 18:18:27 +01:00
# config
INTERVAL=1
REPORTER=stdout # TODO: handle multiple reporters
2015-03-08 17:51:15 +01:00
# handle opts
opts_spec=":dhvr:"
opt_docs=false
opt_verbose=false
usage () {
echo "usage: $0 [-d] [-h] [-v] [-r]"
}
help () {
echo "TODO"
}
while getopts "$opts_spec" opt; do
case "${opt}" in
d)
opt_docs=true
;;
h)
help
exit
;;
v)
opt_verbose=true
;;
r)
REPORTER=$OPTARG
;;
*)
usage
exit 1
;;
esac
done
shift $((OPTIND-1))
# run
source ./lib/main.sh
if [ $opt_verbose = "true" ]; then
verbose_on
verbose "Started in verbose mode"
fi
verbose "OS detected: $OS_TYPE"
main_load
verbose "Metrics loaded: ${__METRICS[@]}"
verbose "Reporters loaded: ${REPORTER}"
if [ "$opt_docs" = true ]; then
main_docs
exit
fi
main_init
verbose "Metrics initialized"
verbose "Collecting metrics every $INTERVAL second(s)"
main_collect