Esempio n. 1
0
 public function export()
 {
     // Grab our export job
     $engine = $this->getEngine();
     $job = $engine->getJob();
     $job->addNotice("NagiosMainExporter attempting to export main configuration.");
     // Grab our main config
     $mainConfig = NagiosMainConfigurationPeer::doSelectOne(new Criteria());
     if (!$mainConfig) {
         $job->addError("Unable to get Main Configuration object.  Your Lilac database is corrupt.");
         return false;
     }
     $finalArray = array();
     $commandLookupArray = array('global_host_event_handler', 'global_service_event_handler', 'ocsp_command', 'ochp_command', 'host_perfdata_command', 'service_perfdata_command', 'host_perfdata_file_processing_command', 'service_perfdata_command', 'service_perfdata_file_processing_command');
     $values = $mainConfig->toArray(BasePeer::TYPE_FIELDNAME);
     foreach ($values as $key => $value) {
         if ($key == 'id' || $key == 'config_dir') {
             continue;
         }
         if ($value === null) {
             continue;
         }
         if ($value === false) {
             $value = '0';
         }
         if (in_array($key, $commandLookupArray)) {
             $command = NagiosCommandPeer::retrieveByPK($value);
             if (!$command) {
                 $job->addError("Unable to find command with id:" . $value . " for " . $key);
                 return false;
             } else {
                 $value = $command->getName();
             }
         }
         $finalArray[$key] = $value;
     }
     $fp = $this->getOutputFile();
     fputs($fp, "# Written by NagiosMainExporter from " . LILAC_NAME . " " . LILAC_VERSION . " on " . date("F j, Y, g:i a") . "\n\n");
     foreach ($finalArray as $key => $val) {
         fputs($fp, $key . "=" . $val . "\n");
     }
     // Get list of broker modules
     $modules = NagiosBrokerModulePeer::doSelect(new Criteria());
     foreach ($modules as $mod) {
         fputs($fp, "broker_module=" . $mod->getLine() . "\n");
     }
     if (!empty($this->configDir)) {
         fputs($fp, "resource_file=" . $this->configDir . "/resource.cfg\n");
     } else {
         fputs($fp, "resource_file=" . $mainConfig->getConfigDir() . "/resource.cfg\n");
     }
     if (!empty($this->configDir)) {
         fputs($fp, "cfg_dir=" . $this->configDir . "/objects\n");
     } else {
         fputs($fp, "cfg_dir=" . $mainConfig->getConfigDir() . "/objects\n");
     }
     $job->addNotice("NagiosMainExporter complete.");
     return true;
 }
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(NagiosBrokerModulePeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(NagiosBrokerModulePeer::DATABASE_NAME);
         $criteria->add(NagiosBrokerModulePeer::ID, $pks, Criteria::IN);
         $objs = NagiosBrokerModulePeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Esempio n. 3
0
                                                            form_select_element_with_enabler($enable_list, "values", "text", "main_config", "use_embedded_perl_implicitly", "Use Embedded Perl Implicitly", $lilac->element_desc("use_embedded_perl_implicitly", "nagios_main_desc"), $mainValues, null);
                                                            form_text_element_with_enabler(60, 255, "main_config", "p1_file", "P1 File", $lilac->element_desc("p1_file", "nagios_main_desc"), $mainValues, null);
                                                            form_select_element_with_enabler($enable_list, "values", "text", "main_config", "daemon_dumps_core", "Daemon Dumps Core", $lilac->element_desc("daemon_dumps_core", "nagios_main_desc"), $mainValues, null);
                                                            form_text_element_with_enabler(60, 255, "main_config", "admin_email", "Admin Email", $lilac->element_desc("admin_email", "nagios_main_desc"), $mainValues, null);
                                                            form_text_element_with_enabler(60, 255, "main_config", "admin_pager", "Admin Pager", $lilac->element_desc("admin_pager", "nagios_main_desc"), $mainValues, null);
                                                            form_text_element_with_enabler(60, 255, "main_config", "use_timezone", "use_timezone", $lilac->element_desc("use_timezone", "nagios_main_desc"), $mainValues, null);
                                                            double_pane_form_window_finish();
                                                            ?>
		<div class="formbox">
		<input type="submit" value="Update Other Configuration" />
		</div>
		</form>
		<?php 
                                                        } else {
                                                            if ($_GET['section'] == 'broker') {
                                                                $module_list = NagiosBrokerModulePeer::doSelect(new Criteria());
                                                                $numOfModules = count($module_list);
                                                                $broker_list = array();
                                                                $broker_list[] = array("value" => "0", "label" => "Broker nothing");
                                                                $broker_list[] = array("value" => "-1", "label" => "Broker everything");
                                                                ?>
		<form name="main_broker_config" method="post" action="main.php?section=broker">
		<input type="hidden" name="request" value="main_modify_broker" />
		<div class="formbox">
			<b>Event Broker Options:</b> <?php 
                                                                print_select("main_config[event_broker_options]", $broker_list, "value", "label", $mainConfig->getEventBrokerOptions());
                                                                ?>
<br />
			<?php 
                                                                echo $lilac->element_desc("event_broker_options", "nagios_main_desc");
                                                                ?>
Esempio n. 4
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = NagiosBrokerModulePeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setLine($arr[$keys[1]]);
     }
 }
