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

« back to all changes in this revision

Viewing changes to ksysguard/ksysguardd/FreeBSD/uptime.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) 2010 David Naylor <naylor.b.david@gmail.com>
 
5
 
 
6
    This program is free software; you can redistribute it and/or
 
7
    modify it under the terms of version 2 or later 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 <time.h>
 
23
 
 
24
#include "Command.h"
 
25
#include "ksysguardd.h"
 
26
 
 
27
#include "uptime.h"
 
28
 
 
29
void initUptime( struct SensorModul* sm ) {
 
30
    registerMonitor( "system/uptime", "float", printUptime, printUptimeInfo, sm );
 
31
}
 
32
 
 
33
void exitUptime( void ) {
 
34
    removeMonitor("system/uptime");
 
35
}
 
36
 
 
37
void printUptime( const char* cmd ) {
 
38
    struct timespec tp;
 
39
    float uptime = 0.;
 
40
 
 
41
    if (clock_gettime(CLOCK_UPTIME, &tp) != -1)
 
42
        uptime = tp.tv_nsec / 1000000000.0 + tp.tv_sec;
 
43
    fprintf( CurrentClient, "%f\n", uptime);
 
44
}
 
45
 
 
46
void printUptimeInfo( const char* cmd ) {
 
47
    fprintf( CurrentClient, "System uptime\t0\t0\ts\n" );
 
48
}