xcat-core/xCAT-UI/monitor/flot_get_data.php
2009-09-10 06:57:06 +00:00

63 lines
4.9 KiB
PHP

<?php
if(!isset($TOPDIR)) { $TOPDIR="..";}
require_once "$TOPDIR/lib/security.php";
require_once "$TOPDIR/lib/functions.php";
require_once "$TOPDIR/lib/display.php";
require_once "$TOPDIR/lib/monitor_display.php";
//get the data from "monshow" command
$attr = $_REQUEST['attr'];
$xml = docmd("monshow", "", array("rmcmon","-t", "60", "-s", "-a", "$attr"));
/*
*
SimpleXMLElement Object
(
[xcatresponse] => SimpleXMLElement Object
(
[data] => Array
(
[0] => hv8plus01.ppd.pok.ibm.com-summary:
[1] => PctTotalTimeUser
[2] => Wed Sep 9 23:20:00 2009 0.0090
[3] => Wed Sep 9 23:21:00 2009 0.0097
[4] => Wed Sep 9 23:22:00 2009 0.0081
[5] => Wed Sep 9 23:23:00 2009 0.0081
[6] => Wed Sep 9 23:24:00 2009 0.0072
)
)
)
*/
$index = 0;
echo "[{label: \"$attr\", data: [";
foreach ($xml->children() as $response) foreach($response->children() as $data)
{
//remove the first 2 lines.
if($index++ < 2) {
continue;
}
//then, parse "date" & "value"
$arr = preg_split("/\s+/", $data);
array_pop($arr);
$val = array_pop($arr);
$time = implode(" ", $arr);
$timestamp = strtotime($time);
$timestamp .=1000;
if($index++==2) {
echo "[$timestamp,$val]";
} else {
echo ",[$timestamp,$val]";
}
}
echo "]}]";
//echo <<<TOS1
//[{label: "PctTotalTimeUser", data: [[1251776160000,0.0080],[1251777600000,0.0075],[1251779040000,0.0081],[1251780480000,0.0080],[1251781920000,0.0083],[1251783360000,0.0080],[1251784800000,0.0083],[1251786240000,0.0073],[1251787680000,0.0081],[1251789120000,0.0083],[1251790560000,0.0080],[1251792000000,0.0075],[1251793440000,0.0081],[1251794880000,0.0080],[1251796320000,0.0082],[1251797760000,0.0081],[1251799200000,0.0074],[1251800640000,0.0080],[1251802080000,0.0080],[1251803520000,0.0083],[1251804960000,0.0080],[1251806400000,0.0076],[1251807840000,0.0080],[1251809280000,0.0081],[1251810720000,0.0083],[1251812160000,0.0080],[1251813600000,0.0076],[1251815040000,0.0080],[1251816480000,0.0081],[1251817920000,0.0081],[1251819360000,0.0080],[1251820800000,0.0075],[1251822240000,0.0081],[1251823680000,0.0080],[1251825120000,0.0083],[1251826560000,0.0080],[1251828000000,0.0082],[1251829440000,0.0073],[1251830880000,0.0080],[1251832320000,0.0083],[1251833760000,0.0079],[1251835200000,0.0075],[1251836640000,0.0082],[1251838080000,0.0081],[1251839520000,0.0084],[1251840960000,0.0087],[1251842400000,0.0082],[1251843840000,0.0080],[1251845280000,0.0081],[1251846720000,0.0082],[1251848160000,0.0081],[1251849600000,0.0076],[1251851040000,0.0081],[1251852480000,0.0082],[1251853920000,0.0082],[1251855360000,0.0082],[1251856800000,0.0081],[1251858240000,0.0073],[1251859680000,0.0080],[1251861120000,0.0082],[1251862560000,0.0080],[1251864000000,0.0076],[1251865440000,0.0080],[1251866880000,0.0080],[1251868320000,0.0083],[1251869760000,0.0080],[1251871200000,0.0075],[1251872640000,0.0080],[1251874080000,0.0080],[1251875520000,0.0083],[1251876960000,0.0080],[1251878400000,0.0075],[1251879840000,0.0081],[1251881280000,0.0080],[1251882720000,0.0081],[1251884160000,0.0080],[1251885600000,0.0082],[1251887040000,0.0073],[1251888480000,0.0081],[1251889920000,0.0082],[1251891360000,0.0079],[1251892800000,0.0075],[1251894240000,0.0081],[1251895680000,0.0081],[1251897120000,0.0081],[1251898560000,0.0081],[1251900000000,0.0083],[1251901440000,0.0073],[1251902880000,0.0081],[1251904320000,0.0083],[1251905760000,0.0081],[1251907200000,0.0082],[1251908640000,0.0074],[1251910080000,0.0081],[1251911520000,0.0084],[1251912960000,0.0081],[1251914400000,0.0082],[1251915840000,0.0075],[1251917280000,0.0081],[1251918720000,0.0082],[1251920160000,0.0081],[1251921600000,0.0076],[1251923040000,0.0082],[1251924480000,0.0080],[1251925920000,0.0083],[1251927360000,0.0086],[1251928800000,0.0075],[1251930240000,0.0087],[1251931680000,0.0081],[1251933120000,0.0082],[1251934560000,0.0081],[1251936000000,0.0077],[1251937440000,0.0081],[1251938880000,0.0081],[1251940320000,0.0082],[1251941760000,0.0079],[1251943200000,0.0081],[1251944640000,0.0073],[1251946080000,0.0081],[1251947520000,0.0081],[1251948960000,0.0080],[1251950400000,0.0075],[1251951840000,0.0080],[1251953280000,0.0080],[1251954720000,0.0083],[1251956160000,0.0080],[1251957600000,0.0075],[1251959040000,0.0081],[1251960480000,0.0080],[1251961920000,0.0083],[1251963360000,0.0080],[1251964800000,0.0076],[1251966240000,0.0080],[1251967680000,0.0079],[1251969120000,0.0083],[1251970560000,0.0079],[1251972000000,0.0076],[1251973440000,0.0080],[1251974880000,0.0080],[1251976320000,0.0082],[1251977760000,0.0080],[1251979200000,0.0082],[1251980640000,0.0073],[1251982080000,0.0080],[1251983520000,0.0083],[1251984960000,0.0080],[1251986400000,0.0074],[1251987840000,0.0080],[1251989280000,0.0081],[1251990720000,0.0082]]}]
//TOS1;
?>