- Some pre-release cleanup and format beautification.

This commit is contained in:
Frank Fegert 2009-06-19 21:34:23 +00:00
parent 6f9003206b
commit 252b04ad95
3 changed files with 9 additions and 42 deletions

View File

@ -82,7 +82,6 @@ class PollD {
$this->servers = $this->getServers(); $this->servers = $this->getServers();
$this->queries = $this->getQueries(); $this->queries = $this->getQueries();
$this->overviewqueries = $this->getOverviewQueries(); $this->overviewqueries = $this->getOverviewQueries();
//$this->controlPollD("off");
} }
@ -125,8 +124,6 @@ class PollD {
} }
/** /**
* setDebuglevel * setDebuglevel
* *
@ -179,8 +176,6 @@ class PollD {
} }
/** /**
* getOverviewQueries - returns an array filled with all configured TSM overview queries * getOverviewQueries - returns an array filled with all configured TSM overview queries
* *
@ -213,9 +208,6 @@ class PollD {
} }
/** /**
* execute - executes a TSM query on a TSM server and returns an array containing SQL insert statements including the results * execute - executes a TSM query on a TSM server and returns an array containing SQL insert statements including the results
* *
@ -275,7 +267,7 @@ class PollD {
} }
$return["sql"] = $out; $return["sql"] = $out;
$return["md5"] = md5($hashstring); $return["md5"] = md5($hashstring);
if (!$stop || ($blank && $stop)){ if (!$stop || ($blank && $stop)) {
return $return; return $return;
} else { } else {
return ""; return "";
@ -291,7 +283,7 @@ class PollD {
* @param string $hash md5 hash checksum of current resultSet * @param string $hash md5 hash checksum of current resultSet
* @return boolean * @return boolean
*/ */
function checkHash($tablename = '', $hash = ''){ function checkHash($tablename = '', $hash = '') {
$sql = "select count(*) from log_hashes where TABLENAME='".$tablename."' and HASH='".$hash."'"; $sql = "select count(*) from log_hashes where TABLENAME='".$tablename."' and HASH='".$hash."'";
$countobj = $this->adodb->fetchArrayDB($sql); $countobj = $this->adodb->fetchArrayDB($sql);
@ -312,7 +304,6 @@ class PollD {
} }
/** /**
* checkFreq - checks if configured checking frequency is reached * checkFreq - checks if configured checking frequency is reached
* *
@ -336,7 +327,6 @@ class PollD {
} }
/** /**
* getSleeptime - searches for the smallest polling frequency and returns the time to sleep * getSleeptime - searches for the smallest polling frequency and returns the time to sleep
* *
@ -367,7 +357,7 @@ class PollD {
* @param boolean $ignorePollFreq * @param boolean $ignorePollFreq
* @param string $timestamp * @param string $timestamp
*/ */
function pollQuery($query = "", $server = "", $ignorePollFreq = TRUE, $timestamp){ function pollQuery($query = "", $server = "", $ignorePollFreq = TRUE, $timestamp) {
$starttquery = time(); $starttquery = time();
$querytime = 0; $querytime = 0;
@ -389,7 +379,7 @@ class PollD {
$this->adodb->execDB($ctsql); $this->adodb->execDB($ctsql);
} }
// execute query and store result in mysql db // execute query and store result in mysql db
if ($ignorePollFreq || !$this->checkFreq($tablename, $query["pollfreq"], $timestamp)){ if ($ignorePollFreq || !$this->checkFreq($tablename, $query["pollfreq"], $timestamp)) {
try { try {
$result = $this->execute($query["tsmquery"], $server["servername"], $tablename, $timestamp); $result = $this->execute($query["tsmquery"], $server["servername"], $tablename, $timestamp);
} catch (exception $e) { } catch (exception $e) {
@ -440,7 +430,7 @@ class PollD {
* @param boolean $ignorePollFreq * @param boolean $ignorePollFreq
* @param string $timestamp * @param string $timestamp
*/ */
function pollOverviewQuery($query = "", $server = "", $timestamp){ function pollOverviewQuery($query = "", $server = "", $timestamp) {
$starttquery = time(); $starttquery = time();
$querytime = 0; $querytime = 0;
@ -463,8 +453,6 @@ class PollD {
} }
/** /**
* cleanupDatabase - cleans up database (single result tables and/or hash entry) * cleanupDatabase - cleans up database (single result tables and/or hash entry)
* *
@ -473,7 +461,7 @@ class PollD {
* @param string $overviewqueryname * @param string $overviewqueryname
* @param string $hashonly do not drop table, just delete entry in log_hashes * @param string $hashonly do not drop table, just delete entry in log_hashes
*/ */
function cleanupDatabase($servername = "", $queryname = "", $overviewqueryname = "", $months = "9999" ,$hashonly = "yes"){ function cleanupDatabase($servername = "", $queryname = "", $overviewqueryname = "", $months = "9999" ,$hashonly = "yes") {
if ($servername != "" && $queryname != "" && $overviewqueryname != "") { if ($servername != "" && $queryname != "" && $overviewqueryname != "") {
$time = time()-($months*30*24*60*60); $time = time()-($months*30*24*60*60);
@ -505,8 +493,6 @@ class PollD {
} }
/** /**
* setPollDStatus * setPollDStatus
* *
@ -525,7 +511,6 @@ class PollD {
} }
/** /**
* isEnabled - returns true if PollD is enabled * isEnabled - returns true if PollD is enabled
* *
@ -536,12 +521,11 @@ class PollD {
$sql = "select enabled from log_polldstat WHERE `id`='1'"; $sql = "select enabled from log_polldstat WHERE `id`='1'";
$result = $this->adodb->fetchArrayDB($sql); $result = $this->adodb->fetchArrayDB($sql);
if ($result != "" && $result[0]["enabled"] == "1"){ if ($result != "" && $result[0]["enabled"] == "1") {
return TRUE; return TRUE;
} else { } else {
return FALSE; return FALSE;
} }
} }
@ -575,8 +559,6 @@ class PollD {
$result = $this->adodb->fetchArrayDB($sql); $result = $this->adodb->fetchArrayDB($sql);
return $result[0]["status"]; return $result[0]["status"];
} }
@ -585,33 +567,25 @@ class PollD {
* *
* @return boolean * @return boolean
*/ */
function poll(){ function poll() {
$sleeptime = $this->getSleeptime(); $sleeptime = $this->getSleeptime();
$this->writeMSG("Sleeptime will be ".$sleeptime." seconds\n", "WARN"); $this->writeMSG("Sleeptime will be ".$sleeptime." seconds\n", "WARN");
// infinite loop // infinite loop
while(true) { while(true) {
if ($this->isEnabled()) { if ($this->isEnabled()) {
$timestamp = time(); $timestamp = time();
$this->writeMSG("running!\ntimestamp for this run is ".$timestamp."\n", "WARN"); $this->writeMSG("running!\ntimestamp for this run is ".$timestamp."\n", "WARN");
$this->setPollDStatus("running", "", ""); $this->setPollDStatus("running", "", "");
foreach ($this->servers as $server) { foreach ($this->servers as $server) {
$this->log_timeneeded = time(); $this->log_timeneeded = time();
$this->log_unchangedresult = 0; $this->log_unchangedresult = 0;
$this->log_pollfreqnoreached = 0; $this->log_pollfreqnoreached = 0;
$this->log_updated = 0; $this->log_updated = 0;
// go through all queries defined in xml file
$this->writeMSG("---querying server ".$server["servername"]."\n", "WARN"); $this->writeMSG("---querying server ".$server["servername"]."\n", "WARN");
$this->writeMSG("------querying normal queries\n", "WARN"); $this->writeMSG("------querying normal queries\n", "WARN");
foreach ($this->queries as $query) { foreach ($this->queries as $query) {
@ -628,7 +602,6 @@ class PollD {
$this->writeMSG("needed ".(time()-$timestamp)." seconds for this run.\n", "INFO"); $this->writeMSG("needed ".(time()-$timestamp)." seconds for this run.\n", "INFO");
//$tempsleeptime = $sleeptime-(time()-$timestamp);
$tempsleeptime = 900 -(time()-$timestamp); $tempsleeptime = 900 -(time()-$timestamp);
if ($tempsleeptime < 0) { if ($tempsleeptime < 0) {
$tempsleeptime = 0; $tempsleeptime = 0;
@ -647,10 +620,7 @@ class PollD {
} }
} }
} }
} }
?> ?>

View File

@ -777,7 +777,6 @@ class TSMMonitor {
$i++; $i++;
} else { } else {
$outp = $this->adodb->fetchArrayDB($sql); $outp = $this->adodb->fetchArrayDB($sql);
//var_dump($outp);
} }
} }
return $outp; return $outp;

View File

@ -35,9 +35,7 @@
include_once("../includes/global.php"); include_once("../includes/global.php");
$tmonpolld = new PollD($adodb, $config["server_os"]); $tmonpolld = new PollD($adodb, $config["server_os"]);
//$tmonpolld->setDebuglevel("WARN");
$tmonpolld->controlPollD("on"); $tmonpolld->controlPollD("on");
$tmonpolld->poll(); $tmonpolld->poll();