Skip to content

Commit 3197ecc

Browse files
committed
Added disk utilization graph
1 parent d3c5bdd commit 3197ecc

File tree

6 files changed

+36
-6
lines changed

6 files changed

+36
-6
lines changed

RRDCpu.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ public function graph($period = 'day', $graphPath = __DIR__)
105105
"--upper-limit=100",
106106
"--lower-limit=0",
107107
"--rigid",
108+
"--pango-markup",
108109
"DEF:usr={$this->rrdFilePath}:usr:AVERAGE",
109110
"DEF:nice={$this->rrdFilePath}:nice:AVERAGE",
110111
"DEF:sys={$this->rrdFilePath}:sys:AVERAGE",
@@ -170,7 +171,9 @@ public function graph($period = 'day', $graphPath = __DIR__)
170171
"GPRINT:idle:AVERAGE:Average\\: %5.2lf%%",
171172
"GPRINT:idle:MAX:Max\\: %5.2lf%%\\n",
172173

173-
"HRULE:0#000000"
174+
"HRULE:0#000000",,
175+
176+
'COMMENT:<span foreground="#ABABAB" size="x-small">'. date('D M jS H') . '\:' . date('i') . '\:' . date('s') .'</span>\r'
174177

175178
])) {
176179
$this->fail('Error writing connections graph for period '. $period .' ['. rrd_error() .']');

RRDDiskIO.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ public function graph($period = 'day', $graphPath = __DIR__)
201201
"-h", "150", "-w", "700",
202202
"-l 0",
203203
"-a", "PNG",
204+
"--pango-markup",
205+
"--lower-limit=0",
206+
"--units-exponent=0",
204207
"-v Utilization %"
205208
];
206209

@@ -210,7 +213,7 @@ public function graph($period = 'day', $graphPath = __DIR__)
210213
}
211214

212215
foreach ($this->devices as $device) {
213-
$colour = array_pop($colours);
216+
$colour = array_shift($colours);
214217
$config = array_merge($config, [
215218
"LINE2:{$device}Avg{$colour}:" . $device . ' Utilization',
216219
"GPRINT:{$device}Avg:LAST: Current\\: %5.2lf%%",
@@ -220,6 +223,8 @@ public function graph($period = 'day', $graphPath = __DIR__)
220223
]);
221224
}
222225

226+
array_push($config, 'COMMENT:<span foreground="#ABABAB" size="x-small">'. date('D M jS H') . '\:' . date('i') . '\:' . date('s') .'</span>\r');
227+
223228
if(!rrd_graph($graphPath . '/disk_usage_' . $period . '.png', $config)) {
224229
$this->fail('Error writing connections graph for period '. $period .' ['. rrd_error() .']');
225230
}
@@ -230,3 +235,7 @@ public function graph($period = 'day', $graphPath = __DIR__)
230235
$p = new RRDDiskIO(__DIR__, true, ['nb0', 'nb1']);
231236
$p->collect();
232237
$p->graph('hour', __DIR__ . '/../httpdocs/img');
238+
$p->graph('day', __DIR__ . '/../httpdocs/img');
239+
$p->graph('week', __DIR__ . '/../httpdocs/img');
240+
$p->graph('month', __DIR__ . '/../httpdocs/img');
241+
$p->graph('year', __DIR__ . '/../httpdocs/img');

RRDMemory.php

+4
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ public function graph($period = 'day', $graphPath = __DIR__)
134134
"-l 0",
135135
"-a", "PNG",
136136
"-v RAM (bytes)",
137+
"--pango-markup",
138+
137139
"DEF:total={$this->rrdFilePath}:memTotal:AVERAGE",
138140

139141
"DEF:used={$this->rrdFilePath}:memUsed:AVERAGE",
@@ -191,6 +193,8 @@ public function graph($period = 'day', $graphPath = __DIR__)
191193
"LINE1:total#21392D:Total",
192194
'GPRINT:total:LAST:%5.1lf %sB \l',
193195

