[pve-devel] r5520 - in pve-manager/pve2: debian lib/PVE/API2 www/css www/manager

svn-commits at proxmox.com svn-commits at proxmox.com
Mon Feb 14 11:56:49 CET 2011


Author: dietmar
Date: 2011-02-14 11:56:49 +0100 (Mon, 14 Feb 2011)
New Revision: 5520

Modified:
   pve-manager/pve2/debian/control.in
   pve-manager/pve2/lib/PVE/API2/Nodes.pm
   pve-manager/pve2/www/css/ext-pve.css
   pve-manager/pve2/www/manager/NodeConfig.js
   pve-manager/pve2/www/manager/PVEUtils.js
Log:
implement status view


Modified: pve-manager/pve2/debian/control.in
===================================================================
--- pve-manager/pve2/debian/control.in	2011-02-14 07:36:33 UTC (rev 5519)
+++ pve-manager/pve2/debian/control.in	2011-02-14 10:56:49 UTC (rev 5520)
@@ -3,7 +3,7 @@
 Section: admin
 Priority: optional
 Architecture: all
-Depends: perl5, libtimedate-perl, apache2-mpm-prefork, libauthen-pam-perl, libintl-perl, rsync, libapache2-request-perl, libjson-perl, libdigest-sha1-perl, vncterm, qemu-server (>= 1.1-1), libwww-perl, wget, libnet-dns-perl, vlan, ifenslave-2.6 (>= 1.1.0-10), liblinux-inotify2-perl, debconf (>= 0.5) | debconf-2.0, libjs-prototype (>= 1.6.0.3-1), netcat-traditional, pve-cluster, libpve-common-perl, libpve-storage-perl, libterm-readline-gnu-perl, libhttp-request-params-perl, libpve-access-control, libio-socket-ssl-perl
+Depends: perl5, libtimedate-perl, apache2-mpm-prefork, libauthen-pam-perl, libintl-perl, rsync, libapache2-request-perl, libjson-perl, libdigest-sha1-perl, vncterm, qemu-server (>= 1.1-1), libwww-perl, wget, libnet-dns-perl, vlan, ifenslave-2.6 (>= 1.1.0-10), liblinux-inotify2-perl, debconf (>= 0.5) | debconf-2.0, libjs-prototype (>= 1.6.0.3-1), netcat-traditional, pve-cluster, libpve-common-perl, libpve-storage-perl, libterm-readline-gnu-perl, libhttp-request-params-perl, libpve-access-control, libio-socket-ssl-perl, libfilesys-df-perl
 Conflicts: netcat-openbsd
 Maintainer: Proxmox Support Team <support at proxmox.com>
 Description: The Proxmox Virtual Environment

Modified: pve-manager/pve2/lib/PVE/API2/Nodes.pm
===================================================================
--- pve-manager/pve2/lib/PVE/API2/Nodes.pm	2011-02-14 07:36:33 UTC (rev 5519)
+++ pve-manager/pve2/lib/PVE/API2/Nodes.pm	2011-02-14 10:56:49 UTC (rev 5520)
@@ -2,8 +2,12 @@
 
 use strict;
 use warnings;
+use POSIX;
+use Filesys::Df;
 use Time::Local qw(timegm_nocheck);
+use PVE::pvecfg;
 use PVE::Tools;
+use PVE::ProcFSTools;
 use PVE::SafeSyslog;
 use PVE::Cluster;
 use PVE::INotify;
