SUMMARY: getting system temperature from a C program

From: Eiler, James A. <James.Eiler_at_alcoa.com>
Date: Tue, 15 Jan 2002 19:03:39 -0500

many thanks to:

Weirick, Robert
Tarasyuk, Nik
sysadmin_at_astro.su.se
Markley, Sean

Best response was to use the cfg_subsys_query(3) function.

Sample program:

#include <errno.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/sysconfig.h>
#include <cfg.h>

main(int argc, char **argv)
{
   cfg_handle_t *handle_ptr=NULL;
   cfg_status_t retval;
   cfg_attr_t attributes;

   /* Initialize attribute names for the query */
   strcpy (attributes.name, "env_current_temp");

   /* Call the cfg_subsys_query() routine */
   retval = cfg_subsys_query(handle_ptr, "envmon", &attributes, 1);

   if (retval != CFG_SUCCESS) printf( "error\n" );

   printf ( "System temperature = %d\n", attributes.attr.num.val );

} /* end of main() */




Original Question:


Dear Admins,

I looked in the archives and found the command to get the system temperature
interactively:

   % sysconfig -q envmon env_current_temp

Does anyone know of a C callable function that I can use to get the
temperature from inside a program?

Thanks,

Jim
Received on Wed Jan 16 2002 - 00:04:03 NZDT

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:43 NZDT