/[pxelator]/lib/PXElator/ip.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/PXElator/ip.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 224 by dpavlin, Sat Aug 15 22:38:02 2009 UTC revision 265 by dpavlin, Wed Aug 19 12:46:07 2009 UTC
# Line 6  use strict; Line 6  use strict;
6  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
7    
8  use html;  use html;
9    use server;
10    
11  sub lines {  sub lines {
12          my ( $object ) = @_;          my ( $object ) = @_;
13    
14            my $debug = server::debug;
15    
16          $object ||= 'link';          $object ||= 'link';
17    
18          my $i = 0;          my $i = 0;
# Line 19  sub lines { Line 22  sub lines {
22          my $headers;          my $headers;
23    
24          foreach my $line ( split(/\n/, `ip $object`) ) {          foreach my $line ( split(/\n/, `ip $object`) ) {
25                  warn "# $line\n";                  warn "# $line\n" if $debug;
26                  my $add_header;                  my $add_header;
27    
28                  if ( $line =~ s{^(\d+):\s+(\w+):\s+}{} ) {                  if ( $line =~ s{^(\d+):\s+(\w+):\s+}{} ) {
29                          $i = $1;                          $i = $1;
30                          $objects[$i] = { $object => $2 };                          $objects[$i] = { dev => $2 };
31                          $add_header = $object;                          $add_header = $object;
32                  } elsif ( $line =~ s{^\s+}{} ) {                  } elsif ( $line =~ s{^\s+}{} ) {
33                          # line continues                          # line continues
# Line 88  sub html { Line 91  sub html {
91          return html::table( @table );          return html::table( @table );
92  }  }
93    
94    sub devices_up {
95            my @links = ip::lines( 'link' );
96            my @devs;
97            foreach ( 1 .. $#links ) {
98                    push @devs, $links[$_]->{dev} if $links[$_]->{flags} =~ m{UP};
99            }
100            return @devs;
101    }
102    
103    
104  1;  1;

Legend:
Removed from v.224  
changed lines
  Added in v.265

  ViewVC Help
Powered by ViewVC 1.1.26