summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xminimunin393
1 files changed, 198 insertions, 195 deletions
diff --git a/minimunin b/minimunin
index 881d6be..557e0dc 100755
--- a/minimunin
+++ b/minimunin
@@ -13,7 +13,7 @@ SYSCTL=/sbin/sysctl
13[ -f ${SYSCTL} ] || SYSCTL=/usr/sbin/sysctl 13[ -f ${SYSCTL} ] || SYSCTL=/usr/sbin/sysctl
14 14
15# list plugins, read configs 15# list plugins, read configs
16PLUGINS=$(/usr/bin/find ${PLUGIN_DIR} \( -type l -or -type f \) -not -name '*_' -perm +111 -exec basename {} \; 2> /dev/null | /usr/bin/xargs) 16PLUGINS=$(/usr/bin/find ${PLUGIN_DIR} \( -type l -or -type f \) -not -name '*_' -perm +111 -exec basename {} \; 2> /dev/null)
17CONFIGS=$(/usr/bin/find ${CONFIG_DIR} -type f -exec /usr/bin/grep -v -e ^\# -e ^$ {} \; -exec /bin/echo [] \; 2> /dev/null) 17CONFIGS=$(/usr/bin/find ${CONFIG_DIR} -type f -exec /usr/bin/grep -v -e ^\# -e ^$ {} \; -exec /bin/echo [] \; 2> /dev/null)
18 18
19main() { 19main() {
@@ -31,7 +31,7 @@ main() {
31 # dispatch commands 31 # dispatch commands
32 case ${command} in 32 case ${command} in
33 list) 33 list)
34 printf "%s\n" "${BUILTIN} ${PLUGINS}" 34 printf "%s " "${BUILTIN}" "${PLUGINS}"; printf '\n'
35 ;; 35 ;;
36 fetch) 36 fetch)
37 print_fetch ${arg}; printf ".\n" 37 print_fetch ${arg}; printf ".\n"
@@ -62,7 +62,7 @@ open_files)
62 printf "used.value %d\n" $(get_sys kern.openfiles) 62 printf "used.value %d\n" $(get_sys kern.openfiles)
63 ;; 63 ;;
64load) 64load)
65 printf "load.value %s\n" $(get_sys vm.loadavg | /usr/bin/cut -f3 -d ' ') 65 printf "load.value %s\n" $(get_sys vm.loadavg | /usr/bin/cut -wf3)
66 ;; 66 ;;
67swap) 67swap)
68 printf "swap_in.value %d\n" $(get_sys vm.stats.vm.v_swappgsin) 68 printf "swap_in.value %d\n" $(get_sys vm.stats.vm.v_swappgsin)
@@ -76,11 +76,12 @@ memory)
76 pagesize=$(get_sys vm.stats.vm.v_page_size) 76 pagesize=$(get_sys vm.stats.vm.v_page_size)
77 printf "active.value %d\n" $(( pagesize * `get_sys vm.stats.vm.v_active_count` )) 77 printf "active.value %d\n" $(( pagesize * `get_sys vm.stats.vm.v_active_count` ))
78 printf "inactive.value %d\n" $(( pagesize * `get_sys vm.stats.vm.v_inactive_count` )) 78 printf "inactive.value %d\n" $(( pagesize * `get_sys vm.stats.vm.v_inactive_count` ))
79 printf "laundry.value %d\n" $(( pagesize * `get_sys vm.stats.vm.v_laundry_count` ))
79 printf "wired.value %d\n" $(( pagesize * `get_sys vm.stats.vm.v_wire_count` )) 80 printf "wired.value %d\n" $(( pagesize * `get_sys vm.stats.vm.v_wire_count` ))
80 printf "cached.value %d\n" $(( pagesize * `get_sys vm.stats.vm.v_cache_count` )) 81 printf "cached.value %d\n" $(( pagesize * `get_sys vm.stats.vm.v_cache_count` ))
81 printf "free.value %d\n" $(( pagesize * `get_sys vm.stats.vm.v_free_count` )) 82 printf "free.value %d\n" $(( pagesize * `get_sys vm.stats.vm.v_free_count` ))
82 printf "buffers.value %d\n" $(( `get_sys vfs.bufspace` )) 83 printf "buffers.value %d\n" $(( `get_sys vfs.bufspace` ))
83 printf "swap.value %d\n" $(( `/usr/sbin/swapinfo -k | /usr/bin/tail -n 1 | /usr/bin/xargs | /usr/bin/cut -d ' ' -f 3` * 1024 )) 84 printf "swap.value %d\n" $(( `/usr/sbin/swapinfo -k | /usr/bin/tail -n 1 | /usr/bin/cut -wf 3` * 1024 ))
84 ;; 85 ;;
85cpu) 86cpu)
86 set -- $(get_sys kern.cp_time) 87 set -- $(get_sys kern.cp_time)
@@ -92,8 +93,8 @@ processes)
92 printf "maxprocesses.value %d\n" $(get_sys kern.maxproc) 93 printf "maxprocesses.value %d\n" $(get_sys kern.maxproc)
93 ;; 94 ;;
94iostat) 95iostat)
95 for d in $(/usr/sbin/iostat -Id | /usr/bin/head -n 1 | /usr/bin/xargs); do 96 for d in $(/usr/sbin/iostat -Id | /usr/bin/head -n 1); do
96 set -- $(/usr/sbin/iostat -Idx ${d} | /usr/bin/tail -n 1 | /usr/bin/xargs) 97 set -- $(/usr/sbin/iostat -Idx ${d} | /usr/bin/tail -n 1)
97 printf "${d}_read.value %d\n${d}_write.value %d\n" "${4%.*}" "${5%.*}" 98 printf "${d}_read.value %d\n${d}_write.value %d\n" "${4%.*}" "${5%.*}"
98 done 99 done
99 ;; 100 ;;
@@ -122,215 +123,217 @@ call_plugin ${_plugin} config && return 0
122# if not, execute built in commands 123# if not, execute built in commands
123case ${_plugin} in 124case ${_plugin} in
124load) 125load)
125cat <<-EOF 126printf %s \
126 graph_title Load average 127"graph_title Load average
127 graph_info The load average of the machine describes how many processes are in the run-queue (scheduled to run "immediately"). 128graph_info The load average of the machine describes how many processes are in the run-queue (scheduled to run \"immediately\").
128 graph_category system 129graph_category system
129 graph_args --base 1000 -l 0 130graph_args --base 1000 -l 0
130 graph_vlabel load 131graph_vlabel load
131 graph_scale no 132graph_scale no
132 load.label load 133load.label load
133 load.info Average load for the last five minutes. 134load.info Average load for the last five minutes.
134 load.warning 10 135load.warning 10
135 load.critical 120 136load.critical 120
136EOF 137"
137;; 138;;
138swap) 139swap)
139cat <<-EOF 140printf %s \
140 graph_title Swap in/out 141"graph_title Swap in/out
141 graph_args --base 1000 -l 0 142graph_args --base 1000 -l 0
142 graph_info This graph shows the swap activity of the system. 143graph_info This graph shows the swap activity of the system.
143 graph_category system 144graph_category system
144 graph_vlabel pages per second in (-) / out (+) 145graph_vlabel pages per second in (-) / out (+)
145 swap_in.label swap 146swap_in.label swap
146 swap_in.type DERIVE 147swap_in.type DERIVE
147 swap_in.min 0 148swap_in.min 0
148 swap_in.max 100000 149swap_in.max 100000
149 swap_in.graph no 150swap_in.graph no
150 swap_out.label swap 151swap_out.label swap
151 swap_out.type DERIVE 152swap_out.type DERIVE
152 swap_out.min 0 153swap_out.min 0
153 swap_out.max 100000 154swap_out.max 100000
154 swap_out.negative swap_in 155swap_out.negative swap_in
155EOF 156"
156;; 157;;
157iostat) 158iostat)
158 drives=$(/usr/sbin/iostat -Id | /usr/bin/head -n 1 | /usr/bin/xargs) 159 printf %s \
159cat <<-EOF 160"graph_title IOstat by bytes
160 graph_title IOstat by bytes 161graph_args --base 1024 -l 0
161 graph_args --base 1024 -l 0 162graph_vlabel MB per second read+written
162 graph_vlabel MB per second read+written 163graph_category disk
163 graph_category disk 164graph_info This graph shows the I/O to and from block devices
164 graph_info This graph shows the I/O to and from block devices 165graph_order"
165EOF 166 set -- $(/usr/sbin/iostat -Id | /usr/bin/head -n 1)
166 printf "graph_order" 167 for d; do printf " %s_read %s_write" "$d" "$d"; done
167for d in ${drives}; do printf " %s_read %s_write" "$d" "$d"; done
168 printf "\n" 168 printf "\n"
169for d in ${drives}; do 169 for d; do
170 cat <<-EOF 170 printf %s \
171 ${d}_read.label ${d} 171"${d}_read.label ${d}
172 ${d}_read.type DERIVE 172${d}_read.type DERIVE
173 ${d}_read.max 2000 173${d}_read.max 2000
174 ${d}_read.min 0 174${d}_read.min 0
175 ${d}_read.graph no 175${d}_read.graph no
176 ${d}_write.label ${d} 176${d}_write.label ${d}
177 ${d}_write.info I/O on device ${d} 177${d}_write.info I/O on device ${d}
178 ${d}_write.type DERIVE 178${d}_write.type DERIVE
179 ${d}_write.max 2000 179${d}_write.max 2000
180 ${d}_write.min 0 180${d}_write.min 0
181 ${d}_write.negative ${d}_read 181${d}_write.negative ${d}_read
182 EOF 182"
183done 183 done
184;; 184;;
185uptime) 185uptime)
186cat <<-EOF 186printf %s \
187 graph_title Uptime 187"graph_title Uptime
188 graph_args --base 1000 -l 0 188graph_args --base 1000 -l 0
189 graph_vlabel uptime in days 189graph_vlabel uptime in days
190 graph_scale no 190graph_scale no
191 graph_category system 191graph_category system
192 uptime.label uptime 192uptime.label uptime
193 uptime.draw AREA 193uptime.draw AREA
194EOF 194"
195;; 195;;
196memory) 196memory)
197cat <<-EOF 197printf %s \
198 graph_title Memory usage 198"graph_title Memory usage
199 graph_args --base 1024 -l 0 --vertical-label Bytes --upper-limit $(( `get_sys vm.stats.vm.v_page_size` * `get_sys vm.stats.vm.v_page_count`)) 199graph_args --base 1024 -l 0 --vertical-label Bytes --upper-limit $(( `get_sys vm.stats.vm.v_page_size` * `get_sys vm.stats.vm.v_page_count`))
200 graph_category system 200graph_category system
201 graph_info This graph shows what the machine uses its memory for. 201graph_info This graph shows what the machine uses its memory for.
202 graph_order active inactive wired buffers cached free swap 202graph_order active inactive wired buffers cached free swap
203 active.label active 203active.label active
204 active.info pages recently statistically used 204active.info pages recently statistically used
205 active.draw AREA 205active.draw AREA
206 inactive.label inactive 206inactive.label inactive
207 inactive.info pages recently statistically unused 207inactive.info pages recently statistically unused
208 inactive.draw STACK 208inactive.draw STACK
209 wired.label wired 209laundry.label laundry
210 wired.info pages that are fixed into memory, usually for kernel purposes, but also sometimes for special use in processes 210laundry.info pages eligible for laundering
211 wired.draw STACK 211laundry.draw STACK
212 buffers.label buffers 212wired.label wired
213 buffers.info pages used for filesystem buffers 213wired.info pages that are fixed into memory, usually for kernel purposes, but also sometimes for special use in processes
214 buffers.draw STACK 214wired.draw STACK
215 cached.label cache 215buffers.label buffers
216 cached.info pages that have percolated from inactive to a status where they maintain their data, but can often be immediately reused 216buffers.info pages used for filesystem buffers
217 cached.draw STACK 217buffers.draw STACK
218 free.label free 218cached.label cache
219 free.info pages without data content 219cached.info pages that have percolated from inactive to a status where they maintain their data, but can often be immediately reused
220 free.draw STACK 220cached.draw STACK
221 swap.label swap 221free.label free
222 swap.info Swap space used 222free.info pages without data content
223 swap.draw STACK 223free.draw STACK
224EOF 224swap.label swap
225swap.info Swap space used
226swap.draw STACK
227"
225;; 228;;
226open_files) 229open_files)
227cat <<-EOF 230printf %s \
228 graph_title File table usage 231"graph_title File table usage
229 graph_args --base 1000 -l 0 232graph_args --base 1000 -l 0
230 graph_vlabel number of open files 233graph_vlabel number of open files
231 graph_category system 234graph_category system
232 graph_info This graph monitors the number of open files. 235graph_info This graph monitors the number of open files.
233 used.label open files 236used.label open files
234 used.info The number of currently open files. 237used.info The number of currently open files.
235 used.warning $(( `get_sys kern.maxfiles` * 92 / 100 )) 238used.warning $(( `get_sys kern.maxfiles` * 92 / 100 ))
236 used.critical $(( `get_sys kern.maxfiles` * 98 / 100 )) 239used.critical $(( `get_sys kern.maxfiles` * 98 / 100 ))
237 max.label max open files 240max.label max open files
238 max.info The maximum supported number of open files. 241max.info The maximum supported number of open files.
239EOF 242"
240;; 243;;
241cpu) 244cpu)
242 cdef=$(get_sys kern.clockrate) ; cdef=${cdef#*stathz = }; cdef=${cdef% *}",/,100,*" 245 cdef=$(get_sys kern.clockrate) ; cdef=${cdef#*stathz = }; cdef=${cdef% *}",/,100,*"
243cat <<-EOF 246printf %s \
244 graph_title CPU usage 247"graph_title CPU usage
245 graph_order system interrupt user nice idle 248graph_order system interrupt user nice idle
246 graph_args --base 1000 -r --lower-limit 0 --upper-limit $(( `get_sys hw.ncpu` * 100 )) 249graph_args --base 1000 -r --lower-limit 0 --upper-limit $(( `get_sys hw.ncpu` * 100 ))
247 graph_vlabel % 250graph_vlabel %
248 graph_scale no 251graph_scale no
249 graph_info This graph shows how CPU time is spent. 252graph_info This graph shows how CPU time is spent.
250 graph_category system 253graph_category system
251 graph_period second 254graph_period second
252 system.label system 255system.label system
253 system.draw AREA 256system.draw AREA
254 system.max 5000 257system.max 5000
255 system.type DERIVE 258system.type DERIVE
256 system.min 0 259system.min 0
257 system.info CPU time spent by the kernel in system activities 260system.info CPU time spent by the kernel in system activities
258 system.cdef system,${cdef} 261system.cdef system,${cdef}
259 interrupt.label interrupt 262interrupt.label interrupt
260 interrupt.draw STACK 263interrupt.draw STACK
261 interrupt.max 5000 264interrupt.max 5000
262 interrupt.type DERIVE 265interrupt.type DERIVE
263 interrupt.min 0 266interrupt.min 0
264 interrupt.info CPU time spent by the kernel processing interrupts 267interrupt.info CPU time spent by the kernel processing interrupts
265 interrupt.cdef interrupt,${cdef} 268interrupt.cdef interrupt,${cdef}
266 user.label user 269user.label user
267 user.draw STACK 270user.draw STACK
268 user.max 5000 271user.max 5000
269 user.type DERIVE 272user.type DERIVE
270 user.info CPU time spent by normal programs and daemons 273user.info CPU time spent by normal programs and daemons
271 user.min 0 274user.min 0
272 user.cdef user,${cdef} 275user.cdef user,${cdef}
273 nice.label nice 276nice.label nice
274 nice.draw STACK 277nice.draw STACK
275 nice.max 5000 278nice.max 5000
276 nice.type DERIVE 279nice.type DERIVE
277 nice.info CPU time spent by nice(1)d programs 280nice.info CPU time spent by nice(1)d programs
278 nice.min 0 281nice.min 0
279 nice.cdef nice,${cdef} 282nice.cdef nice,${cdef}
280 idle.label idle 283idle.label idle
281 idle.draw STACK 284idle.draw STACK
282 idle.max 5000 285idle.max 5000
283 idle.type DERIVE 286idle.type DERIVE
284 idle.info Idle CPU time 287idle.info Idle CPU time
285 idle.min 0 288idle.min 0
286 idle.cdef idle,${cdef} 289idle.cdef idle,${cdef}
287EOF 290"
288;; 291;;
289systat) 292systat)
290cat <<-EOF 293printf %s \
291 graph_title System Statistics 294"graph_title System Statistics
292 graph_vlabel per second 295graph_vlabel per second
293 graph_scale no 296graph_scale no
294 graph_category system 297graph_category system
295 graph_info FreeBSD systat plugin 298graph_info FreeBSD systat plugin
296 softint.label Software interrupts 299softint.label Software interrupts
297 softint.type DERIVE 300softint.type DERIVE
298 softint.min 0 301softint.min 0
299 hardint.label Hardware interrupts 302hardint.label Hardware interrupts
300 hardint.type DERIVE 303hardint.type DERIVE
301 hardint.min 0 304hardint.min 0
302 syscall.label System calls 305syscall.label System calls
303 syscall.type DERIVE 306syscall.type DERIVE
304 syscall.min 0 307syscall.min 0
305 cs.label Context switches 308cs.label Context switches
306 cs.type DERIVE 309cs.type DERIVE
307 cs.min 0 310cs.min 0
308 forks.label Fork rate 311forks.label Fork rate
309 forks.type DERIVE 312forks.type DERIVE
310 forks.min 0 313forks.min 0
311EOF 314"
312;; 315;;
313processes) 316processes)
314cat <<-EOF 317printf %s \
315 graph_title Process Statistics 318"graph_title Process Statistics
316 graph_args --base 1000 -l 0 319graph_args --base 1000 -l 0
317 graph_vlabel number of processes 320graph_vlabel number of processes
318 graph_category system 321graph_category system
319 graph_info This graph monitors the number of running processes and threads. 322graph_info This graph monitors the number of running processes and threads.
320 processes.label The number of processes in the system 323processes.label The number of processes in the system
321 threads.label The number of threads in the system 324threads.label The number of threads in the system
322 maxprocesses.label The maximum number of processes in the system 325maxprocesses.label The maximum number of processes in the system
323 processes.warning $(( `get_sys kern.maxproc` * 92 / 100 )) 326processes.warning $(( `get_sys kern.maxproc` * 92 / 100 ))
324 processes.critical $(( `get_sys kern.maxproc` * 98 / 100 )) 327processes.critical $(( `get_sys kern.maxproc` * 98 / 100 ))
325EOF 328"
326;; 329;;
327df) 330df)
328cat <<-EOF 331printf %s \
329 graph_title Filesystem usage (in bytes) 332"graph_title Filesystem usage (in bytes)
330 graph_args --base 1024 --lower-limit 0 333graph_args --base 1024 --lower-limit 0
331 graph_vlabel bytes 334graph_vlabel bytes
332 graph_category disk 335graph_category disk
333EOF 336"
334/bin/df -P -t noprocfs,devfs,fdescfs,linprocfs,linsysfs,nfs,nullfs | /usr/bin/tail -n +2 | 337/bin/df -P -t noprocfs,devfs,fdescfs,linprocfs,linsysfs,nfs,nullfs | /usr/bin/tail -n +2 |
335while read -r fs blocks used avail cap mount; do 338while read -r fs blocks used avail cap mount; do
336 fs=$(printf "%s" ${fs} | /usr/bin/tr -c '[:alnum:]' _) 339 fs=$(printf "%s" ${fs} | /usr/bin/tr -c '[:alnum:]' _)