fixed some minor UI bugs

fixed problem with offline tsm servers with polld
speeded up polld
This commit is contained in:
Michael Clemens 2009-05-11 10:58:53 +00:00
parent 14fb779ea1
commit e519fa54bc
3 changed files with 99 additions and 89 deletions

View File

@ -127,7 +127,7 @@ function initialize() {
} }
if (($_POST['Poll'] == "Poll Now!" || $_SESSION['timemachine']['date'] == "") && $queryarray[$GETVars['qq']]["polltype"]=="snapshot" || $_POST['s'] != "") { if (($_POST['Poll'] == "Poll Now!" || $_SESSION['timemachine']['date'] == "") && $queryarray[$GETVars['qq']]["polltype"]=="snapshot" || $_POST['s'] != "" && $GETVars['qq'] != "overview") {
$qtable = $configarray["queryarray"][$GETVars['qq']]["name"]; $qtable = $configarray["queryarray"][$GETVars['qq']]["name"];
$sql = "SELECT MAX(TimeStamp) FROM res_".$qtable."_".$GETVars["server"]; $sql = "SELECT MAX(TimeStamp) FROM res_".$qtable."_".$GETVars["server"];
$res = fetchArrayDB($sql, $conn); $res = fetchArrayDB($sql, $conn);
@ -734,14 +734,8 @@ function execute($type = 'table') {
$outp_cache = ''; $outp_cache = '';
$stop=FALSE; $stop=FALSE;
$tablearray = array(); $tablearray = array();
$bContinue = TRUE;
/**
$query = ereg_replace("NOTEQUAL","<>",$query);
$query = ereg_replace("LESS","<",$query);
if (isset($timetablestarttime) && $timetablestarttime != "") {
$query = ereg_replace("SEARCHFIELD","$timetablestarttime",$query);
**/
if ($GETVars['ob'] != '' ) { if ($GETVars['ob'] != '' ) {
$sqlappend = " order by `".$GETVars['ob']."` ".$GETVars['orderdir']; $sqlappend = " order by `".$GETVars['ob']."` ".$GETVars['orderdir'];
} elseif ($configarray["queryarray"][$GETVars['qq']]["orderby"] != '') { } elseif ($configarray["queryarray"][$GETVars['qq']]["orderby"] != '') {
@ -752,7 +746,6 @@ function execute($type = 'table') {
$polltype = $configarray["queryarray"][$GETVars['qq']]["polltype"]; $polltype = $configarray["queryarray"][$GETVars['qq']]["polltype"];
if ($polltype == "snapshot") { if ($polltype == "snapshot") {
//if ($_SESSION['timemachine']['time'] == date) {
if ($_SESSION['timemachine']['time'] == $_SESSION['timemachine']['date']) { if ($_SESSION['timemachine']['time'] == $_SESSION['timemachine']['date']) {
$timestampquery = " WHERE timestamp=(SELECT MAX(TimeStamp) FROM res_".$qtable."_".$server.")"; $timestampquery = " WHERE timestamp=(SELECT MAX(TimeStamp) FROM res_".$qtable."_".$server.")";
} else { } else {
@ -763,8 +756,6 @@ function execute($type = 'table') {
} }
// get only latest entry // get only latest entry
//if ($whereclause["field"]!="" && $whereclause["val"]!="") {
$searcharr = $_SESSION["search"][$GETVars['qq']]; $searcharr = $_SESSION["search"][$GETVars['qq']];
if (isset($searcharr) && $searcharr["field"] != "" && $searcharr["val"] != "") { if (isset($searcharr) && $searcharr["field"] != "" && $searcharr["val"] != "") {
if ($polltype == "snapshot") { if ($polltype == "snapshot") {
@ -785,12 +776,15 @@ function execute($type = 'table') {
$columnnames = getTableFields("res_".$qtable."_".$server); $columnnames = getTableFields("res_".$qtable."_".$server);
if ($columnnames == "") $bContinue = FALSE;
//execute the constructed query //execute the constructed query
$sql = "SELECT ".$columnnames." from res_".$qtable."_".$server.$timestampquery.$wc.$sqlappend; $sql = "SELECT ".$columnnames." from res_".$qtable."_".$server.$timestampquery.$wc.$sqlappend;
$_SESSION["lastsql"] = $sql; $_SESSION["lastsql"] = $sql;
if ($sqlres) $message = $sql; if ($sqlres) $message = $sql;
if ($bContinue) {
if ($type == "table") { if ($type == "table") {
$i = 1; $i = 1;
$rs = fetchSplitArrayDB($sql,$conn,20); $rs = fetchSplitArrayDB($sql,$conn,20);
@ -850,6 +844,7 @@ function execute($type = 'table') {
array_push($outp, $rowarray2); array_push($outp, $rowarray2);
} }
} }
}
return $outp; return $outp;
} }
@ -863,7 +858,7 @@ function execute($type = 'table') {
* *
* @return string * @return string
*/ */
/**
function getCustomQuery() { function getCustomQuery() {
global $GETVars; global $GETVars;
@ -929,6 +924,8 @@ function getCustomQuery() {
return $input.$header.$outp; return $input.$header.$outp;
} }
**/
/** /**
* getSearchfield - returns the HTML code of the upper searchfield panel * getSearchfield - returns the HTML code of the upper searchfield panel
@ -1066,7 +1063,7 @@ function getPollDStat() {
} }
$nav = showPageNavigation("20"); $nav = showPageNavigation("20");
if ($nav!="") { if ($nav!="") {
$outp = $outp."<tr><td colspan='0' align='center' class='footer'><a class='navhead'>".$nav."</a></td></tr>"; $outp = $outp."<tr><td colspan='6' align='center' class='footer'><a class='navhead'>".$nav."</a></td></tr>";
} }
return $outp."</table>"; return $outp."</table>";
@ -1339,7 +1336,6 @@ function getConfigArray() {
$menuarrayxml = $queryconfigarray["navigation"]["mainmenuitem"]; $menuarrayxml = $queryconfigarray["navigation"]["mainmenuitem"];
$mainmenuarrayxml = $menuarrayxml; $mainmenuarrayxml = $menuarrayxml;
$mainmenuarray["trennlinie"] = "trennlinie"; $mainmenuarray["trennlinie"] = "trennlinie";
$mainmenuarray["q=custom&m=main"] = "Custom TSM Query";
$mainmenuarray["q=polldstat&m=main"] = "Polling Daemon Log"; $mainmenuarray["q=polldstat&m=main"] = "Polling Daemon Log";
$mainmenuarray["q=serverlist&m=main"] = "Change Server"; $mainmenuarray["q=serverlist&m=main"] = "Change Server";
if ($_SESSION["logindata"]["role"] == "admin") $mainmenuarray["admin"] = "Admin"; if ($_SESSION["logindata"]["role"] == "admin") $mainmenuarray["admin"] = "Admin";
@ -1366,7 +1362,6 @@ function getConfigArray() {
$submenuarray[$url] = $submenuitem_label; $submenuarray[$url] = $submenuitem_label;
} }
$submenuarray["trennlinie"] = "trennlinie"; $submenuarray["trennlinie"] = "trennlinie";
$submenuarray["q=custom&m=".$submenu['name']] = "Custom TSM Query";
$submenuarray["q=polldstat&m=".$submenu['name']] = "Polling Daemon Log"; $submenuarray["q=polldstat&m=".$submenu['name']] = "Polling Daemon Log";
$submenuarray["q=serverlist&m=".$submenu['name']] = "Change Server"; $submenuarray["q=serverlist&m=".$submenu['name']] = "Change Server";
if ($_SESSION["logindata"]["role"] == "admin") $submenuarray["admin"] = "Admin"; if ($_SESSION["logindata"]["role"] == "admin") $submenuarray["admin"] = "Admin";

View File

@ -220,6 +220,8 @@ function execute($query = '', $servername = '', $restable = '', $timestamp = '',
$read = fgets($handle, 4096); $read = fgets($handle, 4096);
$hashstring .= $read; $hashstring .= $read;
$stop = strstr($read, 'ANR2034E'); $stop = strstr($read, 'ANR2034E');
$stop = strstr($read, 'ANS1017E');
$stop = strstr($read, 'ANS8023E');
//$stop = strstr($read, 'ANS8023E'); //$stop = strstr($read, 'ANS8023E');
if ($read != ' ' && $read != '' && !$stop) { if ($read != ' ' && $read != '' && !$stop) {
$read = preg_replace('/[\n]+/', '', $read); $read = preg_replace('/[\n]+/', '', $read);
@ -237,7 +239,11 @@ function execute($query = '', $servername = '', $restable = '', $timestamp = '',
} }
$return["sql"] = $out; $return["sql"] = $out;
$return["md5"] = md5($hashstring); $return["md5"] = md5($hashstring);
if (!$stop){
return $return; return $return;
} else {
return "";
}
} }
@ -351,8 +357,9 @@ function pollQuery($query = "", $server = "", $ignorePollFreq = FALSE, $timestam
$this->fireMySQLQuery($ctsql, FALSE); $this->fireMySQLQuery($ctsql, FALSE);
} }
// execute query and store result in mysql db // execute query and store result in mysql db
$result = $this->execute($query["tsmquery"], $server["servername"], $tablename, $timestamp);
if ($ignorePollFreq || !$this->checkFreq($tablename, $query["pollfreq"], $timestamp)){ if ($ignorePollFreq || !$this->checkFreq($tablename, $query["pollfreq"], $timestamp)){
$result = $this->execute($query["tsmquery"], $server["servername"], $tablename, $timestamp);
if ($result != "") {
if (!$this->checkHash($tablename, $result["md5"])) { if (!$this->checkHash($tablename, $result["md5"])) {
if ($query["polltype"]=="update") { if ($query["polltype"]=="update") {
$dropsql = "truncate table ".$tablename; $dropsql = "truncate table ".$tablename;
@ -369,6 +376,9 @@ function pollQuery($query = "", $server = "", $ignorePollFreq = FALSE, $timestam
if (!$ignorePollFreq) echo "no need to update result -> result is the same as last time\n"; if (!$ignorePollFreq) echo "no need to update result -> result is the same as last time\n";
$this->log_unchangedresult++; $this->log_unchangedresult++;
} }
} else {
echo "There was a problem querying the TSM Server ".$server["servername"]."!\n";
}
} else { } else {
if (!$ignorePollFreq) echo "no need to update result -> pollfreq not reached!\n"; if (!$ignorePollFreq) echo "no need to update result -> pollfreq not reached!\n";
$this->log_pollfreqnoreached++; $this->log_pollfreqnoreached++;
@ -396,10 +406,14 @@ function pollOverviewQuery($query = "", $server = "", $timestamp){
$ctsql = "CREATE TABLE IF NOT EXISTS ".$tablename." ( `name` varchar(35) collate utf8_unicode_ci NOT NULL, `result` varchar(255) collate utf8_unicode_ci NOT NULL, UNIQUE KEY `name` (`name`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $ctsql = "CREATE TABLE IF NOT EXISTS ".$tablename." ( `name` varchar(35) collate utf8_unicode_ci NOT NULL, `result` varchar(255) collate utf8_unicode_ci NOT NULL, UNIQUE KEY `name` (`name`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
$this->fireMySQLQuery($ctsql, FALSE); $this->fireMySQLQuery($ctsql, FALSE);
$result = $this->execute($query["query"], $server["servername"], $tablename, '', $query["name"]); $result = $this->execute($query["query"], $server["servername"], $tablename, '', $query["name"]);
if ($result != "") {
foreach ($result["sql"] as $insertquery) { foreach ($result["sql"] as $insertquery) {
$this->fireMySQLQuery($insertquery, FALSE); $this->fireMySQLQuery($insertquery, FALSE);
echo "inserted row\n"; echo "inserted row\n";
} }
} else {
echo "There was a problem querying the TSM Server ".$server["servername"]."!\n";
}
} }

View File

@ -33,10 +33,11 @@
<form action="<?php echo $_SERVER['PHP_SELF']."?q=".$GETVars['qq']."&m=".$GETVars['menu']."&s=".$GETVars['server']; ?>" method="post"> <form action="<?php echo $_SERVER['PHP_SELF']."?q=".$GETVars['qq']."&m=".$GETVars['menu']."&s=".$GETVars['server']; ?>" method="post">
<?php <?php
if ($GETVars['qq'] != "admin" && !$_POST["edit"] == "edit") { //if ($GETVars['qq'] != "admin" && !$_POST["edit"] == "edit") {
if ($GETVars['qq'] != "index" && $GETVars['qq'] != "overview") { if ($GETVars['qq'] != "index" && $GETVars['qq'] != "overview" && $GETVars['qq'] != "serverlist") {
echo "<input type='button' value='PDF' onclick='genPDF()' class='button'>"; echo "<input type='button' value='PDF' onclick='genPDF()' class='button'>";
} }
if ($GETVars['qq'] != "polldstat" && $GETVars['qq'] != "serverlist") {
echo "<select name='s' size=1 onChange='submit();' class='button'>"; echo "<select name='s' size=1 onChange='submit();' class='button'>";