diff options
author | erdgeist <> | 2013-09-21 18:52:58 +0000 |
---|---|---|
committer | erdgeist <> | 2013-09-21 18:52:58 +0000 |
commit | 2f94cce5fc69550bedc787658c013c6a571bf324 (patch) | |
tree | 2cc50d0be25356c9f4663c2587dda1b1329a9751 | |
parent | a8aafc7725cfb9b0747008dbfa316062ef1ee489 (diff) |
Chomp arguments, as well.
-rwxr-xr-x | minimunin | 25 |
1 files changed, 13 insertions, 12 deletions
@@ -18,7 +18,8 @@ main() { | |||
18 | while read command arg; do | 18 | while read command arg; do |
19 | 19 | ||
20 | # chomp | 20 | # chomp |
21 | command=`printf ${command} | /usr/bin/tr -d '\r'` | 21 | command=`printf %s "${command}" | /usr/bin/tr -d '\r'` |
22 | arg=`printf %s "${arg}" | /usr/bin/tr -d '\r'` | ||
22 | 23 | ||
23 | # printf "%s %s\n" "$command" "$arg" >> /var/log/minimunin.log | 24 | # printf "%s %s\n" "$command" "$arg" >> /var/log/minimunin.log |
24 | # dispatch commands | 25 | # dispatch commands |
@@ -27,16 +28,16 @@ main() { | |||
27 | printf "%s\n" "${BUILTIN} ${PLUGINS}" | 28 | printf "%s\n" "${BUILTIN} ${PLUGINS}" |
28 | ;; | 29 | ;; |
29 | fetch) | 30 | fetch) |
30 | print_fetch $arg; printf ".\n" | 31 | print_fetch ${arg}; printf ".\n" |
31 | ;; | 32 | ;; |
32 | config) | 33 | config) |
33 | print_config $arg; printf ".\n" | 34 | print_config ${arg}; printf ".\n" |
34 | ;; | 35 | ;; |
35 | quit) | 36 | quit) |
36 | exit 0 | 37 | exit 0 |
37 | ;; | 38 | ;; |
38 | *) | 39 | *) |
39 | printf "# Unknown command.\n" | 40 | printf "# Unknown command ${command}.\n" |
40 | # printf %s ${command} | hexdump -C >> /var/log/minimunin.log | 41 | # printf %s ${command} | hexdump -C >> /var/log/minimunin.log |
41 | ;; | 42 | ;; |
42 | esac | 43 | esac |
@@ -44,12 +45,12 @@ main() { | |||
44 | } | 45 | } |
45 | 46 | ||
46 | print_fetch() { | 47 | print_fetch() { |
47 | |||
48 | # see if we're serving a plugin | 48 | # see if we're serving a plugin |
49 | call_plugin $1 fetch && return 0 | 49 | _plugin=$1 |
50 | call_plugin ${_plugin} fetch && return 0 | ||
50 | 51 | ||
51 | # if not, let our builtins answer | 52 | # if not, let our builtins answer |
52 | case $1 in | 53 | case ${_plugin} in |
53 | open_files) | 54 | open_files) |
54 | printf "max.value %d\n" `get_sys kern.maxfiles` | 55 | printf "max.value %d\n" `get_sys kern.maxfiles` |
55 | printf "used.value %d\n" `get_sys kern.openfiles` | 56 | printf "used.value %d\n" `get_sys kern.openfiles` |
@@ -90,18 +91,18 @@ systat) | |||
90 | printf "softint.value %d\nhardint.value %d\nsyscall.value %d\ncs.value %d\nforks.value %d\n" "$1" "$2" "$3" "$4" $(( ${5}+${6}+${7} )) | 91 | printf "softint.value %d\nhardint.value %d\nsyscall.value %d\ncs.value %d\nforks.value %d\n" "$1" "$2" "$3" "$4" $(( ${5}+${6}+${7} )) |
91 | ;; | 92 | ;; |
92 | *) | 93 | *) |
93 | printf "# Unknown command.\n" | 94 | printf "# Unknown plugin ${_plugin}.\n" |
94 | ;; | 95 | ;; |
95 | esac | 96 | esac |
96 | } | 97 | } |
97 | 98 | ||
98 | print_config() { | 99 | print_config() { |
99 | 100 | _plugin=$1 | |
100 | # see if we're configuring a plugin | 101 | # see if we're configuring a plugin |
101 | call_plugin $1 config && return 0 | 102 | call_plugin ${_plugin} config && return 0 |
102 | 103 | ||
103 | # if not, execute built in commands | 104 | # if not, execute built in commands |
104 | case $1 in | 105 | case ${_plugin} in |
105 | load) | 106 | load) |
106 | cat <<-EOF | 107 | cat <<-EOF |
107 | graph_title Load average | 108 | graph_title Load average |
@@ -292,7 +293,7 @@ cat <<-EOF | |||
292 | EOF | 293 | EOF |
293 | ;; | 294 | ;; |
294 | *) | 295 | *) |
295 | printf "# Unknown command.\n" | 296 | printf "# Unknown plugin ${_plugin}.\n" |
296 | ;; | 297 | ;; |
297 | esac | 298 | esac |
298 | } | 299 | } |