mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
Fix
Fix `printf` and `sprintf` output numbers from %s to %d
This commit is contained in:
parent
bba98f95b3
commit
3226446348
2 changed files with 27 additions and 37 deletions
|
@ -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'});
|
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");
|
print ("graph_args --base 1000\n");
|
||||||
printf ("graph_title 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 %s (%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");
|
print ("graph_category sensors\n");
|
||||||
if ($graph_type eq "capacity")
|
if ($graph_type eq "capacity")
|
||||||
{
|
{
|
||||||
|
@ -182,31 +182,23 @@ sub percent
|
||||||
|
|
||||||
if ($graph_type eq "capacity")
|
if ($graph_type eq "capacity")
|
||||||
{
|
{
|
||||||
printf ("dc.value %s\n", $batt_data->{'info'}{'design capacity'});
|
printf ("dc.value %d\n", $batt_data->{'info'}{'design capacity'});
|
||||||
printf ("lfc.value %s\n", $batt_data->{'info'}{'last full capacity'});
|
printf ("lfc.value %d\n", $batt_data->{'info'}{'last full capacity'});
|
||||||
printf ("dcl.value %s\n", $batt_data->{'info'}{'design capacity low'});
|
printf ("dcl.value %d\n", $batt_data->{'info'}{'design capacity low'});
|
||||||
printf ("dcw.value %s\n", $batt_data->{'info'}{'design capacity warning'});
|
printf ("dcw.value %d\n", $batt_data->{'info'}{'design capacity warning'});
|
||||||
printf ("cg1.value %s\n", $batt_data->{'info'}{'capacity granularity 1'});
|
printf ("cg1.value %d\n", $batt_data->{'info'}{'capacity granularity 1'});
|
||||||
printf ("cg2.value %s\n", $batt_data->{'info'}{'capacity granularity 2'});
|
printf ("cg2.value %d\n", $batt_data->{'info'}{'capacity granularity 2'});
|
||||||
printf ("rc.value %s\n", $batt_data->{'state'}{'remaining capacity'});
|
printf ("rc.value %d\n", $batt_data->{'state'}{'remaining capacity'});
|
||||||
printf ("pr.value %s\n", $batt_data->{'state'}{'present rate'});
|
printf ("pr.value %d\n", $batt_data->{'state'}{'present rate'});
|
||||||
}
|
}
|
||||||
elsif ($graph_type eq "voltage")
|
elsif ($graph_type eq "voltage")
|
||||||
{
|
{
|
||||||
printf ("d.value %s\n", $batt_data->{'info'}{'design voltage'});
|
printf ("d.value %d\n", $batt_data->{'info'}{'design voltage'});
|
||||||
printf ("p.value %s\n", $batt_data->{'state'}{'present voltage'});
|
printf ("p.value %d\n", $batt_data->{'state'}{'present voltage'});
|
||||||
}
|
}
|
||||||
elsif ($graph_type eq "percents")
|
elsif ($graph_type eq "percents")
|
||||||
{
|
{
|
||||||
printf ("cv.value %s\n", percent($batt_data->{'info'}{'design voltage'},$batt_data->{'state'}{'present voltage'}));
|
printf ("cv.value %d\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 ("cc.value %d\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 ("fc.value %d\n", percent($batt_data->{'info'}{'design capacity'},$batt_data->{'info'}{'last full capacity'}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ if ($0 =~ /^(?:|.*\/)acpi_sys_batt_([^_]+)_(.+)$/)
|
||||||
elsif (!defined($batt_num) or !defined($graph_type)) {
|
elsif (!defined($batt_num) or !defined($graph_type)) {
|
||||||
die "# Error: couldn't understand what I'm supposed to monitor."; }
|
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";
|
#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'));
|
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");
|
print ("graph_args --base 1000\n");
|
||||||
printf ("graph_title 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 %s (%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");
|
print ("graph_category sensors\n");
|
||||||
if ($graph_type eq "capacity")
|
if ($graph_type eq "capacity")
|
||||||
{
|
{
|
||||||
|
@ -144,24 +144,22 @@ sub percent
|
||||||
|
|
||||||
if ($graph_type eq "capacity")
|
if ($graph_type eq "capacity")
|
||||||
{
|
{
|
||||||
printf ("cfd.value %s\n", cat_file('charge_full_design'));
|
printf ("cfd.value %d\n", cat_file('charge_full_design'));
|
||||||
printf ("cf.value %s\n", cat_file('charge_full'));
|
printf ("cf.value %d\n", cat_file('charge_full'));
|
||||||
printf ("cn.value %s\n", cat_file('charge_now'));
|
printf ("cn.value %d\n", cat_file('charge_now'));
|
||||||
}
|
}
|
||||||
elsif ($graph_type eq "voltage")
|
elsif ($graph_type eq "voltage")
|
||||||
{
|
{
|
||||||
printf ("vmd.value %s\n", cat_file('voltage_min_design'));
|
printf ("vmd.value %d\n", cat_file('voltage_min_design'));
|
||||||
printf ("vn.value %s\n", cat_file('voltage_now'));
|
printf ("vn.value %d\n", cat_file('voltage_now'));
|
||||||
}
|
}
|
||||||
elsif ($graph_type eq "current")
|
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")
|
elsif ($graph_type eq "percents")
|
||||||
{
|
{
|
||||||
printf ("cv.value %s\n", percent(cat_file('voltage_min_design'),cat_file('voltage_now')));
|
printf ("cv.value %d\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 ("cc.value %d\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 ("fc.value %d\n", percent(cat_file('charge_full_design'),cat_file('charge_full')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue