]>
git.proxmox.com Git - ifupdown-pve.git/blob - contrib/ifstate-check
3 # Generate a report of the status of interfaces configured
5 # (c) 2004 Javier Fernandez-Sanguino <jfs@debian.org>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 $statefile="/run/network/ifstate";
23 $configfile="/etc/network/interfaces";
25 open (IFACE
,"<$configfile") || die ("Could not open $configfile: $!\n");
28 if ( /^iface\s+(\w+)\s+/ ) {
35 open (IPLINK
,"ip link show|") || die ("Could not execute ip: $!\n");
39 # #: AAAA: <XXXXX,UP> mtu 16436 qdisc noqueue
40 if ( /^\d+: (\w+):.*?\<.*?,UP.*?\>/ ) {
47 open (STATE
,"<$statefile") || die ("Could not open $statefile: $!\n");
52 # Format is IFACE=IFACE
53 if ( /^(\w+)=(\w+)$/ ) {
56 if ( $iface ne $ifaces ) {
57 print STDERR
"Error in $statefile (line $line), interface names do not match ('$iface' and '$ifaces')\n";
62 print STDERR
"Error in $statefile (line $line), unknown content\n";
74 # Check if it's really up, this is done basically because ifupdown
75 # might not have configured it properly even if it thinks he has
76 # (sample: ifconfig croaks when wrong parameters are used and
77 # ifupdown does not detect that the system call went awry)
78 $status = "ERROR_NOT_REALLY_UP" if ! defined ($iplink{$int}) ;
79 if ( defined ( $configured{$int} ) ) {
80 $status .= ",CONFIGURED";
82 $status .= ",MANUALLY_CONFIGURED";