From 40fd98ff95a2e1b07de824e962f00653d661ac4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Guzm=C3=A1n=20Maeso?= <=> Date: Fri, 17 Feb 2012 05:14:43 +0100 Subject: [PATCH] Improve the var naming empty values of find_cpuusage function and create phpdoc documentation --- .../httpdocs/lib/vps/driver/vps__xenlib.php | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/hypervm/httpdocs/lib/vps/driver/vps__xenlib.php b/hypervm/httpdocs/lib/vps/driver/vps__xenlib.php index 2572fe4a..be1ca711 100644 --- a/hypervm/httpdocs/lib/vps/driver/vps__xenlib.php +++ b/hypervm/httpdocs/lib/vps/driver/vps__xenlib.php @@ -1,20 +1,32 @@ + * @author Ángel Guzmán Maeso + * + * @return void + */ public static function find_cpuusage() { - $out = lxshell_output("xm", "list"); - $list = explode("\n", $out); + $xen_list_output = lxshell_output('xm', 'list'); + $xen_list_lines = explode("\n", $xen_list_output); - foreach($list as $l) { - $l = trimSpaces($l); - $val = explode(" ", $l); - - if (!cse($val[0], ".vm")) { - continue; + if(!empty($xen_list_lines)) { + foreach($xen_list_lines as $line) { + $line = trimSpaces($line); + $value = explode(' ', $line); + + if (!cse($value[0], '.vm')) { + continue; + } + + execRrdSingle('cpu', 'DERIVE', $value[0], $value[5]); } - execRrdSingle("cpu", "DERIVE", $val[0], $val[5]); } }