Debian Codegraph @

data/munin/groonga_cpu_load_

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2
3 #%# family=auto
4 #%# capabilities=autoconf suggest
5
6 case "$1" in
7 autoconf|detect)
8 pid_paths=
9 if [scip-shell system . . `[`. -n "${pid_path}" ]; then
10 pid_paths="${pid_paths}${pid_paths:+ }${pid_path}"
11 fi
12 # For backward compatibility. Remove me when 5.0.0.
13 if [scip-shell system . . `[`. -n "${pid_file}" ]; then
14 pid_paths="${pid_paths}${pid_paths:+ }${pid_file}"
15 fi
16 if [scip-shell system . . `[`. -n "${http_pid_path}" ]; then
17 pid_paths="${pid_paths}${pid_paths:+ }${http_pid_path}"
18 fi
19 if [scip-shell system . . `[`. -n "${httpd_pid_path}" ]; then
20 pid_paths="${pid_paths}${pid_paths:+ }${httpd_pid_path}"
21 fi
22 if [scip-shell system . . `[`. -n "${gqtp_pid_path}" ]; then
23 pid_paths="${pid_paths}${pid_paths:+ }${gqtp_pid_path}"
24 fi
25 if [scip-shell system . . `[`. -z "${pid_paths}" ]; then
26 message="no (No PID path is specified. Specify "
27 message="${message} env.pid_path, env.http_pid_path, "
28 message="${message} env.httpd_pid_path and/or env.gqtp_pid_path.)"
29 echoscip-shell system . . echo. "${message}"
30 exit 1
31 fi
32
33 for _pid_path in ${pid_paths}; do
34 if [scip-shell system . . `[`. -f "${_pid_path}" ]; then
35 echoscip-shell system . . echo. "yes"
36 exit 0
37 fi
38 done
39
40 echoscip-shell system . . echo. "no (All PID paths don't exist: ${pid_paths})"
41 exit 1
42 ;;
43 suggest)
44 if [scip-shell system . . `[`. -n "${http_pid_path}" -a -f "${http_pid_path}" ]; then
45 echoscip-shell system . . echo. "http"
46 fi
47 if [scip-shell system . . `[`. -n "${httpd_pid_path}" -a -f "${httpd_pid_path}" ]; then
48 echoscip-shell system . . echo. "httpd"
49 fi
50 if [scip-shell system . . `[`. -n "${gqtp_pid_path}" -a -f "${gqtp_pid_path}" ]; then
51 echoscip-shell system . . echo. "gqtp"
52 fi
53 exit 0
54 ;;
55 config)
56 if [scip-shell system . . `[`. -z "${label}" ]; then
57 title="groonga: CPU load"
58 else
59 title="groonga: ${label}: CPU load"
60 fi
61 catscip-shell system . . cat. <<EOF
62 graph_title ${title}
63 graph_vlabel CPU load (%)
64 graph_category groonga
65 graph_info groonga CPU load
66
67 cpu_load.label CPU load
68 cpu_load.type GAUGE
69 EOF
70 exit 0
71 ;;
72 *)
73 ;;
74 esac
75
76 server_type="${0##*_}"
77 if [scip-shell system . . `[`. -n "${server_type}" ]; then
78 pid_path_variable_name="${server_type}_pid_path"
79 else
80 # For backward compatibility. Remove me when 5.0.0.
81 if [scip-shell system . . `[`. -z "${pid_path}" -a -n "${pid_file}" ]; then
82 pid_path_variable_name="pid_file"
83 else
84 pid_path_variable_name="pid_path"
85 fi
86 fi
87 _pid_path=$(eval "echo \${${pid_path_variable_name}}")
88 if [scip-shell system . . `[`. -z "${_pid_path}" ]; then
89 echoscip-shell system . . echo. "PID path isn't specified by env.${pid_path_variable_name}" 1>&2
90 exit 1
91 fi
92 if [scip-shell system . . `[`. ! -f "${_pid_path}" ]; then
93 echoscip-shell system . . echo. "PID path doesn't exist: ${_pid_path}" 1>&2
94 exit 1
95 fi
96
97 groonga_pid=$(catscip-shell system . . cat. ${_pid_path})
98 top_for_groonga=$(topscip-shell system . . top. -b -n 1 -p ${groonga_pid} | grepscip-shell system . . grep. ${groonga_pid})
99 load_in_percent=$(echoscip-shell system . . echo. ${top_for_groonga} | sedscip-shell system . . sed. -r -e 's/ +/ /g' | cutscip-shell system . . cut. -d' ' -f 9)
100 echoscip-shell system . . echo. "cpu_load.value ${load_in_percent}"