Esempio n. 5
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.");
 }
Esempio n. 6
0
 public function import()
 {
     $job = $this->getJob();
     $job->addNotice("FruityImportEngine beginning import...");
     $config = $this->getConfig();
     $job->addNotice("Removing existing Nagios objects.");
     NagiosTimeperiodPeer::doDeleteAll();
     NagiosCommandPeer::doDeleteAll();
     NagiosContactPeer::doDeleteAll();
     NagiosContactGroupPeer::doDeleteAll();
     NagiosHostTemplatePeer::doDeleteAll();
     NagiosHostPeer::doDeleteAll();
     NagiosHostgroupPeer::doDeleteAll();
     NagiosServiceGroupPeer::doDeleteAll();
     NagiosServiceTemplatePeer::doDeleteAll();
     NagiosServicePeer::doDeleteAll();
     NagiosDependencyPeer::doDeleteAll();
     NagiosDependencyTargetPeer::doDeleteAll();
     NagiosEscalationPeer::doDeleteAll();
     NagiosBrokerModulePeer::doDeleteAll();
     NagiosMainConfigurationPeer::doDeleteAll();
     NagiosCgiConfigurationPeer::doDeleteAll();
     $importer = new FruityResourceImporter($this, $this->dbConn);
     $importer->import();
     $importer = new FruityCgiImporter($this, $this->dbConn);
     $importer->import();
     $importer = new FruityCommandImporter($this, $this->dbConn);
     $importer->import();
     $importer = new FruityTimeperiodImporter($this, $this->dbConn);
     $importer->import();
     $importer = new FruityContactImporter($this, $this->dbConn);
     $importer->import();
     $importer = new FruityServiceGroupImporter($this, $this->dbConn);
     $importer->import();
     $importer = new FruityServiceTemplateImporter($this, $this->dbConn);
     $importer->import();
     $importer = new FruityHostTemplateImporter($this, $this->dbConn);
     $importer->import();
     $importer = new FruityHostGroupImporter($this, $this->dbConn);
     $importer->import();
     $importer = new FruityHostImporter($this, $this->dbConn);
     $importer->import();
     $importer = new FruityServiceImporter($this, $this->dbConn);
     $importer->import();
     $importer = new FruityDependencyImporter($this, $this->dbConn);
     $importer->import();
     $importer = new FruityEscalationImporter($this, $this->dbConn);
     $importer->import();
     $importer = new FruityMainImporter($this, $this->dbConn);
     $importer->import();
     $job->addNotice("FruityImportEngine completed job.");
     return true;
 }