integrated adodb into PollD
added external switchable debug mode for class ADOdb
This commit is contained in:
parent
94c879b58b
commit
8e5e0648a5
|
@ -76,9 +76,7 @@ if (isset($_SESSION["logindata"]["user"]) && isset($_SESSION["logindata"]["pass"
|
||||||
// do nothing
|
// do nothing
|
||||||
// show settings page
|
// show settings page
|
||||||
} else if ($tsmmonitor->GETVars['qq'] == "settings") {
|
} else if ($tsmmonitor->GETVars['qq'] == "settings") {
|
||||||
$tmonpolld = new PollD();
|
$tmonpolld = new PollD($adodb);
|
||||||
$tmonpolld->setDBParams($db_host, $db_name, $db_user, $db_password);
|
|
||||||
$tmonpolld->initialize();
|
|
||||||
|
|
||||||
// If start/stop button was pressed
|
// If start/stop button was pressed
|
||||||
if ($_POST["PollDControl"] != "") {
|
if ($_POST["PollDControl"] != "") {
|
||||||
|
|
|
@ -41,6 +41,7 @@ class ADOdb {
|
||||||
|
|
||||||
|
|
||||||
var $conn;
|
var $conn;
|
||||||
|
var $debug;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* constructor - establishes a DB connection via ADODB
|
* constructor - establishes a DB connection via ADODB
|
||||||
|
@ -54,7 +55,10 @@ class ADOdb {
|
||||||
* @param string $retr the number attempts for the DB connection before a failure is reported
|
* @param string $retr the number attempts for the DB connection before a failure is reported
|
||||||
* @return 0
|
* @return 0
|
||||||
*/
|
*/
|
||||||
function ADOdb($host, $port = "3306", $user, $pass, $db_name, $db_type, $retr = 20) {
|
function ADOdb($host, $port = "3306", $user, $pass, $db_name, $db_type, $retr = 20, $debug = FALSE) {
|
||||||
|
|
||||||
|
$this->debug = $debug;
|
||||||
|
|
||||||
$try = 0;
|
$try = 0;
|
||||||
$hostport = $host . ":" . $port;
|
$hostport = $host . ":" . $port;
|
||||||
$this->conn = NewADOConnection($db_type);
|
$this->conn = NewADOConnection($db_type);
|
||||||
|
@ -72,6 +76,19 @@ class ADOdb {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* setDebug - enables or disabled debug mode
|
||||||
|
*
|
||||||
|
* @param boolean $debug
|
||||||
|
*/
|
||||||
|
function setDebug($debug) {
|
||||||
|
$this->debug = $debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* closeDB - close an open DB connection
|
* closeDB - close an open DB connection
|
||||||
*
|
*
|
||||||
|
@ -91,7 +108,7 @@ class ADOdb {
|
||||||
* @return ADORecordSet
|
* @return ADORecordSet
|
||||||
*/
|
*/
|
||||||
function execDB($sql) {
|
function execDB($sql) {
|
||||||
// $this->conn->debug = true;
|
$this->conn->debug = $this->debug;
|
||||||
$sql = $this->sanitizeSQL($sql);
|
$sql = $this->sanitizeSQL($sql);
|
||||||
|
|
||||||
$recordSet = &$this->conn->Execute($sql);
|
$recordSet = &$this->conn->Execute($sql);
|
||||||
|
@ -115,6 +132,7 @@ class ADOdb {
|
||||||
*/
|
*/
|
||||||
function fetchCellDB($sql, $column_name) {
|
function fetchCellDB($sql, $column_name) {
|
||||||
//$this->conn->debug = true;
|
//$this->conn->debug = true;
|
||||||
|
$this->conn->debug = $this->debug;
|
||||||
$sql = $this->sanitizeSQL($sql);
|
$sql = $this->sanitizeSQL($sql);
|
||||||
|
|
||||||
if ($column_name != '') {
|
if ($column_name != '') {
|
||||||
|
@ -151,6 +169,7 @@ class ADOdb {
|
||||||
*/
|
*/
|
||||||
function fetchRowDB($sql) {
|
function fetchRowDB($sql) {
|
||||||
//$this->conn->debug = true;
|
//$this->conn->debug = true;
|
||||||
|
$this->conn->debug = $this->debug;
|
||||||
$sql = $this->sanitizeSQL($sql);
|
$sql = $this->sanitizeSQL($sql);
|
||||||
|
|
||||||
$this->conn->SetFetchMode(ADODB_FETCH_ASSOC);
|
$this->conn->SetFetchMode(ADODB_FETCH_ASSOC);
|
||||||
|
@ -179,6 +198,7 @@ class ADOdb {
|
||||||
*/
|
*/
|
||||||
function fetchArrayDB($sql) {
|
function fetchArrayDB($sql) {
|
||||||
//$this->conn->debug = true;
|
//$this->conn->debug = true;
|
||||||
|
$this->conn->debug = $this->debug;
|
||||||
$sql = $this->sanitizeSQL($sql);
|
$sql = $this->sanitizeSQL($sql);
|
||||||
|
|
||||||
$recordArray = array();
|
$recordArray = array();
|
||||||
|
@ -213,6 +233,7 @@ class ADOdb {
|
||||||
*/
|
*/
|
||||||
function updateDB($table, $cells, $keys, $autoquote = TRUE) {
|
function updateDB($table, $cells, $keys, $autoquote = TRUE) {
|
||||||
//$this->conn->debug = true;
|
//$this->conn->debug = true;
|
||||||
|
$this->conn->debug = $this->debug;
|
||||||
$this->conn->Replace($table, $cells, $keys, $autoquote);
|
$this->conn->Replace($table, $cells, $keys, $autoquote);
|
||||||
|
|
||||||
return $this->conn->Insert_ID();
|
return $this->conn->Insert_ID();
|
||||||
|
|
|
@ -95,14 +95,11 @@ $adodb = new ADOdb($db_host, $db_port, $db_user, $db_password, $db_name, $db_typ
|
||||||
$tsmmonitor = new TSMMonitor($adodb);
|
$tsmmonitor = new TSMMonitor($adodb);
|
||||||
|
|
||||||
// check to see if this is a new installation
|
// check to see if this is a new installation
|
||||||
$version = $adodb->fetchCellDB("select confval from cfg_config where confkey='version'", '', $tsmmonitor->conn);
|
$version = $adodb->fetchCellDB("select confval from cfg_config where confkey='version'", '');
|
||||||
if ($version != $config["tsm_monitor_version"] && basename($_SERVER['REQUEST_URI']) != 'install.php') {
|
if ($version != $config["tsm_monitor_version"] && basename($_SERVER['REQUEST_URI']) != 'install.php') {
|
||||||
header("Location: install.php");
|
header("Location: install.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
// ** Initialize PHP session ** //
|
|
||||||
//initialize();
|
|
||||||
//$tsmmonitor->initialize();
|
|
||||||
|
|
||||||
// ** Include generic code and external libraries ** //
|
// ** Include generic code and external libraries ** //
|
||||||
// ... more includes here
|
// ... more includes here
|
||||||
|
|
|
@ -46,10 +46,13 @@ class PollD {
|
||||||
var $servers;
|
var $servers;
|
||||||
var $queries;
|
var $queries;
|
||||||
var $overviewqueries;
|
var $overviewqueries;
|
||||||
|
/**
|
||||||
var $db_host;
|
var $db_host;
|
||||||
var $db_name;
|
var $db_name;
|
||||||
var $db_user;
|
var $db_user;
|
||||||
var $db_password;
|
var $db_password;
|
||||||
|
**/
|
||||||
|
var $adodb;
|
||||||
|
|
||||||
var $log_timeneeded;
|
var $log_timeneeded;
|
||||||
var $log_unchangedresult;
|
var $log_unchangedresult;
|
||||||
|
@ -58,38 +61,20 @@ var $log_updated;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* setDBParams - helper function to set db parameter properties
|
|
||||||
*
|
|
||||||
* @param string $db_host
|
|
||||||
* @param string $db_name
|
|
||||||
* @param string $db_user
|
|
||||||
* @param string $db_password
|
|
||||||
*/
|
|
||||||
|
|
||||||
function setDBParams($db_host, $db_name, $db_user, $db_password){
|
|
||||||
|
|
||||||
$this->db_host = $db_host;
|
|
||||||
$this->db_name = $db_name;
|
|
||||||
$this->db_user = $db_user;
|
|
||||||
$this->db_password = $db_password;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* initialize - initializes this class
|
* constructor
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function initialize() {
|
function PollD($adodb) {
|
||||||
|
|
||||||
$this->setDBParams("localhost", "tsmmonitor", "tsmmonitor", "tsmmonitor");
|
$this->adodb = $adodb;
|
||||||
|
|
||||||
|
//$this->setDBParams("localhost", "tsmmonitor", "tsmmonitor", "tsmmonitor");
|
||||||
$this->servers = $this->getServers();
|
$this->servers = $this->getServers();
|
||||||
$this->queries = $this->getQueries();
|
$this->queries = $this->getQueries();
|
||||||
$this->overviewqueries = $this->getOverviewQueries();
|
$this->overviewqueries = $this->getOverviewQueries();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -102,7 +87,7 @@ function initialize() {
|
||||||
* @param boolean $direct give back MySQLResultSet directly or Array of Objects
|
* @param boolean $direct give back MySQLResultSet directly or Array of Objects
|
||||||
* @return MySQLResultSet/Array
|
* @return MySQLResultSet/Array
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
function fireMySQLQuery($sql, $getreturnval = TRUE){
|
function fireMySQLQuery($sql, $getreturnval = TRUE){
|
||||||
|
|
||||||
$ret = array();
|
$ret = array();
|
||||||
|
@ -121,7 +106,7 @@ function fireMySQLQuery($sql, $getreturnval = TRUE){
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -132,9 +117,9 @@ function fireMySQLQuery($sql, $getreturnval = TRUE){
|
||||||
function getQueries() {
|
function getQueries() {
|
||||||
$queries = array();
|
$queries = array();
|
||||||
$query = "select * from cfg_queries";
|
$query = "select * from cfg_queries";
|
||||||
$querytablerows = $this->fireMySQLQuery($query);
|
$querytablerows = $this->adodb->fetchArrayDB($query);
|
||||||
while (list ($subkey, $queryrow) = each ($querytablerows)) {
|
while (list ($subkey, $queryrow) = each ($querytablerows)) {
|
||||||
$queries[$queryrow->name] = (array)$queryrow;
|
$queries[$queryrow["name"]] = (array)$queryrow;
|
||||||
$temparray=split(",", $queryrow->Fields);
|
$temparray=split(",", $queryrow->Fields);
|
||||||
$cols = array();
|
$cols = array();
|
||||||
while (list ($subkey, $col) = each ($temparray)) {
|
while (list ($subkey, $col) = each ($temparray)) {
|
||||||
|
@ -142,7 +127,7 @@ function getQueries() {
|
||||||
$cols[$subkey]["label"] = $temp[0];
|
$cols[$subkey]["label"] = $temp[0];
|
||||||
$cols[$subkey]["name"] = $temp[1];
|
$cols[$subkey]["name"] = $temp[1];
|
||||||
}
|
}
|
||||||
$queries[$queryrow->name]["header"]["column"] = $cols;
|
if ($queryrow->name != "") $queries[$queryrow->name]["header"]["column"] = $cols;
|
||||||
}
|
}
|
||||||
return $queries;
|
return $queries;
|
||||||
}
|
}
|
||||||
|
@ -159,9 +144,9 @@ function getQueries() {
|
||||||
function getOverviewQueries() {
|
function getOverviewQueries() {
|
||||||
$queries = array();
|
$queries = array();
|
||||||
$query = "select * from cfg_overviewqueries";
|
$query = "select * from cfg_overviewqueries";
|
||||||
$querytablerows = $this->fireMySQLQuery($query);
|
$querytablerows = $this->adodb->fetchArrayDB($query);
|
||||||
while (list ($subkey, $queryrow) = each ($querytablerows)) {
|
while (list ($subkey, $queryrow) = each ($querytablerows)) {
|
||||||
$queries[$queryrow->name] = (array)$queryrow;
|
$queries[$queryrow["name"]] = (array)$queryrow;
|
||||||
}
|
}
|
||||||
return $queries;
|
return $queries;
|
||||||
}
|
}
|
||||||
|
@ -175,12 +160,13 @@ function getOverviewQueries() {
|
||||||
|
|
||||||
function getServers() {
|
function getServers() {
|
||||||
$query = "select * from cfg_servers";
|
$query = "select * from cfg_servers";
|
||||||
$rows = $this->fireMySQLQuery($query);
|
$rows = $this->adodb->fetchArrayDB($query);
|
||||||
$servers = array();
|
$servers = array();
|
||||||
while (list ($key, $val) = each ($rows)) {
|
while (list ($key, $val) = each ($rows)) {
|
||||||
$servers[$val->servername] = (array)$val;
|
$servers[$val["servername"]] = (array)$val;
|
||||||
}
|
}
|
||||||
return $servers;
|
return $servers;
|
||||||
|
//return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -260,7 +246,8 @@ function execute($query = '', $servername = '', $restable = '', $timestamp = '',
|
||||||
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->fireMySQLQuery($sql, TRUE);
|
$countobj = $this->adodb->fetchArrayDB($sql);
|
||||||
|
//$countobj = $this->fireMySQLQuery($sql, TRUE);
|
||||||
$countarray = (array)$countobj[0];
|
$countarray = (array)$countobj[0];
|
||||||
$count = $countarray["count(*)"];
|
$count = $countarray["count(*)"];
|
||||||
|
|
||||||
|
@ -268,8 +255,11 @@ function checkHash($tablename = '', $hash = ''){
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
$sql = 'INSERT INTO log_hashes VALUES ("'.$tablename.'", "'.$hash.'")';
|
$sql = 'INSERT INTO log_hashes VALUES ("'.$tablename.'", "'.$hash.'")';
|
||||||
|
$colarray = array();
|
||||||
|
$colarray[$tablename] = $hash;
|
||||||
//echo $sql;
|
//echo $sql;
|
||||||
$this->fireMySQLQuery($sql, FALSE);
|
$this->adodb->updateDB("log_hashes", $colarray, 'tablename');
|
||||||
|
//$this->fireMySQLQuery($sql, FALSE);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,8 +279,9 @@ function checkHash($tablename = '', $hash = ''){
|
||||||
function checkFreq($tablename, $pollfreq, $timestamp) {
|
function checkFreq($tablename, $pollfreq, $timestamp) {
|
||||||
|
|
||||||
$sql = "select MAX(TimeStamp) from ".$tablename;
|
$sql = "select MAX(TimeStamp) from ".$tablename;
|
||||||
$res = $this->fireMySQLQuery($sql, TRUE);
|
//$res = $this->fireMySQLQuery($sql, TRUE);
|
||||||
$resarray = (array)$res[0];
|
$res = $this->adodb->fetchArrayDB($sql);
|
||||||
|
$resarray = $res[0];
|
||||||
$lastinsert = $resarray["MAX(TimeStamp)"];
|
$lastinsert = $resarray["MAX(TimeStamp)"];
|
||||||
|
|
||||||
if ($lastinsert!="" && ($lastinsert+($pollfreq*60))>=$timestamp) {
|
if ($lastinsert!="" && ($lastinsert+($pollfreq*60))>=$timestamp) {
|
||||||
|
@ -311,12 +302,14 @@ function checkFreq($tablename, $pollfreq, $timestamp) {
|
||||||
function getSleeptime() {
|
function getSleeptime() {
|
||||||
|
|
||||||
$sql = "select MIN(pollfreq) from cfg_queries";
|
$sql = "select MIN(pollfreq) from cfg_queries";
|
||||||
$res = $this->fireMySQLQuery($sql, TRUE);
|
$res = $this->adodb->fetchArrayDB($sql);
|
||||||
|
//$res = $this->fireMySQLQuery($sql, TRUE);
|
||||||
$resarray = (array)$res[0];
|
$resarray = (array)$res[0];
|
||||||
$minqueries = $resarray["MIN(pollfreq)"];
|
$minqueries = $resarray["MIN(pollfreq)"];
|
||||||
|
|
||||||
$sql = "select MIN(pollfreq) from cfg_overviewqueries";
|
$sql = "select MIN(pollfreq) from cfg_overviewqueries";
|
||||||
$res = $this->fireMySQLQuery($sql, TRUE);
|
$res = $this->adodb->fetchArrayDB($sql);
|
||||||
|
//$res = $this->fireMySQLQuery($sql, TRUE);
|
||||||
$resarray = (array)$res[0];
|
$resarray = (array)$res[0];
|
||||||
$minoverview = $resarray["MIN(pollfreq)"];
|
$minoverview = $resarray["MIN(pollfreq)"];
|
||||||
|
|
||||||
|
@ -336,18 +329,23 @@ function getSleeptime() {
|
||||||
|
|
||||||
function pollQuery($query = "", $server = "", $ignorePollFreq = FALSE, $timestamp){
|
function pollQuery($query = "", $server = "", $ignorePollFreq = FALSE, $timestamp){
|
||||||
|
|
||||||
$tablename = "res_".$query["name"]."_".$server["servername"];
|
$queryname = $query["name"];
|
||||||
if (!$ignorePollFreq) echo "---------".$query["name"].": ";
|
$tablename = "res_".$queryname."_".$server["servername"];
|
||||||
|
if (!$ignorePollFreq) echo "---------".$queryname.": ";
|
||||||
// create table if not exists
|
// create table if not exists
|
||||||
$showsql = "SHOW TABLES LIKE '".$tablename."'";
|
$showsql = "SHOW TABLES LIKE '".$tablename."'";
|
||||||
$res = $this->fireMySQLQuery($showsql, TRUE);
|
//$res = $this->fireMySQLQuery($showsql, TRUE);
|
||||||
|
$res = $this->adodb->fetchArrayDB($showsql);
|
||||||
if (!isset($res[0])) {
|
if (!isset($res[0])) {
|
||||||
$fieldsql = "select fields from cfg_queries where name='".$query["name"]."'";
|
$fieldsql = "select fields from cfg_queries where name='".$queryname."'";
|
||||||
$fields = $this->fireMySQLQuery($fieldsql, TRUE);
|
//$fields = $this->fireMySQLQuery($fieldsql, TRUE);
|
||||||
$ctsql = "CREATE TABLE `".$tablename."` (".$fields[0]->fields.") DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
|
$fields = $this->adodb->fetchArrayDB($fieldsql);
|
||||||
|
var_dump($fields);
|
||||||
|
$ctsql = "CREATE TABLE `".$tablename."` (".$fields[0]['fields'].") DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
|
||||||
if (!$ignorePollFreq) echo "created table ".$tablename." and ";
|
if (!$ignorePollFreq) echo "created table ".$tablename." and ";
|
||||||
//$ctsql = "CREATE TABLE IF NOT EXISTS ".$tablename." LIKE smp_".$query["name"];
|
//$ctsql = "CREATE TABLE IF NOT EXISTS ".$tablename." LIKE smp_".$query["name"];
|
||||||
$this->fireMySQLQuery($ctsql, FALSE);
|
//$this->fireMySQLQuery($ctsql, FALSE);
|
||||||
|
$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)){
|
||||||
|
@ -356,12 +354,14 @@ function pollQuery($query = "", $server = "", $ignorePollFreq = FALSE, $timestam
|
||||||
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;
|
||||||
$this->fireMySQLQuery($dropsql, FALSE);
|
//$this->fireMySQLQuery($dropsql, FALSE);
|
||||||
|
$this->adodb->execDB($dropsql);
|
||||||
if (!$ignorePollFreq) echo " TRUNCATED TABLE and ";
|
if (!$ignorePollFreq) echo " TRUNCATED TABLE and ";
|
||||||
}
|
}
|
||||||
foreach ($result["sql"] as $insertquery) {
|
foreach ($result["sql"] as $insertquery) {
|
||||||
if ($query["name"] == "querysession") echo "\n\n".$insertquery."\n\n";
|
if ($queryname == "querysession") echo "\n\n".$insertquery."\n\n";
|
||||||
$this->fireMySQLQuery($insertquery, FALSE);
|
//$this->fireMySQLQuery($insertquery, FALSE);
|
||||||
|
$this->adodb->execDB($insertquery);
|
||||||
}
|
}
|
||||||
if (!$ignorePollFreq) echo "inserted new rows into ".$tablename."\n";
|
if (!$ignorePollFreq) echo "inserted new rows into ".$tablename."\n";
|
||||||
$this->log_updated++;
|
$this->log_updated++;
|
||||||
|
@ -394,11 +394,13 @@ function pollOverviewQuery($query = "", $server = "", $timestamp){
|
||||||
echo "---------".$query["name"].": ";
|
echo "---------".$query["name"].": ";
|
||||||
//$ctsql = "CREATE TABLE IF NOT EXISTS ".$tablename." LIKE smp_overview";
|
//$ctsql = "CREATE TABLE IF NOT EXISTS ".$tablename." LIKE smp_overview";
|
||||||
$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->adodb->execDB($ctsql);
|
||||||
|
//$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 != "") {
|
if ($result != "") {
|
||||||
foreach ($result["sql"] as $insertquery) {
|
foreach ($result["sql"] as $insertquery) {
|
||||||
$this->fireMySQLQuery($insertquery, FALSE);
|
//$this->fireMySQLQuery($insertquery, FALSE);
|
||||||
|
$this->adodb->execDB($insertquery);
|
||||||
echo "inserted row\n";
|
echo "inserted row\n";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -429,17 +431,20 @@ function cleanupDatabase($servername = "", $queryname = "", $overviewqueryname =
|
||||||
$tablename = "res_".$query["name"]."_".$server["servername"];
|
$tablename = "res_".$query["name"]."_".$server["servername"];
|
||||||
if ($hashonly != "yes") {
|
if ($hashonly != "yes") {
|
||||||
$dropsql = "drop table ".$tablename;
|
$dropsql = "drop table ".$tablename;
|
||||||
$this->fireMySQLQuery($dropsql, FALSE);
|
//$this->fireMySQLQuery($dropsql, FALSE);
|
||||||
|
$this->adodb->execDB($dropsql);
|
||||||
}
|
}
|
||||||
$delsql = "DELETE FROM log_hashes where `tablename` = '".$tablename."'";
|
$delsql = "DELETE FROM log_hashes where `tablename` = '".$tablename."'";
|
||||||
$this->fireMySQLQuery($delsql, FALSE);
|
//$this->fireMySQLQuery($delsql, FALSE);
|
||||||
|
$this->adodb->execDB($delsql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach ($this->overviewqueries as $query) {
|
foreach ($this->overviewqueries as $query) {
|
||||||
if (($overviewqueryname == "all" || $query["name"] == $overviewqueryname) && $overviewqueryname != "none") {
|
if (($overviewqueryname == "all" || $query["name"] == $overviewqueryname) && $overviewqueryname != "none") {
|
||||||
$tablename = "res_overview_".$server["servername"];
|
$tablename = "res_overview_".$server["servername"];
|
||||||
$dropsql = "drop table ".$tablename;
|
$dropsql = "drop table ".$tablename;
|
||||||
$this->fireMySQLQuery($dropsql, FALSE);
|
//$this->fireMySQLQuery($dropsql, FALSE);
|
||||||
|
$this->adodb->execDB($dropsql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -465,8 +470,8 @@ function setPollDStatus($status, $lastrun, $nextrun) {
|
||||||
if ($nextrun != "") $nextrun = ", `nextrun`='".$nextrun."'";
|
if ($nextrun != "") $nextrun = ", `nextrun`='".$nextrun."'";
|
||||||
|
|
||||||
$sql = "update log_polldstat set ".$status." ".$lastrun." ".$nextrun." WHERE `id`='1'";
|
$sql = "update log_polldstat set ".$status." ".$lastrun." ".$nextrun." WHERE `id`='1'";
|
||||||
$this->fireMySQLQuery($sql, FALSE);
|
//$this->fireMySQLQuery($sql, FALSE);
|
||||||
|
$this->adodb->execDB($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -480,9 +485,10 @@ function setPollDStatus($status, $lastrun, $nextrun) {
|
||||||
function isEnabled() {
|
function isEnabled() {
|
||||||
|
|
||||||
$sql = "select enabled from log_polldstat WHERE `id`='1'";
|
$sql = "select enabled from log_polldstat WHERE `id`='1'";
|
||||||
$result = $this->fireMySQLQuery($sql, TRUE);
|
//$result = $this->fireMySQLQuery($sql, TRUE);
|
||||||
|
$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;
|
||||||
|
@ -506,9 +512,13 @@ function controlPollD($switch = "") {
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
//$colarray = array();
|
||||||
|
//$colarray["enabled"] = $val;
|
||||||
$sql = "update log_polldstat set `enabled` = '".$val."' WHERE `id`='1'";
|
$sql = "update log_polldstat set `enabled` = '".$val."' WHERE `id`='1'";
|
||||||
$this->fireMySQLQuery($sql, FALSE);
|
//$this->fireMySQLQuery($sql, FALSE);
|
||||||
|
echo $sql;
|
||||||
|
$this->adodb->execDB($sql);
|
||||||
|
//$this->adodb->updateDB("log_polldstat", $colarray, 'id');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -521,7 +531,8 @@ function controlPollD($switch = "") {
|
||||||
function getStatus() {
|
function getStatus() {
|
||||||
|
|
||||||
$sql = "select status from log_polldstat WHERE `id`='1'";
|
$sql = "select status from log_polldstat WHERE `id`='1'";
|
||||||
$result = $this->fireMySQLQuery($sql, TRUE);
|
//$result = $this->fireMySQLQuery($sql, TRUE);
|
||||||
|
$result = $this->adodb->fetchArrayDB($sql);
|
||||||
|
|
||||||
return $result[0]->status;
|
return $result[0]->status;
|
||||||
|
|
||||||
|
@ -537,7 +548,7 @@ function getStatus() {
|
||||||
|
|
||||||
function poll(){
|
function poll(){
|
||||||
|
|
||||||
$this->controlPollD("off");
|
//$this->controlPollD("off");
|
||||||
|
|
||||||
$sleeptime = $this->getSleeptime();
|
$sleeptime = $this->getSleeptime();
|
||||||
|
|
||||||
|
@ -557,6 +568,7 @@ function poll(){
|
||||||
|
|
||||||
$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;
|
||||||
|
@ -573,7 +585,8 @@ function poll(){
|
||||||
$this->pollOverviewQuery($query, $server, $timestamp);
|
$this->pollOverviewQuery($query, $server, $timestamp);
|
||||||
}
|
}
|
||||||
$sql = 'INSERT INTO log_polldlog VALUES ("'.$timestamp.'", "'.$server["servername"].'", "'.$log_updated.'", "'.$log_unchangedresult.'", "'.$log_pollfreqnoreached.'", "'.(time()-$log_timeneeded).'")';
|
$sql = 'INSERT INTO log_polldlog VALUES ("'.$timestamp.'", "'.$server["servername"].'", "'.$log_updated.'", "'.$log_unchangedresult.'", "'.$log_pollfreqnoreached.'", "'.(time()-$log_timeneeded).'")';
|
||||||
$this->fireMySQLQuery($sql, FALSE);
|
//$this->fireMySQLQuery($sql, FALSE);
|
||||||
|
$this->adodb->execDB($sql);
|
||||||
}
|
}
|
||||||
$init = "no";
|
$init = "no";
|
||||||
|
|
||||||
|
@ -592,7 +605,7 @@ function poll(){
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
echo "PollD is disabled. Sleeping for 5 minutes...\n";
|
echo "PollD is disabled. Sleeping for 5 minutes...\n";
|
||||||
sleep (300);
|
sleep (3);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,9 +131,9 @@ class TSMMonitor {
|
||||||
|
|
||||||
if ($_POST["Poll"] == "Poll Now!") {
|
if ($_POST["Poll"] == "Poll Now!") {
|
||||||
$timestamp = time();
|
$timestamp = time();
|
||||||
$tmonpolld = new PollD();
|
$tmonpolld = new PollD($this->adodb);
|
||||||
//$tmonpolld->setDBParams($this->db_host, $this->db_name, $this->db_user, $this>db_password);
|
//$tmonpolld->setDBParams($this->db_host, $this->db_name, $this->db_user, $this>db_password);
|
||||||
$tmonpolld->initialize();
|
//$tmonpolld->initialize();
|
||||||
$tmonpolld->pollQuery($tmonpolld->queries[$this->GETVars['qq']], $tmonpolld->servers[$this->GETVars['server']], TRUE, $timestamp);
|
$tmonpolld->pollQuery($tmonpolld->queries[$this->GETVars['qq']], $tmonpolld->servers[$this->GETVars['server']], TRUE, $timestamp);
|
||||||
$_SESSION['timemachine']['date'] = $timestamp;
|
$_SESSION['timemachine']['date'] = $timestamp;
|
||||||
$_SESSION['timemachine']['time'] = $timestamp;
|
$_SESSION['timemachine']['time'] = $timestamp;
|
||||||
|
|
|
@ -32,15 +32,36 @@
|
||||||
* @package tsmmonitor
|
* @package tsmmonitor
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// ** Default database settings ** //
|
||||||
|
/**
|
||||||
|
$db_type = 'mysql';
|
||||||
|
$db_name = 'tsmmonitor';
|
||||||
|
$db_user = 'tsmmonitor';
|
||||||
|
$db_password = 'tsmmonitor';
|
||||||
|
$db_host = 'localhost';
|
||||||
|
$db_port = '3306';
|
||||||
|
$db_charset = 'utf8';
|
||||||
|
$db_collate = '';
|
||||||
|
*/
|
||||||
|
// ** Include user configureable definitions ** //
|
||||||
|
//include(dirname(__FILE__) . "/../includes/config.php");
|
||||||
|
|
||||||
require('../includes/config.php');
|
// ** Global configuration array ** //
|
||||||
require('../includes/polld.php');
|
//$config = array();
|
||||||
|
|
||||||
|
// ** Display ALL PHP errors ** //
|
||||||
|
//error_reporting(E_ALL);
|
||||||
|
|
||||||
$tmonpolld = new PollD();
|
// ** Include generic code and external libraries ** //
|
||||||
$tmonpolld->setDBParams($db_host, $db_name, $db_user, $db_password);
|
//include ("../extlib/adodb5/adodb.inc.php");
|
||||||
$tmonpolld->initialize();
|
//include_once("../includes/adodb.php");
|
||||||
$tmonpolld->poll();
|
include_once("../includes/global.php");
|
||||||
|
|
||||||
|
// ** Connect to the database ** //
|
||||||
|
//$adodb = new ADOdb($db_host, $db_port, $db_user, $db_password, $db_name, $db_type, '' ,FALSE);
|
||||||
|
|
||||||
|
$tmonpolld = new PollD($adodb);
|
||||||
|
$tmonpolld->poll();
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue