diff options
author | Dirk Engling <erdgeist@erdgeist.org> | 2019-04-13 21:27:00 +0200 |
---|---|---|
committer | Dirk Engling <erdgeist@erdgeist.org> | 2019-04-13 21:27:00 +0200 |
commit | 998261d1d08bb5d05610f6b05fa84697f5b27b44 (patch) | |
tree | fc3bcb02f4a8298fbe31ad4f24f4254a2facb85e | |
parent | 941288a85098c489a268d40adddd4751545d057e (diff) |
Add laundry to memory info
-rwxr-xr-x | minimunin | 393 |
1 files changed, 198 insertions, 195 deletions
@@ -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 |
16 | PLUGINS=$(/usr/bin/find ${PLUGIN_DIR} \( -type l -or -type f \) -not -name '*_' -perm +111 -exec basename {} \; 2> /dev/null | /usr/bin/xargs) | 16 | PLUGINS=$(/usr/bin/find ${PLUGIN_DIR} \( -type l -or -type f \) -not -name '*_' -perm +111 -exec basename {} \; 2> /dev/null) |
17 | CONFIGS=$(/usr/bin/find ${CONFIG_DIR} -type f -exec /usr/bin/grep -v -e ^\# -e ^$ {} \; -exec /bin/echo [] \; 2> /dev/null) | 17 | CONFIGS=$(/usr/bin/find ${CONFIG_DIR} -type f -exec /usr/bin/grep -v -e ^\# -e ^$ {} \; -exec /bin/echo [] \; 2> /dev/null) |
18 | 18 | ||
19 | main() { | 19 | main() { |
@@ -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 | ;; |
64 | load) | 64 | load) |
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 | ;; |
67 | swap) | 67 | swap) |
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 | ;; |
85 | cpu) | 86 | cpu) |
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 | ;; |
94 | iostat) | 95 | iostat) |
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 |
123 | case ${_plugin} in | 124 | case ${_plugin} in |
124 | load) | 125 | load) |
125 | cat <<-EOF | 126 | printf %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"). | 128 | graph_info The load average of the machine describes how many processes are in the run-queue (scheduled to run \"immediately\"). |
128 | graph_category system | 129 | graph_category system |
129 | graph_args --base 1000 -l 0 | 130 | graph_args --base 1000 -l 0 |
130 | graph_vlabel load | 131 | graph_vlabel load |
131 | graph_scale no | 132 | graph_scale no |
132 | load.label load | 133 | load.label load |
133 | load.info Average load for the last five minutes. | 134 | load.info Average load for the last five minutes. |
134 | load.warning 10 | 135 | load.warning 10 |
135 | load.critical 120 | 136 | load.critical 120 |
136 | EOF | 137 | " |
137 | ;; | 138 | ;; |
138 | swap) | 139 | swap) |
139 | cat <<-EOF | 140 | printf %s \ |
140 | graph_title Swap in/out | 141 | "graph_title Swap in/out |
141 | graph_args --base 1000 -l 0 | 142 | graph_args --base 1000 -l 0 |
142 | graph_info This graph shows the swap activity of the system. | 143 | graph_info This graph shows the swap activity of the system. |
143 | graph_category system | 144 | graph_category system |
144 | graph_vlabel pages per second in (-) / out (+) | 145 | graph_vlabel pages per second in (-) / out (+) |
145 | swap_in.label swap | 146 | swap_in.label swap |
146 | swap_in.type DERIVE | 147 | swap_in.type DERIVE |
147 | swap_in.min 0 | 148 | swap_in.min 0 |
148 | swap_in.max 100000 | 149 | swap_in.max 100000 |
149 | swap_in.graph no | 150 | swap_in.graph no |
150 | swap_out.label swap | 151 | swap_out.label swap |
151 | swap_out.type DERIVE | 152 | swap_out.type DERIVE |
152 | swap_out.min 0 | 153 | swap_out.min 0 |
153 | swap_out.max 100000 | 154 | swap_out.max 100000 |
154 | swap_out.negative swap_in | 155 | swap_out.negative swap_in |
155 | EOF | 156 | " |
156 | ;; | 157 | ;; |
157 | iostat) | 158 | iostat) |
158 | drives=$(/usr/sbin/iostat -Id | /usr/bin/head -n 1 | /usr/bin/xargs) | 159 | printf %s \ |
159 | cat <<-EOF | 160 | "graph_title IOstat by bytes |
160 | graph_title IOstat by bytes | 161 | graph_args --base 1024 -l 0 |
161 | graph_args --base 1024 -l 0 | 162 | graph_vlabel MB per second read+written |
162 | graph_vlabel MB per second read+written | 163 | graph_category disk |
163 | graph_category disk | 164 | graph_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 | 165 | graph_order" |
165 | EOF | 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 |
167 | for d in ${drives}; do printf " %s_read %s_write" "$d" "$d"; done | ||
168 | printf "\n" | 168 | printf "\n" |
169 | for 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 | " |
183 | done | 183 | done |
184 | ;; | 184 | ;; |
185 | uptime) | 185 | uptime) |
186 | cat <<-EOF | 186 | printf %s \ |
187 | graph_title Uptime | 187 | "graph_title Uptime |
188 | graph_args --base 1000 -l 0 | 188 | graph_args --base 1000 -l 0 |
189 | graph_vlabel uptime in days | 189 | graph_vlabel uptime in days |
190 | graph_scale no | 190 | graph_scale no |
191 | graph_category system | 191 | graph_category system |
192 | uptime.label uptime | 192 | uptime.label uptime |
193 | uptime.draw AREA | 193 | uptime.draw AREA |
194 | EOF | 194 | " |
195 | ;; | 195 | ;; |
196 | memory) | 196 | memory) |
197 | cat <<-EOF | 197 | printf %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`)) | 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`)) |
200 | graph_category system | 200 | graph_category system |
201 | graph_info This graph shows what the machine uses its memory for. | 201 | graph_info This graph shows what the machine uses its memory for. |
202 | graph_order active inactive wired buffers cached free swap | 202 | graph_order active inactive wired buffers cached free swap |
203 | active.label active | 203 | active.label active |
204 | active.info pages recently statistically used | 204 | active.info pages recently statistically used |
205 | active.draw AREA | 205 | active.draw AREA |
206 | inactive.label inactive | 206 | inactive.label inactive |
207 | inactive.info pages recently statistically unused | 207 | inactive.info pages recently statistically unused |
208 | inactive.draw STACK | 208 | inactive.draw STACK |
209 | wired.label wired | 209 | laundry.label laundry |
210 | wired.info pages that are fixed into memory, usually for kernel purposes, but also sometimes for special use in processes | 210 | laundry.info pages eligible for laundering |
211 | wired.draw STACK | 211 | laundry.draw STACK |
212 | buffers.label buffers | 212 | wired.label wired |
213 | buffers.info pages used for filesystem buffers | 213 | wired.info pages that are fixed into memory, usually for kernel purposes, but also sometimes for special use in processes |
214 | buffers.draw STACK | 214 | wired.draw STACK |
215 | cached.label cache | 215 | buffers.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 | 216 | buffers.info pages used for filesystem buffers |
217 | cached.draw STACK | 217 | buffers.draw STACK |
218 | free.label free | 218 | cached.label cache |
219 | free.info pages without data content | 219 | cached.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 | 220 | cached.draw STACK |
221 | swap.label swap | 221 | free.label free |
222 | swap.info Swap space used | 222 | free.info pages without data content |
223 | swap.draw STACK | 223 | free.draw STACK |
224 | EOF | 224 | swap.label swap |
225 | swap.info Swap space used | ||
226 | swap.draw STACK | ||
227 | " | ||
225 | ;; | 228 | ;; |
226 | open_files) | 229 | open_files) |
227 | cat <<-EOF | 230 | printf %s \ |
228 | graph_title File table usage | 231 | "graph_title File table usage |
229 | graph_args --base 1000 -l 0 | 232 | graph_args --base 1000 -l 0 |
230 | graph_vlabel number of open files | 233 | graph_vlabel number of open files |
231 | graph_category system | 234 | graph_category system |
232 | graph_info This graph monitors the number of open files. | 235 | graph_info This graph monitors the number of open files. |
233 | used.label open files | 236 | used.label open files |
234 | used.info The number of currently open files. | 237 | used.info The number of currently open files. |
235 | used.warning $(( `get_sys kern.maxfiles` * 92 / 100 )) | 238 | used.warning $(( `get_sys kern.maxfiles` * 92 / 100 )) |
236 | used.critical $(( `get_sys kern.maxfiles` * 98 / 100 )) | 239 | used.critical $(( `get_sys kern.maxfiles` * 98 / 100 )) |
237 | max.label max open files | 240 | max.label max open files |
238 | max.info The maximum supported number of open files. | 241 | max.info The maximum supported number of open files. |
239 | EOF | 242 | " |
240 | ;; | 243 | ;; |
241 | cpu) | 244 | cpu) |
242 | cdef=$(get_sys kern.clockrate) ; cdef=${cdef#*stathz = }; cdef=${cdef% *}",/,100,*" | 245 | cdef=$(get_sys kern.clockrate) ; cdef=${cdef#*stathz = }; cdef=${cdef% *}",/,100,*" |
243 | cat <<-EOF | 246 | printf %s \ |
244 | graph_title CPU usage | 247 | "graph_title CPU usage |
245 | graph_order system interrupt user nice idle | 248 | graph_order system interrupt user nice idle |
246 | graph_args --base 1000 -r --lower-limit 0 --upper-limit $(( `get_sys hw.ncpu` * 100 )) | 249 | graph_args --base 1000 -r --lower-limit 0 --upper-limit $(( `get_sys hw.ncpu` * 100 )) |
247 | graph_vlabel % | 250 | graph_vlabel % |
248 | graph_scale no | 251 | graph_scale no |
249 | graph_info This graph shows how CPU time is spent. | 252 | graph_info This graph shows how CPU time is spent. |
250 | graph_category system | 253 | graph_category system |
251 | graph_period second | 254 | graph_period second |
252 | system.label system | 255 | system.label system |
253 | system.draw AREA | 256 | system.draw AREA |
254 | system.max 5000 | 257 | system.max 5000 |
255 | system.type DERIVE | 258 | system.type DERIVE |
256 | system.min 0 | 259 | system.min 0 |
257 | system.info CPU time spent by the kernel in system activities | 260 | system.info CPU time spent by the kernel in system activities |
258 | system.cdef system,${cdef} | 261 | system.cdef system,${cdef} |
259 | interrupt.label interrupt | 262 | interrupt.label interrupt |
260 | interrupt.draw STACK | 263 | interrupt.draw STACK |
261 | interrupt.max 5000 | 264 | interrupt.max 5000 |
262 | interrupt.type DERIVE | 265 | interrupt.type DERIVE |
263 | interrupt.min 0 | 266 | interrupt.min 0 |
264 | interrupt.info CPU time spent by the kernel processing interrupts | 267 | interrupt.info CPU time spent by the kernel processing interrupts |
265 | interrupt.cdef interrupt,${cdef} | 268 | interrupt.cdef interrupt,${cdef} |
266 | user.label user | 269 | user.label user |
267 | user.draw STACK | 270 | user.draw STACK |
268 | user.max 5000 | 271 | user.max 5000 |
269 | user.type DERIVE | 272 | user.type DERIVE |
270 | user.info CPU time spent by normal programs and daemons | 273 | user.info CPU time spent by normal programs and daemons |
271 | user.min 0 | 274 | user.min 0 |
272 | user.cdef user,${cdef} | 275 | user.cdef user,${cdef} |
273 | nice.label nice | 276 | nice.label nice |
274 | nice.draw STACK | 277 | nice.draw STACK |
275 | nice.max 5000 | 278 | nice.max 5000 |
276 | nice.type DERIVE | 279 | nice.type DERIVE |
277 | nice.info CPU time spent by nice(1)d programs | 280 | nice.info CPU time spent by nice(1)d programs |
278 | nice.min 0 | 281 | nice.min 0 |
279 | nice.cdef nice,${cdef} | 282 | nice.cdef nice,${cdef} |
280 | idle.label idle | 283 | idle.label idle |
281 | idle.draw STACK | 284 | idle.draw STACK |
282 | idle.max 5000 | 285 | idle.max 5000 |
283 | idle.type DERIVE | 286 | idle.type DERIVE |
284 | idle.info Idle CPU time | 287 | idle.info Idle CPU time |
285 | idle.min 0 | 288 | idle.min 0 |
286 | idle.cdef idle,${cdef} | 289 | idle.cdef idle,${cdef} |
287 | EOF | 290 | " |
288 | ;; | 291 | ;; |
289 | systat) | 292 | systat) |
290 | cat <<-EOF | 293 | printf %s \ |
291 | graph_title System Statistics | 294 | "graph_title System Statistics |
292 | graph_vlabel per second | 295 | graph_vlabel per second |
293 | graph_scale no | 296 | graph_scale no |
294 | graph_category system | 297 | graph_category system |
295 | graph_info FreeBSD systat plugin | 298 | graph_info FreeBSD systat plugin |
296 | softint.label Software interrupts | 299 | softint.label Software interrupts |
297 | softint.type DERIVE | 300 | softint.type DERIVE |
298 | softint.min 0 | 301 | softint.min 0 |
299 | hardint.label Hardware interrupts | 302 | hardint.label Hardware interrupts |
300 | hardint.type DERIVE | 303 | hardint.type DERIVE |
301 | hardint.min 0 | 304 | hardint.min 0 |
302 | syscall.label System calls | 305 | syscall.label System calls |
303 | syscall.type DERIVE | 306 | syscall.type DERIVE |
304 | syscall.min 0 | 307 | syscall.min 0 |
305 | cs.label Context switches | 308 | cs.label Context switches |
306 | cs.type DERIVE | 309 | cs.type DERIVE |
307 | cs.min 0 | 310 | cs.min 0 |
308 | forks.label Fork rate | 311 | forks.label Fork rate |
309 | forks.type DERIVE | 312 | forks.type DERIVE |
310 | forks.min 0 | 313 | forks.min 0 |
311 | EOF | 314 | " |
312 | ;; | 315 | ;; |
313 | processes) | 316 | processes) |
314 | cat <<-EOF | 317 | printf %s \ |
315 | graph_title Process Statistics | 318 | "graph_title Process Statistics |
316 | graph_args --base 1000 -l 0 | 319 | graph_args --base 1000 -l 0 |
317 | graph_vlabel number of processes | 320 | graph_vlabel number of processes |
318 | graph_category system | 321 | graph_category system |
319 | graph_info This graph monitors the number of running processes and threads. | 322 | graph_info This graph monitors the number of running processes and threads. |
320 | processes.label The number of processes in the system | 323 | processes.label The number of processes in the system |
321 | threads.label The number of threads in the system | 324 | threads.label The number of threads in the system |
322 | maxprocesses.label The maximum number of processes in the system | 325 | maxprocesses.label The maximum number of processes in the system |
323 | processes.warning $(( `get_sys kern.maxproc` * 92 / 100 )) | 326 | processes.warning $(( `get_sys kern.maxproc` * 92 / 100 )) |
324 | processes.critical $(( `get_sys kern.maxproc` * 98 / 100 )) | 327 | processes.critical $(( `get_sys kern.maxproc` * 98 / 100 )) |
325 | EOF | 328 | " |
326 | ;; | 329 | ;; |
327 | df) | 330 | df) |
328 | cat <<-EOF | 331 | printf %s \ |
329 | graph_title Filesystem usage (in bytes) | 332 | "graph_title Filesystem usage (in bytes) |
330 | graph_args --base 1024 --lower-limit 0 | 333 | graph_args --base 1024 --lower-limit 0 |
331 | graph_vlabel bytes | 334 | graph_vlabel bytes |
332 | graph_category disk | 335 | graph_category disk |
333 | EOF | 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 | |
335 | while read -r fs blocks used avail cap mount; do | 338 | while 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:]' _) |