2
KSysGuard, the KDE System Guard
4
Copyright (c) 1999 - 2001 Chris Schlaeger <cs@kde.org>
6
This program is free software; you can redistribute it and/or
7
modify it under the terms of version 2 of the GNU General Public
8
License as published by the Free Software Foundation.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
15
You should have received a copy of the GNU General Public License
16
along with this program; if not, write to the Free Software
17
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24
#include <sys/types.h>
28
#include "ksysguardd.h"
32
#ifdef HAVE_I8K_SUPPORT
35
static int cpuTemp, fan0Speed, fan1Speed;
37
#define I8KBUFSIZE 128
38
static char I8kBuf[ I8KBUFSIZE ];
41
================================ public part =================================
44
void initI8k( struct SensorModul* sm )
46
if ( updateI8k() < 0 ) {
52
registerMonitor( "dell/cputemp", "integer", printI8kCPUTemperature,
53
printI8kCPUTemperatureInfo, sm );
54
registerMonitor( "dell/fan0", "integer", printI8kFan0Speed,
55
printI8kFan0SpeedInfo, sm );
56
registerMonitor( "dell/fan1", "integer", printI8kFan1Speed,
57
printI8kFan1SpeedInfo, sm );
73
if ( ( fd = open( "/proc/i8k", O_RDONLY ) ) < 0 ) {
74
print_error( "Cannot open file \'/proc/i8k\'!\n"
75
"The kernel needs to be compiled with support\n"
76
"for /proc file system enabled!\n" );
80
if ( ( n = read( fd, I8kBuf, I8KBUFSIZE - 1 ) ) == I8KBUFSIZE - 1 ) {
81
log_error( "Internal buffer too small to read \'/proc/i8k\'" );
90
sscanf( I8kBuf, "%*f %*s %*s %d %*d %*d %d %d %*d %*d",
91
&cpuTemp, &fan0Speed, &fan1Speed );
96
void printI8kCPUTemperature( const char* cmd )
99
output( "%d\n", cpuTemp );
102
void printI8kCPUTemperatureInfo( const char* cmd )
105
output( "CPU Temperature\t0\t0\tC\n" );
108
void printI8kFan0Speed( const char* cmd )
111
output( "%d\n", fan0Speed );
114
void printI8kFan0SpeedInfo( const char* cmd )
117
output( "Left fan\t0\t0\trpm\n" );
120
void printI8kFan1Speed( const char* cmd )
123
output( "%d\n", fan1Speed );
126
void printI8kFan1SpeedInfo( const char* cmd )
129
output( "Right fan\t0\t0\trpm\n" );
132
#else /* HAVE_I8K_SUPPORT */
134
/* dummy version for systems that have no i8k support */
136
void initI8k( struct SensorModul* sm )
145
int updateI8k( void )