summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xminimunin25
1 files changed, 13 insertions, 12 deletions
diff --git a/minimunin b/minimunin
index 72e155d..f7f6d0b 100755
--- a/minimunin
+++ b/minimunin
@@ -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
46print_fetch() { 47print_fetch() {
47
48# see if we're serving a plugin 48# see if we're serving a plugin
49call_plugin $1 fetch && return 0 49_plugin=$1
50call_plugin ${_plugin} fetch && return 0
50 51
51# if not, let our builtins answer 52# if not, let our builtins answer
52case $1 in 53case ${_plugin} in
53open_files) 54open_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 ;;
95esac 96esac
96} 97}
97 98
98print_config() { 99print_config() {
99 100_plugin=$1
100# see if we're configuring a plugin 101# see if we're configuring a plugin
101call_plugin $1 config && return 0 102call_plugin ${_plugin} config && return 0
102 103
103# if not, execute built in commands 104# if not, execute built in commands
104case $1 in 105case ${_plugin} in
105load) 106load)
106cat <<-EOF 107cat <<-EOF
107 graph_title Load average 108 graph_title Load average
@@ -292,7 +293,7 @@ cat <<-EOF
292EOF 293EOF
293;; 294;;
294*) 295*)
295 printf "# Unknown command.\n" 296 printf "# Unknown plugin ${_plugin}.\n"
296 ;; 297 ;;
297esac 298esac
298} 299}