예제 #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;
 }
예제 #2
0
 /**
  * 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;
 }
예제 #3
0
파일: main.php 프로젝트: Evolix/lilac
                                                            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");
                                                                ?>