add status to node stats

by default it is unknown,
if it is a standalone node its online
else it is either 'online' or 'offline' depending on the corosync status

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2017-11-03 09:51:32 +01:00 committed by Fabian Grünbichler
parent 4d8a345568
commit b67e63988a

View File

@ -33,6 +33,7 @@ sub extract_node_stats {
id => "node/$node",
node => $node,
type => "node",
status => 'unknown',
};
if (my $d = $rrd->{"pve2-node/$node"}) {
@ -43,6 +44,7 @@ sub extract_node_stats {
$entry->{cpu} = ($d->[5] || 0) + 0;
$entry->{mem} = ($d->[8] || 0) + 0;
$entry->{disk} = ($d->[12] || 0) + 0;
$entry->{status} = 'online';
}
$entry->{level} = $d->[1];
$entry->{maxcpu} = ($d->[4] || 0) + 0;
@ -50,6 +52,11 @@ sub extract_node_stats {
$entry->{maxdisk} = ($d->[11] || 0) + 0;
}
if ($members && $members->{$node} &&
!$members->{$node}->{online}) {
$entry->{status} = 'offline';
}
return $entry;
}