new perls v5.39.10
[andk-cpan-tools.git] / bin / watch-tmp-partition-size.chart.pl
blob08e957075f4996693524a433f4bc35054d363c18
1 use strict;
2 use Time::Local;
3 my $file = shift || "bin/watch-tmp-partition-size.out";
4 open my $fh, $file or die "Could not open '$file': $!";
5 my(@keys,@values);
6 my($t,$score,@t);
7 my $i = 0;
8 while (<$fh>) {
9 chomp;
10 (@t) = /(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/;
11 if (@t) {
12 $t[0]-=1900;
13 $t[1]--;
14 $t = timelocal(reverse @t);
15 @t = ();
17 ($score) = $1 if m|\d+\s+\d+\s+\d+\s+(\d+)\%\s+/tmp|;
18 if ($t && $score && !(++$i % 67)) {
19 # if ($t && $score) {
20 if ($t > 1290241849 && $t < 1290249769) {
21 push @keys, $t;
22 push @values, $score;
24 $t = $score = "";
25 $i = 0;
28 require Chart::Clicker;
29 require Chart::Clicker::Axis::DateTime;
30 require Chart::Clicker::Data::Series;
31 require Chart::Clicker::Data::DataSet;
33 # build the chart
34 my $chart = Chart::Clicker->new(width => 1200, height => 400);
36 # build the series (static here, will usually be supplied arrayrefs from elsewhere)
37 $DB::single++;
38 my $series = Chart::Clicker::Data::Series->new
40 keys => \@keys,
41 values => \@values,
44 # build the dataset
45 my $dataset = Chart::Clicker::Data::DataSet->new
47 series => [ $series ],
50 # add the dataset to the chart
51 $chart->add_to_datasets($dataset);
52 my $def = $chart->get_context('default');
53 my $dtaxis = Chart::Clicker::Axis::DateTime->new
55 format => '%Y-%m-%d %H:%M',
56 position => 'bottom',
57 orientation => 'horizontal'
59 $def->domain_axis($dtaxis);
60 my $yaxis = Chart::Clicker::Axis->new
62 format => "%s",
63 position => 'left',
64 orientation => 'vertical',
65 range => Chart::Clicker::Data::Range->new
67 lower => 0,
68 upper => 100,
69 }),
71 $def->range_axis($yaxis);
73 my $title = "title";
74 $chart->title->text($title);
75 $chart->legend->visible(0);
76 # $chart->title->font->size(20);
78 use Chart::Clicker::Renderer::Point;
79 my $renderer = Chart::Clicker::Renderer::Point->new
81 opacity => .75,
84 $renderer->shape
86 Geometry::Primitive::Circle->new({radius => 1})
90 # assign the renderer to the default context
91 $chart->set_renderer($renderer);
93 # write the chart to a file
94 $chart->write_output("watch-tmp-partition-size.png");