blob: 39f5a73593e84c1a64f7ae2ced54afda6055c1e4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
/* System Information
*
* Copyright (C) 2001 Robbie Ward <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SYSTEMINFO_H
#define SYSTEMINFO_H
class System
{
public:
/**
* converts bytes to megabytes
*/
static int bytesToMegs( unsigned long );
/**
* @return a pointer to the instance
*/
static System & self();
/**
* Deletes the instance and cleans up after itself
*/
static void cleanup();
/**
* @return the total amount of seconds
* the pc has been running
*/
long uptime() const { return m_uptime; }
/**
* @return the 3 load averages
*/
const double * loadAverages() const { return m_loads; }
/**
* this function does the same as the
* above but returns only the @ref load
* average
*/
double loadAverage( int ) const;
/**
* @return the total ram the system has
*/
unsigned long totalRam() const { return m_totalram; }
/**
* @return the total used ram
*/
unsigned long usedRam() const { return m_usedram; }
/**
* @return the total free ram the system has
*/
unsigned long freeRam() const { return m_freeram; }
/**
* @return the amount of shared
* memory in the system
*/
unsigned long sharedRam() const { return m_sharedram; }
/**
* @return the amount of buffered
* memory in the system
*/
unsigned long bufferRam() const { return m_bufferram; }
/**
* @return the amount of buffered
* memory in the system
*/
unsigned long cacheRam() const { return m_cacheram; }
/**
* @return the total amount of
* high memory
*/
unsigned long totalHigh() const { return m_totalhigh; }
/**
* @return the total amount of
* high free memory
*/
unsigned long freeHigh() const { return m_freehigh; }
/**
* @return the total amount of
* swap the system has
*/
unsigned long totalSwap() const { return m_totalswap; }
/**
* @return the total amount of
* swap used
*/
unsigned long usedSwap() const { return m_usedswap; }
/**
* @return the total amount of
* free swap the system has
*/
unsigned long freeSwap() const { return m_freeswap; }
/**
* @return the number of
* procs running
*/
unsigned short procs() const { return m_procs; }
private:
System();
System( const System & );
System & operator=( const System & );
~System();
void updateData();
long m_uptime; // seconds since boot
double m_loads[3]; // 1, 5, and 15 minute load averages
unsigned long m_totalram; // Total usable main memory size
unsigned long m_usedram; // Used memory size
unsigned long m_freeram; // Available memory size
unsigned long m_sharedram; // Amount of shared memory
unsigned long m_bufferram; // Memory used by buffers
unsigned long m_cacheram; // Amount of cached ram
unsigned long m_totalhigh; // Total high memory size
unsigned long m_freehigh; // Available high memory size
unsigned long m_totalswap; // Total swap space size
unsigned long m_usedswap; // Used swap space size
unsigned long m_freeswap; // Swap space still available
unsigned short m_procs; // Number of current processes
static System * m_self;
};
#endif
|