Esempio n. 1
0
         // continue for the foreach if one of the files is not available as this compare will be invalid
         echo 'continue invoked for ' . $device['deviceName'] . "\n";
         continue;
     }
     $pathResult_a = $pathResultToday['configLocation'];
     $pathResult_b = $pathResultYesterday['configLocation'];
     $filenameResult_a = $pathResultToday['configFilename'];
     $filenameResult_b = $pathResultYesterday['configFilename'];
     $path_a = $pathResult_a . '/' . $filenameResult_a;
     $path_b = $pathResult_b . '/' . $filenameResult_b;
     // run the compare with no linepadding set
     $diff = new diff();
     $text = $diff->inline($path_a, $path_b);
     $count = count($diff->changes) . ' changes';
     // send output to the report
     $report->eachData($device['deviceName'], $count, $text);
     // log to report
 }
 // End Data insert loop
 // script endTime
 $endTime = date('h:i:s A');
 $time_end = microtime(true);
 $time = round($time_end - $time_start) . " Seconds";
 $report->findReplace('<taskEndTime>', $endTime);
 $report->findReplace('<taskRunTime>', $time);
 $report->footer();
 if ($taskRow['mailConnectionReport'] == '1') {
     require "/home/rconfig/classes/phpmailer/class.phpmailer.php";
     $q = $db->q("SELECT smtpServerAddr, smtpFromAddr, smtpRecipientAddr, smtpAuth, smtpAuthUser, smtpAuthPass FROM settings");
     $result = mysql_fetch_assoc($q);
     $smtpServerAddr = $result['smtpServerAddr'];
Esempio n. 2
0
 // 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
     $commands = $db->q("SELECT cmd.command \n\t\t\t\t\t\t\tFROM cmdCatTbl AS cct\n\t\t\t\t\t\t\tLEFT JOIN configcommands AS cmd ON cmd.id = cct.configCmdId\n\t\t\t\t\t\t\tWHERE cct.nodeCatId = " . $device['nodeCatId']);
     $cmdNumRows = mysql_num_rows($commands);
     // get the category for the device
     $catNameQ = $db->q("SELECT categoryName FROM categories WHERE id = " . $device['nodeCatId']);
     $catNameRow = mysql_fetch_row($catNameQ);
     $catName = $catNameRow[0];
     // select only first value returned