~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to ksysguard/ksysguardd/NetBSD/loadavg.c

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    KSysGuard, the KDE System Guard
 
3
   
 
4
        Copyright (c) 2001 Tobias Koenig <tokoe@kde.org>
 
5
    
 
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.
 
9
 
 
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.
 
14
 
 
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.
 
18
 
 
19
*/
 
20
 
 
21
#include <stdio.h>
 
22
#include <stdlib.h>
 
23
 
 
24
#include "Command.h"
 
25
#include "ksysguardd.h"
 
26
#include "loadavg.h"
 
27
 
 
28
static double LoadAvg[3];
 
29
 
 
30
/*
 
31
================================ public part =================================
 
32
*/
 
33
 
 
34
void
 
35
initLoadAvg(struct SensorModul* sm)
 
36
{
 
37
        if (updateLoadAvg() < 0)
 
38
                return;
 
39
 
 
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);
 
43
        
 
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);
 
48
}
 
49
 
 
50
void
 
51
exitLoadAvg(void)
 
52
{
 
53
        removeMonitor("cpu/system/loadavg1");
 
54
        removeMonitor("cpu/system/loadavg5");
 
55
        removeMonitor("cpu/system/loadavg15");
 
56
        
 
57
        /* These were registered as legacy monitors */
 
58
        removeMonitor("cpu/loadavg1");
 
59
        removeMonitor("cpu/loadavg5");
 
60
        removeMonitor("cpu/loadavg15");
 
61
}
 
62
 
 
63
int
 
64
updateLoadAvg(void)
 
65
{
 
66
        return getloadavg(LoadAvg, 3);
 
67
}
 
68
 
 
69
void
 
70
printLoadAvg1(const char* c)
 
71
{
 
72
        fprintf(CurrentClient, "%f\n", LoadAvg[0]);
 
73
}
 
74
 
 
75
void
 
76
printLoadAvg1Info(const char* c)
 
77
{
 
78
        fprintf(CurrentClient, "Load average 1 min\t0\t0\t\n");
 
79
}
 
80
 
 
81
void
 
82
printLoadAvg5(const char* c)
 
83
{
 
84
        fprintf(CurrentClient, "%f\n", LoadAvg[1]);
 
85
}
 
86
 
 
87
void
 
88
printLoadAvg5Info(const char* c)
 
89
{
 
90
        fprintf(CurrentClient, "Load average 5 min\t0\t0\t\n");
 
91
}
 
92
 
 
93
void
 
94
printLoadAvg15(const char* c)
 
95
{
 
96
        fprintf(CurrentClient, "%f\n", LoadAvg[2]);
 
97
}
 
98
 
 
99
void
 
100
printLoadAvg15Info(const char* c)
 
101
{
 
102
        fprintf(CurrentClient, "Load average 15 min\t0\t0\t\n");
 
103
}