2
KSysGuard, the KDE System Guard
4
Copyright (c) 1999, 2000 Chris Schlaeger <cs@kde.org>
6
Solaris support by Torsten Kasch <tk@Genetik.Uni-Bielefeld.DE>
8
This program is free software; you can redistribute it and/or
9
modify it under the terms of version 2 of the GNU General Public
10
License as published by the Free Software Foundation.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
34
#include "ksysguardd.h"
38
double loadavg1 = 0.0;
39
double loadavg5 = 0.0;
40
double loadavg15 = 0.0;
42
void initLoadAvg( struct SensorModul* sm ) {
44
registerMonitor( "cpu/loadavg1", "float",
45
printLoadAvg1, printLoadAvg1Info, sm );
46
registerMonitor( "cpu/loadavg5", "float",
47
printLoadAvg5, printLoadAvg5Info, sm );
48
registerMonitor( "cpu/loadavg15", "float",
49
printLoadAvg15, printLoadAvg15Info, sm );
53
void exitLoadAvg( void ) {
56
int updateLoadAvg( void ) {
64
* get a kstat handle and update the user's kstat chain
66
if( (kctl = kstat_open()) == NULL )
68
while( kstat_chain_update( kctl ) != 0 )
72
* traverse the kstat chain to find the appropriate statistics
74
if( (ksp = kstat_lookup( kctl, "unix", 0, "system_misc" )) == NULL )
76
if( kstat_read( kctl, ksp, NULL ) == -1 )
82
kdata = (kstat_named_t *) kstat_data_lookup( ksp, "avenrun_1min" );
84
loadavg1 = LOAD( kdata->value.ui32 );
85
kdata = (kstat_named_t *) kstat_data_lookup( ksp, "avenrun_5min" );
87
loadavg5 = LOAD( kdata->value.ui32 );
88
kdata = (kstat_named_t *) kstat_data_lookup( ksp, "avenrun_15min" );
90
loadavg15 = LOAD( kdata->value.ui32 );
93
#endif /* ! HAVE_KSTAT */
98
void printLoadAvg1Info( const char *cmd ) {
99
fprintf(CurrentClient, "avnrun 1min\t0\t0\n" );
102
void printLoadAvg1( const char *cmd ) {
103
fprintf(CurrentClient, "%f\n", loadavg1 );
106
void printLoadAvg5Info( const char *cmd ) {
107
fprintf(CurrentClient, "avnrun 5min\t0\t0\n" );
110
void printLoadAvg5( const char *cmd ) {
111
fprintf(CurrentClient, "%f\n", loadavg5 );
114
void printLoadAvg15Info( const char *cmd ) {
115
fprintf(CurrentClient, "avnrun 15min\t0\t0\n" );
118
void printLoadAvg15( const char *cmd ) {
119
fprintf(CurrentClient, "%f\n", loadavg15 );