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

@ -63,7 +63,7 @@ if ($0 =~ /^(?:|.*\/)acpi_sys_batt_([^_]+)_(.+)$/)
elsif (!defined($batt_num) or !defined($graph_type)) {
die "# Error: couldn't understand what I'm supposed to monitor."; }
my $sys_path=sprintf("/sys/class/power_supply/BAT%s", $batt_num);
my $sys_path=sprintf("/sys/class/power_supply/BAT%d", $batt_num);
#print "$batt_num, $graph_type \n";
@ -97,8 +97,8 @@ if ($ARGV[0] and $ARGV[0] eq "config")
my $batt_name = sprintf("%s %s %s %s (sn: %s)", cat_file('technology'), cat_file('type'), cat_file('manufacturer'), cat_file('model_name'), cat_file('serial_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")
{
@ -144,24 +144,22 @@ sub percent
if ($graph_type eq "capacity")
{
printf ("cfd.value %s\n", cat_file('charge_full_design'));
printf ("cf.value %s\n", cat_file('charge_full'));
printf ("cn.value %s\n", cat_file('charge_now'));
printf ("cfd.value %d\n", cat_file('charge_full_design'));
printf ("cf.value %d\n", cat_file('charge_full'));
printf ("cn.value %d\n", cat_file('charge_now'));
}
elsif ($graph_type eq "voltage")
{
printf ("vmd.value %s\n", cat_file('voltage_min_design'));
printf ("vn.value %s\n", cat_file('voltage_now'));
printf ("vmd.value %d\n", cat_file('voltage_min_design'));
printf ("vn.value %d\n", cat_file('voltage_now'));
}
elsif ($graph_type eq "current")
{
printf ("currn.value %s\n", cat_file('current_now'));
printf ("currn.value %d\n", cat_file('current_now'));
}
elsif ($graph_type eq "percents")
{
printf ("cv.value %s\n", percent(cat_file('voltage_min_design'),cat_file('voltage_now')));
printf ("cc.value %s\n", percent(cat_file('charge_full'),cat_file('charge_now')));
printf ("fc.value %s\n", percent(cat_file('charge_full_design'),cat_file('charge_full')));
printf ("cv.value %d\n", percent(cat_file('voltage_min_design'),cat_file('voltage_now')));
printf ("cc.value %d\n", percent(cat_file('charge_full'),cat_file('charge_now')));
printf ("fc.value %d\n", percent(cat_file('charge_full_design'),cat_file('charge_full')));
}