Subversion Repositories ALCASAR

Rev

Rev 2976 | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
2788 rexy 1
<?php
2
/**
3
 * DiskDevice TO class
4
 *
5
 * PHP version 5
6
 *
7
 * @category  PHP
8
 * @package   PSI_TO
9
 * @author    Michael Cramer <BigMichi1@users.sourceforge.net>
10
 * @copyright 2009 phpSysInfo
11
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
12
 * @version   SVN: $Id: class.DiskDevice.inc.php 252 2009-06-17 13:06:44Z bigmichi1 $
13
 * @link      http://phpsysinfo.sourceforge.net
14
 */
15
 /**
16
 * DiskDevice TO class
17
 *
18
 * @category  PHP
19
 * @package   PSI_TO
20
 * @author    Michael Cramer <BigMichi1@users.sourceforge.net>
21
 * @copyright 2009 phpSysInfo
22
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
23
 * @version   Release: 3.0
24
 * @link      http://phpsysinfo.sourceforge.net
25
 */
26
class DiskDevice
27
{
28
    /**
29
     * name of the disk device
30
     *
3037 rexy 31
     * @var string
2788 rexy 32
     */
33
    private $_name = "";
34
 
35
    /**
36
     * type of the filesystem on the disk device
37
     *
3037 rexy 38
     * @var string
2788 rexy 39
     */
40
    private $_fsType = "";
41
 
42
    /**
43
     * diskspace that is free in bytes
44
     *
3037 rexy 45
     * @var int
2788 rexy 46
     */
47
    private $_free = 0;
48
 
49
    /**
50
     * diskspace that is used in bytes
51
     *
3037 rexy 52
     * @var int
2788 rexy 53
     */
54
    private $_used = 0;
55
 
56
    /**
57
     * total diskspace
58
     *
3037 rexy 59
     * @var int
2788 rexy 60
     */
61
    private $_total = 0;
62
 
63
    /**
64
     * mount point of the disk device if available
65
     *
3037 rexy 66
     * @var string
2788 rexy 67
     */
68
    private $_mountPoint = null;
69
 
70
    /**
71
     * additional options of the device, like mount options
72
     *
3037 rexy 73
     * @var string
2788 rexy 74
     */
75
    private $_options = null;
76
 
77
    /**
78
     * inodes usage in percent if available
79
     *
3037 rexy 80
     * @var int
2788 rexy 81
     */
82
    private $_percentInodesUsed = null;
83
 
84
    /**
85
     * ignore mode
86
     *
3037 rexy 87
     * @var int
2788 rexy 88
     */
89
    private $_ignore = 0;
90
 
91
    /**
92
     * Returns PercentUsed calculated when function is called from internal values
93
     *
94
     * @see DiskDevice::$_total
95
     * @see DiskDevice::$_used
96
     *
3037 rexy 97
     * @return int
2788 rexy 98
     */
99
    public function getPercentUsed()
100
    {
101
        if ($this->_total > 0) {
2976 rexy 102
            return 100 - min(floor($this->_free / $this->_total * 100), 100);
2788 rexy 103
        } else {
104
            return 0;
105
        }
106
    }
107
 
108
    /**
109
     * Returns $_PercentInodesUsed.
110
     *
111
     * @see DiskDevice::$_PercentInodesUsed
112
     *
3037 rexy 113
     * @return int
2788 rexy 114
     */
115
    public function getPercentInodesUsed()
116
    {
117
        return $this->_percentInodesUsed;
118
    }
119
 
120
    /**
121
     * Sets $_PercentInodesUsed.
122
     *
3037 rexy 123
     * @param int $percentInodesUsed inodes percent
2788 rexy 124
     *
125
     * @see DiskDevice::$_PercentInodesUsed
126
     *
3037 rexy 127
     * @return void
2788 rexy 128
     */
129
    public function setPercentInodesUsed($percentInodesUsed)
130
    {
131
        $this->_percentInodesUsed = $percentInodesUsed;
132
    }
133
 
134
    /**
135
     * Returns $_free.
136
     *
137
     * @see DiskDevice::$_free
138
     *
3037 rexy 139
     * @return int
2788 rexy 140
     */
141
    public function getFree()
142
    {
143
        return $this->_free;
144
    }
145
 
146
    /**
147
     * Sets $_free.
148
     *
3037 rexy 149
     * @param int $free free bytes
2788 rexy 150
     *
151
     * @see DiskDevice::$_free
152
     *
3037 rexy 153
     * @return void
2788 rexy 154
     */
155
    public function setFree($free)
156
    {
157
        $this->_free = $free;
158
    }
159
 
160
    /**
161
     * Returns $_fsType.
162
     *
163
     * @see DiskDevice::$_fsType
164
     *
3037 rexy 165
     * @return string
2788 rexy 166
     */
167
    public function getFsType()
168
    {
169
        return $this->_fsType;
170
    }
171
 
172
    /**
173
     * Sets $_fsType.
174
     *
175
     * @param String $fsType filesystemtype
176
     *
177
     * @see DiskDevice::$_fsType
178
     *
3037 rexy 179
     * @return void
2788 rexy 180
     */
181
    public function setFsType($fsType)
182
    {
183
        $this->_fsType = $fsType;
184
    }
185
 
186
    /**
187
     * Returns $_mountPoint.
188
     *
189
     * @see DiskDevice::$_mountPoint
190
     *
3037 rexy 191
     * @return string
2788 rexy 192
     */
193
    public function getMountPoint()
194
    {
195
        return $this->_mountPoint;
196
    }
197
 
198
    /**
199
     * Sets $_mountPoint.
200
     *
3037 rexy 201
     * @param string $mountPoint mountpoint
2788 rexy 202
     *
203
     * @see DiskDevice::$_mountPoint
204
     *
3037 rexy 205
     * @return void
2788 rexy 206
     */
207
    public function setMountPoint($mountPoint)
208
    {
209
        $this->_mountPoint = $mountPoint;
210
    }
211
 
212
    /**
213
     * Returns $_name.
214
     *
215
     * @see DiskDevice::$_name
216
     *
3037 rexy 217
     * @return string
2788 rexy 218
     */
219
    public function getName()
220
    {
221
        return $this->_name;
222
    }
223
 
224
    /**
225
     * Sets $_name.
226
     *
3037 rexy 227
     * @param string $name device name
2788 rexy 228
     *
229
     * @see DiskDevice::$_name
230
     *
3037 rexy 231
     * @return void
2788 rexy 232
     */
233
    public function setName($name)
234
    {
235
        $this->_name = $name;
236
    }
237
 
238
    /**
239
     * Returns $_options.
240
     *
241
     * @see DiskDevice::$_options
242
     *
3037 rexy 243
     * @return string
2788 rexy 244
     */
245
    public function getOptions()
246
    {
247
        return $this->_options;
248
    }
249
 
250
    /**
251
     * Sets $_options.
252
     *
3037 rexy 253
     * @param string $options additional options
2788 rexy 254
     *
255
     * @see DiskDevice::$_options
256
     *
3037 rexy 257
     * @return void
2788 rexy 258
     */
259
    public function setOptions($options)
260
    {
261
        $this->_options = $options;
262
    }
263
 
264
    /**
265
     * Returns $_total.
266
     *
267
     * @see DiskDevice::$_total
268
     *
3037 rexy 269
     * @return int
2788 rexy 270
     */
271
    public function getTotal()
272
    {
273
        return $this->_total;
274
    }
275
 
276
    /**
277
     * Sets $_total.
278
     *
3037 rexy 279
     * @param int $total total bytes
2788 rexy 280
     *
281
     * @see DiskDevice::$_total
282
     *
3037 rexy 283
     * @return void
2788 rexy 284
     */
285
    public function setTotal($total)
286
    {
287
        $this->_total = $total;
288
    }
289
 
290
    /**
291
     * Returns $_used.
292
     *
293
     * @see DiskDevice::$_used
294
     *
3037 rexy 295
     * @return int
2788 rexy 296
     */
297
    public function getUsed()
298
    {
299
        return $this->_used;
300
    }
301
 
302
    /**
303
     * Sets $_used.
304
     *
3037 rexy 305
     * @param int $used used bytes
2788 rexy 306
     *
307
     * @see DiskDevice::$_used
308
     *
3037 rexy 309
     * @return void
2788 rexy 310
     */
311
    public function setUsed($used)
312
    {
313
        $this->_used = $used;
314
    }
315
 
316
    /**
317
     * Returns $_ignore.
318
     *
319
     * @see DiskDevice::$_ignore
320
     *
3037 rexy 321
     * @return int
2788 rexy 322
     */
323
    public function getIgnore()
324
    {
325
        return $this->_ignore;
326
    }
327
 
328
    /**
329
     * Sets $_ignore.
330
     *
331
     * @see DiskDevice::$_ignore
332
     *
3037 rexy 333
     * @return void
2788 rexy 334
     */
335
    public function setIgnore($ignore)
336
    {
337
        $this->_ignore = $ignore;
338
    }
339
}