Beispiel #1
0
            $mainConfig->setUseTimezone(null);
        }
        $mainConfig->save();
        $success = "Modified Main Debug Configuration";
    }
    if ($_POST['request'] == "main_modify_broker") {
        $mainConfig->setEventBrokerOptions($_POST['main_config']['event_broker_options']);
        $mainConfig->save();
        $success = "Modified Main Broker Configuration";
    } else {
        if ($_POST['request'] == "module_add") {
            if (!isset($_POST['module_line']) || !strlen(trim($_POST['module_line']))) {
                $error = "Broker module line cannot be blank.";
            } else {
                // We want to add an event broker module
                $module = new NagiosBrokerModule();
                $module->setLine($_POST['module_line']);
                $module->save();
                $success = "Added Broker Module";
            }
        }
    }
}
$mainValues = array();
$mainValues = $mainConfig->getValues();
// To create a "default" command
$lilac->return_command_list($tempList);
$command_list[] = array("command_id" => '', "command_name" => "None");
foreach ($tempList as $tempCommand) {
    $command_list[] = array("command_id" => $tempCommand->getId(), "command_name" => $tempCommand->getName());
}
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      NagiosBrokerModule $value A NagiosBrokerModule object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(NagiosBrokerModule $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Beispiel #3
0
 public function import()
 {
     global $lilac;
     $engine = $this->getEngine();
     $job = $engine->getJob();
     $job->addNotice("FruityMainImporter beginning to import Main Configuration.");
     $res = $this->dbConn->query("SELECT * FROM nagios_main");
     // Fruity has just one record in the main, if we get it, import
     // it.
     $row = $res->fetch(PDO::FETCH_ASSOC);
     // Get our main obj.
     $mainConfig = $lilac->get_main_conf();
     foreach ($row as $key => $val) {
         unset($name);
         if ($key == "id" || $key == "p1_file" || $key == "comment_file" || $key == "downtime_file" || $key == "aggregate_status_updates") {
             continue;
         }
         if ($key == "service_perfdata_template") {
             $key = "service_perfdata_file_template";
         }
         if ($key == "host_perfdata_template") {
             $key = "host_perfdata_file_template";
         }
         if ($key == "global_host_event_handler") {
             $commandName = $this->getCommandNameById($val);
             $command = NagiosCommandPeer::getByName($commandName);
             if ($command) {
                 $val = $command->getId();
             } else {
                 $val = null;
             }
         }
         if ($key == "global_service_event_handler") {
             $commandName = $this->getCommandNameById($val);
             $command = NagiosCommandPeer::getByName($commandName);
             if ($command) {
                 $val = $command->getId();
             } else {
                 $val = null;
             }
         }
         if ($key == "ocsp_command") {
             $commandName = $this->getCommandNameById($val);
             $command = NagiosCommandPeer::getByName($commandName);
             if ($command) {
                 $val = $command->getId();
             } else {
                 $val = null;
             }
         }
         if ($key == "ochp_command") {
             $commandName = $this->getCommandNameById($val);
             $command = NagiosCommandPeer::getByName($commandName);
             if ($command) {
                 $val = $command->getId();
             } else {
                 $val = null;
             }
         }
         if ($key == "host_perfdata_command") {
             $commandName = $this->getCommandNameById($val);
             $command = NagiosCommandPeer::getByName($commandName);
             if ($command) {
                 $val = $command->getId();
             } else {
                 $val = null;
             }
         }
         if ($key == "service_perfdata_command") {
             $commandName = $this->getCommandNameById($val);
             $command = NagiosCommandPeer::getByName($commandName);
             if ($command) {
                 $val = $command->getId();
             } else {
                 $val = null;
             }
         }
         if ($key == "host_perfdata_file_processing_command") {
             $commandName = $this->getCommandNameById($val);
             $command = NagiosCommandPeer::getByName($commandName);
             if ($command) {
                 $val = $command->getId();
             } else {
                 $val = null;
             }
         }
         if ($key == "service_perfdata_file_processing_command") {
             $commandName = $this->getCommandNameById($val);
             $command = NagiosCommandPeer::getByName($commandName);
             if ($command) {
                 $val = $command->getId();
             } else {
                 $val = null;
             }
         }
         try {
             $name = NagiosMainConfigurationPeer::translateFieldName($key, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_PHPNAME);
         } catch (Exception $e) {
             $job->addNotice("Main Configuration: Was unable to store unsupported value: " . $key);
         }
         if (!empty($name)) {
             $method = "set" . $name;
             $mainConfig->{$method}($val);
         }
     }
     $mainConfig->save();
     // Save main configuration
     // Broker modules
     foreach ($this->dbConn->query("SELECT * FROM nagios_broker_modules", PDO::FETCH_ASSOC) as $brokerModule) {
         $newModule = new NagiosBrokerModule();
         foreach ($brokerModule as $key => $val) {
             unset($name);
             if ($key == "module_id") {
                 continue;
             }
             if ($key == "module_line") {
                 $key = "line";
             }
             try {
                 $name = NagiosBrokerModulePeer::translateFieldName($key, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_PHPNAME);
             } catch (Exception $e) {
                 $job->addNotice("Broker Module: Was unable to store unsupported value: " . $key);
             }
             if (!empty($name)) {
                 $method = "set" . $name;
                 $newModule->{$method}($val);
             }
         }
         $newModule->save();
     }
     $job->addNotice("FruityMainImporter finished importing Main Configuration.");
 }