Perl con comandos Linux netstat y awk
Publicado: 2016-06-15 17:16 @761
SO: Centos
Comando ejecutado:
resultado:
Formato: totalconexiones-direcciónIP
Ejemplo: 75-186.121.250.114
Necesito guardar esto en un array en Perl y una función de Perl que se alimente de cada valor.
Ejemplo:
GeolocalizacionIP(@arrayip);
Resultado:
Código:
Resultado:
Comando ejecutado:
Using bash Syntax Highlighting
- netstat -plan | grep ":80" | awk '{print $5}' | cut -d ":" -f 1 | sort | uniq -c | sort -nk 1 | awk '{print $1"-"$2}'
Coloreado en 0.003 segundos, usando GeSHi 1.0.8.4
resultado:
Using text Syntax Highlighting
1..........
2....
20-190.186.38.13
25-200.105.185.159
27-181.114.119.34
35-186.167.244.224
40-190.102.144.100
40-190.186.216.195
45-107.167.106.145
46-190.180.5.136
52-181.114.123.176
53-181.51.100.15
53-65.55.185.254
75-186.121.250.114
2....
20-190.186.38.13
25-200.105.185.159
27-181.114.119.34
35-186.167.244.224
40-190.102.144.100
40-190.186.216.195
45-107.167.106.145
46-190.180.5.136
52-181.114.123.176
53-181.51.100.15
53-65.55.185.254
75-186.121.250.114
Coloreado en 0.000 segundos, usando GeSHi 1.0.8.4
Formato: totalconexiones-direcciónIP
Ejemplo: 75-186.121.250.114
Necesito guardar esto en un array en Perl y una función de Perl que se alimente de cada valor.
Ejemplo:
GeolocalizacionIP(@arrayip);
Resultado:
Using text Syntax Highlighting
IP 65.55.185.254 PAIS EEUU CONEXIONES 53
IP 186.121.250.114 PAIS CHINA CONEXIONES 75
IP 186.121.250.114 PAIS CHINA CONEXIONES 75
Coloreado en 0.000 segundos, usando GeSHi 1.0.8.4
Código:
Using perl Syntax Highlighting
- print " CONEXION ACTIVAS : HTTP : 80 \n";
- print "============================================================================\n";
- my @var = `netstat -plan | grep ":80" | awk '{print $5}' | cut -d ":" -f 1 | sort | uniq -c | sort -nk 1 | awk '{print $1":"$2}' `;
- print "@var";
Coloreado en 0.002 segundos, usando GeSHi 1.0.8.4
Resultado: