Révision 99346c44
Initial version
| plugins/other/openvpn_multi | ||
|---|---|---|
| 1 |
#!/bin/sh |
|
| 2 |
# |
|
| 3 |
# Plugin Configuration |
|
| 4 |
# [openvpn_multi] |
|
| 5 |
# user root |
|
| 6 |
# env.statusfile /var/log/openvpn.status |
|
| 7 |
# env.userlist user1 user2 ... |
|
| 8 |
# |
|
| 9 |
# |
|
| 10 |
# No error handling/mapping for ${userlist} => ${statusfile}
|
|
| 11 |
# |
|
| 12 |
# Magic markers (optional - used by munin-config and some installation |
|
| 13 |
# scripts): |
|
| 14 |
# |
|
| 15 |
#%# family=auto |
|
| 16 |
#%# capabilities=autoconf suggest |
|
| 17 |
|
|
| 18 |
if [ "$1" = "autoconf" ]; then |
|
| 19 |
if [ -f ${statusfile} ]; then
|
|
| 20 |
echo yes |
|
| 21 |
exit 0 |
|
| 22 |
else |
|
| 23 |
echo "no (${statusfile} not found)"
|
|
| 24 |
exit 1 |
|
| 25 |
fi |
|
| 26 |
fi |
|
| 27 |
|
|
| 28 |
if [ "$1" = "suggest" ]; then |
|
| 29 |
echo "Configure a status file..." |
|
| 30 |
exit 0 |
|
| 31 |
fi |
|
| 32 |
|
|
| 33 |
FieldAttrib () {
|
|
| 34 |
echo "${USER}_in.label ${USER} Received"
|
|
| 35 |
echo "${USER}_in.type DERIVE"
|
|
| 36 |
echo "${USER}_in.min 0"
|
|
| 37 |
echo "${USER}_in.graph no"
|
|
| 38 |
echo "${USER}_in.cdef ${USER}_in,1,*"
|
|
| 39 |
echo "${USER}_out.label ${USER} Bps"
|
|
| 40 |
echo "${USER}_out.type DERIVE"
|
|
| 41 |
echo "${USER}_out.min 0"
|
|
| 42 |
echo "${USER}_out.negative ${USER}_in"
|
|
| 43 |
echo "${USER}_out.cdef ${USER}_out,1,*"
|
|
| 44 |
} |
|
| 45 |
|
|
| 46 |
GetValues () {
|
|
| 47 |
if grep -q ^$USER $statusfile; then |
|
| 48 |
awk -F , '/^'"$USER"'/ {print $1"_in.value "$3 "\n"$1"_out.value "$4}' $statusfile
|
|
| 49 |
else |
|
| 50 |
echo "${USER}_in.value -1"
|
|
| 51 |
echo "${USER}_out.value -1"
|
|
| 52 |
fi |
|
| 53 |
} |
|
| 54 |
|
|
| 55 |
|
|
| 56 |
# Setup config |
|
| 57 |
if [ "$1" = "config" ]; then |
|
| 58 |
echo "graph_title Root Graph of Openvpn Traffic by CN" |
|
| 59 |
echo "graph_args --base 1024 --lower-limit 0" |
|
| 60 |
echo "graph_vlabel Bytes Out (-) / In (+) per \${graph_period}"
|
|
| 61 |
echo "graph_category openvpn" |
|
| 62 |
echo "graph_info This graph shows the bandwidth usage in Bytes/s. It prepulates the graph lines from a list of user CN's in the plugin conf file, this must correlate with the values in the ${statusfile} log file."
|
|
| 63 |
for USER in $userlist |
|
| 64 |
do |
|
| 65 |
FieldAttrib |
|
| 66 |
done |
|
| 67 |
for USER in $userlist |
|
| 68 |
do |
|
| 69 |
echo "multigraph openvpn_multi.${USER}"
|
|
| 70 |
echo "graph_title ${USER} sub-graph"
|
|
| 71 |
echo "graph_category openvpn" |
|
| 72 |
echo "graph_info This graph shows the bandwidth usage in bytes/s. It prepulates the graph lines from a list of user CN's in the plugin conf file, this must correlate with the values in the ${statusfile} log file."
|
|
| 73 |
FieldAttrib |
|
| 74 |
done |
|
| 75 |
exit 0 |
|
| 76 |
fi; |
|
| 77 |
|
|
| 78 |
# Get .values for root graph |
|
| 79 |
for USER in $userlist |
|
| 80 |
do |
|
| 81 |
GetValues |
|
| 82 |
done |
|
| 83 |
|
|
| 84 |
# Get .values for sub-graphs |
|
| 85 |
for USER in $userlist |
|
| 86 |
do |
|
| 87 |
echo "multigraph openvpn_multi.${USER}"
|
|
| 88 |
GetValues |
|
| 89 |
done |
|
Formats disponibles : Unified diff