-
Notifications
You must be signed in to change notification settings - Fork 90
/
mkdash.pl
executable file
·91 lines (79 loc) · 1.88 KB
/
mkdash.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
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/perl
my $dir="dash";
# here's the list of newly made graphs
open(S, "<$dir/stats.list");
while(<S>) {
chomp;
if($_ =~ /^(.*) = (.*)/) {
$svg{$1} = $2;
}
}
close(S);
print <<TOP
#ifndef DASHDATA
TOP
;
for my $s (sort keys %svg) {
my $alt = $s;
$alt =~ s/-/ /g;
printf "<a id=\"%s\" href=\"dashboard1.html#%s\"><img alt=\"%s\" class=\"dash\" src=\"$dir/%s\"></a>\n",
$s, $s, $alt, $svg{$s};
}
print <<MID
#else
MID
;
# get the data pointers for the graphs
open(S, "<$dir/stats.data");
while(<S>) {
chomp;
if($_ =~ /^(.*) = (.*)/) {
# presumable the same names as the above list
$data{$1} = $2;
}
}
close(S);
sub now {
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
gmtime(time);
return sprintf "%04d-%02d-%02d %02d:%02d:%02d UTC",
$year + 1900, $mon + 1, $mday, $hour, $min, $sec;
}
for my $s (sort keys %svg) {
my $alt = $s;
$alt =~ s/-/ /g;
printf "<h2 style=\"clear: both;\">%s data</h2><a id=\"%s\" href=\"dash/%s\"><img alt=\"%s\" class=\"dash\" src=\"$dir/%s\" style=\"float: left;\"></a>\n",
$s, $s, $data{$s}, $alt, $svg{$s};
print "<pre style=\"float: left;\">\n";
open(C, "<dash/$data{$s}");
my $c=0;
my @end;
my $foot = 0;
while(<C>) {
if($foot) {
push @end, $_;
if(scalar(@end) > 5) {
shift @end;
}
}
else {
print $_;
if($c++ >= 4) {
print "...\n";
$foot = 1;
}
}
}
close(C);
print @end;
print "</pre>\n";
open(F, "<$dir/stats/$s.txt");
my @h = <F>;
close(F);
print "<div style=\"float: left; margin-left: 10px; width: 30%;\">".join("", @h)."</div>\n";
}
print <<BOTTOM
#endif
BOTTOM
;
print "<br style=\"clear: both;\"> Updated ".now()."\n";