Changeset 50
- Timestamp:
- Jul 23, 2009, 11:24:08 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/klask
r49 r50 148 148 149 149 # my $cmdarping = `arping -c 1 -w 1 -rR $param 2>/dev/null`; 150 if ( not $param_ip_or_host =~ m/^\d+\.\d+\.\d+\.\d+$/) {151 $param_ip_or_host =~ s/ \..*//;150 if ( not $param_ip_or_host =~ m/^\d+ \. \d+ \. \d+ \. \d+$/x ) { 151 $param_ip_or_host =~ s/ \. .* //x; 152 152 } 153 153 … … 161 161 my $cmd_arpwatch = `$cmd`; 162 162 chomp $cmd_arpwatch; 163 my ($arp, $ip, $timestamp, $host) = split /\s+/, $cmd_arpwatch;163 my ($arp, $ip, $timestamp, $host) = split m/ \s+ /x, $cmd_arpwatch; 164 164 165 165 $ret{ipv4_address} = $ip if $ip; … … 179 179 my $cmd_arp = `arp -a $param_ip_or_host 2>/dev/null`; 180 180 chomp $cmd_arp; 181 $cmd_arp =~ /(\S*)\s\(([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})\)\sat\s([0-9,A-Z]{2}:[0-9,A-Z]{2}:[0-9,A-Z]{2}:[0-9,A-Z]{2}:[0-9,A-Z]{2}:[0-9,A-Z]{2})/ ;181 $cmd_arp =~ /(\S*)\s\(([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})\)\sat\s([0-9,A-Z]{2}:[0-9,A-Z]{2}:[0-9,A-Z]{2}:[0-9,A-Z]{2}:[0-9,A-Z]{2}:[0-9,A-Z]{2})/x; 182 182 $ret{hostname_fq} = $1 if(defined($1)); 183 183 $ret{ipv4_address} = $2 if(defined($2)); … … 188 188 my $cmd_host = `host $param_ip_or_host 2>/dev/null`; 189 189 chomp $cmd_host; 190 $cmd_host =~ m/domain \sname\spointer\s(\S+)\.$/;190 $cmd_host =~ m/domain \s name \s pointer \s (\S+) \.$/x; 191 191 $ret{hostname_fq} = $1 if defined $1; 192 192 193 193 # resultat de la commande host si parametre est hostname 194 194 # tech7meylan.hmg.inpg.fr has address 194.254.66.240 195 $cmd_host =~ m/(\S*) \shas\saddress\s([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})$/;195 $cmd_host =~ m/(\S*) \s has \s address \s ( [0-9]{1,3} \. [0-9]{1,3} \. [0-9]{1,3} \. [0-9]{1,3} )$/x; 196 196 $ret{hostname_fq} = $1 if defined $1; 197 197 $ret{ipv4_address} = $2 if defined $2; 198 198 199 $cmd_host =~ m/ \b([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.in-addr\.arpa\s/;199 $cmd_host =~ m/ \b ([0-9]{1,3}) \. ([0-9]{1,3}) \. ([0-9]{1,3}) \. ([0-9]{1,3}) \. in-addr \. arpa \s/x; 200 200 $ret{ipv4_address} = "$4.$3.$2.$1" if defined $1 and defined $2 and defined $3 and defined $4; 201 201 $ret{hostname_fq} = $param_ip_or_host if not defined $1 and $ret{hostname_fq} eq 'unknow'; … … 203 203 unless ($ret{mac_address} eq 'unknow') { 204 204 my @paquets = (); 205 foreach ( split (/:/, $ret{mac_address})) {206 my @chars = split //, uc("00$_");205 foreach ( split m/ : /x, $ret{mac_address} ) { 206 my @chars = split m//x, uc("00$_"); 207 207 push @paquets, "$chars[-2]$chars[-1]"; 208 208 } … … 218 218 219 219 for my $sw_kind (keys %SWITCH_KIND) { 220 next if not $sw_snmp_description =~ m/$SWITCH_KIND{$sw_kind}->{match}/ ;220 next if not $sw_snmp_description =~ m/$SWITCH_KIND{$sw_kind}->{match}/x; 221 221 222 222 return $SWITCH_KIND{$sw_kind}->{model}; … … 287 287 "A"=>"10", "B"=>"11", "C"=>"12", "D"=>"13", "E"=>"14", "F"=>"15" 288 288 ); 289 my @chars = split //, $car;289 my @chars = split m//x, $car; 290 290 return $table{$chars[-2]}*16 + $table{$chars[-1]}; 291 291 } … … 297 297 my $arp = shift; 298 298 299 my @paquets = split /:/, $arp;299 my @paquets = split m/ : /x, $arp; 300 300 my $return = ''; 301 301 foreach(@paquets) { … … 441 441 my $net = new NetAddr::IP $cidr; 442 442 for my $ip (@$net) { 443 $ip =~ s #/32##;443 $ip =~ s{ /32 }{}x; 444 444 push @res, $ip; 445 445 } … … 732 732 733 733 my $dirdb = $KLASK_DB_FILE; 734 $dirdb =~ s #/[^/]*$##;734 $dirdb =~ s{ / [^/]* $}{}x; 735 735 mkdir "$dirdb", 0755 unless -d "$dirdb"; 736 736 YAML::Syck::DumpFile("$KLASK_DB_FILE", $computerdb); … … 760 760 761 761 my $dirdb = $KLASK_DB_FILE; 762 $dirdb =~ s #/[^/]*$##;762 $dirdb =~ s{ / [^/]* $}{}x; 763 763 mkdir "$dirdb", 0755 unless -d "$dirdb"; 764 764 YAML::Syck::DumpFile("$KLASK_DB_FILE", $computerdb); … … 888 888 my $switch_hostname_sort = sprintf "%s %3s" ,$switch_hostname, $computerdb->{$ip}{switch_port}; 889 889 890 my $ip_sort = sprintf "%03i%03i%03i%03i", split( /\./, $ip);890 my $ip_sort = sprintf "%03i%03i%03i%03i", split( m/ \. /x, $ip); 891 891 892 892 my $mac_sort = sprintf "%04i-%s", 9999 - $mac_count{$computerdb->{$ip}{mac_address}}, $computerdb->{$ip}{mac_address}; 893 893 894 $computerdb->{$ip}{hostname_fq} = 'unknow' if $computerdb->{$ip}{hostname_fq} =~ m/^ \d+\.\d+\.\d+\.\d+$/;895 my ( $host_short ) = split /\./, $computerdb->{$ip}{hostname_fq};894 $computerdb->{$ip}{hostname_fq} = 'unknow' if $computerdb->{$ip}{hostname_fq} =~ m/^ \d+ \. \d+ \. \d+ \. \d+ $/x; 895 my ( $host_short ) = split m/ \. /x, $computerdb->{$ip}{hostname_fq}; 896 896 897 897 print <<"END_HTML"; … … 932 932 my $date = sprintf "%04i-%02i-%02i %02i:%02i", $year,$mon,$mday,$hour,$min; 933 933 934 my $ip_sort = sprintf "%03i%03i%03i%03i", split( /\./, $ipv4_address);934 my $ip_sort = sprintf "%03i%03i%03i%03i", split( m/ \. /x, $ipv4_address); 935 935 936 936 my $mac_sort = sprintf "%04i-%s", 9999, $mac_address; 937 937 938 my ( $host_short ) = sprintf "%s %3s" , split( /\./, $db_switch_parent{$sw}->{switch}, 1), $db_switch_parent{$sw}->{port};938 my ( $host_short ) = sprintf "%s %3s" , split(m/ \. /x, $db_switch_parent{$sw}->{switch}, 1), $db_switch_parent{$sw}->{port}; 939 939 940 940 print <<"END_HTML"; … … 980 980 my $date = sprintf "%04i-%02i-%02i %02i:%02i", $year,$mon,$mday,$hour,$min; 981 981 982 my $ip_sort = sprintf "%03i%03i%03i%03i", split( /\./, $ipv4_address);982 my $ip_sort = sprintf "%03i%03i%03i%03i", split( m/ \. /x, $ipv4_address); 983 983 984 984 my $mac_sort = sprintf "%04i-%s", 9999, $mac_address; … … 988 988 if (exists $db_switch_output_port{$sw}) { 989 989 990 my ( $host_short ) = sprintf "%s %3s" , split( /\./, $sw, 1), $db_switch_output_port{$sw};990 my ( $host_short ) = sprintf "%s %3s" , split( m/\./x , $sw, 1), $db_switch_output_port{$sw}; 991 991 992 992 print <<"END_HTML"; … … 1367 1367 my %db_building= (); 1368 1368 for my $sw (@SWITCH) { 1369 my ($building, $location) = split /\//, $sw->{location}, 2;1369 my ($building, $location) = split m/ \/ /x, $sw->{location}, 2; 1370 1370 $db_building{$building} ||= {}; 1371 1371 $db_building{$building}->{$location} ||= {};
Note: See TracChangeset
for help on using the changeset viewer.