|
|
|
| Здравствуйте! Сущесвуют строчки:
Protocol Address Age (min) Hardware Addr Type Interface
Internet 10.0.250.225 0 0011.114f.45a7 ARPA FastEthernet0/1
Internet 10.0.250.226 0 0020.ed9a.1d1f ARPA FastEthernet0/1
Internet 10.0.250.227 1 000d.61a4.f69c ARPA FastEthernet0/1
Internet 10.0.250.228 0 0020.ed9f.3c5a ARPA FastEthernet0/1
Internet 10.0.250.230 0 000c.7655.436d ARPA FastEthernet0/1
Internet 10.0.250.210 2 0013.d4cd.c5f1 ARPA FastEthernet0/1
Internet 10.0.250.212 0 0017.3148.442b ARPA FastEthernet0/1
Internet 10.0.250.214 1 000d.61a8.9b1d ARPA FastEthernet0/1
Internet 10.0.250.215 2 0013.d4cd.d06d ARPA FastEthernet0/1
Как получить из них IP-адресс и MAC и занести их массив (на PHP)? | |
|
|
|
|
|
|
|
для: SlaDER
(06.05.2009 в 08:06)
| |
<?php
$log = '
Internet 10.0.250.225 0 0011.114f.45a7 ARPA FastEthernet0/1
Internet 10.0.250.226 0 0020.ed9a.1d1f ARPA FastEthernet0/1
Internet 10.0.250.227 1 000d.61a4.f69c ARPA FastEthernet0/1
Internet 10.0.250.228 0 0020.ed9f.3c5a ARPA FastEthernet0/1
Internet 10.0.250.230 0 000c.7655.436d ARPA FastEthernet0/1
Internet 10.0.250.210 2 0013.d4cd.c5f1 ARPA FastEthernet0/1
Internet 10.0.250.212 0 0017.3148.442b ARPA FastEthernet0/1
Internet 10.0.250.214 1 000d.61a8.9b1d ARPA FastEthernet0/1
Internet 10.0.250.215 2 0013.d4cd.d06d ARPA FastEthernet0/1
';
$pattern = '|^ Internet \\s+
([0-9a-fA-F\\.:]+) \\s+ \\d+ \\s+ ([-0-9a-fA-F\\.]+)
\\s+ ARPA \\s+ FastEthernet0/1 \\s*$|xm';
preg_match_all($pattern, $log, $res);
unset($res[0]);
$res = array_combine($res[2], $res[1]);
echo '<pre>'; print_r($res);
?>
|
| |
|
|
|
|
|
|
|
для: Trianon
(06.05.2009 в 10:02)
| | Спасибо. Еще вопрос как можно сделать чтобы не использовать FastEthernet0/1 в регулярном выражении, чтобы там было только до ARP? Так как этот столбец может меняться. | |
|
|
|
|
|
|
|
для: SlaDER
(06.05.2009 в 10:35)
| | чтобы там было только до ARP? Так как этот столбец может меняться.
<?php
$log = '
Internet 10.0.250.225 0 0011.114f.45a7 ARPA FastEthernet0/1
Internet 10.0.250.226 0 0020.ed9a.1d1f ARPA FastEthernet0/1
Internet 10.0.250.227 1 000d.61a4.f69c ARPA FastEthernet0/1
Internet 10.0.250.228 0 0020.ed9f.3c5a ARPA FastEthernet0/1
Internet 10.0.250.230 0 000c.7655.436d ARPA FastEthernet0/1
Internet 10.0.250.210 2 0013.d4cd.c5f1 ARPA FastEthernet0/1
Internet 10.0.250.212 0 0017.3148.442b ARPA FastEthernet0/1
Internet 10.0.250.214 1 000d.61a8.9b1d ARPA FastEthernet0/1
Internet 10.0.250.215 2 0013.d4cd.d06d ARPA FastEthernet0/1
';
$pattern = '|Internet\s([0-9\.]+)\s\d+\s([-0-9a-fA-F\\.]+)|';
preg_match_all($pattern, $log, $res);
unset($res[0]);
echo '<pre>'; print_r($res);
?>
|
| |
|
|
|