Commit 950cdcee authored by anne munoz's avatar anne munoz Committed by Adam Wujek

www: wr_mon -w get information improved

Fixed: Extract WR data in one place ... draw in many!
Fixed: Replace tail | head by grep if possible
parent e4b2d3cb
<?php
/*
* Obtain info from wr_mon
*
* @author Anne M. <anne@sevensols.com>
*
*/
include 'functions.php';
#Save info to temp file so we dont have to execute command at each call
function createTempDataFile(){
shell_exec("/wr/bin/wr_mon -w > /tmp/wrinfo");
}
createTempDataFile();
#Obtain the temperatures
function getTemperatures(){
$temperatures=shell_exec("cat /tmp/wrinfo | grep TEMP");
$temperatures = split(" ", $temperatures);
return $temperatures;
}
function getFgpaTemperatures(){
$temperatures=shell_exec("cat /tmp/wrinfo | grep TEMP");
$arr = split(" ", $temperatures);
$temperatures = $arr[1];
return $temperatures;
}
#Obtain the wr servo timing
function getTiming(){
$ports = shell_exec("cat /tmp/wrinfo | grep SERVO");
$ports = explode(" ", $ports);
$txt = $ports;
return $txt;
}
#Obtain wr date
function getWrDate(){
$wr_date = str_replace("\n","<br>", shell_exec("/wr/bin/wr_date -n get |tail -2"));
return $wr_date;
}
#Obtain the wr info as html table
function getTablePortStatus(){
ob_start();
draw_table();
$sfp = ob_get_contents();
ob_end_clean();
return $sfp;
}
#Obtain the wr info
function getPortStatus(){
$wrinfo=shell_exec("cat /tmp/wrinfo | grep wri");
$wrinfo = explode("\n", $wrinfo);
return $wrinfo;
}
?>
......@@ -8,41 +8,15 @@
*/
include 'json.php';
include 'functions.php';
include 'functionsget.php';
$data = array();
#Obtain the temperatures using the last line of (wr-mon -w)
$temperatures=shell_exec("/wr/bin/wr_mon -w | tail -1");
$arr = split(" ", $temperatures);
$temperatures = $arr[1];
array_push($data, $temperatures);
#Obtain wr date
$wr_date = str_replace("\n","<br>", shell_exec("/wr/bin/wr_date -n get |tail -2"));
array_push($data, $wr_date);
$sfp = updateSfp();
array_push($data, $sfp);
$timing = getTimingParams();
array_push($data, $timing);
array_push($data, getFgpaTemperatures());
array_push($data, getWrDate());
array_push($data, getTablePortStatus());
array_push($data, getTiming());
echo __json_encode($data);
function getTimingParams(){
$ports = shell_exec("/wr/bin/wr_mon -w | tail -2 | head -1");
$ports = explode(" ", $ports);
$txt = $ports;
return $txt;
}
function updateSfp(){
ob_start();
draw_table();
$txt = ob_get_contents();
ob_end_clean();
return $txt;
}
?>
......@@ -8,27 +8,14 @@
*/
include 'json.php';
include 'functionsget.php';
$data = array();
#Obtain the wr info
$wrinfo=shell_exec("/wr/bin/wr_mon -w | head -19 | tail -18");
$wrinfo = explode("\n", $wrinfo);
array_push($data, $wrinfo);
#Obtain the temperatures using the last line of (wr-mon -w)
$temperatures = shell_exec("/wr/bin/wr_mon -w | tail -1");
$temperatures = explode(" ",$temperatures);
array_push($data, $temperatures);
#Obtain wr date
$wr_date = shell_exec("/wr/bin/wr_date -n get |tail -2");
$wr_date = explode("\n",$wr_date);
array_push($data, $wr_date);
$ports = shell_exec("/wr/bin/wr_mon -w | tail -2 | head -1");
$ports = explode(" ", $ports);
array_push($data, $ports);
array_push($data, getPortStatus());
array_push($data, getTemperatures());
array_push($data, getWrDate());
array_push($data, getTiming());
echo __json_encode($data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment