/** * Initialize debug * * @param array $options */ public static function init($options) { self::$debug = !empty($options['debug']) ? true : false; if (self::$debug) { self::$email = !empty($options['email']) ? $options['email'] : null; self::$toolbar = !empty($options['toolbar']) ? true : false; self::benchmark('application start'); } }
$timeoutSql = $db->q("SELECT deviceConnectionTimout FROM settings"); $result = mysql_fetch_assoc($timeoutSql); $timeout = $result['deviceConnectionTimout']; // Get active nodes for a given task ID // Query to retrieve row for given ID (tidxxxxxx is stored in nodes and is generated when task is created) $getNodesSql = "SELECT \n\t\t\t\t\t\t\t\t\t\tid, \n\t\t\t\t\t\t\t\t\t\tdeviceName, \n\t\t\t\t\t\t\t\t\t\tdeviceIpAddr, \n\t\t\t\t\t\t\t\t\t\tdevicePrompt, \n\t\t\t\t\t\t\t\t\t\tdeviceUsername, \n\t\t\t\t\t\t\t\t\t\tdevicePassword, \n\t\t\t\t\t\t\t\t\t\tdeviceEnableMode, \n\t\t\t\t\t\t\t\t\t\tdeviceEnablePassword, \n\t\t\t\t\t\t\t\t\t\tnodeCatId, \n\t\t\t\t\t\t\t\t\t\tdeviceAccessMethodId, \n\t\t\t\t\t\t\t\t\t\tconnPort \n\t\t\t\t\t\t\t\t\t\tFROM nodes WHERE taskId" . $tid . " = 1 AND status = 1"; if ($result = $db->q($getNodesSql)) { // push rows to $devices array $devices = array(); while ($row = mysql_fetch_assoc($result)) { array_push($devices, $row); } foreach ($devices as $device) { // debugging check and action if ($debugOnOff === '1' || isset($cliDebugOutput)) { $debug->debug($device); } // ok, verification of host reachability based on fsockopen to host port i.e. 22 or 23. If fails, continue to next foreach iteration $status = getHostStatus($device['deviceIpAddr'], $device['connPort']); // getHostStatus() from functions.php if ($status === "<font color=red>Unavailable</font>") { $text = "Failure: Unable to connect to " . $device['deviceName'] . " - " . $device['deviceIpAddr'] . " when running taskID " . $tid; $report->eachData($device['deviceName'], $connStatusFail, $text); // log to report echo $text . " - getHostStatus() Error:(File: " . $_SERVER['PHP_SELF'] . ")\n"; // log to console $log->Conn($text . " - getHostStatus() Error:(File: " . $_SERVER['PHP_SELF'] . ")"); // logg to file continue; } // get command list for device. This is based on the catId. i.e. catId->cmdId->CmdName->Node
public static function stop() { self::$debug = false; }
function debug_mock() { parent::debug(); }
while ($row = mysql_fetch_assoc($result)) { array_push($devices, $row); } // get the config snippet data from the DB $cmdsSql = $db->q("SELECT * FROM snippets WHERE id = " . $snipId); $result = mysql_fetch_assoc($cmdsSql); $snippet = $result['snippet']; $snippetArr = explode("\n", $snippet); // explode text new lines to array $snippetArr = array_map('trim', $snippetArr); // trim whitespace from each array value $tableRow = ""; foreach ($devices as $device) { // debugging check and action if ($debugOnOff === '1' || isset($cliDebugOutput)) { $debug->debug($device); } // ok, verification of host reachability based on fsockopen to host port i.e. 22 or 23. If fails, continue to next foreach iteration $status = getHostStatus($device['deviceIpAddr'], $device['connPort']); // getHostStatus() from functions.php if ($status === "<font color=red>Unavailable</font>") { $text = "Failure: Unable to connect to " . $device['deviceName'] . " - " . $device['deviceIpAddr'] . " when running taskID " . $tid; $report->eachComplianceDataRowDeviceName($device['deviceName'], $connStatusFail, $text); // log to report echo $text . " - getHostStatus() Error:(File: " . $_SERVER['PHP_SELF'] . ")\n"; // log to console $log->Conn($text . " - getHostStatus() Error:(File: " . $_SERVER['PHP_SELF'] . ")"); // logg to file continue; } // get the category for the device