Révision 32264463
Fix
Fix `printf` and `sprintf` output numbers from %s to %d
| plugins/battery/acpi_batt_ | ||
|---|---|---|
| 142 | 142 |
{
|
| 143 | 143 |
my $batt_name = sprintf("%s %s %s", $batt_data->{'info'}{'OEM info'}, $batt_data->{'info'}{'battery type'}, $batt_data->{'info'}{'model number'});
|
| 144 | 144 |
print ("graph_args --base 1000\n");
|
| 145 |
printf ("graph_title Battery %s (%s) %s\n" , $batt_num, $batt_name, $graph_type);
|
|
| 146 |
printf ("graph_info This graph shows battery %s (%s) %s\n" , $batt_num, $batt_name, $graph_type);
|
|
| 145 |
printf ("graph_title Battery %d (%s) %s\n" , $batt_num, $batt_name, $graph_type);
|
|
| 146 |
printf ("graph_info This graph shows battery %d (%s) %s\n" , $batt_num, $batt_name, $graph_type);
|
|
| 147 | 147 |
print ("graph_category sensors\n");
|
| 148 | 148 |
if ($graph_type eq "capacity") |
| 149 | 149 |
{
|
| ... | ... | |
| 182 | 182 |
|
| 183 | 183 |
if ($graph_type eq "capacity") |
| 184 | 184 |
{
|
| 185 |
printf ("dc.value %s\n", $batt_data->{'info'}{'design capacity'});
|
|
| 186 |
printf ("lfc.value %s\n", $batt_data->{'info'}{'last full capacity'});
|
|
| 187 |
printf ("dcl.value %s\n", $batt_data->{'info'}{'design capacity low'});
|
|
| 188 |
printf ("dcw.value %s\n", $batt_data->{'info'}{'design capacity warning'});
|
|
| 189 |
printf ("cg1.value %s\n", $batt_data->{'info'}{'capacity granularity 1'});
|
|
| 190 |
printf ("cg2.value %s\n", $batt_data->{'info'}{'capacity granularity 2'});
|
|
| 191 |
printf ("rc.value %s\n", $batt_data->{'state'}{'remaining capacity'});
|
|
| 192 |
printf ("pr.value %s\n", $batt_data->{'state'}{'present rate'});
|
|
| 185 |
printf ("dc.value %d\n", $batt_data->{'info'}{'design capacity'});
|
|
| 186 |
printf ("lfc.value %d\n", $batt_data->{'info'}{'last full capacity'});
|
|
| 187 |
printf ("dcl.value %d\n", $batt_data->{'info'}{'design capacity low'});
|
|
| 188 |
printf ("dcw.value %d\n", $batt_data->{'info'}{'design capacity warning'});
|
|
| 189 |
printf ("cg1.value %d\n", $batt_data->{'info'}{'capacity granularity 1'});
|
|
| 190 |
printf ("cg2.value %d\n", $batt_data->{'info'}{'capacity granularity 2'});
|
|
| 191 |
printf ("rc.value %d\n", $batt_data->{'state'}{'remaining capacity'});
|
|
| 192 |
printf ("pr.value %d\n", $batt_data->{'state'}{'present rate'});
|
|
| 193 | 193 |
} |
| 194 | 194 |
elsif ($graph_type eq "voltage") |
| 195 | 195 |
{
|
| 196 |
printf ("d.value %s\n", $batt_data->{'info'}{'design voltage'});
|
|
| 197 |
printf ("p.value %s\n", $batt_data->{'state'}{'present voltage'});
|
|
| 196 |
printf ("d.value %d\n", $batt_data->{'info'}{'design voltage'});
|
|
| 197 |
printf ("p.value %d\n", $batt_data->{'state'}{'present voltage'});
|
|
| 198 | 198 |
} |
| 199 | 199 |
elsif ($graph_type eq "percents") |
| 200 | 200 |
{
|
| 201 |
printf ("cv.value %s\n", percent($batt_data->{'info'}{'design voltage'},$batt_data->{'state'}{'present voltage'}));
|
|
| 202 |
printf ("cc.value %s\n", percent($batt_data->{'info'}{'design capacity'},$batt_data->{'state'}{'remaining capacity'}));
|
|
| 203 |
printf ("fc.value %s\n", percent($batt_data->{'info'}{'design capacity'},$batt_data->{'info'}{'last full capacity'}));
|
|
| 201 |
printf ("cv.value %d\n", percent($batt_data->{'info'}{'design voltage'},$batt_data->{'state'}{'present voltage'}));
|
|
| 202 |
printf ("cc.value %d\n", percent($batt_data->{'info'}{'design capacity'},$batt_data->{'state'}{'remaining capacity'}));
|
|
| 203 |
printf ("fc.value %d\n", percent($batt_data->{'info'}{'design capacity'},$batt_data->{'info'}{'last full capacity'}));
|
|
| 204 | 204 |
} |
| 205 |
|
|
| 206 |
|
|
| 207 |
|
|
| 208 |
|
|
| 209 |
|
|
| 210 |
|
|
| 211 |
|
|
| 212 |
|
|
| plugins/battery/acpi_sys_batt_ | ||
|---|---|---|
| 63 | 63 |
elsif (!defined($batt_num) or !defined($graph_type)) {
|
| 64 | 64 |
die "# Error: couldn't understand what I'm supposed to monitor."; } |
| 65 | 65 |
|
| 66 |
my $sys_path=sprintf("/sys/class/power_supply/BAT%s", $batt_num);
|
|
| 66 |
my $sys_path=sprintf("/sys/class/power_supply/BAT%d", $batt_num);
|
|
| 67 | 67 |
|
| 68 | 68 |
#print "$batt_num, $graph_type \n"; |
| 69 | 69 |
|
| ... | ... | |
| 97 | 97 |
|
| 98 | 98 |
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'));
|
| 99 | 99 |
print ("graph_args --base 1000\n");
|
| 100 |
printf ("graph_title Battery %s (%s) %s\n" , $batt_num, $batt_name, $graph_type);
|
|
| 101 |
printf ("graph_info This graph shows battery %s (%s) %s\n" , $batt_num, $batt_name, $graph_type);
|
|
| 100 |
printf ("graph_title Battery %d (%s) %s\n" , $batt_num, $batt_name, $graph_type);
|
|
| 101 |
printf ("graph_info This graph shows battery %d (%s) %s\n" , $batt_num, $batt_name, $graph_type);
|
|
| 102 | 102 |
print ("graph_category sensors\n");
|
| 103 | 103 |
if ($graph_type eq "capacity") |
| 104 | 104 |
{
|
| ... | ... | |
| 144 | 144 |
|
| 145 | 145 |
if ($graph_type eq "capacity") |
| 146 | 146 |
{
|
| 147 |
printf ("cfd.value %s\n", cat_file('charge_full_design'));
|
|
| 148 |
printf ("cf.value %s\n", cat_file('charge_full'));
|
|
| 149 |
printf ("cn.value %s\n", cat_file('charge_now'));
|
|
| 147 |
printf ("cfd.value %d\n", cat_file('charge_full_design'));
|
|
| 148 |
printf ("cf.value %d\n", cat_file('charge_full'));
|
|
| 149 |
printf ("cn.value %d\n", cat_file('charge_now'));
|
|
| 150 | 150 |
} |
| 151 | 151 |
elsif ($graph_type eq "voltage") |
| 152 | 152 |
{
|
| 153 |
printf ("vmd.value %s\n", cat_file('voltage_min_design'));
|
|
| 154 |
printf ("vn.value %s\n", cat_file('voltage_now'));
|
|
| 153 |
printf ("vmd.value %d\n", cat_file('voltage_min_design'));
|
|
| 154 |
printf ("vn.value %d\n", cat_file('voltage_now'));
|
|
| 155 | 155 |
} |
| 156 | 156 |
elsif ($graph_type eq "current") |
| 157 | 157 |
{
|
| 158 |
printf ("currn.value %s\n", cat_file('current_now'));
|
|
| 158 |
printf ("currn.value %d\n", cat_file('current_now'));
|
|
| 159 | 159 |
} |
| 160 | 160 |
elsif ($graph_type eq "percents") |
| 161 | 161 |
{
|
| 162 |
printf ("cv.value %s\n", percent(cat_file('voltage_min_design'),cat_file('voltage_now')));
|
|
| 163 |
printf ("cc.value %s\n", percent(cat_file('charge_full'),cat_file('charge_now')));
|
|
| 164 |
printf ("fc.value %s\n", percent(cat_file('charge_full_design'),cat_file('charge_full')));
|
|
| 162 |
printf ("cv.value %d\n", percent(cat_file('voltage_min_design'),cat_file('voltage_now')));
|
|
| 163 |
printf ("cc.value %d\n", percent(cat_file('charge_full'),cat_file('charge_now')));
|
|
| 164 |
printf ("fc.value %d\n", percent(cat_file('charge_full_design'),cat_file('charge_full')));
|
|
| 165 | 165 |
} |
| 166 |
|
|
| 167 |
|
|
Formats disponibles : Unified diff