File: bonding_err_.in

package info (click to toggle)
munin 2.0.76-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,064 kB
  • sloc: perl: 11,684; java: 1,924; sh: 1,632; makefile: 636; javascript: 365; python: 267
file content (106 lines) | stat: -rw-r--r-- 2,500 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!@@GOODSH@@
# -*- sh -*-

: <<EOF

=head1 NAME

bonding_err_ - Wildcard plugin to graph bonding interface errors

=head1 CONFIGURATION

This is a wildcard plugin.  The link name extension is the bonding
interface to monitor.

=head1 AUTHORS

Copyright Bjørn Ruberg 2009

=head1 LICENSE

Gnu GPLv2

=begin comment

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 dated June, 1991.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

=end comment

=head1 MAGIC MARKERS

 #%# family=auto
 #%# capabilities=autoconf suggest

=cut

EOF

# Source plugin library functions
# shellcheck disable=SC1090
. "$MUNIN_LIBDIR/plugins/plugin.sh"

PROCDIR="/proc/net/bonding"
MYSELF=$(basename "$0")
FILENAME="bonding_err_"
BONDINGIF=$(echo "$MYSELF" | sed "s/^$FILENAME//")


get_bonding_interface_names() {
    grep "^Slave Interface:" "${PROCDIR}/${BONDINGIF}" | awk '{print $3}'
}


if [ "$1" = "autoconf" ]; then
  if [ -d "${PROCDIR}" ]; then
    echo "yes"
  else
    echo "no (No ${PROCDIR})"
  fi
  exit 0
fi

if [ "$1" = "suggest" ]; then
  ls -1 "$PROCDIR"
  exit 0
fi

if [ "$MYSELF" = "$FILENAME" ]; then
    echo "Can't run an un-symlinked plugin. Please run the plugin with 'suggest' before attempting this."
    exit 1
fi

if [ "$1" = "config" ]; then
    echo "graph_title Bonding interface errors for $BONDINGIF"
    echo "graph_category Network"
    echo "graph_args --base 1000 -l 0"
    get_bonding_interface_names | while read -r if_name; do
      fieldname=$(clean_fieldname "$if_name")
      echo "if_${fieldname}.label $if_name"
      echo "if_${fieldname}.type DERIVE"
      echo "if_${fieldname}.min 0"
      echo "if_${fieldname}.warning 0"
    done
    exit 0
fi

get_bonding_interface_names | while read -r if_name; do
  fieldname=$(clean_fieldname "$if_name")
  echo -n "if_${fieldname}.value "
  sed "0,/^Slave Interface: ${if_name}/d; /^\$/,\$d" "${PROCDIR}/${BONDINGIF}" \
    | grep "Link Failure Count:" \
    | cut -d " " -f 4
done


# vim: syntax=sh ts=2 et