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

« back to all changes in this revision

Viewing changes to parsers/syslog2picviz.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=\"Time\"];\n"; # Time
 
12
print "    string   m [label=\"Machine\"];\n"; # Machine
 
13
print "    string   a [label=\"Application\"];\n"; # Application
 
14
print "    string   l [label=\"Log\"];\n"; # Log
 
15
print "}\n";
 
16
 
 
17
print "data {\n";
 
18
 
 
19
while ($line = <>) {
 
20
 
 
21
        $line =~ s/\\/\\\\/g;
 
22
        $line =~ s/\"/\\"/g; # We escape our quotes
 
23
        $line =~ s/&//g; # We escape our quotes
 
24
        $line =~ s/<//g; # We escape our quotes
 
25
        $line =~ s/>//g; # We escape our quotes
 
26
        $line =~ m/\w+  ?\d+ (\d+:\d+):\d+ ([\w-.]+) (\S+) (.*)/;
 
27
 
 
28
        $t=$1;
 
29
        $m=$2;
 
30
        $a=$3;
 
31
        $l=$4;
 
32
 
 
33
        if ($l =~ m/.*[sS]eg.*[fF]ault.*/) {
 
34
                print "    t=\"$t\",m=\"$m\",a=\"$a\",l=\"$l\" [color=\"red\"];\n";
 
35
        } else {
 
36
                        print "    t=\"$t\",m=\"$m\",a=\"$a\",l=\"$l\";\n";
 
37
        }
 
38
}
 
39
 
 
40
print "}\n";
 
41
 
 
42