@@ -63,6 +67,7 @@
     
 	my $result = [
 	    { name => 'syslog' },
+	    { name => 'status' },
 	    { name => 'vncshell' },
 	    { name => 'time' },
 	    { name => 'dns' },
@@ -77,6 +82,76 @@
     }});
 
 __PACKAGE__->register_method({
+    name => 'status', 
+    path => 'status', 
+    method => 'GET',
+    description => "Read node status",
+    proxyto => 'node',
+    parameters => {
+    	additionalProperties => 0,
+	properties => {
+	    node => get_standard_option('pve-node'),
+	},
+    },
+    returns => {
+	type => "object",
+	properties => {
+
+	},
+    },
+    code => sub {
+	my ($param) = @_;
+
+	my $res = {
+	    uptime => 0,
+	    idle => 0,
+	};
+
+	my ($uptime, $idle) = PVE::ProcFSTools::read_proc_uptime();
+	$res->{uptime} = $uptime;
+	
+	my ($avg1, $avg5, $avg15) = PVE::ProcFSTools::read_loadavg();
+	$res->{loadavg} = [ $avg1, $avg5, $avg15];
+   
+	my ($sysname, $nodename, $release, $version, $machine) = POSIX::uname();
+
+	$res->{kversion} = "$sysname $release $version";
+
+	$res->{cpuinfo} = PVE::ProcFSTools::read_cpuinfo();
+
+	my $stat = PVE::ProcFSTools::read_proc_stat();
+	$res->{cpu} = $stat->{cpu};
+	$res->{wait} = $stat->{wait};
+
+	my $meminfo = PVE::ProcFSTools::read_meminfo();
+	$res->{memory} = {
+	    free => $meminfo->{memfree},
+	    total => $meminfo->{memtotal},
+	    used => $meminfo->{memused},
+	};
+	$res->{swap} = {
+	    free => $meminfo->{swapfree},
+	    total => $meminfo->{swaptotal},
+	    used => $meminfo->{spawused},
+	};
+
+	$res->{pveversion} = PVE::pvecfg::package() . "/" .
+	    PVE::pvecfg::version() . "/" .
+	    PVE::pvecfg::repoid();
+
+	my $dinfo = df('/', 1);     # output is bytes
+
+	$res->{rootfs} = {
+	    total => $dinfo->{blocks},
+	    avail => $dinfo->{bavail},
+	    used => $dinfo->{used},
+	    free => $dinfo->{bavail} - $dinfo->{used},
+	};
+
+	return $res;
+    }});
+
+__PACKAGE__->register_method({
     name => 'syslog', 
     path => 'syslog', 
     method => 'GET',

Modified: pve-manager/pve2/www/css/ext-pve.css
===================================================================
--- pve-manager/pve2/www/css/ext-pve.css	2011-02-14 07:36:33 UTC (rev 5519)
+++ pve-manager/pve2/www/css/ext-pve.css	2011-02-14 10:56:49 UTC (rev 5520)
@@ -53,7 +53,37 @@
     height:6px;
 }
 
+.pve-largebar-border
+{
+    position:relative;
+    padding:0px;
+    background-color:#C0C0C0;
+    border:1px solid #000000;
+    width:200px;
+    height:12px;
+}
 
+.pve-largebar-inner
+{
+    background-color: #00C000;
+    border:0px;
+    height:12px;
+}
+
+.pve-largebar-text
+{
+    position:absolute;
+    top:0px;
+    left:0px;
+    text-align:center; 
+    line-height: 12px;
+    font-size: 11px;
+    border:0px;
+    width:200px;
+    height:12px;
+}
+
+
 /*!
  * Ext JS Library 3.2.1
  * Copyright(c) 2006-2010 Ext JS, Inc.

Modified: pve-manager/pve2/www/manager/NodeConfig.js
===================================================================
--- pve-manager/pve2/www/manager/NodeConfig.js	2011-02-14 07:36:33 UTC (rev 5519)
+++ pve-manager/pve2/www/manager/NodeConfig.js	2011-02-14 10:56:49 UTC (rev 5520)
@@ -929,6 +929,87 @@
 });
 Ext.reg('pveNodeServiceView', PVE.NodeServiceView);
 
+PVE.NodeStatusView = Ext.extend(PVE.grid.ObjectView, {
+
+    initComponent : function() {
+	var self = this;
+
+	var nodename = self.nodename;
+
+	if (!nodename) 
+	    throw "no node name specified";
+
+	var render_cpuinfo = function(value) {
+	    return value.cpus + " x " + value.model;
+	};
+
+	var render_loadavg = function(value) {
+	    return value[0] + ", " + value[1] + ", " + value[2]; 
+	};
+
+	var render_cpu = function(value) {
+	    return PVE.Utils.format_large_bar(value*100);
+	};
+
+	var render_meminfo_old = function(value) {
+	    var per = (value.used / value.total)*100;
+	    var text = PVE.Utils.format_size(value.used) + "/" + 
+		PVE.Utils.format_size(value.total);
+	    return PVE.Utils.format_large_bar(per, text);
+	};
+
+	var render_meminfo = function(value) {
+	    var per = (value.used / value.total)*100;
+	    var text = "<div>Total: " + PVE.Utils.format_size(value.total) + "</div>" + 
+		"<div>Used: " + PVE.Utils.format_size(value.used) + "</div>";
+	    return text + PVE.Utils.format_large_bar(per);
+	};
+
+	var store = new PVE.data.ObjectStore({
+	    url: "/api2/json/nodes/" + nodename + "/status",
+	    method: 'GET',
+	    rows: {
+		uptime: { header: 'Uptime', renderer: PVE.Utils.format_duration_long },
+		loadavg: { header: 'Load average', renderer: render_loadavg },
+		cpuinfo: { header: 'CPUs', renderer: render_cpuinfo },
+		cpu: { header: 'CPU usage', renderer: render_cpu },
+		wait: { header: 'IO delay', renderer: render_cpu },
+		memory: { header: 'RAM usage', renderer: render_meminfo },
+		swap: { header: 'SWAP usage', renderer: render_meminfo },
+		rootfs: { header: 'HD space (root)', renderer: render_meminfo },
+		pveversion: { header: 'PVE Manager version' },
+		kversion: { header: 'Kernel version' }
+	    }
+	});
+
+	var load_task = new Ext.util.DelayedTask(function(delay) {
+	    store.load();
+	    load_task.delay(delay === undefined ? 1000 : delay);
+	});
+
+	Ext.apply(self, {
+	    store: store,
+	    layout: 'fit',
+	    cwidth1: 150,
+	    listeners: {
+		show: function() {
+		    load_task.delay(10);
+		    store.load();
+		},
+		hide: function() {
+		    load_task.cancel();
+		},
+		destroy: function() {
+		    load_task.cancel();
+		}
+	    }
+	});
+
+	PVE.NodeStatusView.superclass.initComponent.call(self);
+    }
+});
+Ext.reg('pveNodeStatusView', PVE.NodeStatusView);
+
 PVE.NodeConfig = Ext.extend(PVE.ConfigPanel, {
 
     initComponent : function() {
@@ -957,7 +1038,8 @@
 			    }
 			}
 		    ],
-		    html: 'summary ' + nodename
+		    xtype: 'pveNodeStatusView',
+		    nodename: nodename
 		},
 		{
 		    title: 'Services',

Modified: pve-manager/pve2/www/manager/PVEUtils.js
===================================================================
--- pve-manager/pve2/www/manager/PVEUtils.js	2011-02-14 07:36:33 UTC (rev 5519)
+++ pve-manager/pve2/www/manager/PVEUtils.js	2011-02-14 10:56:49 UTC (rev 5520)
@@ -84,7 +84,7 @@
 	    
 	},
 
-	formar_cpu_bar: function(per1, per2, text) {
+	format_cpu_bar: function(per1, per2, text) {
 
 	    return "<div class='pve-bar-border'>" +
 		"<div class='pve-bar-inner' style='width:" + per1 + "%;'></div>" +
@@ -93,6 +93,17 @@
 		"</div>";
 	},
 
+	format_large_bar: function(per, text) {
+
+	    if (!text)
+		text = per.toFixed(1) + "%";
+
+	    return "<div class='pve-largebar-border'>" +
+		"<div class='pve-largebar-inner' style='width:" + per + "%;'></div>" +
+		"<div class='pve-largebar-text'>" + text + "</div>" + 
+		"</div>";
+	},
+
 	format_duration_long: function(ut) {
 
 	    var days = Math.floor(ut / 86400);



More information about the pve-devel mailing list