aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/plugin/swap.php
blob: dee569271d05f5733942aed47b83cfb372a862cb (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
<?php

# Collectd Swap plugin

require_once 'conf/common.inc.php';
require_once 'inc/collectd.inc.php';

## LAYOUT
# swap/
# swap/swap-cached.rrd
# swap/swap-free.rrd
# swap/swap-used.rrd

switch(GET('t')) {
	case 'swap':
		require_once 'type/GenericStacked.class.php';
		$obj = new Type_GenericStacked($CONFIG);
		$obj->order = array('free', 'cached', 'used');
		$obj->ds_names = array(
			'free'   => 'Free',
			'cached' => 'Cached',
			'used'   => 'Used',
		);
		$obj->colors = array(
			'free'   => '00e000',
			'cached' => '0000ff',
			'used'   => 'ff0000',
		);
		$obj->rrd_title = 'Swap utilization';
		$obj->rrd_vertical = ucfirst($CONFIG['datasize']);
		$obj->scale = $CONFIG['datasize'] == 'bits' ? 8 : 1;
	break;
	case 'swap_io':
		require_once 'type/GenericIO.class.php';
		$obj = new Type_GenericIO($CONFIG);
		$obj->order = array('out', 'in');
		$obj->ds_names = array(
			'out' => 'Out',
			'in'  => 'In',
		);
		$obj->colors = array(
			'out' => '0000ff',
			'in'  => '00b000',
		);
		$obj->rrd_title = 'Swapped I/O pages';
		$obj->rrd_vertical = 'Pages';
	break;
}

$obj->width = $width;
$obj->heigth = $heigth;
$obj->rrd_format = '%5.1lf%s';

collectd_flush($obj->identifiers);
$obj->rrd_graph();