[pve-devel] [PATCH manager v2 1/7] add status to node stats

Dominik Csapak d.csapak at proxmox.com
Wed May 3 16:35:15 CEST 2017


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 at proxmox.com>
---
 PVE/API2Tools.pm | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/PVE/API2Tools.pm b/PVE/API2Tools.pm
index 24947753..78eb4718 100644
--- a/PVE/API2Tools.pm
+++ b/PVE/API2Tools.pm
@@ -31,6 +31,7 @@ sub extract_node_stats {
 	id => "node/$node",
 	node => $node,
 	type => "node",
+	status => 'unknown',
     };
 
     if (my $d = $rrd->{"pve2-node/$node"}) {
@@ -41,6 +42,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;
@@ -48,6 +50,11 @@ sub extract_node_stats {
 	$entry->{maxdisk} = ($d->[11] || 0) + 0;
     }
 
+    if ($members && $members->{$node} &&
+	!$members->{$node}->{online}) {
+	$entry->{status} = 'offline';
+    }
+
     return $entry;
 }
 
-- 
2.11.0





More information about the pve-devel mailing list