~ubuntu-branches/ubuntu/trusty/picviz/trusty

« back to all changes in this revision

Viewing changes to parsers/net/named2picviz.pl

  • Committer: Bazaar Package Importer
  • Author(s): Pierre Chifflier
  • Date: 2009-03-30 10:42:08 UTC
  • Revision ID: james.westby@ubuntu.com-20090330104208-j095obwkp574t1lm
Tags: upstream-0.5
ImportĀ upstreamĀ versionĀ 0.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
#
 
3
# For python folks: show me the equivalent code for this
 
4
#
 
5
 
 
6
print "header {\n";
 
7
print "    title = \"Syslog picviz analysis\";\n";
 
8
print "}\n";
 
9
 
 
10
print "axes {\n";
 
11
print "    timeline t [label=\"Timeline\"];\n";
 
12
#print "    string   cat [label=\"Category\"];\n";
 
13
print "    ipv4     source [label=\"Source\"];\n";
 
14
print "    integer  port [label=\"Port\"];\n";
 
15
print "    enum     dnsaction [label=\"DNS Action\"];\n";
 
16
print "    enum     type [label=\"Type\"];\n";
 
17
print "    string   url [label=\"URL\",relative=\"true\"];\n";
 
18
print "}\n";
 
19
 
 
20
print "data {\n";
 
21
 
 
22
while ($line = <>) {
 
23
 
 
24
        $typed = 0;
 
25
 
 
26
        $line =~ s/\\/\\\\/g;
 
27
        $line =~ s/\"/\\"/g; # We escape our quotes
 
28
        $line =~ s/&//g; # We escape our quotes
 
29
        $line =~ s/<//g; # We escape our quotes
 
30
        $line =~ s/>//g; # We escape our quotes
 
31
 
 
32
        $line =~ m/.* (\d+:\d+:\d+).\d+ (\S+): (\S+): \S+ (\d+.\d+.\d+.\d+)#(\d+): (.*) '(.*)\/(.*)\/(.*)' (.*)/;
 
33
 
 
34
#       print "$1,$2,$3,$4,$5,$6,$7,$8,$9,$10\n";
 
35
 
 
36
 
 
37
        $t=$1;
 
38
        $cat=$2;
 
39
        $msgtype=$3; # info, warning, error
 
40
        $source=$4;
 
41
        $port=$5;
 
42
        $dnsaction=$6;
 
43
        $url=$7;
 
44
        $type=$8;
 
45
 
 
46
        if ($t=="") {
 
47
        } else {
 
48
        # 29-Jul-2008 09:14:09.692 update-security: error: client 84.91.74.38#32773: update 'mylinux.net/IN' denied
 
49
        if ($msgtype =~ m/error/) {
 
50
                print "t=\"$t\", source=\"$source\", port=\"$port\", dnsaction=\"$dnsaction\", type=\"$type\", url=\"$url\" [color=\"red\"];\n";
 
51
                $typed = 1;
 
52
        }
 
53
        if ($msgtype =~ m/warning/) {
 
54
                print "t=\"$t\", source=\"$source\", port=\"$port\", dnsaction=\"$dnsaction\", type=\"$type\", url=\"$url\" [color=\"orange\"];\n";
 
55
                $typed = 1;
 
56
        }
 
57
        if ($msgtype =~ m/info/) {
 
58
                print "t=\"$t\", source=\"$source\", port=\"$port\", dnsaction=\"$dnsaction\", type=\"$type\", url=\"$url\" [color=\"blue\"];\n";
 
59
                $typed = 1;
 
60
        }
 
61
 
 
62
        if ($typed == 0) {
 
63
                print "t=\"$t\", cat=\"$cat\", source=\"$source\", port=\"$port\", dnsaction=\"$dnsaction\", url=\"$url\", type=\"$type\" [color=\"red\"];\n";
 
64
        }
 
65
        }
 
66
}
 
67
 
 
68
print "}\n";
 
69