Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / workspace / ksysguard / ksysguardd / NetBSD / loadavg.c
blob8a31cc375aa0a8894d1203bdfc5b56922508638b
1 /*
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.
21 #include <stdio.h>
22 #include <stdlib.h>
24 #include "Command.h"
25 #include "ksysguardd.h"
26 #include "loadavg.h"
28 static double LoadAvg[3];
31 ================================ public part =================================
34 void
35 initLoadAvg(struct SensorModul* sm)
37 if (updateLoadAvg() < 0)
38 return;
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);
50 void
51 exitLoadAvg(void)
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");
63 int
64 updateLoadAvg(void)
66 return getloadavg(LoadAvg, 3);
69 void
70 printLoadAvg1(const char* c)
72 fprintf(CurrentClient, "%f\n", LoadAvg[0]);
75 void
76 printLoadAvg1Info(const char* c)
78 fprintf(CurrentClient, "Load average 1 min\t0\t0\t\n");
81 void
82 printLoadAvg5(const char* c)
84 fprintf(CurrentClient, "%f\n", LoadAvg[1]);
87 void
88 printLoadAvg5Info(const char* c)
90 fprintf(CurrentClient, "Load average 5 min\t0\t0\t\n");
93 void
94 printLoadAvg15(const char* c)
96 fprintf(CurrentClient, "%f\n", LoadAvg[2]);
99 void
100 printLoadAvg15Info(const char* c)
102 fprintf(CurrentClient, "Load average 15 min\t0\t0\t\n");