increase type of output graphs.
This commit is contained in:
parent
3674880f07
commit
d79f1aa172
@ -135,21 +135,22 @@ class Temperature
|
|||||||
* output graph.
|
* output graph.
|
||||||
*
|
*
|
||||||
* @param string $type output graph type
|
* @param string $type output graph type
|
||||||
|
* @param int $num output period of graph type
|
||||||
* @param string $fpath output image file path
|
* @param string $fpath output image file path
|
||||||
*
|
*
|
||||||
* @return bool false if failure
|
* @return bool false if failure
|
||||||
*/
|
*/
|
||||||
public function outputGraph(string $type, string $fpath): bool
|
public function outputGraph(string $type, int $num, string $fpath): bool
|
||||||
{
|
{
|
||||||
static $colors = [
|
static $colors = [
|
||||||
'#FF0000', '#00FF00', '#0000FF', '#FFFF00', '#00FFFF', '#FF00FF',
|
'#FF0000', '#00FF00', '#0000FF', '#FFFF00', '#00FFFF', '#FF00FF',
|
||||||
'#FF9999', '#99FF99', '#9999FF', '#FFFF99', '#99FFFF', '#FF99FF',
|
'#FF9999', '#99FF99', '#9999FF', '#FFFF99', '#99FFFF', '#FF99FF',
|
||||||
];
|
];
|
||||||
static $types = ['hour', 'day', 'week', 'month', 'year', '3year'];
|
static $types = ['hour', 'day', 'week', 'month', 'year'];
|
||||||
if (!in_array($type, $types)) {
|
if (!in_array($type, $types)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$start = '3year' == $type ? '-3year' : '-1'.$type;
|
$start = sprintf('-%u%s', $num, $type);
|
||||||
$options = [
|
$options = [
|
||||||
'--imgformat', 'PNG',
|
'--imgformat', 'PNG',
|
||||||
'--lower-limit', '10',
|
'--lower-limit', '10',
|
||||||
@ -160,7 +161,7 @@ class Temperature
|
|||||||
'--height', '200',
|
'--height', '200',
|
||||||
'--units-exponent', '0',
|
'--units-exponent', '0',
|
||||||
'--vertical-label', "Temperature [\xc2\xb0C]",
|
'--vertical-label', "Temperature [\xc2\xb0C]",
|
||||||
'--title', 'Server Room Temperature - by '.$type,
|
'--title', 'Server Room Temperature - by '.$num.$type.'(s)',
|
||||||
];
|
];
|
||||||
$idlen = 0;
|
$idlen = 0;
|
||||||
foreach ($this->sensorIds as $key => $id) {
|
foreach ($this->sensorIds as $key => $id) {
|
||||||
|
@ -16,7 +16,16 @@ for ($i = 0; $i < $num; ++$i) {
|
|||||||
$now = time();
|
$now = time();
|
||||||
$rrdtemp->update($id, $now, $value);
|
$rrdtemp->update($id, $now, $value);
|
||||||
}
|
}
|
||||||
foreach ($types = ['hour', 'day', 'week', 'month', 'year', '3year'] as $type) {
|
$types = [
|
||||||
$fpath = APPDIR.'/'.$config['images_dir'].'/graph-'.$type.'.png';
|
'hour' => [1, 3, 6, 12],
|
||||||
$rrdtemp->outputGraph($type, $fpath);
|
'day' => [1, 3],
|
||||||
|
'week' => [1, 2],
|
||||||
|
'month' => [1, 3, 6],
|
||||||
|
'year' => [1, 3, 5, 10],
|
||||||
|
];
|
||||||
|
foreach ($types as $type => $nums) {
|
||||||
|
foreach ($nums as $num) {
|
||||||
|
$fpath = APPDIR.'/'.$config['images_dir'].'/graph-'.(1 === $num ? '' : $num).$type.'.png';
|
||||||
|
$rrdtemp->outputGraph($type, $num, $fpath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user