PollD starts now disabled

PollD is now controlled by admin backend (settings)
This commit is contained in:
Michael Clemens 2009-05-11 16:27:05 +00:00
parent 2bce5107f9
commit 28e85af0fd
3 changed files with 81 additions and 4 deletions

View File

@ -73,7 +73,43 @@ if (isset($_SESSION["logindata"]["user"]) && isset($_SESSION["logindata"]["pass"
// show overview page
if ($GETVars['qq'] == "index") {
//include_once "includes/overview.php" ;
// do nothing
// show settings page
} else if ($GETVars['qq'] == "settings") {
$tmonpolld = new PollD();
$tmonpolld->setDBParams($db_host, $db_name, $db_user, $db_password);
$tmonpolld->initialize();
// If start/stop button was pressed
if ($_POST["PollDControl"] != "") {
if ($_POST["PollDControl"] == "Start") {
$tmonpolld->controlPollD("on");
} else if ($_POST["PollDControl"] == "Stop") {
$tmonpolld->controlPollD("off");
}
}
if ($tmonpolld->isEnabled()=="1") {
$polldenabled = "enabled and ".$tmonpolld->getStatus();
$cellcolor = "green";
} else {
$polldenabled = "disabled";
$cellcolor = "red";
}
echo "<b>PollD Control</b><br>";
echo "<form action=".$_SERVER['PHP_SELF']."?q=".$GETVars['qq']."&m=".$GETVars['menu']." method='post'>";
echo "<table class='zebra'>";
echo "<tr><th>Start/Stop</th><th>Status</th></tr>";
echo "<tr class='d0'><td>";
echo "<input type='submit' class='button' name='PollDControl' value='Start' onclick='submit();'>";
echo "<input type='submit' class='button' name='PollDControl' value='Stop' onclick='submit();'>";
echo "</td></td><td bgcolor=".$cellcolor.">PollD is ".$polldenabled."</td></tr>";
echo "</table>";
echo "<br><br>";
echo "</form>";
} else {
if ( ($_GET['action'] != "" && ($_GET['action'] == "edit" && $_GET['id'] != "")) || $_POST['Add'] == "Add") {

View File

@ -127,7 +127,7 @@ function initialize() {
}
if (($_POST['Poll'] == "Poll Now!" || $_SESSION['timemachine']['date'] == "") && $queryarray[$GETVars['qq']]["polltype"]=="snapshot" || $_POST['s'] != "" && $GETVars['qq'] != "overview") {
if (($_POST['Poll'] == "Poll Now!" || $_SESSION['timemachine']['date'] == "") && $queryarray[$GETVars['qq']]["polltype"]=="snapshot" || $_POST['s'] != "" && $GETVars['qq'] != "overview" && $GETVars['qq'] != "index") {
$qtable = $configarray["queryarray"][$GETVars['qq']]["name"];
$sql = "SELECT MAX(TimeStamp) FROM res_".$qtable."_".$GETVars["server"];
$res = fetchArrayDB($sql, $conn);
@ -1405,6 +1405,8 @@ function getConfigArray() {
$adminmenuarray["q=mainmenu&m=main"] = "Mainmenu";
$adminmenuarray["q=queries&m=main"] = "Queries";
$adminmenuarray["trennlinie"] = "trennlinie";
$adminmenuarray["q=settings&m=main"] = "Settings";
$adminmenuarray["trennlinie2"] = "trennlinie";
$adminmenuarray["tsmmonitor"] = "TSM Monitor";
$adminmenuarray["q=logout"] = "Logout";
$retArray["adminmenuarray"] = $adminmenuarray;

View File

@ -481,9 +481,9 @@ function setPollDStatus($status, $lastrun, $nextrun) {
function isEnabled() {
$sql = "select enabled from log_polldstat WHERE `id`='1'";
$enabled = $this->fireMySQLQuery($sql, TRUE);
$result = $this->fireMySQLQuery($sql, TRUE);
if ($enabled != "" && $enabled[0]->enabled == "1"){
if ($result != "" && $result[0]->enabled == "1"){
return TRUE;
} else {
return FALSE;
@ -492,6 +492,43 @@ function isEnabled() {
}
/**
* controlPollD - enables or disables polld
*
* @param string switch on or off
*/
function controlPollD($switch = "") {
if ($switch == "on") {
$val = "1";
} else if ($switch == "off") {
$val = "0";
} else {
return "";
}
$sql = "update log_polldstat set `enabled` = '".$val."' WHERE `id`='1'";
$this->fireMySQLQuery($sql, FALSE);
}
/**
* get Status - returns status of PollD
*
* @returns string
*/
function getStatus() {
$sql = "select status from log_polldstat WHERE `id`='1'";
$result = $this->fireMySQLQuery($sql, TRUE);
return $result[0]->status;
}
/**
* poll - the main function that polls the data
@ -501,6 +538,8 @@ function isEnabled() {
function poll(){
$this->controlPollD("off");
$sleeptime = $this->getSleeptime();