2 KSysGuard, the KDE System Guard
4 Copyright (c) 2001 Tobias Koenig <tokoe@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.
25 #include "ksysguardd.h"
28 static double LoadAvg
[3];
31 ================================ public part =================================
35 initLoadAvg(struct SensorModul
* sm
)
37 if (updateLoadAvg() < 0)
40 registerMonitor("cpu/system/loadavg1", "float", printLoadAvg1
, printLoadAvg1Info
, sm
);
41 registerMonitor("cpu/system/loadavg5", "float", printLoadAvg5
, printLoadAvg5Info
, sm
);
42 registerMonitor("cpu/system/loadavg15", "float", printLoadAvg15
, printLoadAvg15Info
, sm
);
44 /* Monitor names changed from kde3 => kde4. Remain compatible with legacy requests when possible. */
45 registerLegacyMonitor("cpu/loadavg1", "float", printLoadAvg1
, printLoadAvg1Info
, sm
);
46 registerLegacyMonitor("cpu/loadavg5", "float", printLoadAvg5
, printLoadAvg5Info
, sm
);
47 registerLegacyMonitor("cpu/loadavg15", "float", printLoadAvg15
, printLoadAvg15Info
, sm
);
53 removeMonitor("cpu/system/loadavg1");
54 removeMonitor("cpu/system/loadavg5");
55 removeMonitor("cpu/system/loadavg15");
57 /* These were registered as legacy monitors */
58 removeMonitor("cpu/loadavg1");
59 removeMonitor("cpu/loadavg5");
60 removeMonitor("cpu/loadavg15");
66 return getloadavg(LoadAvg
, 3);
70 printLoadAvg1(const char* c
)
72 fprintf(CurrentClient
, "%f\n", LoadAvg
[0]);
76 printLoadAvg1Info(const char* c
)
78 fprintf(CurrentClient
, "Load average 1 min\t0\t0\t\n");
82 printLoadAvg5(const char* c
)
84 fprintf(CurrentClient
, "%f\n", LoadAvg
[1]);
88 printLoadAvg5Info(const char* c
)
90 fprintf(CurrentClient
, "Load average 5 min\t0\t0\t\n");
94 printLoadAvg15(const char* c
)
96 fprintf(CurrentClient
, "%f\n", LoadAvg
[2]);
100 printLoadAvg15Info(const char* c
)
102 fprintf(CurrentClient
, "Load average 15 min\t0\t0\t\n");