Examples of sysctl/sysctlbyname/sysctlnametomib?

Stanislav Sedov stas at FreeBSD.org
Tue Jan 15 02:41:05 PST 2008


On Mon, Jan 14, 2008 at 05:24:40AM -0800 Jeremy Chadwick mentioned:
> 
> I'm attempting to retrieve the integer values for dev.cpu.X.temperature.
> For example, using sysctlbyname("dev.cpu.X.temperature") does work, but
> the results returned in *oldp don't match that of what sysctl(8) shows.
> This lead me to consider using sysctlnametomib("dev.cpu.X"), which also
> returns success, but from there I'm confused...
> 

sysctl converts temperature values to Celsius or Farenheit according to
locale, e.g.:
	printf("%.1fC", (mv - 2732.0) / 10);

When you retrive value using sysctlbyname, it's raw number, and it'll
differ from what sysctl displays.

-- 
Stanislav Sedov
ST4096-RIPE


More information about the freebsd-hackers mailing list