evisum/src/bin/evisum_watcher.c

89 lines
2.0 KiB
C
Raw Normal View History

2021-05-16 04:12:19 -07:00
#include "next/machine.h"
#include <Ecore.h>
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
2021-05-16 04:12:19 -07:00
static Eina_List *batteries = NULL;
static Eina_List *sensors = NULL;
static Eina_List *network_interfaces = NULL;
2021-05-17 05:36:40 -07:00
static Eina_List *cores = NULL;
2021-05-16 04:12:19 -07:00
2021-05-17 08:02:03 -07:00
static int
test(void)
2021-05-16 04:12:19 -07:00
{
2021-05-17 05:36:40 -07:00
Eina_List *l;
Cpu_Core *core;
2021-05-16 09:39:04 -07:00
ecore_init();
2021-05-16 04:12:19 -07:00
2021-05-17 04:21:07 -07:00
puts("CORES:");
2021-05-17 07:55:50 -07:00
printf("total: %i online %i\n", cores_count(), cores_online_count());
2021-05-17 05:36:40 -07:00
cores = cores_find();
for (int i = 0; i < 10; i++)
2021-05-17 04:21:07 -07:00
{
2021-05-17 08:19:44 -07:00
cores_update(cores);
2021-05-17 05:36:40 -07:00
EINA_LIST_FOREACH(cores, l, core)
{
2021-05-17 07:55:50 -07:00
printf("core %i = %1.2f%%\t%1.2fMHz %iC\n", core->id, core->percent,
(double) core_id_frequency(core->id) / 1000, core_id_temperature(core->id));
2021-05-17 05:36:40 -07:00
}
2021-05-17 07:55:50 -07:00
usleep(1000000);
2021-05-17 04:21:07 -07:00
}
2021-05-17 05:36:40 -07:00
EINA_LIST_FREE(cores, core)
free(core);
2021-05-17 04:21:07 -07:00
puts("BATTERIES:");
Battery *bat;
2021-05-16 09:39:04 -07:00
batteries = batteries_find();
2021-05-17 04:21:07 -07:00
EINA_LIST_FREE(batteries, bat)
2021-05-16 09:39:04 -07:00
{
battery_check(bat);
printf("battery %s (%s) => %1.2f\n", bat->model, bat->vendor, bat->percent);
2021-05-17 04:21:07 -07:00
battery_free(bat);
2021-05-16 09:39:04 -07:00
}
2021-05-16 04:12:19 -07:00
2021-05-17 04:21:07 -07:00
printf("POWER: %i\n", power_ac_check());
puts("SENSORS:");
Sensor *sensor;
sensors = sensors_find();
EINA_LIST_FREE(sensors, sensor)
{
if (sensor_check(sensor))
printf("sensor %s (%s) = %1.1f", sensor->name, sensor->child_name, sensor->value);
if (sensor->type == FANRPM)
printf("RPM\n");
else if (sensor->type == THERMAL)
printf("C\n");
else
{
printf(" - UNHANDLED!\n");
exit(1);
}
sensor_free(sensor);
}
2021-05-17 04:21:07 -07:00
puts("NETWORK:");
Network_Interface *iface;
network_interfaces = network_interfaces_find();
EINA_LIST_FREE(network_interfaces, iface)
{
printf("name => %s => %"PRIi64" %"PRIi64"\n", iface->name, iface->total_in, iface->total_out);
free(iface);
}
2021-05-16 04:12:19 -07:00
ecore_shutdown();
return 0;
}
2021-05-17 08:02:03 -07:00
int main(int argc, char **argv)
{
return test();
}