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

« back to all changes in this revision

Viewing changes to ksysguard/ksysguardd/Irix/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) 1999, 2000 Chris Schlaeger <cs@kde.org>
 
5
 
 
6
        Irix support by Carsten Kroll <CKroll@pinnaclesys.com>
 
7
    
 
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.
 
11
 
 
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.
 
16
 
 
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.
 
20
 
 
21
*/
 
22
 
 
23
#include <stdio.h>
 
24
#include <stdlib.h>
 
25
#include <unistd.h>
 
26
#include <sys/stat.h>
 
27
#include <sys/swap.h>
 
28
 
 
29
#include "config.h"
 
30
 
 
31
#include "ksysguardd.h"
 
32
#include "Command.h"
 
33
#include "LoadAvg.h"
 
34
 
 
35
double loadavg1 = 0.0;
 
36
double loadavg5 = 0.0;
 
37
double loadavg15 = 0.0;
 
38
 
 
39
void initLoadAvg(struct SensorModul* sm ) {
 
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 exitLoadAvg( void ) {
 
51
        removeMonitor("cpu/system/loadavg1");
 
52
        removeMonitor("cpu/system/loadavg5");
 
53
        removeMonitor("cpu/system/loadavg15");
 
54
 
 
55
        /* These were registered as legacy monitors */
 
56
        removeMonitor("cpu/loadavg1");
 
57
        removeMonitor("cpu/loadavg5");
 
58
        removeMonitor("cpu/loadavg15");
 
59
}
 
60
 
 
61
int updateLoadAvg( void ) {
 
62
 
 
63
        return( 0 );
 
64
}
 
65
 
 
66
void printLoadAvg1Info( const char *cmd ) {
 
67
        fprintf(CurrentClient, "avnrun 1min\t0\t0\n" );
 
68
}
 
69
 
 
70
void printLoadAvg1( const char *cmd ) {
 
71
        fprintf(CurrentClient, "%f\n", loadavg1 );
 
72
}
 
73
 
 
74
void printLoadAvg5Info( const char *cmd ) {
 
75
        fprintf(CurrentClient, "avnrun 5min\t0\t0\n" );
 
76
}
 
77
 
 
78
void printLoadAvg5( const char *cmd ) {
 
79
        fprintf(CurrentClient, "%f\n", loadavg5 );
 
80
}
 
81
 
 
82
void printLoadAvg15Info( const char *cmd ) {
 
83
        fprintf(CurrentClient, "avnrun 15min\t0\t0\n" );
 
84
}
 
85
 
 
86
void printLoadAvg15( const char *cmd ) {
 
87
        fprintf(CurrentClient, "%f\n", loadavg15 );
 
88
}