[pve-devel] r5982 - in pve-manager/pve2: debian lib/PVE/API2 www/new/qemu
svn-commits at proxmox.com
svn-commits at proxmox.com
Mon May 16 10:45:38 CEST 2011
Author: dietmar
Date: 2011-05-16 10:45:38 +0200 (Mon, 16 May 2011)
New Revision: 5982
Modified:
pve-manager/pve2/debian/control.in
pve-manager/pve2/lib/PVE/API2/Nodes.pm
pve-manager/pve2/www/new/qemu/Config.js
Log:
move RRD code to PVE::Cluster
display qemu RRD data
Modified: pve-manager/pve2/debian/control.in
===================================================================
--- pve-manager/pve2/debian/control.in 2011-05-16 08:37:18 UTC (rev 5981)
+++ pve-manager/pve2/debian/control.in 2011-05-16 08:45:38 UTC (rev 5982)
@@ -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, 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, librrds-perl, rrdcached, libfile-readbackwards-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, 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, libfile-readbackwards-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-05-16 08:37:18 UTC (rev 5981)
+++ pve-manager/pve2/lib/PVE/API2/Nodes.pm 2011-05-16 08:45:38 UTC (rev 5982)
@@ -21,7 +21,6 @@
use PVE::API2::Storage::Status;
use PVE::API2::Qemu;
use JSON;
-use RRDs;
use base qw(PVE::RESTHandler);
@@ -299,8 +298,7 @@
path => '/nodes/{node}',
privs => [ 'Sys.Audit' ],
},
- description => "Read node RRD statistics",
-# proxyto => 'node',
+ description => "Read node RRD statistics (returns PNG)",
parameters => {
additionalProperties => 0,
properties => {
@@ -331,60 +329,10 @@
code => sub {
my ($param) = @_;
-# this is just some test code. Using RRD graph is clumsy - maybe it
-# is better to simply fetch the data, and do all display
-# related things with javascript (new extjs html5 graph library).
-
- my $rrddir = "/var/lib/rrdcached/db";
+ return PVE::Cluster::create_rrd_graph(
+ "pve2-node/$param->{node}", $param->{timeframe},
+ $param->{ds}, $param->{cf});
- my $rrd = "$rrddir/pve2-node/$param->{node}";
-
- my $filename = "$rrd.png";
-
- my $setup = {
- hour => [ 60, 60 ],
- day => [ 60*30, 70 ],
- week => [ 60*180, 70 ],
- month => [ 60*720, 70 ],
- year => [ 60*10080, 70 ],
- };
-
- my ($reso, $count) = @{$setup->{$param->{timeframe}}};
-
- my @args = (
- "--daemon" => "unix:/var/run/rrdcached.sock",
- "--imgformat" => "PNG",
- "--border" => 0,
- "--height" => 200,
- "--width" => 800,
- "--start" => - $reso*$count,
- "--end" => 'now' ,
- );
-
- my @ids = PVE::Tools::split_list($param->{ds});
-
- my @coldef = ('#00ddff', '#ff0000');
-
- my $cf = $param->{cf} || "AVERAGE";
-
- my $i = 0;
- foreach my $id (@ids) {
- my $col = $coldef[$i++] || die "fixme: no color definition";
- push @args, "DEF:${id}=$rrd:${id}:$cf";
- my $dataid = $id;
- if ($id eq 'cpu' || $id eq 'iowait') {
- push @args, "CDEF:${id}_per=${id},100,*";
- $dataid = "${id}_per";
- }
- push @args, "LINE2:${dataid}${col}:${id}";
- }
-
- RRDs::graph($filename, @args);
-
- my $err = RRDs::error;
- die "RRD error: $err\n" if $err;
-
- return { filename => $filename };
}});
__PACKAGE__->register_method({
@@ -397,7 +345,6 @@
privs => [ 'Sys.Audit' ],
},
description => "Read node RRD statistics",
-# proxyto => 'node',
parameters => {
additionalProperties => 0,
properties => {
@@ -406,7 +353,13 @@
description => "Specify the time frame you are interested in.",
type => 'string',
enum => [ 'hour', 'day', 'week', 'month', 'year' ],
- }
+ },
+ cf => {
+ description => "The RRD consolidation function",
+ type => 'string',
+ enum => [ 'AVERAGE', 'MAX' ],
+ optional => 1,
+ },
},
},
returns => {
@@ -419,57 +372,8 @@
code => sub {
my ($param) = @_;
- my $rrddir = "/var/lib/rrdcached/db";
- my $filename = "$rrddir/pve2-node/$param->{node}";
-
- my $setup = {
- hour => [ 60, 70 ],
- day => [ 60*30, 70 ],
- week => [ 60*180, 70 ],
- month => [ 60*720, 70 ],
- year => [ 60*10080, 70 ],
- };
-
- my ($reso, $count) = @{$setup->{$param->{timeframe}}};
- my $ctime = $reso*int(time()/$reso);
- my $req_start = $ctime - $reso*$count;
-
- print "TEST $filename\n";
-
- my ($start, $step, $names, $data) =
- RRDs::fetch($filename, 'AVERAGE',
- "-s" => $req_start,
- "-e" => $ctime - 1,
- "-r" => $reso,
- "--daemon" => "unix:/var/run/rrdcached.sock");
-
- my $err = RRDs::error;
- die "RRD error: $err\n" if $err;
-
- die "got wrong time resolution ($step != $reso)\n"
- if $step != $reso;
-
-
- my $res = [];
- my $fields = scalar(@$names);
- for my $line (@$data) {
- my $entry = { 'time' => $start };
- $start += $step;
- my $found_undefs;
- for (my $i = 0; $i < $fields; $i++) {
- my $name = $names->[$i];
- if (defined(my $val = $line->[$i])) {
- $entry->{$name} = $val;
- } else {
- # we only add entryies with all data defined
- # extjs chart has problems with undefined values
- $found_undefs = 1;
- }
- }
- push @$res, $entry if !$found_undefs;
- }
-
- return $res;
+ return PVE::Cluster::create_rrd_data(
+ "pve2-node/$param->{node}", $param->{timeframe}, $param->{cf});
}});
__PACKAGE__->register_method({
Modified: pve-manager/pve2/www/new/qemu/Config.js
===================================================================
--- pve-manager/pve2/www/new/qemu/Config.js 2011-05-16 08:37:18 UTC (rev 5981)
+++ pve-manager/pve2/www/new/qemu/Config.js 2011-05-16 08:45:38 UTC (rev 5982)
@@ -64,12 +64,20 @@
initComponent: function() {
var me = this;
- //var rrdurl = "/api2/png/nodes/" + nodename + "/rrd";
+ var nodename = me.pveSelNode.data.node;
+ if (!nodename)
+ throw "no node name specified";
+
+ var vmid = me.pveSelNode.data.vmid;
+ if (!vmid)
+ throw "no VM ID specified";
+
+ var rrdurl = "/api2/png/nodes/" + nodename + "/qemu/" + vmid + "/rrd";
Ext.apply(me, {
layout: {
type: 'table',
- columns: 2
+ columns: 1
},
autoScroll: true,
bodyStyle: 'padding:10px',
@@ -87,24 +95,55 @@
},
items: [
{
- title: 'Status',
- xtype: 'pveQemuStatusView',
- width: 400
+ layout: {
+ type: 'hbox',
+ align: 'stretchmax'
+ },
+ listeners: {
+ show: function() {
+ this.items.each(function(item) { item.fireEvent('show', item); });
+ },
+ hide: function() {
+ this.items.each(function(item) { item.fireEvent('hide', item); });
+ }
+ },
+ width: 800,
+ border: false,
+ items: [
+ {
+ title: 'Status',
+ xtype: 'pveQemuStatusView',
+ pveSelNode: me.pveSelNode,
+ width: 400
+ },
+ {
+ title: 'Comments',
+ style: 'padding-left:10px',
+ pveSelNode: me.pveSelNode,
+ html: "test",
+ width: 400
+ }
+ ]
},
+
{
- title: 'Comments',
- style: 'padding-left:10px',
- html: "test",
- width: 400,
- autoHeight: true
- }
-
- /*{
xtype: 'pveRRDView',
title: "CPU usage %",
- datasource: 'cpu,iowait',
+ datasource: 'cpu',
rrdurl: rrdurl
- }*/
+ },
+ {
+ xtype: 'pveRRDView',
+ title: "Memory usage",
+ datasource: 'mem,maxmem',
+ rrdurl: rrdurl
+ },
+ {
+ xtype: 'pveRRDView',
+ title: "Network traffic",
+ datasource: 'netin,netout',
+ rrdurl: rrdurl
+ }
]
});
More information about the pve-devel
mailing list