~ubuntu-branches/ubuntu/lucid/kdebase/lucid

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Ana Beatriz Guerrero Lopez
  • Date: 2009-04-05 05:22:13 UTC
  • mfrom: (0.4.2 experimental) (0.2.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 235.
  • Revision ID: james.westby@ubuntu.com-20090405052213-39thr4l6p2ss07uj
Tags: 4:4.2.2-1
* New upstream release:
  - khtml fixes. (Closes: #290285, #359680)
  - Default konsole sessions can be deleted. (Closes: #286342)
  - Tag widget uses standard application palette. (Closes: #444800)
  - ... and surely many more but we have lost track...

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/loadavg1", "float", printLoadAvg1,
41
 
                                        printLoadAvg1Info, sm);
42
 
        registerMonitor("cpu/loadavg5", "float", printLoadAvg5,
43
 
                                        printLoadAvg5Info, sm);
44
 
        registerMonitor("cpu/loadavg15", "float", printLoadAvg15,
45
 
                                        printLoadAvg15Info, sm);
46
 
}
47
 
 
48
 
void
49
 
exitLoadAvg(void)
50
 
{
51
 
        removeMonitor("cpu/loadavg1");
52
 
        removeMonitor("cpu/loadavg5");
53
 
        removeMonitor("cpu/loadavg15");
54
 
}
55
 
 
56
 
int
57
 
updateLoadAvg(void)
58
 
{
59
 
        return getloadavg(LoadAvg, 3);
60
 
}
61
 
 
62
 
void
63
 
printLoadAvg1(const char* c)
64
 
{
65
 
        fprintf(CurrentClient, "%f\n", LoadAvg[0]);
66
 
}
67
 
 
68
 
void
69
 
printLoadAvg1Info(const char* c)
70
 
{
71
 
        fprintf(CurrentClient, "Load average 1 min\t0\t0\t\n");
72
 
}
73
 
 
74
 
void
75
 
printLoadAvg5(const char* c)
76
 
{
77
 
        fprintf(CurrentClient, "%f\n", LoadAvg[1]);
78
 
}
79
 
 
80
 
void
81
 
printLoadAvg5Info(const char* c)
82
 
{
83
 
        fprintf(CurrentClient, "Load average 5 min\t0\t0\t\n");
84
 
}
85
 
 
86
 
void
87
 
printLoadAvg15(const char* c)
88
 
{
89
 
        fprintf(CurrentClient, "%f\n", LoadAvg[2]);
90
 
}
91
 
 
92
 
void
93
 
printLoadAvg15Info(const char* c)
94
 
{
95
 
        fprintf(CurrentClient, "Load average 15 min\t0\t0\t\n");
96
 
}