1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-08-03 22:58:20 +00:00
Fix `printf` and `sprintf` output numbers from %s to %d
This commit is contained in:
ScratchBuild 2020-09-07 11:11:22 +09:00 committed by Lars Kruse
parent bba98f95b3
commit 3226446348
2 changed files with 27 additions and 37 deletions

View file

@ -142,8 +142,8 @@ if ($ARGV[0] and $ARGV[0] eq "config")
{
my $batt_name = sprintf("%s %s %s", $batt_data->{'info'}{'OEM info'}, $batt_data->{'info'}{'battery type'}, $batt_data->{'info'}{'model number'});
print ("graph_args --base 1000\n");
printf ("graph_title Battery %s (%s) %s\n" , $batt_num, $batt_name, $graph_type);
printf ("graph_info This graph shows battery %s (%s) %s\n" , $batt_num, $batt_name, $graph_type);
printf ("graph_title Battery %d (%s) %s\n" , $batt_num, $batt_name, $graph_type);
printf ("graph_info This graph shows battery %d (%s) %s\n" , $batt_num, $batt_name, $graph_type);
print ("graph_category sensors\n");
if ($graph_type eq "capacity")
{
@ -182,31 +182,23 @@ sub percent
if ($graph_type eq "capacity")
{
printf ("dc.value %s\n", $batt_data->{'info'}{'design capacity'});
printf ("lfc.value %s\n", $batt_data->{'info'}{'last full capacity'});
printf ("dcl.value %s\n", $batt_data->{'info'}{'design capacity low'});
printf ("dcw.value %s\n", $batt_data->{'info'}{'design capacity warning'});
printf ("cg1.value %s\n", $batt_data->{'info'}{'capacity granularity 1'});
printf ("cg2.value %s\n", $batt_data->{'info'}{'capacity granularity 2'});
printf ("rc.value %s\n", $batt_data->{'state'}{'remaining capacity'});
printf ("pr.value %s\n", $batt_data->{'state'}{'present rate'});
printf ("dc.value %d\n", $batt_data->{'info'}{'design capacity'});
printf ("lfc.value %d\n", $batt_data->{'info'}{'last full capacity'});
printf ("dcl.value %d\n", $batt_data->{'info'}{'design capacity low'});
printf ("dcw.value %d\n", $batt_data->{'info'}{'design capacity warning'});
printf ("cg1.value %d\n", $batt_data->{'info'}{'capacity granularity 1'});
printf ("cg2.value %d\n", $batt_data->{'info'}{'capacity granularity 2'});
printf ("rc.value %d\n", $batt_data->{'state'}{'remaining capacity'});
printf ("pr.value %d\n", $batt_data->{'state'}{'present rate'});
}
elsif ($graph_type eq "voltage")
{
printf ("d.value %s\n", $batt_data->{'info'}{'design voltage'});
printf ("p.value %s\n", $batt_data->{'state'}{'present voltage'});
printf ("d.value %d\n", $batt_data->{'info'}{'design voltage'});
printf ("p.value %d\n", $batt_data->{'state'}{'present voltage'});
}
elsif ($graph_type eq "percents")
{
printf ("cv.value %s\n", percent($batt_data->{'info'}{'design voltage'},$batt_data->{'state'}{'present voltage'}));
printf ("cc.value %s\n", percent($batt_data->{'info'}{'design capacity'},$batt_data->{'state'}{'remaining capacity'}));
printf ("fc.value %s\n", percent($batt_data->{'info'}{'design capacity'},$batt_data->{'info'}{'last full capacity'}));
printf ("cv.value %d\n", percent($batt_data->{'info'}{'design voltage'},$batt_data->{'state'}{'present voltage'}));
printf ("cc.value %d\n", percent($batt_data->{'info'}{'design capacity'},$batt_data->{'state'}{'remaining capacity'}));
printf ("fc.value %d\n", percent($batt_data->{'info'}{'design capacity'},$batt_data->{'info'}{'last full capacity'}));
}