-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsyslog2picviz.pl
executable file
·42 lines (32 loc) · 1.04 KB
/
syslog2picviz.pl
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
#!/usr/bin/perl
#
# For python folks: show me the equivalent code for this
#
print "header {\n";
print " title = \"Syslog picviz analysis\";\n";
print "}\n";
print "axes {\n";
print " timeline t [label=\"Time\"];\n"; # Time
print " enum m [label=\"Machine\"];\n"; # Machine
print " enum a [label=\"Application\"];\n"; # Application
print " string l [label=\"Log\",relative=\"true\"];\n"; # Log
print "}\n";
print "data {\n";
while ($line = <>) {
$line =~ s/\\/\\\\/g;
$line =~ s/\"/\\"/g; # We escape our quotes
$line =~ s/&//g; # We escape our quotes
$line =~ s/<//g; # We escape our quotes
$line =~ s/>//g; # We escape our quotes
$line =~ m/\w+ ?\d+ (\d+:\d+):\d+ ([\w-.]+) (\S+) (.*)/;
$t=$1;
$m=$2;
$a=$3;
$l=$4;
if ($l =~ m/.*[sS]eg.*[fF]ault.*/) {
print " t=\"$t\",m=\"$m\",a=\"$a\",l=\"$l\" [color=\"red\"];\n";
} else {
print " t=\"$t\",m=\"$m\",a=\"$a\",l=\"$l\";\n";
}
}
print "}\n";