%values;
}
+sub dayGraphFunc {
+ my $dataSrc = shift;
+ my $mode = shift;
+ my $color = shift;
+ my $label = shift;
+ my $dataPoints = shift;
+ my @args = ();
+ push @args, "CDEF:prev${mode}1=PREV(${dataSrc})";
+ for (my $i = 1; $i < $dataPoints - 1; ++$i) {
+ my $prev = $i;
+ my $next = $i+1;
+ push @args, "CDEF:prev${mode}${next}=PREV(prev${mode}${prev})";
+ }
+ my $dayCons = '';
+ my $consFunc = '';
+ for (my $i = 1; $i < $dataPoints; ++$i) {
+ $dayCons .= "prev${mode}${i},";
+ $consFunc .= ",${mode}";
+ }
+ push @args, "CDEF:day${mode}=${dayCons}${dataSrc}${consFunc}";
+ push @args, "CDEF:fillCalDay${mode}0=COUNT,${dataPoints},%,0,EQ,day${mode},UNKN,IF";
+ for (my $i = 1; $i < $dataPoints; ++$i) {
+ my $prev = $i-1;
+ my $next = $i;
+ push @args, "CDEF:fillCalDay${mode}${next}=PREV(fillCalDay${mode}${prev})";
+ }
+ my $fillPoint = '';
+ my $if = '';
+ for (my $i = 0; $i < $dataPoints; ++$i) {
+ $fillPoint .= "COUNT,${dataPoints},%,${i},EQ,fillCalDay${mode}${i},";
+ $if .= ",IF";
+ }
+ push @args, "CDEF:${mode}Curve=${fillPoint}UNKN${if}";
+ my $forwardShift = (24*60*60) * ($dataPoints - 1) / $dataPoints;
+ push @args, "SHIFT:${mode}Curve:-${forwardShift}";
+ push @args, "LINE1:${mode}Curve#${color}:${label}";
+ return \@args;
+}
+
if ($> == 0) {
if (@ARGV != 2) {
print STDERR "Running as root, please provide UID as 2th argument!\n";