root / plugins / solaris / interrupts @ 17f78427
Historique | Voir | Annoter | Télécharger (2,81 ko)
| 1 |
#!/bin/bash |
|---|---|
| 2 |
|
| 3 |
: << =cut |
| 4 |
|
| 5 |
=head1 NAME |
| 6 |
|
| 7 |
interrupts - Munin plugin to monitor Solaris cpu interrupts and context switches |
| 8 |
|
| 9 |
=head1 CONFIGURATION |
| 10 |
|
| 11 |
Make symlink: |
| 12 |
cd /path/to/munin/etc/plugins |
| 13 |
ln -s /path/to/munin/lib/plugins/interrupts . |
| 14 |
|
| 15 |
=head1 AUTHOR |
| 16 |
|
| 17 |
K.Cima https://github.com/shakemid |
| 18 |
|
| 19 |
=head1 LICENSE |
| 20 |
|
| 21 |
GPLv2 |
| 22 |
|
| 23 |
=head1 Magic markers |
| 24 |
|
| 25 |
#%# family=contrib |
| 26 |
#%# capabilities=autoconf |
| 27 |
|
| 28 |
=cut |
| 29 |
|
| 30 |
# Include plugin.sh |
| 31 |
. "${MUNIN_LIBDIR:-}/plugins/plugin.sh"
|
| 32 |
|
| 33 |
# Shell options |
| 34 |
set -o nounset # Like perl use strict; |
| 35 |
|
| 36 |
# Graph settings |
| 37 |
global_attr=" |
| 38 |
graph_title Interrupts and context switches |
| 39 |
graph_category system |
| 40 |
graph_args --base 1000 --lower-limit 0 --rigid |
| 41 |
graph_vlabel count per second |
| 42 |
graph_info Interrupts and context switches |
| 43 |
|
| 44 |
rw_wrfails.graph no |
| 45 |
rw_rdfails.cdef rw_rdfails,rw_wrfails,+ |
| 46 |
" |
| 47 |
# data_attr format: field type draw label |
| 48 |
# label can contain white-spaces. |
| 49 |
data_attr=" |
| 50 |
intr DERIVE LINE interrupts |
| 51 |
intrthread DERIVE LINE interrupts as threads |
| 52 |
pswitch DERIVE LINE context switches |
| 53 |
inv_swtch DERIVE LINE involuntary context switches |
| 54 |
cpumigrate DERIVE LINE thread migrations |
| 55 |
xcalls DERIVE LINE inter-processor cross-calls |
| 56 |
mutex_adenters DERIVE LINE spins on mutexes |
| 57 |
rw_rdfails DERIVE LINE spins on r/w locks |
| 58 |
rw_wrfails DERIVE LINE dummy |
| 59 |
syscall DERIVE LINE system calls |
| 60 |
trap DERIVE LINE traps |
| 61 |
" |
| 62 |
# They can be shown by vmstat -s or mpstat |
| 63 |
|
| 64 |
# Functions |
| 65 |
|
| 66 |
autoconf() {
|
| 67 |
if which kstat >/dev/null ; then |
| 68 |
echo yes |
| 69 |
else |
| 70 |
echo "no (failed to find executable 'kstat')" |
| 71 |
fi |
| 72 |
} |
| 73 |
|
| 74 |
config() {
|
| 75 |
local label_max_length=45 |
| 76 |
|
| 77 |
# print global attributes |
| 78 |
echo "$global_attr" | sed -e 's/^ *//' -e '/^$/d' |
| 79 |
|
| 80 |
# print data source attributes |
| 81 |
# split line into field,type,draw,label |
| 82 |
local field type draw label |
| 83 |
echo "$data_attr" | while read -r field type draw label |
| 84 |
do |
| 85 |
[ -z "$field" ] && continue |
| 86 |
|
| 87 |
echo "${field}.type ${type}"
|
| 88 |
echo "${field}.draw ${draw}"
|
| 89 |
echo "${field}.label ${label:0:${label_max_length}}"
|
| 90 |
if [ "${type}" = DERIVE ]; then
|
| 91 |
echo "${field}.min 0"
|
| 92 |
fi |
| 93 |
done |
| 94 |
} |
| 95 |
|
| 96 |
fetch() {
|
| 97 |
local field type draw label |
| 98 |
echo "$data_attr" | while read -r field type draw label |
| 99 |
do |
| 100 |
[ -z "$field" ] && continue |
| 101 |
|
| 102 |
# kstat output example: |
| 103 |
# $ kstat -p cpu::sys:intr |
| 104 |
# cpu:0:sys:intr 5728473528 |
| 105 |
# cpu:1:sys:intr 1060016014 |
| 106 |
# cpu:2:sys:intr 1297441213 |
| 107 |
# ... |
| 108 |
value=$( kstat -p "cpu::sys:${field}" | awk '{ sum += $2 } END { print sum }' )
|
| 109 |
|
| 110 |
echo "${field}.value ${value}"
|
| 111 |
done |
| 112 |
} |
| 113 |
|
| 114 |
# Main |
| 115 |
case ${1:-} in
|
| 116 |
autoconf) |
| 117 |
autoconf |
| 118 |
;; |
| 119 |
config) |
| 120 |
config |
| 121 |
if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then fetch; fi
|
| 122 |
;; |
| 123 |
*) |
| 124 |
fetch |
| 125 |
;; |
| 126 |
esac |
| 127 |
|
| 128 |
exit 0 |