196+
'COMMENT:<span foreground="#ABABAB" size="x-small">'. date('D M jS H') . '\:' . date('i') . '\:' . date('s') .'</span>\r'
197+
194198
])) {
195199
$this->fail('Error writing connections graph for period '. $period .' ['. rrd_error() .']');
196200
}

RRDNetwork.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ public function graph($period = 'day', $graphPath = __DIR__)
7575
"-a", "PNG",
7676
"-v bytes/sec",
7777
"--slope-mode",
78+
"--pango-markup",
79+
7880
"DEF:in={$this->rrdFilePath}:in:AVERAGE",
7981
"DEF:maxin={$this->rrdFilePath}:in:MAX",
8082
"DEF:out={$this->rrdFilePath}:out:AVERAGE",
@@ -96,7 +98,9 @@ public function graph($period = 'day', $graphPath = __DIR__)
9698
"GPRINT:out:AVERAGE: Avg\\: %6.1lf %S",
9799
"GPRINT:out:LAST: Current\\: %6.1lf %SBytes/sec\\n",
98100

99-
"HRULE:0#000000"
101+
"HRULE:0#000000",
102+
103+
'COMMENT:<span foreground="#ABABAB" size="x-small">'. date('D M jS H') . '\:' . date('i') . '\:' . date('s') .'</span>\r'
100104
])) {
101105
$this->fail('Error writing network graph for period '. $period .' ['. rrd_error() .']');
102106
}

RRDNginx.php

+12-3
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,17 @@ public function graph($period = 'day', $graphPath = __DIR__)
8888
"-v requests/sec",
8989
"-Y",
9090
"--units-exponent=0",
91+
"--pango-markup",
92+
9193
"DEF:requests=".$this->rrdFilePath.":requests:AVERAGE",
9294
"LINE2:requests#27AE60:Requests",
9395
"GPRINT:requests:MAX: Max\\: %5.2lf",
9496
"GPRINT:requests:AVERAGE: Avg\\: %5.2lf",
95-
"GPRINT:requests:LAST: Current\\: %5.2lf req/sec",
96-
"HRULE:0#000000"
97+
"GPRINT:requests:LAST: Current\\: %5.2lf req/sec\\n",
98+
99+
"HRULE:0#000000",
100+
101+
'COMMENT:<span foreground="#ABABAB" size="x-small">'. date('D M jS H') . '\:' . date('i') . '\:' . date('s') .'</span>\r'
97102
])) {
98103
$this->fail('Error writing requests graph for period '. $period .' ['. rrd_error() .']');
99104
}
@@ -109,6 +114,8 @@ public function graph($period = 'day', $graphPath = __DIR__)
109114
"-v requests/sec",
110115
"-Y",
111116
"--units-exponent=0",
117+
"--pango-markup",
118+
112119
"DEF:total={$this->rrdFilePath}:total:AVERAGE",
113120
"DEF:reading={$this->rrdFilePath}:reading:AVERAGE",
114121
"DEF:writing={$this->rrdFilePath}:writing:AVERAGE",
@@ -138,7 +145,9 @@ public function graph($period = 'day', $graphPath = __DIR__)
138145
"GPRINT:waiting:AVERAGE: Avg\\: %5.2lf",
139146
"GPRINT:waiting:MAX: Max\\: %5.2lf\\n",
140147

141-
"HRULE:0#000000"
148+
"HRULE:0#000000",
149+
150+
'COMMENT:<span foreground="#ABABAB" size="x-small">'. date('D M jS H') . '\:' . date('i') . '\:' . date('s') .'</span>\r'
142151

143152
])) {
144153
$this->fail('Error writing connections graph for period '. $period .' ['. rrd_error() .']');

all.sh

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ php ./RRDNginx.php
22
php ./RRDCpu.php
33
php ./RRDMemory.php
44
php ./RRDNetwork.php
5+
php ./RRDDiskIO.php

0 commit comments

Comments
 (0)