File: test.pl

package info (click to toggle)
ntop 3%3A5.0.1%2Bdfsg1-2.1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 15,720 kB
  • ctags: 11,480
  • sloc: ansic: 79,804; sh: 21,658; python: 1,948; awk: 1,504; perl: 971; makefile: 745; php: 123; xml: 71; sql: 13; sed: 11
file content (70 lines) | stat: -rw-r--r-- 1,745 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#
# (C) 2008 - Luca Deri <deri@ntop.org>
#

#use strict;
#use warnings;

send_http_header(1, "Known ntop hosts ".$ENV{'QUERY_STRING_UNESCAPED'});

# ---------------------------------------------

print "################################################\n";

getFirstHost(0);
loadHost();
while(($host{'ethAddress'} ne "") || ($host{'ipAddress'} ne ""))  {
    print "+ [ipAddress=",$host{'ipAddress'},"][macAddress=",$host{'macAddress'},"][pktSent/pktRcvd=",$host{'pktSent'},"/",$host{'pktRcvd'},"]\n";
    getNextHost(0);
    loadHost();
}

#for my $k1 ( sort keys %hosts ) {
#    print "k1: $k1\n";
#    for my $k2 ( keys %{$k1} ) {
#	print "k2: $k2 $hosts{ $k1 }{ $k2 }\n";
#    }
#}

#foreach $key (sort(keys %hosts{'a'})) {
#    print $key,"\n";
#}

#exit
# ---------------------------------------------

getFirstHost(0);
loadHost();

sendString("<center>\n");
sendString("<table border>\n");
sendString("<tr><th>MAC</th><th colspan=2>IP</th><th>Packets</th><th>Bytes</th></tr>\n");


while(($host{'ethAddress'} ne "") || ($host{'ipAddress'} ne ""))  {
    my $mac_addr;

    if($host{'ethAddress'} ne "") {
	my $mac = $host{'ethAddress'};
	$mac =~ tr/:/_/;
	$mac_addr = "<A HREF=/".$mac.".html>".$host{'ethAddress'}."</A>";
    } else {
	$mac_addr = "";
    }

    sendString("<tr><td>".$mac_addr
	       ."&nbsp;</td><td><A HREF=/".$host{'ipAddress'}.".html>".$host{'ipAddress'}."</A>"
	       ."&nbsp;</td><td>".$host{'hostResolvedName'}
	       ."&nbsp;</td><td> ".$host{'pktSent'}." / ".$host{'pktRcvd'}.""
	       ."&nbsp;</td><td> ".$host{'bytesSent'}." / ".$host{'bytesRcvd'}.""
	       ."&nbsp;</td></tr>\n");
    getNextHost(0);
    loadHost();
}

sendString("</table>\n");
sendString("</center>\n");
send_html_footer();

########