mirror of
https://github.com/lm-sensors/lm-sensors
synced 2025-08-29 13:28:01 +00:00
Subject: [PATCH 3/4 v2] sensors: Print energy and power meters
Display power and energy meters in sensors. Signed-off-by: Darrick J. Wong <djwong@us.ibm.com> git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5184 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
parent
bb840c486c
commit
4c93dffd4f
1
CHANGES
1
CHANGES
@ -2,6 +2,7 @@ lm-sensors CHANGES file
|
|||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
SVN-HEAD
|
SVN-HEAD
|
||||||
|
sensors: Print energy and power sensors
|
||||||
libsensors: Use __func__ instead of __FUNCTION__
|
libsensors: Use __func__ instead of __FUNCTION__
|
||||||
Parse the configuration file in C locale
|
Parse the configuration file in C locale
|
||||||
Late compute statements override early ones
|
Late compute statements override early ones
|
||||||
|
@ -401,6 +401,85 @@ static void print_chip_fan(const sensors_chip_name *name,
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void print_chip_power(const sensors_chip_name *name,
|
||||||
|
const sensors_feature *feature,
|
||||||
|
int label_size)
|
||||||
|
{
|
||||||
|
int need_space = 0;
|
||||||
|
const sensors_subfeature *sf, *sfmin, *sfmax, *sfint;
|
||||||
|
char *label;
|
||||||
|
|
||||||
|
if (!(label = sensors_get_label(name, feature))) {
|
||||||
|
fprintf(stderr, "ERROR: Can't get label of feature %s!\n",
|
||||||
|
feature->name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
print_label(label, label_size);
|
||||||
|
free(label);
|
||||||
|
|
||||||
|
sf = sensors_get_subfeature(name, feature,
|
||||||
|
SENSORS_SUBFEATURE_POWER_AVERAGE);
|
||||||
|
if (sf)
|
||||||
|
printf("%6.2f W", get_value(name, sf));
|
||||||
|
else
|
||||||
|
printf(" N/A");
|
||||||
|
|
||||||
|
sfmin = sensors_get_subfeature(name, feature,
|
||||||
|
SENSORS_SUBFEATURE_POWER_AVERAGE_HIGHEST);
|
||||||
|
sfmax = sensors_get_subfeature(name, feature,
|
||||||
|
SENSORS_SUBFEATURE_POWER_AVERAGE_LOWEST);
|
||||||
|
sfint = sensors_get_subfeature(name, feature,
|
||||||
|
SENSORS_SUBFEATURE_POWER_AVERAGE_INTERVAL);
|
||||||
|
if (sfmin || sfmax || sfint) {
|
||||||
|
printf(" (");
|
||||||
|
|
||||||
|
if (sfmin) {
|
||||||
|
printf("min = %6.2f W", get_value(name, sfmin));
|
||||||
|
need_space = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sfmax) {
|
||||||
|
printf("%smax = %6.2f W", (need_space ? ", " : ""),
|
||||||
|
get_value(name, sfmax));
|
||||||
|
need_space = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sfint) {
|
||||||
|
printf("%sinterval = %6.2f s", (need_space ? ", " : ""),
|
||||||
|
get_value(name, sfint));
|
||||||
|
need_space = 1;
|
||||||
|
}
|
||||||
|
printf(")");
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void print_chip_energy(const sensors_chip_name *name,
|
||||||
|
const sensors_feature *feature,
|
||||||
|
int label_size)
|
||||||
|
{
|
||||||
|
const sensors_subfeature *sf;
|
||||||
|
char *label;
|
||||||
|
|
||||||
|
if (!(label = sensors_get_label(name, feature))) {
|
||||||
|
fprintf(stderr, "ERROR: Can't get label of feature %s!\n",
|
||||||
|
feature->name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
print_label(label, label_size);
|
||||||
|
free(label);
|
||||||
|
|
||||||
|
sf = sensors_get_subfeature(name, feature,
|
||||||
|
SENSORS_SUBFEATURE_ENERGY_INPUT);
|
||||||
|
if (sf)
|
||||||
|
printf("%6.2f J", get_value(name, sf));
|
||||||
|
else
|
||||||
|
printf(" N/A");
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
static void print_chip_vid(const sensors_chip_name *name,
|
static void print_chip_vid(const sensors_chip_name *name,
|
||||||
const sensors_feature *feature,
|
const sensors_feature *feature,
|
||||||
int label_size)
|
int label_size)
|
||||||
@ -468,6 +547,12 @@ void print_chip(const sensors_chip_name *name)
|
|||||||
case SENSORS_FEATURE_BEEP_ENABLE:
|
case SENSORS_FEATURE_BEEP_ENABLE:
|
||||||
print_chip_beep_enable(name, feature, label_size);
|
print_chip_beep_enable(name, feature, label_size);
|
||||||
break;
|
break;
|
||||||
|
case SENSORS_FEATURE_POWER:
|
||||||
|
print_chip_power(name, feature, label_size);
|
||||||
|
break;
|
||||||
|
case SENSORS_FEATURE_ENERGY:
|
||||||
|
print_chip_energy(name, feature, label_size);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user