File: network_interface.cmd.in

package info (click to toggle)
nagios-plugin-check-multi 0.26-6
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,172 kB
  • sloc: perl: 2,296; makefile: 415; sh: 239
file content (25 lines) | stat: -rw-r--r-- 1,065 bytes parent folder | download | duplicates (7)
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
#
# network_interface.cmd (adopted for Linux hosts)
#
# Copyright (c) 2008-2009 Matthias Flacke (matthias.flacke at gmx.de)
#
# Matthias Flacke, 20.01.2008

# determine def_gw interface from /proc/net/route
command [ def_gw  ] = awk '$2 == "00000000" {print $1}' /proc/net/route

# get ethtool output and store it in temporary file
command [ ethtool ] = sudo @ethtool@ $def_gw$ > /tmp/if_$def_gw$.txt \
                      && echo OK

# get interface settings using ethtool
command [ link    ] = awk '/Link detected:/    {print $3}' /tmp/if_$def_gw$.txt 
command [ speed   ] = awk '/Speed:/            {print $2}' /tmp/if_$def_gw$.txt 
command [ duplex  ] = awk '/Duplex:/           {print $2}' /tmp/if_$def_gw$.txt 
command [ autoneg ] = awk '/Auto-negotiation:/ {print $2}' /tmp/if_$def_gw$.txt 

# evaluate results
state   [ UNKNOWN ] =  "$def_gw$"  eq "" || ethtool != OK
state   [ WARNING ] = ("$speed$"   && "$speed$"   !~ /100/)   || \
                      ("$duplex$"  && "$duplex$"  !~ /FULL/i)
state   [ CRITICAL] =  "$link$"    && "$link$"    eq "no"