+sub updatembmondata
+{
+ if ( ! -e "$path_rrd/mbmon.rrd" )
+ {
+ # database did not exist -> create
+
+ @args = ("$path_rrd/mbmon.rrd");
+
+ push(@args, "--step=300");
+ foreach $key ( sort(keys %mbmon_values) )
+ {
+ push(@args, "DS:$key:GAUGE:600:U:U");
+ }
+ push(@args, "RRA:AVERAGE:0.5:1:576");
+ push(@args, "RRA:AVERAGE:0.5:6:672");
+ push(@args, "RRA:AVERAGE:0.5:24:732");
+ push(@args, "RRA:AVERAGE:0.5:144:1460");
+
+ print("create ". join( ", ", @args)) if ( $dbg );
+
+ RRDs::create (@args);
+ $ERROR = RRDs::error;
+ print("Error in RRD::create for mbmon: $ERROR\n") if $ERROR;
+ }
+
+ my @ds;
+ my @val;
+ my $template;
+
+ foreach $key ( sort(keys %mbmon_values) )
+ {
+ push(@ds, $key);
+ push(@val, $mbmon_values{$key});
+ }
+
+ $template = join(':', @ds);
+ $value = "N:".join(':', @val);
+
+ print("update template = '$template'\n") if ( $dbg );
+ print("update value = '$value'\n") if ( $dbg );
+
+ RRDs::update("$path_rrd/mbmon.rrd", "-t", $template, $value);
+ $ERROR = RRDs::error;
+ print("Error in RRD::update for mbmon: $ERROR\n") if $ERROR;
+}
+
+sub updatetempgraph
+{
+ my $type = "temp";
+ my $period = $_[0];
+
+ @args = ("$path_graphs/mbmon-$type-$period.png", "--start", "-1$period", "-aPNG", "-i", "-z",
+ "--alt-y-grid", "-w 600", "-h 100", "--alt-autoscale",
+ "--color", "SHADEA#EAE9EE",
+ "--color", "SHADEB#EAE9EE",
+ "--color", "BACK#EAE9EE",
+ "-t $tr{'mbmon temp'} ($tr{'graph per'} $tr{$period})" );
+
+ $count = 1;
+ foreach $key ( sort(keys %mbmon_values) )
+ {
+ if ( (index($key, $type) != -1) && ($mbmon_settings{'LINE-'.$key} eq 'on') )
+ {
+ if ( !defined($mbmon_settings{'LABEL-'.$key}) || ($mbmon_settings{'LABEL-'.$key} eq '') )
+ {
+ $mbmon_settings{'LABEL-'.$key} = $key;
+ }
+
+ push(@args, "DEF:$key=$path_rrd/mbmon.rrd:$key:AVERAGE");
+ push(@args, "LINE2:$key$colors{$count}:$mbmon_settings{'LABEL-'.$key} $tr{'mbmon temp in'} °C");
+ push(@args, "GPRINT:$key:MAX:$tr{'maximal'}\\:%5.1lf °C");
+ push(@args, "GPRINT:$key:AVERAGE:$tr{'average'}\\:%5.1lf °C");
+ push(@args, "GPRINT:$key:LAST:$tr{'current'}\\:%5.1lf °C\\j");
+
+ $count++;
+ }
+ }
+
+ if ( $count > 1 )
+ {
+ RRDs::graph ( @args );
+ $ERROR = RRDs::error;
+ print("Error in RRD::graph for temp: $ERROR\n")if $ERROR;
+ }
+}
+
+sub updatefangraph
+{
+ my $type = "fan";
+ my $period = $_[0];
+
+ @args = ("$path_graphs/mbmon-$type-$period.png", "--start", "-1$period", "-aPNG", "-i", "-z",
+ "--alt-y-grid", "-w 600", "-h 100", "--alt-autoscale",
+ "--color", "SHADEA#EAE9EE",
+ "--color", "SHADEB#EAE9EE",
+ "--color", "BACK#EAE9EE",
+ "-t $tr{'mbmon temp'} ($tr{'graph per'} $tr{$period})" );
+
+ $count = 1;
+ foreach $key ( sort(keys %mbmon_values) )
+ {
+ if ( (index($key, $type) != -1) && ($mbmon_settings{'LINE-'.$key} eq 'on') )
+ {
+ if ( !defined($mbmon_settings{'LABEL-'.$key}) || ($mbmon_settings{'LABEL-'.$key} eq '') )
+ {
+ $mbmon_settings{'LABEL-'.$key} = $key;
+ }
+
+ push(@args, "DEF:$key=$path_rrd/mbmon.rrd:$key:AVERAGE");
+ push(@args, "LINE2:$key$colors{$count}:$mbmon_settings{'LABEL-'.$key} $tr{'mbmon fan in'} rpm");
+ push(@args, "GPRINT:$key:MAX:$tr{'maximal'}\\:%5.0lf rpm");
+ push(@args, "GPRINT:$key:AVERAGE:$tr{'average'}\\:%5.0lf rpm");
+ push(@args, "GPRINT:$key:LAST:$tr{'current'}\\:%5.0lf rpm\\j");
+
+ $count++;
+ }
+ }
+
+ if ( $count > 1 )
+ {
+ RRDs::graph ( @args );
+ $ERROR = RRDs::error;
+ print("Error in RRD::graph for temp: $ERROR\n")if $ERROR;
+ }
+}
+
+sub updatevoltgraph
+{
+ my $type = "volt";
+ my $period = $_[0];
+
+ @args = ("$path_graphs/mbmon-$type-$period.png", "--start", "-1$period", "-aPNG", "-i", "-z",
+ "--alt-y-grid", "-w 600", "-h 100", "--alt-autoscale",
+ "--color", "SHADEA#EAE9EE",
+ "--color", "SHADEB#EAE9EE",
+ "--color", "BACK#EAE9EE",
+ "-t $tr{'mbmon temp'} ($tr{'graph per'} $tr{$period})" );
+
+ $count = 1;
+ foreach $key ( sort(keys %mbmon_values) )
+ {
+ my $v = substr($key,0,1);
+ if ( ($v eq 'v') && ($mbmon_settings{'LINE-'.$key} eq 'on') )
+ {
+ if ( !defined($mbmon_settings{'LABEL-'.$key}) || ($mbmon_settings{'LABEL-'.$key} eq '') )
+ {
+ $mbmon_settings{'LABEL-'.$key} = $key;
+ }
+
+ push(@args, "DEF:$key=$path_rrd/mbmon.rrd:$key:AVERAGE");
+ push(@args, "LINE2:$key$colors{$count}:$mbmon_settings{'LABEL-'.$key} V");
+ push(@args, "GPRINT:$key:MAX:$tr{'maximal'}\\:%5.2lf V");
+ push(@args, "GPRINT:$key:AVERAGE:$tr{'average'}\\:%5.2lf V");
+ push(@args, "GPRINT:$key:LAST:$tr{'current'}\\:%5.2lf V\\j");
+
+ $count++;
+ }
+ }
+
+ if ( $count > 1 )
+ {
+ RRDs::graph ( @args );
+ $ERROR = RRDs::error;
+ print("Error in RRD::graph for temp: $ERROR\n")if $ERROR;
+ }
+}
+