- Some pre-release cleanup.
- First attempt to reduce the PollD runtime, by querying only the events for backups_all/archives_all that occured since the last PollD run.
This commit is contained in:
parent
93f877b70e
commit
6f95782ec3
@ -44,9 +44,12 @@ class PollD {
|
||||
|
||||
var $servers;
|
||||
var $queries;
|
||||
var $lastrun;
|
||||
var $os;
|
||||
var $overviewqueries;
|
||||
var $adodb;
|
||||
var $dsmadmc;
|
||||
|
||||
var $debuglevel; // VERBOSE=4, INFO=3, WARN=2, ERROR=1, OFF=0
|
||||
var $loghandle;
|
||||
|
||||
@ -69,16 +72,29 @@ class PollD {
|
||||
$this->adodb = $adodb;
|
||||
$sql = "select confval from cfg_config WHERE `confkey`='loglevel_polld'";
|
||||
$loglevel = $this->adodb->fetchArrayDB($sql);
|
||||
$loglevel = strtoupper($loglevel[0][confval]);
|
||||
$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');
|
||||
if ($logfile[0]["confval"] != "") {
|
||||
$this->loghandle = fopen($logfile[0]["confval"], 'at');
|
||||
if (!$this->loghandle) {
|
||||
echo "ERROR: Cannot open logfile: '".$logfile[0][confval]."' for writing. Falling back to STDOUT.\n";
|
||||
echo "ERROR: Cannot open logfile: '".$logfile[0]["confval"]."' for writing. Falling back to STDOUT.\n";
|
||||
}
|
||||
}
|
||||
$sql = "select confval from cfg_config WHERE `confkey`='path_dsmadmc'";
|
||||
$tsmclient = $this->adodb->fetchArrayDB($sql);
|
||||
if ($tsmclient[0]["confval"] != "") {
|
||||
$this->dsmadmc = $tsmclient[0]["confval"];
|
||||
if (!is_executable($this->dsmadmc)) {
|
||||
$this->writeMSG("$this->dsmadmc is not executable.\n", "ERROR");
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$this->writeMSG("TSM Monitor has not been installed correctly, path to dsmadmc could not be found.\n", "ERROR");
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->servers = $this->getServers();
|
||||
$this->queries = $this->getQueries();
|
||||
$this->overviewqueries = $this->getOverviewQueries();
|
||||
@ -230,9 +246,18 @@ class PollD {
|
||||
$originalquery = $query;
|
||||
$query = ereg_replace("NOTEQUAL","<>",$query);
|
||||
$query = ereg_replace("LESS","<",$query);
|
||||
if (ereg(" summary ", $query)) {
|
||||
if ($this->lastrun > 0) {
|
||||
$tdiff = $timestamp - $this->lastrun;
|
||||
$tdiff = ceil($tdiff / 60) * 60;
|
||||
$query = ereg_replace(" @@@WHERE@@@ "," AND start_time>current_timestamp-($tdiff)seconds ",$query);
|
||||
} else {
|
||||
$query = ereg_replace(" @@@WHERE@@@ "," ",$query);
|
||||
}
|
||||
}
|
||||
|
||||
$popen_flags = ($os == "win32") ? 'rb' : 'r';
|
||||
$handle = popen("dsmadmc -se=$servername -id=$user -password=$pass -TCPServeraddress=$ip -COMMMethod=TCPIP -TCPPort=$port -dataonly=yes -TAB \"$query\" ", "$popen_flags");
|
||||
$handle = popen("$this->dsmadmc -se=$servername -id=$user -password=$pass -TCPServeraddress=$ip -COMMMethod=TCPIP -TCPPort=$port -dataonly=yes -TAB \"$query\" ", "$popen_flags");
|
||||
|
||||
$hashstring = "";
|
||||
|
||||
@ -245,7 +270,6 @@ class PollD {
|
||||
$stop = strstr($read, 'ANS1017E');
|
||||
$stop = strstr($read, 'ANS8023E');
|
||||
$blank = strstr($read, 'ANR2034E'); // dsmadmc runs correctly but result is empty (e.g. processes)
|
||||
//$stop = strstr($read, 'ANS8023E');
|
||||
if ($read != ' ' && $read != '' && !$stop) {
|
||||
if ($blank == "") {
|
||||
$read = preg_replace('/[\n]+/', '', $read);
|
||||
@ -261,7 +285,6 @@ class PollD {
|
||||
$hashstring = "";
|
||||
$stop = TRUE;
|
||||
}
|
||||
//$out[] = $read;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -293,7 +316,6 @@ class PollD {
|
||||
if ($count > 0) {
|
||||
return TRUE;
|
||||
} else {
|
||||
$sql = 'INSERT INTO log_hashes VALUES ("'.$tablename.'", "'.$hash.'")';
|
||||
$colarray = array();
|
||||
$colarray["tablename"] = $tablename;
|
||||
$colarray["hash"] = $hash;
|
||||
@ -319,7 +341,13 @@ class PollD {
|
||||
$resarray = $res[0];
|
||||
$lastinsert = $resarray["MAX(TimeStamp)"];
|
||||
|
||||
if ($lastinsert!="" && ($lastinsert+($pollfreq*60))>=$timestamp) {
|
||||
if ($lastinsert != "") {
|
||||
$this->lastrun = $lastinsert;
|
||||
} else {
|
||||
$this->lastrun = 0;
|
||||
}
|
||||
|
||||
if ($lastinsert != "" && ($lastinsert+($pollfreq*60)) >= $timestamp) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
@ -387,7 +415,7 @@ class PollD {
|
||||
}
|
||||
if ($result != "") {
|
||||
if (!$this->checkHash($tablename, $result["md5"])) {
|
||||
if ($query["polltype"]=="update") {
|
||||
if ($query["polltype"] == "update") {
|
||||
$dropsql = "truncate table ".$tablename;
|
||||
try {
|
||||
$this->adodb->execDB($dropsql);
|
||||
@ -399,7 +427,6 @@ class PollD {
|
||||
foreach ($result["sql"] as $insertquery) {
|
||||
try {
|
||||
$this->adodb->execDB($insertquery);
|
||||
//echo $insertquery;
|
||||
} catch (exception $e) {
|
||||
$this->writeMSG("Error while inserting into table (".$insertquery.")", "ERROR");
|
||||
}
|
||||
@ -436,7 +463,6 @@ class PollD {
|
||||
|
||||
$tablename = "res_overview_".$server["servername"];
|
||||
$this->writeMSG("---------".$query["name"].": ", "INFO");
|
||||
//$ctsql = "CREATE TABLE IF NOT EXISTS ".$tablename." LIKE smp_overview";
|
||||
$ctsql = "CREATE TABLE IF NOT EXISTS ".$tablename." ( `timestamp` int(11) collate utf8_unicode_ci NOT NULL, `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->adodb->execDB($ctsql);
|
||||
$result = $this->execute($query["query"], $server["servername"], $tablename, $timestamp, $query["name"]);
|
||||
@ -476,7 +502,6 @@ class PollD {
|
||||
$this->adodb->execDB($dropsql);
|
||||
}
|
||||
$delsql = "DELETE FROM log_hashes where `tablename` = '".$tablename."'";
|
||||
//$this->fireMySQLQuery($delsql, FALSE);
|
||||
$this->adodb->execDB($delsql);
|
||||
}
|
||||
}
|
||||
|
@ -228,10 +228,10 @@ INSERT INTO `cfg_queries` (`id`, `name`, `label`, `tsmquery`, `fields`, `timetab
|
||||
(17, 'paths', 'Paths', 'select SOURCE_NAME, SOURCE_TYPE, DESTINATION_NAME, DESTINATION_TYPE, LIBRARY_NAME, NODE_NAME, DEVICE, EXTERNAL_MANAGER, LUN, DIRECTORY, ONLINE from paths', '`timestamp` int(11), `Source Name` varchar(30), `Source Type` varchar(30), `Dest Name` varchar(30), `Dest Type` varchar(30), `Library` varchar(30), `Node Name` varchar(64), `Device` varchar(30), `External Manager` varchar(30), `Lun` varchar(30), `Directory` varchar(30), `Online` varchar(3) ', NULL, 'This is a list of all paths defined in the current tsm server', 'Source Name', 'equal', 'NO', 'Online', 'alarm', 1, 'update', 15, 'server', 100),
|
||||
(18, 'drmedia', 'Disaster Recovery Media', 'select VOLUME_NAME, STGPOOL_NAME, LIB_NAME, VOLTYPE, UPD_DATE, LOCATION, STATE from drmedia', '`timestamp` int(11), `Volume Name` varchar(100), `Storage Pool` varchar(30), `Library` varchar(30), `Volume Type` varchar(30), `Last Update` varchar(26), `Location` varchar(30), `State` varchar(30) ', NULL, 'A list of all available DR media', 'volume Name', 'notequal', 'MOUNTABLE', 'State', 'alarm', 0, 'snapshot', 15, 'server', 110),
|
||||
(19, 'backupstatus_24h', 'Backup Status / 24h', 'select Entity, Successful, cast(float(sum(bytes))/1024/1024/1024 as dec(8,3)) as GB, Examined, Affected, Failed from summary where activity=''BACKUP'' and cast((current_timestamp-start_time)hours as decimal(8,0)) LESS 24 group by Entity,Successful,Examined,AFFECTED,Failed', '`timestamp` int(11), `Entity` varchar(64), `Successful` varchar(3), `GB` varchar(30), `Examined` int(11), `Affected` int(11), `Failed` int(11), UNIQUE KEY `Entity` (`Entity`,`GB`,`Examined`,`Affected`,`Failed`)', NULL, 'A list of all backups that have been started during the last 24 hours', 'Successful', 'equal', 'NO', 'Successful', 'alarm', 0, 'update', 15, 'backup', 10),
|
||||
(20, 'backups_all', 'Backup Times', 'SELECT entity AS "Node_name", CAST(sum(bytes/1024/1024/1024) AS decimal(8,3)) AS "GB_xfer", start_time, end_time, END_TIME-START_TIME as duration, comm_wait, Affected, Failed, Successful FROM summary WHERE activity=''BACKUP'' group by start_time, end_time, Successful,Examined,Affected,Failed,entity,comm_wait', '`timestamp` int(11), `Node Name` varchar(64), `TX/GB` varchar(30), `Start Time` varchar(30), `End Time` varchar(30), `Duration` varchar(30), `Comm Wait` int(11), `Files` int(11), `Failed` int(11), `OK?` varchar(3), UNIQUE KEY `Node Name` (`Node Name`,`TX/GB`,`Start Time`,`End Time`,`Comm Wait`) ', '`Node Name`, `Start Time`, `End Time`, `OK?`', 'Search for a node name and get a list of all backups performed on this node', 'Start Time', 'equal', 'NO', 'Successful', 'alarm', 0, 'append', 15, 'backup', 20),
|
||||
(20, 'backups_all', 'Backup Times', 'SELECT entity AS "Node_name", CAST(sum(bytes/1024/1024/1024) AS decimal(8,3)) AS "GB_xfer", start_time, end_time, END_TIME-START_TIME as duration, comm_wait, Affected, Failed, Successful FROM summary WHERE activity=''BACKUP'' @@@WHERE@@@ group by start_time, end_time, Successful,Examined,Affected,Failed,entity,comm_wait', '`timestamp` int(11), `Node Name` varchar(64), `TX/GB` varchar(30), `Start Time` varchar(30), `End Time` varchar(30), `Duration` varchar(30), `Comm Wait` int(11), `Files` int(11), `Failed` int(11), `OK?` varchar(3), UNIQUE KEY `Node Name` (`Node Name`,`TX/GB`,`Start Time`,`End Time`,`Comm Wait`) ', '`Node Name`, `Start Time`, `End Time`, `OK?`', 'Search for a node name and get a list of all backups performed on this node', 'Start Time', 'equal', 'NO', 'Successful', 'alarm', 0, 'append', 15, 'backup', 20),
|
||||
(21, 'backups_24h', 'Backup Times / 24h', 'SELECT entity AS "Node_name", CAST(sum(bytes/1024/1024/1024) AS decimal(8,3)) AS "GB_xfer", start_time, end_time, END_TIME-START_TIME as duration, comm_wait, Affected, Failed, Successful FROM summary WHERE activity=''BACKUP'' AND start_time>=current_timestamp - 24 hours group by start_time, end_time, Successful,Examined,Affected,Failed,entity,comm_wait', '`timestamp` int(11), `Node Name` varchar(64), `TX/GB` varchar(30), `Start Time` varchar(26), `End Time` varchar(26), `Duration` varchar(30), `Comm Wait` int(11), `Files` int(11), `Failed` int(11), `OK?` varchar(3) ', '`Node Name`, `Start Time`, `End Time`, `OK?`', 'This query gives you an overview over all backups performed during the last 24 hours.', 'Start Time', 'equal', 'NO', 'Successful', 'alarm', 0, 'update', 15, 'backup', 30),
|
||||
(23, 'archivestatus_24h', 'Archive Status / 24h', 'select Entity, Successful, cast(float(sum(bytes))/1024/1024/1024 as dec(8,3)) as GB, Examined, Affected, Failed from summary where activity=''ARCHIVE'' and cast((current_timestamp-start_time)hours as decimal(8,0)) LESS 24 group by Entity,Successful,Examined,AFFECTED,Failed', '`timestamp` int(11), `Entity` varchar(64), `Successful` varchar(3), `GB` varchar(30), `Examined` int(11), `Affected` int(11), `Failed` int(11), UNIQUE KEY `Entity` (`Entity`,`GB`,`Examined`,`Affected`,`Failed`) ', NULL, 'A list of all archives that have been started during the last 24 hours', 'Successful', 'equal', 'NO', 'Successful', 'alarm', 0, 'update', 15, 'backup', 60),
|
||||
(24, 'archives_all', 'Archive Times', 'SELECT entity AS "Node_name", CAST(sum(bytes/1024/1024/1024) AS decimal(8,3)) AS "GB_xfer", start_time, end_time, END_TIME-START_TIME as duration, comm_wait, Affected, Failed, Successful FROM summary WHERE activity=''ARCHIVE'' group by start_time, end_time, Successful,Examined,Affected,Failed,entity,comm_wait', '`timestamp` int(11), `Node Name` varchar(64), `TX/GB` varchar(30), `Start Time` varchar(26), `End Time` varchar(26), `Duration` varchar(30), `Comm Wait` int(11), `Files` int(11), `Failed` int(11), `OK?` varchar(3), UNIQUE KEY `Node Name` (`Node Name`,`Start Time`,`End Time`,`Comm Wait`) ', '`Node Name`, `Start Time`, `End Time`, `OK?`', 'Search for a node name and get a list of all archives performed on this node', 'Start Time', 'equal', 'NO', 'Successful', 'alarm', 0, 'append', 15, 'backup', 70),
|
||||
(24, 'archives_all', 'Archive Times', 'SELECT entity AS "Node_name", CAST(sum(bytes/1024/1024/1024) AS decimal(8,3)) AS "GB_xfer", start_time, end_time, END_TIME-START_TIME as duration, comm_wait, Affected, Failed, Successful FROM summary WHERE activity=''ARCHIVE'' @@@WHERE@@@ group by start_time, end_time, Successful,Examined,Affected,Failed,entity,comm_wait', '`timestamp` int(11), `Node Name` varchar(64), `TX/GB` varchar(30), `Start Time` varchar(26), `End Time` varchar(26), `Duration` varchar(30), `Comm Wait` int(11), `Files` int(11), `Failed` int(11), `OK?` varchar(3), UNIQUE KEY `Node Name` (`Node Name`,`Start Time`,`End Time`,`Comm Wait`) ', '`Node Name`, `Start Time`, `End Time`, `OK?`', 'Search for a node name and get a list of all archives performed on this node', 'Start Time', 'equal', 'NO', 'Successful', 'alarm', 0, 'append', 15, 'backup', 70),
|
||||
(25, 'archives_24h', 'Archive Times / 24h', 'SELECT entity AS "Node_name", CAST(sum(bytes/1024/1024/1024) AS decimal(8,3)) AS "GB_xfer", start_time, end_time, END_TIME-START_TIME as duration, comm_wait, Affected, Failed, Successful FROM summary WHERE activity=''ARCHIVE'' AND start_time>=current_timestamp - 24 hours group by start_time, end_time, Successful,Examined,Affected,Failed,entity,comm_wait', '`timestamp` int(11), `Node Name` varchar(64), `TX/GB` varchar(30), `Start Time` varchar(26), `End Time` varchar(26), `Duration` varchar(30), `Comm Wait` int(11), `Files` int(11), `Failed` int(11), `OK?` varchar(3), UNIQUE KEY `Node Name` (`Node Name`,`Start Time`,`End Time`,`Comm Wait`) ', '`Node Name`, `Start Time`, `End Time`, `OK?`', 'This query gives you an overview over all archives performed during the last 24 hours.', 'Start Time', 'equal', 'NO', 'Successful', 'alarm', 0, 'update', 15, 'backup', 80),
|
||||
(27, 'clientscheddef', 'Client Schedules Definitions', 'select schedule_name, domain_name, description, action, priority, starttime, period, perunits, dayofweek, sched_style from client_schedules', '`timestamp` int(11), `Schedule Name` varchar(30), `Domain` varchar(30), `Description` varchar(255), `Action` varchar(30), `Prio` int(2), `Start` varchar(26), `Period` int(2), `Unit` varchar(30), `Day of Week` varchar(30), `Style` varchar(30) ', NULL, 'A list of all client schedules defined in the current tsm server.', 'Schedule Name', '', '', '', '', 0, 'snapshot', 15, 'schedules', 10),
|
||||
(28, 'clientschedules', 'Client Schedules Results', 'select node_name, schedule_name, scheduled_start, ACTUAL_START,COMPLETED, status, result, reason from events where scheduled_start >= current_timestamp - 24 hours and node_name != '''' and status != ''Future'' and status != ''Started''', '`timestamp` int(11), `Node Name` varchar(64), `Schedule Name` varchar(30), `Scheduled Start` varchar(26), `Actual Start` varchar(26), `End Time` varchar(26), `Status` varchar(30), `Result` int(11), `Reason` int(11), UNIQUE KEY `Node Name` (`Node Name`,`Schedule Name`,`Scheduled Start`,`Actual Start`,`End Time`)', '`Node Name`,`Actual Start`, `End Time`, `Status`', 'This query shows the start times and results of all client schedule that were scheduled during the last 24 hours.', 'Node Name', 'notequal', 'Completed', 'Status', 'alarm', 0, 'append', 15, 'schedules', 20),
|
||||
|
Loading…
Reference in New Issue
Block a user