- Added SQL file for new DB entries (only temporarily until first release).
- Added runtime profiling output to PollD. - Fixed minor bug in PollD for query runtime > 900 sec situations. - Added log to file functionality to PollD.
This commit is contained in:
parent
253659a825
commit
5ce2f693d6
|
@ -47,6 +47,7 @@ class PollD {
|
|||
var $overviewqueries;
|
||||
var $adodb;
|
||||
var $debuglevel; // VERBOSE=4, INFO=3, WARN=2, ERROR=1, OFF=0
|
||||
var $loghandle;
|
||||
|
||||
var $log_timeneeded;
|
||||
var $log_unchangedresult;
|
||||
|
@ -65,6 +66,15 @@ class PollD {
|
|||
|
||||
$this->setDebuglevel("INFO");
|
||||
$this->adodb = $adodb;
|
||||
$sql = "select confval from cfg_config WHERE `confkey`='loglevel_polld'";
|
||||
$loglevel = $this->adodb->fetchArrayDB($sql);
|
||||
$loglevel = strtoupper($loglevel[0][confval]);
|
||||
$this->setDebuglevel("$loglevel");
|
||||
$sql = "select confval from cfg_config WHERE `confkey`='path_polldlog'";
|
||||
$logfile = $this->adodb->fetchArrayDB($sql);
|
||||
if ($logfile[0][confval] != "") {
|
||||
$this->loghandle = fopen($logfile[0][confval], 'at');
|
||||
}
|
||||
$this->servers = $this->getServers();
|
||||
$this->queries = $this->getQueries();
|
||||
$this->overviewqueries = $this->getOverviewQueries();
|
||||
|
@ -101,9 +111,14 @@ class PollD {
|
|||
}
|
||||
|
||||
if ($this->debuglevel >= $ilevel) {
|
||||
if ($this->loghandle) {
|
||||
fwrite($this->loghandle, $level.": ".$msg);
|
||||
}
|
||||
else {
|
||||
echo $level.": ".$msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -347,6 +362,8 @@ class PollD {
|
|||
* @param string $timestamp
|
||||
*/
|
||||
function pollQuery($query = "", $server = "", $ignorePollFreq = TRUE, $timestamp){
|
||||
$starttquery = time();
|
||||
$querytime = 0;
|
||||
|
||||
$queryname = $query["name"];
|
||||
$tablename = "res_".$queryname."_".$server["servername"];
|
||||
|
@ -391,10 +408,12 @@ class PollD {
|
|||
$this->writeMSG("Error while inserting into table (".$insertquery.")", "ERROR");
|
||||
}
|
||||
}
|
||||
$this->writeMSG("inserted new rows into ".$tablename."\n", "INFO");
|
||||
$querytime = time() - $starttquery;
|
||||
$this->writeMSG("inserted new rows into ".$tablename." ($querytime sec)\n", "INFO");
|
||||
$this->log_updated++;
|
||||
} else {
|
||||
$this->writeMSG("no need to update result -> result is the same as last time\n", "INFO");
|
||||
$querytime = time() - $starttquery;
|
||||
$this->writeMSG("no need to update result -> result is the same as last time ($querytime sec)\n", "INFO");
|
||||
$this->log_unchangedresult++;
|
||||
}
|
||||
} else {
|
||||
|
@ -416,6 +435,8 @@ class PollD {
|
|||
* @param string $timestamp
|
||||
*/
|
||||
function pollOverviewQuery($query = "", $server = "", $timestamp){
|
||||
$starttquery = time();
|
||||
$querytime = 0;
|
||||
|
||||
$tablename = "res_overview_".$server["servername"];
|
||||
$this->writeMSG("---------".$query["name"].": ", "INFO");
|
||||
|
@ -426,7 +447,8 @@ class PollD {
|
|||
if ($result != "") {
|
||||
foreach ($result["sql"] as $insertquery) {
|
||||
$this->adodb->execDB($insertquery);
|
||||
$this->writeMSG("inserted row\n", "INFO");
|
||||
$querytime = time() - $starttquery;
|
||||
$this->writeMSG("inserted row ($querytime sec)\n", "INFO");
|
||||
}
|
||||
} else {
|
||||
$this->writeMSG("There was a problem querying the TSM Server ".$server["servername"]."!\n", "ERROR");
|
||||
|
@ -602,12 +624,14 @@ class PollD {
|
|||
$this->writeMSG("needed ".(time()-$timestamp)." seconds for this run.\n", "INFO");
|
||||
//$tempsleeptime = $sleeptime-(time()-$timestamp);
|
||||
$tempsleeptime = 900 -(time()-$timestamp);
|
||||
if ($tempsleeptime < 0) {
|
||||
$tempsleeptime = 0;
|
||||
}
|
||||
$this->writeMSG("sleeping for ".$tempsleeptime." seconds...\n", "WARN");
|
||||
$this->writeMSG("next run will be at ".strftime("%H:%M:%S", (time()+$tempsleeptime))."\n\n", "WARN");
|
||||
|
||||
$this->setPollDStatus("sleeping", $timestamp, (time()+$tempsleeptime));
|
||||
|
||||
|
||||
sleep ($tempsleeptime);
|
||||
|
||||
} else {
|
||||
|
|
|
@ -37,7 +37,7 @@ include_once("../includes/global.php");
|
|||
|
||||
|
||||
$tmonpolld = new PollD($adodb);
|
||||
$tmonpolld->setDebuglevel("WARN");
|
||||
//$tmonpolld->setDebuglevel("WARN");
|
||||
$tmonpolld->controlPollD("on");
|
||||
$tmonpolld->poll();
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
use tsmmonitor;
|
||||
# Make name consistent with other _24h queries
|
||||
UPDATE cfg_queries SET name='archives_24h' WHERE name='archives_24';
|
||||
# Allow longer confvals e.g. file paths
|
||||
ALTER TABLE cfg_config MODIFY confval varchar(255) collate utf8_unicode_ci NOT NULL;
|
||||
# Add description
|
||||
UPDATE cfg_config SET description='TSM Monitor version' WHERE confkey='version';
|
||||
# Add new configuration entries
|
||||
INSERT INTO cfg_config (confkey,confval,description) VALUES ('path_tmlog','','TSM Monitor Logfile Path');
|
||||
INSERT INTO cfg_config (confkey,confval,description) VALUES ('path_polldlog','','PollD Logfile Path');
|
||||
INSERT INTO cfg_config (confkey,confval,description) VALUES ('loglevel_tm','INFO','TSM Monitor Log Level');
|
||||
INSERT INTO cfg_config (confkey,confval,description) VALUES ('loglevel_polld','INFO','PollD Log Level');
|
||||
|
Loading…
Reference in New Issue