#!/usr/bin/perl
# Hace un gráfico de puertos de origen; cada IP tiene un color distinto.
# 17-4-2006 Daniel Clemente Laboreo.
#
use strict; use warnings;
my %fis;
my $lin=0;
open(E,"<","datos");
while(<E>){
#my ($v,$gr)=/(\d+) (.*)/ or next;
my ($gr,$v)=/(\d+\.\d+\.\d+\.\d+)\.(\d+) > 172\.26\.0\.11\.80/ or next;
#print "A $gr le añado $v y al resto un - \n";
unless ($fis{$gr}) { open ( $fis{$gr}, ">", $gr); print { $fis{$gr} } "-\n"x$lin; }
print { $fis{$gr} } "$v\n";
for (keys %fis) { next if $_ eq $gr; print { $fis{$_} } "-\n"; }
$lin++;
}
close(E); close $fis{$_} for keys %fis;
open(GP,"|/usr/bin/gnuplot -persist");
use FileHandle; GP->autoflush(1);
my $cad="set terminal png size 800,600;\n set output 'salida.png'; "
. " set title 'Puertos'; unset key; unset xtics; plot ";
for (keys %fis) {
$cad.= " '$_' using 1 title '$_' with points pointtype 5 pointsize 0.4, ";
#$cad.= " '$_' using 1 title '$_' with dots, ";
}
$cad=~s/, $//; $cad.= ";\n";
#print $cad;
print GP $cad; close(GP);
for (keys %fis) { unlink $_; }
syntax highlighted by Code2HTML, v. 0.9.1