"; close(FILE); run("uname -a >> $file"); run("cat /proc/cpuinfo >> $file") if(-f "/proc/cpuinfo"); run("cat /proc/meminfo >> $file") if(-f "/proc/meminfo"); $file = "$dir/comment.html"; open(FILE, ">$file") or die "cannot open $file for writing : $!"; print FILE "\n"; if(!$comment) { print FILE "No comment\n"; } else { print FILE $comment; } close(FILE); # # Generate a graph for each value # my(%vlabel) = ( 'Write' => 'Pages', 'Read' => 'Pages', 'P_IBTREE' => 'Pages', 'P_LBTREE' => 'Pages', 'P_UNKNOWN' => 'Pages', 'Put' => 'Put', 'Get__0_' => 'Get', 'Get__NEXT_' => 'Get', 'Get__SET_RANGE_' => 'Get', 'Get__Other_' => 'Get', 'LEVEL' => 'Level', 'PGNO' => 'Pages', 'CMP' => 'Compare', ); my(%hlabel) = ( 'Write' => 'Write/second', 'Read' => 'Read/second', 'P_IBTREE' => 'Internal B-Tree nodes read + write / second', 'P_LBTREE' => 'Leaf B-Tree nodes read + write / second', 'P_UNKNOWN' => 'Unknown pages read + write / second', 'Put' => 'Put / second', 'Get__0_' => 'Get(0) / second', 'Get__NEXT_' => 'Get(DB_NEXT) / second', 'Get__SET_RANGE_' => 'Get(DB_SET_RANGE) / second', 'Get__Other_' => 'Get(???) / second', 'LEVEL' => 'Height of the B-Tree', 'PGNO' => 'Size of the B-Tree in pages', 'CMP' => 'Key compare / second', ); my(@graphs); my($field); foreach $field (@fields) { my($image) = "$dir/$field.gif"; my($hlabel) = exists($hlabel{$field}) ? "--title '$hlabel{$field}'" : ""; my($vlabel) = exists($vlabel{$field}) ? "--vertical-label '$vlabel{$field}'" : ""; run("rrdtool graph $image --start $started --end $finished $hlabel $vlabel DEF:in=$dir/monitor.rrd:$field:AVERAGE 'LINE2:in#FF0000' >/dev/null"); } # # Generate a cumulated graph for compression rates # my(%rate) = ( 'Compress_1_1' => 1, 'Compress_1_2' => 2, 'Compress_1_3' => 3, 'Compress_1_4' => 4, 'Compress_1_5' => 5, 'Compress_1_6' => 6, 'Compress_1_7' => 7, 'Compress_1_8' => 8, 'Compress_1_9' => 9, 'Compress_1_10' => 10, 'Compress_1__10' => 11, ); my(%color) = ( 'Compress_1_1' => "#ff0000", 'Compress_1_2' => "#ee1100", 'Compress_1_3' => "#dd2200", 'Compress_1_4' => "#cc3300", 'Compress_1_5' => "#bb4400", 'Compress_1_6' => "#996600", 'Compress_1_7' => "#778800", 'Compress_1_8' => "#55aa00", 'Compress_1_9' => "#33cc00", 'Compress_1_10' => "#11ee00", 'Compress_1__10' => "#00ff00", ); my($last_total); my(@lines); foreach $field (@fields) { next if($field !~ /^Compress/); my($cdef) = ""; my($total) = "cmpr$rate{$field}"; if($last_total) { $total = "total$rate{$field}"; $cdef = "CDEF:$total=$last_total,cmpr$rate{$field},+"; } $last_total = $total; push(@lines, "DEF:cmpr$rate{$field}=$dir/monitor.rrd:$field:AVERAGE $cdef 'LINE1:$total$color{$field}:1/$rate{$field}'"); } run("rrdtool graph $dir/compress.gif --start $started --end $finished --title 'Compression rate comparison / second' --vertical-label 'Pages' @lines >/dev/null"); # # Build home page # $file = "$dir/index.html"; open(FILE, ">$file") or die "cannot open $file for writing : $!"; print FILE <[Configuration | Comment | Samples | Compression] \n"; close(FILE); # # Build compression details page # $file = "$dir/compress.html"; open(FILE, ">$file") or die "cannot open $file for writing : $!"; print FILE <EOF print FILE <
In the graph above, the area under each line is the number of pages compressed in the corresponding proportions. The bottom line is always 1/1 compression. For instance the area between the 1/11 line and the 1/10 line shows how many pages were compressed in a proportion equal or better than 1/11. In the compression report an individual graph is shown for each line.
EOF foreach $field (@fields) { next if($field =~ /^Compress/); print FILE <
EOF } print FILE "[Home page] \n"; close(FILE); } sub run { my($cmd) = @_; system($cmd); print STDERR "$cmd\n" if($verbose); print CMDS "$cmd\n"; } sub build { my($file) = @_; system("cp $file $dir"); my(@fields); my($started); my($step); my($heartbeat); my($finished); my(@updates); open(FILE, "<$file") or die "cannot open $file for reading : $!"; while(EOF print FILE <
EOF foreach $field (@fields) { next if($field !~ /^Compress/); print FILE <
EOF } print FILE ") { if(/WordMonitor starting/) { ($started) = =~ /^Started:(\d+)/; ($step) = =~ /^Period:(\d+)/; $heartbeat = $step * 2; my(@ds); @fields = split(':', scalar( )); shift(@fields); # get rid of Time field pop(@fields); # get rid of last empty field my($field); foreach $field (@fields) { my($type) = $field =~ /^(.)\./; $field =~ s/^..//; $field =~ s/[^a-z0-9_]/_/gi; if($type eq 'C') { push(@ds, "DS:$field:COUNTER:$heartbeat:U:U"); } elsif($type eq 'G') { push(@ds, "DS:$field:GAUGE:$heartbeat:0:U"); } else { print STDERR "Unknown type $type for field $field\n"; exit(1); } } my($ds) = join(' ', @ds); my($rra) = "RRA:AVERAGE:0.5:1:2000"; my($cmd) = "rrdtool create $dir/monitor.rrd --step $step --start $started $ds $rra"; run("rm -f $dir/monitor.rrd ; $cmd"); next; } next if(/-------------/ || /^\s*$/); chop; # remove new line chop; # remove last : ($finished) = m/^(\d+):/; print STDERR "$_\n" if($verbose); push(@updates, $_); if(@updates > 50) { run("rrdtool update $dir/monitor.rrd " . join(' ', @updates)); @updates = (); } } if(@updates) { run("rrdtool update $dir/monitor.rrd " . join(' ', @updates)); } close(FILE); print STDERR "started = $started, finished = $finished\n" if($verbose); return ($started, $finished, @fields); } main();