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,69 +776,73 @@ 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 ($type == "table") { if ($bContinue) {
$i = 1; if ($type == "table") {
$rs = fetchSplitArrayDB($sql,$conn,20); $i = 1;
$rs = fetchSplitArrayDB($sql,$conn,20);
foreach ($rs as $row) { foreach ($rs as $row) {
$color = ""; $color = "";
$col = $queryarray["alert_field"]; $col = $queryarray["alert_field"];
if ($col != '') { if ($col != '') {
$error = checkAlert($queryarray["alert_comp"], $queryarray["alert_val"], $row[$col]); $error = checkAlert($queryarray["alert_comp"], $queryarray["alert_val"], $row[$col]);
if($error) { if($error) {
$color = $queryarray["alert_col"]; $color = $queryarray["alert_col"];
} else {
$color = "ok";
}
$colorzebra = $colorsarray[$color][$i];
}
if ($i % 2 == 0) {
$outp = $outp."<tr class='d1'>";
}else{
$outp = $outp."<tr class='d0'>";
}
$i++;
while(list($keycell, $valcell) = each($row)) {
if($color!="" && $col==$keycell) {
if ($i % 2 == 0) {
$cellcol = $colorsarray[$color."_light"];
} else { } else {
$cellcol = $colorsarray[$color."_dark"]; $color = "ok";
} }
$outp = $outp."<td bgcolor='".$cellcol."'>".$valcell."</td>"; $colorzebra = $colorsarray[$color][$i];
} else {
$outp = $outp."<td>".$valcell."</td>";
} }
if ($i % 2 == 0) {
$outp = $outp."<tr class='d1'>";
}else{
$outp = $outp."<tr class='d0'>";
}
$i++;
while(list($keycell, $valcell) = each($row)) {
if($color!="" && $col==$keycell) {
if ($i % 2 == 0) {
$cellcol = $colorsarray[$color."_light"];
} else {
$cellcol = $colorsarray[$color."_dark"];
}
$outp = $outp."<td bgcolor='".$cellcol."'>".$valcell."</td>";
} else {
$outp = $outp."<td>".$valcell."</td>";
}
}
$outp = $outp."</tr>\n";
}
}
else if ($type == "verticaltable") {
$outp = fetchArrayDB($sql, $conn);
}
else if ($type == "timetable") {
$sqlres = fetchArrayDB($sql, $conn);
$outp = array();;
foreach ($sqlres as $row) {
$rowarray2 = array();
while(list($keycell, $valcell) = each($row)) {
if ($keycell == "Start Time" || $keycell == "End Time") {
$date = $row[$keycell];
$rowarray2[] = mktime(substr($date,11,2),substr($date,14,2),substr($date,17,2),substr($date,5,2),substr($date,8,2),substr($date,0,4));
} else {
$rowarray2[] = $valcell;
} }
$outp = $outp."</tr>\n";
}
}
else if ($type == "verticaltable") {
$outp = fetchArrayDB($sql, $conn);
}
else if ($type == "timetable") {
$sqlres = fetchArrayDB($sql, $conn);
$outp = array();;
foreach ($sqlres as $row) {
$rowarray2 = array();
while(list($keycell, $valcell) = each($row)) {
if ($keycell == "Start Time" || $keycell == "End Time") {
$date = $row[$keycell];
$rowarray2[] = mktime(substr($date,11,2),substr($date,14,2),substr($date,17,2),substr($date,5,2),substr($date,8,2),substr($date,0,4));
} else {
$rowarray2[] = $valcell;
}
}
array_push($outp, $rowarray2);
} }
array_push($outp, $rowarray2);
} }
} }
@ -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);
return $return; if (!$stop){
return $return;
} else {
return "";
}
} }
@ -351,24 +357,28 @@ 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)){
if (!$this->checkHash($tablename, $result["md5"])) { $result = $this->execute($query["tsmquery"], $server["servername"], $tablename, $timestamp);
if ($query["polltype"]=="update") { if ($result != "") {
$dropsql = "truncate table ".$tablename; if (!$this->checkHash($tablename, $result["md5"])) {
$this->fireMySQLQuery($dropsql, FALSE); if ($query["polltype"]=="update") {
if (!$ignorePollFreq) echo " TRUNCATED TABLE and "; $dropsql = "truncate table ".$tablename;
$this->fireMySQLQuery($dropsql, FALSE);
if (!$ignorePollFreq) echo " TRUNCATED TABLE and ";
}
foreach ($result["sql"] as $insertquery) {
if ($query["name"] == "querysession") echo "\n\n".$insertquery."\n\n";
$this->fireMySQLQuery($insertquery, FALSE);
}
if (!$ignorePollFreq) echo "inserted new rows into ".$tablename."\n";
$this->log_updated++;
} else {
if (!$ignorePollFreq) echo "no need to update result -> result is the same as last time\n";
$this->log_unchangedresult++;
} }
foreach ($result["sql"] as $insertquery) {
if ($query["name"] == "querysession") echo "\n\n".$insertquery."\n\n";
$this->fireMySQLQuery($insertquery, FALSE);
}
if (!$ignorePollFreq) echo "inserted new rows into ".$tablename."\n";
$this->log_updated++;
} else { } else {
if (!$ignorePollFreq) echo "no need to update result -> result is the same as last time\n"; echo "There was a problem querying the TSM Server ".$server["servername"]."!\n";
$this->log_unchangedresult++; }
}
} 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"]);
foreach ($result["sql"] as $insertquery) { if ($result != "") {
$this->fireMySQLQuery($insertquery, FALSE); foreach ($result["sql"] as $insertquery) {
echo "inserted row\n"; $this->fireMySQLQuery($insertquery, FALSE);
} 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'>";