root / plugins / dovecot / dovecot_stats_ @ c4b2d9a8
Historique | Voir | Annoter | Télécharger (3,32 ko)
| 1 |
#!/bin/bash |
|---|---|
| 2 |
: <<=cut |
| 3 |
|
| 4 |
=head1 NAME |
| 5 |
|
| 6 |
dovecot_stats_ - Munin plugin to display statistics for the dovecot mail server |
| 7 |
|
| 8 |
=head1 CONFIGURATION |
| 9 |
|
| 10 |
This plugin must be run with permissions to run "doveadm". That usually means root, but to test, run the following as any user: |
| 11 |
|
| 12 |
doveadm who |
| 13 |
|
| 14 |
If you get a permission denied message, check the permissions on the socket mentioned in the error line. |
| 15 |
|
| 16 |
=head1 MAGIC MARKERS |
| 17 |
|
| 18 |
#%# family=contrib |
| 19 |
#%# capability=autoconf suggest |
| 20 |
|
| 21 |
=head1 AUTHOR |
| 22 |
|
| 23 |
Paul Saunders <darac+munin@darac.org.uk> |
| 24 |
|
| 25 |
=cut |
| 26 |
|
| 27 |
. $MUNIN_LIBDIR/plugins/plugin.sh |
| 28 |
is_multigraph |
| 29 |
|
| 30 |
if [[ "$1" == "autoconf" ]]; then |
| 31 |
if [[ -x /usr/bin/doveadm ]]; then |
| 32 |
echo yes |
| 33 |
else |
| 34 |
echo no |
| 35 |
fi |
| 36 |
exit 0 |
| 37 |
fi |
| 38 |
|
| 39 |
if [[ "$1" == "suggest" ]]; then |
| 40 |
doveadm stats dump domain|awk 'NR!=1 {print $1}'
|
| 41 |
exit 0 |
| 42 |
fi |
| 43 |
|
| 44 |
domain=$(basename $0) |
| 45 |
domain=${domain#dovecot_stats_}
|
| 46 |
|
| 47 |
if [[ -z $domain ]]; then |
| 48 |
exit 1 |
| 49 |
fi |
| 50 |
|
| 51 |
if [[ "$1" == "config" ]]; then |
| 52 |
cat <<EOF |
| 53 |
multigraph dovecot_cpu_${domain//\./_}
|
| 54 |
graph_title Dovecot CPU Usage for $domain |
| 55 |
graph_vlabel Seconds |
| 56 |
graph_category mail |
| 57 |
user_cpu.label User CPU |
| 58 |
user_cpu.type DERIVE |
| 59 |
user_cpu.min 0 |
| 60 |
user_cpu.cdef user_cpu,1000000,/ |
| 61 |
sys_cpu.label System CPU |
| 62 |
sys_cpu.type DERIVE |
| 63 |
sys_cpu.min 0 |
| 64 |
sys_cpu.cdef sys_cpu,1000000,/ |
| 65 |
|
| 66 |
multigraph dovecot_system_${domain//\./_}
|
| 67 |
graph_title Dovecot System Usage for $domain |
| 68 |
graph_category mail |
| 69 |
min_faults.label Minor page faults |
| 70 |
min_faults.type DERIVE |
| 71 |
min_faults.min 0 |
| 72 |
maj_faults.label Major page faults |
| 73 |
maj_faults.type DERIVE |
| 74 |
maj_faults.min 0 |
| 75 |
vol_cs.label Voluntary context switches |
| 76 |
vol_cs.type DERIVE |
| 77 |
vol_cs.min 0 |
| 78 |
invol_cs.label Involuntary context switches |
| 79 |
invol_cs.type DERIVE |
| 80 |
invol_cs.min 0 |
| 81 |
read_count.label read() syscalls |
| 82 |
read_count.type DERIVE |
| 83 |
read_count.min 0 |
| 84 |
write_count.label write() syscalls |
| 85 |
write_count.type DERIVE |
| 86 |
write_count.min 0 |
| 87 |
|
| 88 |
multigraph dovecot_mail_${domain//\./_}
|
| 89 |
graph_title Dovecot Mail Access for $domain |
| 90 |
graph_category mail |
| 91 |
num_logins.label Logins |
| 92 |
num_logins.type DERIVE |
| 93 |
num_logins.min 0 |
| 94 |
num_cmds.label Commands |
| 95 |
num_cmds.type DERIVE |
| 96 |
num_cmds.min 0 |
| 97 |
mail_lookup_path.label Path Lookups |
| 98 |
mail_lookup_path.type DERIVE |
| 99 |
mail_lookup_path.min 0 |
| 100 |
mail_lookup_attr.label Attr lookups |
| 101 |
mail_lookup_attr.type DERIVE |
| 102 |
mail_lookup_attr.min 0 |
| 103 |
mail_read_count.label Messages read |
| 104 |
mail_read_count.type DERIVE |
| 105 |
mail_read_count.min 0 |
| 106 |
mail_cache_hits.label Cache hits |
| 107 |
mail_cache_hits.type DERIVE |
| 108 |
mail_cache_hits.min 0 |
| 109 |
EOF |
| 110 |
exit 0 |
| 111 |
fi |
| 112 |
|
| 113 |
# Fetch data |
| 114 |
# Gawk script cadged from http://awk.info/?JanisP |
| 115 |
doveadm stats dump domain domain=$domain | gawk -F\\t -v cols="user_cpu sys_cpu min_faults maj_faults vol_cs invol_cs read_count write_count num_logins num_cmds mail_lookup_path mail_lookup_attr mail_read_count mail_cache_hits " -v domain=${domain//\./_} '
|
| 116 |
BEGIN {
|
| 117 |
n=split(cols,col," ") |
| 118 |
for (i=1; i<=n; i++) s[col[i]]=i |
| 119 |
} |
| 120 |
NR==1 {
|
| 121 |
for (f=1;f<=NF; f++) |
| 122 |
if ($f in s) c[s[$f]]=f |
| 123 |
next |
| 124 |
} |
| 125 |
{ for (f=1; f<=n; f++) {
|
| 126 |
if (col[f] == "user_cpu") printf ("\nmultigraph dovecot_cpu_%s\n", domain)
|
| 127 |
if (col[f] == "min_faults") printf ("\nmultigraph dovecot_system_%s\n", domain)
|
| 128 |
if (col[f] == "num_logins") printf ("\nmultigraph dovecot_mail_%s\n", domain)
|
| 129 |
if (col[f] == "user_cpu" || col[f] == "sys_cpu") |
| 130 |
printf("%s.value %d\n",col[f],$c[f] * 1000000)
|
| 131 |
else |
| 132 |
printf("%s.value %d\n",col[f],$c[f])
|
| 133 |
} |
| 134 |
} |
| 135 |
' |
