Пример #1
0
 public function getByName($name)
 {
     $c = new Criteria();
     $c->add(NagiosServiceTemplatePeer::NAME, $name);
     $c->setIgnoreCase(true);
     $template = NagiosServiceTemplatePeer::doSelectOne($c);
     if (!$template) {
         return false;
     }
     return $template;
 }
Пример #2
0
 public function init()
 {
     $job = $this->getJob();
     $job->addNotice("NagiosImportEngine Starting...");
     $config = $this->getConfig();
     // Attempt to try and open each config file
     $job->addNotice("Attempting to open " . $config->GetVar('config_file'));
     if (!file_exists($config->getVar('config_file')) || !@fopen($config->getVar('config_file'), "r")) {
         $job->addError("Failed to open " . $config->getVar('config_file'));
         return false;
     }
     $job->addNotice("Attempting to open " . $config->GetVar('cgi_file'));
     if (!file_exists($config->getVar('cgi_file')) || !@fopen($config->getVar('cgi_file'), "r")) {
         $job->addError("Failed to open " . $config->getVar('cgi_file'));
         return false;
     }
     $job->addNotice("Attempting to open " . $config->GetVar('resources_file'));
     if (!file_exists($config->getVar('resources_file')) || !@fopen($config->getVar('resources_file'), "r")) {
         $job->addError("Failed to open " . $config->getVar('resources_file'));
         return false;
     }
     $job->addNotice("Config passed sanity check for Nagios import.  Finished initializing.");
     if ($config->getVar('delete_existing')) {
         $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();
     }
     return true;
 }
Пример #3
0
		<td><?php 
echo NagiosServiceGroupPeer::doCount(new Criteria());
?>
</td>
	</tr>
	<tr>
		<td><strong>Total Nagios Host Templates:</strong></td>
		<td><?php 
echo NagiosHostTemplatePeer::doCount(new Criteria());
?>
</td>
	</tr>
	<tr class="odd">
		<td><strong>Total Nagios Service Templates:</strong></td>
		<td><?php 
echo NagiosServiceTemplatePeer::doCount(new Criteria());
?>
</td>
	</tr>
	<tr>
		<td><strong>Total Nagios Hosts:</strong></td>
		<td><?php 
echo NagiosHostPeer::doCount(new Criteria());
?>
</td>
	</tr>
	<tr class="odd">
		<td><strong>Total Nagios Services:</strong></td>
		<td><?php 
echo NagiosServicePeer::doCountAll();
?>
Пример #4
0
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this NagiosTimeperiod is new, it will return
  * an empty collection; or if this NagiosTimeperiod has previously
  * been saved, it will retrieve related NagiosServiceTemplatesRelatedByNotificationPeriod from storage.
  *
  * This method is protected by default in order to keep the public
  * api reasonable.  You can provide public methods for those you
  * actually need in NagiosTimeperiod.
  */
 public function getNagiosServiceTemplatesRelatedByNotificationPeriodJoinNagiosCommandRelatedByEventHandler($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     if ($criteria === null) {
         $criteria = new Criteria(NagiosTimeperiodPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collNagiosServiceTemplatesRelatedByNotificationPeriod === null) {
         if ($this->isNew()) {
             $this->collNagiosServiceTemplatesRelatedByNotificationPeriod = array();
         } else {
             $criteria->add(NagiosServiceTemplatePeer::NOTIFICATION_PERIOD, $this->id);
             $this->collNagiosServiceTemplatesRelatedByNotificationPeriod = NagiosServiceTemplatePeer::doSelectJoinNagiosCommandRelatedByEventHandler($criteria, $con, $join_behavior);
         }
     } else {
         // the following code is to determine if a new query is
         // called for.  If the criteria is the same as the last
         // one, just return the collection.
         $criteria->add(NagiosServiceTemplatePeer::NOTIFICATION_PERIOD, $this->id);
         if (!isset($this->lastNagiosServiceTemplateRelatedByNotificationPeriodCriteria) || !$this->lastNagiosServiceTemplateRelatedByNotificationPeriodCriteria->equals($criteria)) {
             $this->collNagiosServiceTemplatesRelatedByNotificationPeriod = NagiosServiceTemplatePeer::doSelectJoinNagiosCommandRelatedByEventHandler($criteria, $con, $join_behavior);
         }
     }
     $this->lastNagiosServiceTemplateRelatedByNotificationPeriodCriteria = $criteria;
     return $this->collNagiosServiceTemplatesRelatedByNotificationPeriod;
 }
Пример #5
0
 private function importService($serviceData)
 {
     $job = $this->getEngine()->getJob();
     $newService = new NagiosService();
     // Check to see if host or host template exists first
     if (!empty($serviceData['host_id'])) {
         $hostName = $this->getHostNameById($serviceData['host_id']);
         if (!$hostName) {
             $job->addNotice("Fruity Service Importer: Failed to find host with id: " . $serviceData['host_id']);
             return true;
         }
         $host = NagiosHostPeer::getByName($hostName);
         if (!$host) {
             $job->addNotice("Fruity Service Importer: Failed to find host with name: " . $hostName);
             return true;
         }
         $newService->setHost($host->getId());
     } else {
         if (!empty($serviceData['host_template_id'])) {
             $hostTemplateName = $this->getHostTemplateNameById($serviceData['host_template_id']);
             if (!$hostTemplateName) {
                 $job->addNotice("Fruity Service Importer: Failed to find host template with id: " . $serviceData['host_template_id']);
                 return true;
             }
             $hostTemplate = NagiosHostTemplatePeer::getByName($hostTemplateName);
             if (!$hostTemplate) {
                 $job->addNotice("Fruity Service Importer: Failed to find host template with name: " . $hostTemplateName);
                 return true;
             }
             $newService->setHostTemplate($hostTemplate->getId());
         } else {
             if (!empty($serviceData['hostgroup_id'])) {
                 $hostgroupName = $this->getHostGroupNameById($serviceData['hostgroup_id']);
                 if (!$hostgroupName) {
                     $job->addNotice("Fruity Service Importer: Failed to find host group with id: " . $serviceData['host_template_id']);
                     return true;
                 }
                 $hostgroup = NagiosHostGroupPeer::getByName($hostgroupName);
                 if (!$hostgroup) {
                     $job->addNotice("Fruity Service Importer: Failed to find host group with name: " . $hostGroupName);
                     return true;
                 }
                 $newService->setHostgroup($hostgroup->getId());
             }
         }
     }
     // Check to see if we need the template
     if (!empty($serviceData['use_template_id'])) {
         $name = $this->getServiceTemplateNameById($serviceData['use_template_id'], $this->dbConn);
         if (!$name) {
             $job->addNotice("Fruity Service Importer:  Could not find template with id: " . $serviceData['use_template_id'] . ". Aborting it's import.");
             return false;
         } else {
             // Okay, we got the name, does this template exist?
             $template = NagiosServiceTemplatePeer::getByName($name);
             if (!$template) {
                 return false;
             } else {
                 // Create a new inheritance relationship
                 $inheritance = new NagiosServiceTemplateInheritance();
                 $inheritance->setNagiosServiceTemplateRelatedByTargetTemplate($template);
                 $inheritance->setNagiosService($newService);
                 try {
                     $inheritance->save();
                 } catch (Exception $e) {
                     $job->addNotice("Fruity Service Template Importer:  Cannot add inheritance from " . $template->getName() . " to " . $newService->getName());
                 }
             }
         }
     }
     // Okay, start 'er up!
     foreach ($serviceData as $key => $val) {
         unset($name);
         if ($key == "service_template_id" || $key == "use_template_id" || $key == "template_name" || $key == "host_id" || $key == "hostgroup_id" || $key == "host_template_id" || $key == "service_id") {
             continue;
         }
         if ($key == "service_description") {
             $key = "description";
         }
         if ($key == "notification_options_warning") {
             $key = "notification_on_warning";
         }
         if ($key == "notification_options_unknown") {
             $key = "notification_on_unknown";
         }
         if ($key == "notification_options_critical") {
             $key = "notification_on_critical";
         }
         if ($key == "notification_options_recovery") {
             $key = "notification_on_recovery";
         }
         if ($key == "notification_options_flapping") {
             $key = "notification_on_flapping";
         }
         if ($key == "stalking_options_warning") {
             $key = "stalking_on_warning";
         }
         if ($key == "stalking_options_unknown") {
             $key = "stalking_on_unknown";
         }
         if ($key == "stalking_options_critical") {
             $key = "stalking_on_critical";
         }
         if ($key == "stalking_options_ok") {
             $key = "stalking_on_ok";
         }
         if ($key == "max_check_attempts") {
             $key = "maximum_check_attempts";
         }
         if ($key == "retry_check_interval") {
             $key = "retry_interval";
         }
         if ($key == "check_command") {
             $name = $this->getCommandNameById($val);
             if ($name) {
                 $command = NagiosCommandPeer::getByName($name);
                 if ($command) {
                     $newService->setCheckCommand($command->getId());
                 }
             }
             continue;
         }
         if ($key == "check_period") {
             $name = $this->getTimeperiodNameById($val);
             if ($name) {
                 $timeperiod = NagiosTimeperiodPeer::getByName($name);
                 if ($timeperiod) {
                     $newService->setCheckPeriod($timeperiod->getId());
                 }
             }
             continue;
         }
         if ($key == "event_handler") {
             $name = $this->getCommandNameById($val);
             if ($name) {
                 $command = NagiosCommandPeer::getByName($name);
                 if ($command) {
                     $newService->setEventHandler($command->getId());
                 }
             }
             continue;
         }
         if ($key == "notification_period") {
             $name = $this->getTimeperiodNameById($val);
             if ($name) {
                 $timeperiod = NagiosTimeperiodPeer::getByName($name);
                 if ($timeperiod) {
                     $newService->setNotificationPeriod($timeperiod->getId());
                 }
             }
             continue;
         }
         try {
             $name = NagiosServiceTemplatePeer::translateFieldName($key, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_PHPNAME);
         } catch (Exception $e) {
             $job->addNotice("Fruity Service Importer: Was unable to store unsupported value: " . $key);
         }
         if (!empty($name)) {
             $method = "set" . $name;
             $newService->{$method}($val);
         }
     }
     $job->addNotice("Fruity Service Importer: Saved service: " . $newService->getDescription() . " on " . $newService->getOwnerDescription());
     $newService->save();
     $this->totalImported++;
     return true;
 }
Пример #6
0
    ?>
				</td>
			</tr>
			</table>
			<?php 
}
if ($_GET['section'] == 'inheritance') {
    $templateInheritances = $service->getNagiosServiceTemplateInheritances();
    $numOfTemplates = count($templateInheritances);
    $exclude_list = array();
    if ($numOfTemplates) {
        foreach ($templateInheritances as $template) {
            $exclude_list[] = $template->getId();
        }
    }
    $templateList = NagiosServiceTemplatePeer::doSelect(new Criteria());
    ?>
			<table width="100%" border="0">
			<tr>
				<td width="100" align="center" valign="top">
				<img src="<?php 
    echo $service_icon_image;
    ?>
" />
				</td>
				<td valign="top">
				<table width="100%" align="center" cellspacing="0" cellpadding="2" border="0">
					<tr class="altTop">
					<td colspan="4">Service Templates To Inherit From (Top to Bottom):</td>
					</tr>
					<?php 
Пример #7
0
    }
    $type = "hosttemplate";
    $title = "Host Template";
} else {
    if (isset($_GET['host_id'])) {
        $tempSource = NagiosHostPeer::retrieveByPK($_GET['host_id']);
        $fieldName = "host_id";
        $link = "hosts.php";
        if (!$tempSource) {
            header("Location: welcome.php");
        }
        $type = "host";
        $title = "Host";
    } else {
        if (isset($_GET['service_template_id'])) {
            $tempSource = NagiosServiceTemplatePeer::retrieveByPK($_GET['service_template_id']);
            $fieldName = "service_template_id";
            $link = "service_template.php";
            if (!$tempSource) {
                header("Location: welcome.php");
            }
            $type = "servicetemplate";
            $title = "Service Template";
        } else {
            if (isset($_GET['service_id'])) {
                $tempSource = NagiosServicePeer::retrieveByPK($_GET['service_id']);
                $fieldName = "service_id";
                $link = "service.php";
                if (!$tempSource) {
                    header("Location: welcome.php");
                }
Пример #8
0
 private function search_text($text)
 {
     // LOTS of places to check...
     // Hosts: name, alias, addresses
     $c = new Criteria();
     $c1 = $c->getNewCriterion(NagiosHostPeer::NAME, "%" . $text . "%", Criteria::LIKE);
     $c2 = $c->getNewCriterion(nagiosHostPeer::ALIAS, "%" . $text . "%", Criteria::LIKE);
     $c3 = $c->getNewCriterion(nagiosHostPeer::ADDRESS, "%" . $text . "%", Criteria::LIKE);
     $c2->addOr($c3);
     $c1->addOr($c2);
     $c->add($c1);
     $c->setIgnoreCase(true);
     $c->addAscendingOrderByColumn(NagiosHostPeer::NAME);
     $matchedHosts = NagiosHostPeer::doSelect($c);
     if (count($matchedHosts)) {
         foreach ($matchedHosts as $host) {
             $this->searchResults['hosts'][$host->getId()] = $host;
             $this->searchCount++;
         }
     }
     // Hostgroups: name, alias
     $c = new Criteria();
     $c1 = $c->getNewCriterion(NagiosHostgroupPeer::NAME, "%" . $text . "%", Criteria::LIKE);
     $c2 = $c->getNewCriterion(nagiosHostgroupPeer::ALIAS, "%" . $text . "%", Criteria::LIKE);
     $c1->addOr($c2);
     $c->add($c1);
     $c->setIgnoreCase(true);
     $c->addAscendingOrderByColumn(NagiosHostgroupPeer::NAME);
     $matchedHostgroups = NagiosHostgroupPeer::doSelect($c);
     if (count($matchedHostgroups)) {
         foreach ($matchedHostgroups as $hostgroup) {
             $this->searchResults['hostgroups'][$hostgroup->getId()] = $hostgroup;
             $this->searchCount++;
         }
     }
     // Host Templates: name, description
     $c = new Criteria();
     $c1 = $c->getNewCriterion(NagiosHostTemplatePeer::NAME, "%" . $text . "%", Criteria::LIKE);
     $c2 = $c->getNewCriterion(NagiosHostTemplatePeer::DESCRIPTION, "%" . $text . "%", Criteria::LIKE);
     $c1->addOr($c2);
     $c->add($c1);
     $c->setIgnoreCase(true);
     $c->addAscendingOrderByColumn(NagiosHostTemplatePeer::NAME);
     $matchedTemplates = NagiosHostTemplatePeer::doSelect($c);
     if (count($matchedTemplates)) {
         foreach ($matchedTemplates as $template) {
             $this->searchResults['host_templates'][$template->getId()] = $template;
             $this->searchCount++;
         }
     }
     // Services: description
     $c = new Criteria();
     $c1 = $c->getNewCriterion(NagiosServicePeer::DESCRIPTION, "%" . $text . "%", Criteria::LIKE);
     $c->add($c1);
     $c->setIgnoreCase(true);
     $c->addAscendingOrderByColumn(NagiosServicePeer::DESCRIPTION);
     $matchedServices = NagiosServicePeer::doSelect($c);
     if (count($matchedServices)) {
         foreach ($matchedServices as $service) {
             $this->searchResults['services'][$service->getId()] = $service;
             $this->searchCount++;
         }
     }
     // Servicegroups: name, alias
     $c = new Criteria();
     $c1 = $c->getNewCriterion(NagiosServiceGroupPeer::NAME, "%" . $text . "%", Criteria::LIKE);
     $c2 = $c->getNewCriterion(NagiosServiceGroupPeer::ALIAS, "%" . $text . "%", Criteria::LIKE);
     $c1->addOr($c2);
     $c->add($c1);
     $c->setIgnoreCase(true);
     $c->addAscendingOrderByColumn(NagiosServiceGroupPeer::NAME);
     $matchedServicegroups = NagiosServiceGroupPeer::doSelect($c);
     if (count($matchedServicegroups)) {
         foreach ($matchedServicegroups as $servicegroup) {
             $this->searchResults['servicegroups'][$servicegroup->getId()] = $servicegroup;
             $this->searchCount++;
         }
     }
     // Service Templates: name, description
     $c = new Criteria();
     $c1 = $c->getNewCriterion(NagiosServiceTemplatePeer::NAME, "%" . $text . "%", Criteria::LIKE);
     $c2 = $c->getNewCriterion(NagiosServiceTemplatePeer::DESCRIPTION, "%" . $text . "%", Criteria::LIKE);
     $c1->addOr($c2);
     $c->add($c1);
     $c->setIgnoreCase(true);
     $c->addAscendingOrderByColumn(NagiosServiceTemplatePeer::NAME);
     $matchedTemplates = NagiosServiceTemplatePeer::doSelect($c);
     if (count($matchedTemplates)) {
         foreach ($matchedTemplates as $template) {
             $this->searchResults['service_templates'][$template->getId()] = $template;
             $this->searchCount++;
         }
     }
     // Service Templates: name, description
     $c = new Criteria();
     $c1 = $c->getNewCriterion(NagiosContactPeer::NAME, "%" . $text . "%", Criteria::LIKE);
     $c2 = $c->getNewCriterion(NagiosContactPeer::ALIAS, "%" . $text . "%", Criteria::LIKE);
     $c3 = $c->getNewCriterion(NagiosContactPeer::EMAIL, "%" . $text . "%", Criteria::LIKE);
     $c2->addOr($c3);
     $c1->addOr($c2);
     $c->add($c1);
     $c->setIgnoreCase(true);
     $c->addAscendingOrderByColumn(NagiosContactPeer::NAME);
     $matchedContacts = NagiosContactPeer::doSelect($c);
     if (count($matchedContacts)) {
         foreach ($matchedContacts as $contact) {
             $this->searchResults['contacts'][$contact->getId()] = $contact;
             $this->searchCount++;
         }
     }
     // ContactGroups: name, alias
     $c = new Criteria();
     $c1 = $c->getNewCriterion(NagiosContactGroupPeer::NAME, "%" . $text . "%", Criteria::LIKE);
     $c2 = $c->getNewCriterion(NagiosContactGroupPeer::ALIAS, "%" . $text . "%", Criteria::LIKE);
     $c1->addOr($c2);
     $c->add($c1);
     $c->setIgnoreCase(true);
     $c->addAscendingOrderByColumn(NagiosContactGroupPeer::NAME);
     $matchedContactgroups = NagiosContactGroupPeer::doSelect($c);
     if (count($matchedContactgroups)) {
         foreach ($matchedContactgroups as $contactgroup) {
             $this->searchResults['contactgroups'][$contactgroup->getId()] = $contactgroup;
             $this->searchCount++;
         }
     }
     // Timeperiod: name, alias
     $c = new Criteria();
     $c1 = $c->getNewCriterion(NagiosTimeperiodPeer::NAME, "%" . $text . "%", Criteria::LIKE);
     $c2 = $c->getNewCriterion(NagiosTimeperiodPeer::ALIAS, "%" . $text . "%", Criteria::LIKE);
     $c1->addOr($c2);
     $c->add($c1);
     $c->setIgnoreCase(true);
     $c->addAscendingOrderByColumn(NagiosTimeperiodPeer::NAME);
     $matchedPeriods = NagiosTimeperiodPeer::doSelect($c);
     if (count($matchedPeriods)) {
         foreach ($matchedPeriods as $period) {
             $this->searchResults['timeperiods'][$period->getId()] = $period;
             $this->searchCount++;
         }
     }
     // Command: name, description
     $c = new Criteria();
     $c1 = $c->getNewCriterion(NagiosCommandPeer::NAME, "%" . $text . "%", Criteria::LIKE);
     $c2 = $c->getNewCriterion(NagiosCommandPeer::DESCRIPTION, "%" . $text . "%", Criteria::LIKE);
     $c1->addOr($c2);
     $c->add($c1);
     $c->setIgnoreCase(true);
     $c->addAscendingOrderByColumn(NagiosCommandPeer::NAME);
     $matchedCommands = NagiosCommandPeer::doSelect($c);
     if (count($matchedCommands)) {
         foreach ($matchedCommands as $command) {
             $this->searchResults['commands'][$command->getId()] = $command;
             $this->searchCount++;
         }
     }
 }
Пример #9
0
 public function import()
 {
     $engine = $this->getEngine();
     $job = $engine->getJob();
     $job->addNotice("FruityDependencyImporter beginning to import Dependency Configuration.");
     foreach ($this->dbConn->query("SELECT * FROM nagios_dependencies", PDO::FETCH_ASSOC) as $dependency) {
         $newDependency = new NagiosDependency();
         if (!empty($dependency['service_id'])) {
             // This is a service dependency
             $lilacService = $this->getLilacServiceById($dependency['service_id']);
             if (!$lilacService) {
                 $job->addNotice("Fruity Dependency Importer: Failed to get Lilac service with an id matching: " . $dependency['service_id']);
                 return true;
             }
             $newDependency->setService($lilacService->getId());
             // Create Target
             $targetLilacService = $this->getLilacServiceById($dependency['target_service_id']);
             if (!$targetLilacService) {
                 $job->addNotice("Fruity Dependency Importer: Failed to get Lilac service with an id matching: " . $dependency['target_service_id']);
                 return true;
             }
             $target = new NagiosDependencyTarget();
             $target->setNagiosDependency($newDependency);
             $target->setTargetService($targetLilacService->getId());
             $target->save();
         } else {
             if (!empty($dependency['host_id'])) {
                 // This is a host dependency
                 $hostName = $this->getHostNameById($dependency['host_id']);
                 $host = NagiosHostPeer::getByName($hostName);
                 if (!$host) {
                     $job->addNotice("Fruity Dependency Importer: Failed to get Lilac host with an name matching: " . $hostName);
                     return true;
                 }
                 $newDependency->setHost($host->getId());
                 // Create Target
                 $hostName = $this->getHostNameById($dependency['target_host_id']);
                 $host = NagiosHostPeer::getByName($hostName);
                 if (!$host) {
                     $job->addNotice("Fruity Dependency Importer: Failed to get Lilac host with an name matching: " . $hostName);
                     return true;
                 }
                 $target = new NagiosDependencyTarget();
                 $target->setNagiosDependency($newDependency);
                 $target->setTargetHost($host->getId());
                 $target->save();
             } else {
                 if (!empty($dependency['service_template_id'])) {
                     // This is a service template dependency
                     $templateName = $this->getServiceTemplateNameById($dependency['service_template_id']);
                     $template = NagiosServiceTemplatePeer::getByName($templateName);
                     if (!$template) {
                         $job->addNotice("Fruity Dependency Importer: Failed to get Lilac service template with  name matching: " . $templateName);
                         return true;
                     }
                     $newDependency->setServiceTemplate($template->getId());
                     // Create Target
                     $targetLilacService = $this->getLilacServiceById($dependency['target_service_id']);
                     if (!$targetLilacService) {
                         $job->addNotice("Fruity Dependency Importer: Failed to get Lilac service with an id matching: " . $dependency['target_service_id']);
                         return true;
                     }
                     $target = new NagiosDependencyTarget();
                     $target->setNagiosDependency($newDependency);
                     $target->setTargetService($targetLilacService->getId());
                     $target->save();
                 } else {
                     if (!empty($dependency['host_template_id'])) {
                         // This is for a host template dependency
                         $templateName = $this->getHostTemplateNameById($dependency['host_template_id']);
                         $template = NagiosHostTemplatePeer::getByName($templateName);
                         if (!$template) {
                             $job->addNotice("Fruity Dependency Importer: Failed to get Lilac host template with  name matching: " . $templateName);
                             return true;
                         }
                         $newDependency->setHostTemplate($template->getId());
                         $hostName = $this->getHostNameById($dependency['target_host_id']);
                         $host = NagiosHostPeer::getByName($hostName);
                         if (!$host) {
                             $job->addNotice("Fruity Dependency Importer: Failed to get Lilac host with an name matching: " . $hostName);
                             return true;
                         }
                         $target = new NagiosDependencyTarget();
                         $target->setNagiosDependency($newDependency);
                         $target->setTargetHost($host->getId());
                         $target->save();
                     }
                 }
             }
         }
         foreach ($dependency as $key => $val) {
             unset($name);
             if ($key == "dependency_id" || $key == "host_id" || $key == "host_template_id" || $key == "service_template_id" || $key == "service_id" || $key == "target_service_id" || $key == "target_host_id") {
                 continue;
             }
             if ($key == "command_name") {
                 $key = "name";
             }
             if ($key == "command_line") {
                 $key = "line";
             }
             if ($key == "command_desc") {
                 $key = "description";
             }
             try {
                 $name = NagiosDependencyPeer::translateFieldName($key, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_PHPNAME);
             } catch (Exception $e) {
                 $job->addNotice("Fruity Dependency Importer: Was unable to store unsupported value: " . $key);
             }
             if (!empty($name)) {
                 $method = "set" . $name;
                 $newDependency->{$method}($val);
             }
         }
         $newDependency->save();
         $newDependency->setName("Imported Dependency #" . $newDependency->getId());
         $newDependency->save();
         $job->addNotice("FruityDependencyImporter imported dependency with id: " . $newDependency->getId());
     }
     $job->addNotice("FruityDependencyImporter finished importing Dependency Configuration.");
 }
Пример #10
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 = NagiosServiceTemplatePeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setName($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setDescription($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setInitialState($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setIsVolatile($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setCheckCommand($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setMaximumCheckAttempts($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setNormalCheckInterval($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setRetryInterval($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setFirstNotificationDelay($arr[$keys[9]]);
     }
     if (array_key_exists($keys[10], $arr)) {
         $this->setActiveChecksEnabled($arr[$keys[10]]);
     }
     if (array_key_exists($keys[11], $arr)) {
         $this->setPassiveChecksEnabled($arr[$keys[11]]);
     }
     if (array_key_exists($keys[12], $arr)) {
         $this->setCheckPeriod($arr[$keys[12]]);
     }
     if (array_key_exists($keys[13], $arr)) {
         $this->setParallelizeCheck($arr[$keys[13]]);
     }
     if (array_key_exists($keys[14], $arr)) {
         $this->setObsessOverService($arr[$keys[14]]);
     }
     if (array_key_exists($keys[15], $arr)) {
         $this->setCheckFreshness($arr[$keys[15]]);
     }
     if (array_key_exists($keys[16], $arr)) {
         $this->setFreshnessThreshold($arr[$keys[16]]);
     }
     if (array_key_exists($keys[17], $arr)) {
         $this->setEventHandler($arr[$keys[17]]);
     }
     if (array_key_exists($keys[18], $arr)) {
         $this->setEventHandlerEnabled($arr[$keys[18]]);
     }
     if (array_key_exists($keys[19], $arr)) {
         $this->setLowFlapThreshold($arr[$keys[19]]);
     }
     if (array_key_exists($keys[20], $arr)) {
         $this->setHighFlapThreshold($arr[$keys[20]]);
     }
     if (array_key_exists($keys[21], $arr)) {
         $this->setFlapDetectionEnabled($arr[$keys[21]]);
     }
     if (array_key_exists($keys[22], $arr)) {
         $this->setFlapDetectionOnOk($arr[$keys[22]]);
     }
     if (array_key_exists($keys[23], $arr)) {
         $this->setFlapDetectionOnWarning($arr[$keys[23]]);
     }
     if (array_key_exists($keys[24], $arr)) {
         $this->setFlapDetectionOnCritical($arr[$keys[24]]);
     }
     if (array_key_exists($keys[25], $arr)) {
         $this->setFlapDetectionOnUnknown($arr[$keys[25]]);
     }
     if (array_key_exists($keys[26], $arr)) {
         $this->setProcessPerfData($arr[$keys[26]]);
     }
     if (array_key_exists($keys[27], $arr)) {
         $this->setRetainStatusInformation($arr[$keys[27]]);
     }
     if (array_key_exists($keys[28], $arr)) {
         $this->setRetainNonstatusInformation($arr[$keys[28]]);
     }
     if (array_key_exists($keys[29], $arr)) {
         $this->setNotificationInterval($arr[$keys[29]]);
     }
     if (array_key_exists($keys[30], $arr)) {
         $this->setNotificationPeriod($arr[$keys[30]]);
     }
     if (array_key_exists($keys[31], $arr)) {
         $this->setNotificationOnWarning($arr[$keys[31]]);
     }
     if (array_key_exists($keys[32], $arr)) {
         $this->setNotificationOnUnknown($arr[$keys[32]]);
     }
     if (array_key_exists($keys[33], $arr)) {
         $this->setNotificationOnCritical($arr[$keys[33]]);
     }
     if (array_key_exists($keys[34], $arr)) {
         $this->setNotificationOnRecovery($arr[$keys[34]]);
     }
     if (array_key_exists($keys[35], $arr)) {
         $this->setNotificationOnFlapping($arr[$keys[35]]);
     }
     if (array_key_exists($keys[36], $arr)) {
         $this->setNotificationOnScheduledDowntime($arr[$keys[36]]);
     }
     if (array_key_exists($keys[37], $arr)) {
         $this->setNotificationsEnabled($arr[$keys[37]]);
     }
     if (array_key_exists($keys[38], $arr)) {
         $this->setStalkingOnOk($arr[$keys[38]]);
     }
     if (array_key_exists($keys[39], $arr)) {
         $this->setStalkingOnWarning($arr[$keys[39]]);
     }
     if (array_key_exists($keys[40], $arr)) {
         $this->setStalkingOnUnknown($arr[$keys[40]]);
     }
     if (array_key_exists($keys[41], $arr)) {
         $this->setStalkingOnCritical($arr[$keys[41]]);
     }
     if (array_key_exists($keys[42], $arr)) {
         $this->setFailurePredictionEnabled($arr[$keys[42]]);
     }
     if (array_key_exists($keys[43], $arr)) {
         $this->setNotes($arr[$keys[43]]);
     }
     if (array_key_exists($keys[44], $arr)) {
         $this->setNotesUrl($arr[$keys[44]]);
     }
     if (array_key_exists($keys[45], $arr)) {
         $this->setActionUrl($arr[$keys[45]]);
     }
     if (array_key_exists($keys[46], $arr)) {
         $this->setIconImage($arr[$keys[46]]);
     }
     if (array_key_exists($keys[47], $arr)) {
         $this->setIconImageAlt($arr[$keys[47]]);
     }
 }
Пример #11
0
 public function import()
 {
     $engine = $this->getEngine();
     $job = $engine->getJob();
     $job->addNotice("FruityEscalationImporter beginning to import Dependency Configuration.");
     foreach ($this->dbConn->query("SELECT * FROM nagios_escalations", PDO::FETCH_ASSOC) as $escalation) {
         $newEscalation = new NagiosEscalation();
         if (!empty($escalation['service_id'])) {
             // This is a service escalation
             $lilacService = $this->getLilacServiceById($escalation['service_id']);
             if (!$lilacService) {
                 $job->addNotice("Fruity Escalation Importer: Failed to get Lilac service with an id matching: " . $escalation['service_id']);
                 return true;
             }
             $newEscalation->setService($lilacService->getId());
         } else {
             if (!empty($escalation['host_id'])) {
                 // This is a host escalation
                 $hostName = $this->getHostNameById($escalation['host_id']);
                 $host = NagiosHostPeer::getByName($hostName);
                 if (!$host) {
                     $job->addNotice("Fruity Escalation Importer: Failed to get Lilac host with an name matching: " . $hostName);
                     return true;
                 }
                 $newEscalation->setHost($host->getId());
             } else {
                 if (!empty($escalation['service_template_id'])) {
                     // This is a service template escalation
                     $templateName = $this->getServiceTemplateNameById($escalation['service_template_id']);
                     $template = NagiosServiceTemplatePeer::getByName($templateName);
                     if (!$template) {
                         $job->addNotice("Fruity Escalation Importer: Failed to get Lilac service template with  name matching: " . $templateName);
                         return true;
                     }
                     $newEscalation->setServiceTemplate($template->getId());
                 } else {
                     if (!empty($escalation['host_template_id'])) {
                         // This is for a host template escalation
                         $templateName = $this->getHostTemplateNameById($escalation['host_template_id']);
                         $template = NagiosHostTemplatePeer::getByName($templateName);
                         if (!$template) {
                             $job->addNotice("Fruity Escalation Importer: Failed to get Lilac host template with  name matching: " . $templateName);
                             return true;
                         }
                         $newEscalation->setHostTemplate($template->getId());
                     }
                 }
             }
         }
         foreach ($escalation as $key => $val) {
             unset($name);
             if ($key == "escalation_id" || $key == "host_id" || $key == "host_template_id" || $key == "service_template_id" || $key == "service_id") {
                 continue;
             }
             if ($key == "escalation_description") {
                 $key = "description";
             }
             if ($key == "escalation_period") {
                 $escalationName = $this->getTimeperiodNameById($id);
                 if ($escalationName) {
                     $newEscalation->setEscalationPeriodByName($escalationName);
                 }
                 continue;
             }
             try {
                 $name = NagiosEscalationPeer::translateFieldName($key, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_PHPNAME);
             } catch (Exception $e) {
                 $job->addNotice("Fruity Escalation Importer: Was unable to store unsupported value: " . $key);
             }
             if (!empty($name)) {
                 $method = "set" . $name;
                 $newEscalation->{$method}($val);
             }
         }
         $newEscalation->save();
         // Handle escalation contact groups.
         foreach ($this->dbConn->query("SELECT * FROM nagios_escalation_contactgroups WHERE escalation_id = " . $escalation['escalation_id'], PDO::FETCH_ASSOC) as $contactgroup) {
             $contactgroupName = $this->getContactGroupNameById($contactgroup['contactgroup_id']);
             if ($contactgroupName) {
                 $lilacContactGroup = NagiosContactGroupPeer::getByName($contactgroupName);
                 if ($lilacContactGroup) {
                     $newContactGroup = new NagiosEscalationContactgroup();
                     $newContactGroup->setEscalation($newEscalation->getId());
                     $newContactGroup->setContactgroup($lilacContactGroup->getId());
                     $newContactGroup->save();
                 }
             }
         }
     }
     $job->addNotice("FruityEscalationImporter finished importing Escalation Configuration.");
 }
Пример #12
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;
 }
Пример #13
0
 function addTemplateInheritance($name)
 {
     // First get the template by name
     $template = NagiosServiceTemplatePeer::getByName($name);
     if (!$template) {
         return false;
     }
     // Check to see if inheritance already exists
     $id = $this->getId();
     if (!empty($id)) {
         $c = new Criteria();
         $c->add(NagiosServiceTemplateInheritancePeer::SOURCE_TEMPLATE, $this->getId());
         $c->add(NagiosServiceTemplateInheritancePeer::TARGET_TEMPLATE, $template->getId());
         $relationship = NagiosServiceTemplateInheritancePeer::doSelectOne($c);
         if ($relationship) {
             return false;
         }
     }
     // Okay, create new one
     $relationship = new NagiosServiceTemplateInheritance();
     $relationship->setNagiosServiceTemplateRelatedBySourceTemplate($this);
     $relationship->setNagiosServiceTemplateRelatedByTargetTemplate($template);
     $relationship->save();
     return true;
 }
Пример #14
0
 public function valid()
 {
     $values = $this->getSegment()->getValues();
     $job = $this->getEngine()->getJob();
     if (isset($values['use'])) {
         // We need to use a template
         $job->addNotice("This Service uses a template: " . $values['use'][0]['value']);
         $template = NagiosServiceTemplatePeer::getByName($values['use'][0]['value']);
         if (empty($template)) {
             $job->addNotice("That template is not found yet. Setting this service as queued.");
             return false;
         }
         $template->clearAllReferences(true);
     }
     // Check time period existence
     if (isset($values['check_period'])) {
         $c = new Criteria();
         $c->add(NagiosTimeperiodPeer::NAME, $values['check_period'][0]['value']);
         $timePeriod = NagiosTimeperiodPeer::doSelectOne($c);
         if (empty($timePeriod)) {
             $job->addNotice("The time period specified by " . $values['check_period'][0]['value'] . " was not found.  Setting this service as queued.");
             return false;
         }
         $timePeriod->clearAllReferences(true);
     }
     if (isset($values['notification_period'])) {
         $c = new Criteria();
         $c->add(NagiosTimeperiodPeer::NAME, $values['notification_period'][0]['value']);
         $timePeriod = NagiosTimeperiodPeer::doSelectOne($c);
         if (empty($timePeriod)) {
             $job->addNotice("The time period specified by " . $values['notification_period'][0]['value'] . " was not found.  Setting this service as queued.");
             return false;
         }
         $timePeriod->clearAllReferences(true);
     }
     // Check command existence
     if (isset($values['check_command'])) {
         $params = explode('!', $values['check_command'][0]['value']);
         $c = new Criteria();
         $c->add(NagiosCommandPeer::NAME, $params[0]);
         $command = NagiosCommandPeer::doSelectOne($c);
         if (empty($command)) {
             $job->addNotice("The command specified by " . $params[0] . " was not found.  Setting this service as queued.");
             return false;
         }
         $command->clearAllReferences(true);
     }
     if (isset($values['event_handler'])) {
         $c = new Criteria();
         $c->add(NagiosCommandPeer::NAME, $values['event_handler'][0]['value']);
         $command = NagiosCommandPeer::doSelectOne($c);
         if (empty($command)) {
             $job->addNotice("The command specified by " . $values['event_handler'][0]['value'] . " was not found.  Setting this service as queued.");
             return false;
         }
         $command->clearAllReferences(true);
     }
     // Check contact groups
     if (isset($values['contact_groups'])) {
         foreach ($values['contact_groups'] as $contactGroupValues) {
             $c = new Criteria();
             $c->add(NagiosContactGroupPeer::NAME, $contactGroupValues['value']);
             $contactgroup = NagiosContactGroupPeer::doSelectOne($c);
             if (empty($contactgroup)) {
                 $job->addNotice("The contact group specified by " . $contactGroupValues['value'] . " was not found.  Setting this service as queued.");
                 return false;
             }
             $contactgroup->clearAllReferences(true);
         }
     }
     if (isset($values['contacts'])) {
         foreach ($values['contacts'] as $contactValues) {
             $c = new Criteria();
             $c->add(NagiosContactPeer::NAME, $contactValues['value']);
             $contactgroup = NagiosContactPeer::doSelectOne($c);
             if (empty($contactgroup)) {
                 $job->addNotice("The contact specified by " . $contactValues['value'] . " was not found.  Setting this service as queued.");
                 return false;
             }
             $contactgroup->clearAllReferences(true);
         }
     }
     // Check host groups
     if (isset($values['servicegroups'])) {
         foreach ($values['servicegroups'] as $serviceGroupValues) {
             $c = new Criteria();
             $c->add(NagiosServiceGroupPeer::NAME, $serviceGroupValues['value']);
             $servicegroup = NagiosServiceGroupPeer::doSelectOne($c);
             if (empty($servicegroup)) {
                 $job->addNotice("The service group specified by " . $serviceGroupValues['value'] . " was not found.  Setting this service as queued.");
                 return false;
             }
             $servicegroup->clearAllReferences(true);
         }
     }
     // Check for hosts
     if (isset($values['host_name'])) {
         foreach ($values['host_name'] as $hostValues) {
             $host = NagiosHostPeer::getByName($hostValues['value']);
             if (empty($host)) {
                 $job->addNotice("The host specified by " . $hostValues['value'] . " was not found.  Setting this service as queued.");
                 return false;
             }
             $host->clearAllReferences(true);
         }
     }
     // Check for hostgroup_name
     if (isset($values['hostgroup_name'])) {
         foreach ($values['hostgroup_name'] as $hostgroupValues) {
             $hostgroup = NagiosHostgroupPeer::getByName($hostgroupValues['value']);
             if (empty($hostgroup)) {
                 $job->addNotice("The host group specified by " . $hostgroupValues['value'] . " was not found.  Setting this service as queued.");
                 return false;
             }
             $hostgroup->clearAllReferences(true);
         }
     }
     // Check for hostgroup_name
     if (isset($values['hostgroup'])) {
         foreach ($values['hostgroup'] as $hostgroupValues) {
             $hostgroup = NagiosHostgroupPeer::getByName($hostgroupValues['value']);
             if (empty($hostgroup)) {
                 $job->addNotice("The host group specified by " . $hostgroupValues['value'] . " was not found.  Setting this service as queued.");
                 return false;
             }
             $hostgroup->clearAllReferences(true);
         }
     }
     return true;
 }
 /**
  * Get the associated NagiosServiceTemplate object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     NagiosServiceTemplate The associated NagiosServiceTemplate object.
  * @throws     PropelException
  */
 public function getNagiosServiceTemplateRelatedByTargetTemplate(PropelPDO $con = null)
 {
     if ($this->aNagiosServiceTemplateRelatedByTargetTemplate === null && $this->target_template !== null) {
         $c = new Criteria(NagiosServiceTemplatePeer::DATABASE_NAME);
         $c->add(NagiosServiceTemplatePeer::ID, $this->target_template);
         $this->aNagiosServiceTemplateRelatedByTargetTemplate = NagiosServiceTemplatePeer::doSelectOne($c, $con);
         /* The following can be used additionally to
         		   guarantee the related object contains a reference
         		   to this object.  This level of coupling may, however, be
         		   undesirable since it could result in an only partially populated collection
         		   in the referenced object.
         		   $this->aNagiosServiceTemplateRelatedByTargetTemplate->addNagiosServiceTemplateInheritancesRelatedByTargetTemplate($this);
         		 */
     }
     return $this->aNagiosServiceTemplateRelatedByTargetTemplate;
 }
Пример #16
0
 /**
  * Method perform a DELETE on the database, given a NagiosTimeperiod or Criteria object OR a primary key value.
  *
  * @param      mixed $values Criteria or NagiosTimeperiod object or primary key or array of primary keys
  *              which is used to create the DELETE statement
  * @param      PropelPDO $con the connection to use
  * @return     int 	The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
  *				if supported by native driver or if emulated using Propel.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doDelete($values, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(NagiosTimeperiodPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     if ($values instanceof Criteria) {
         // invalidate the cache for all objects of this type, since we have no
         // way of knowing (without running a query) what objects should be invalidated
         // from the cache based on this Criteria.
         NagiosTimeperiodPeer::clearInstancePool();
         // rename for clarity
         $criteria = clone $values;
     } elseif ($values instanceof NagiosTimeperiod) {
         // invalidate the cache for this single object
         NagiosTimeperiodPeer::removeInstanceFromPool($values);
         // create criteria based on pk values
         $criteria = $values->buildPkeyCriteria();
     } else {
         // it must be the primary key
         $criteria = new Criteria(self::DATABASE_NAME);
         $criteria->add(NagiosTimeperiodPeer::ID, (array) $values, Criteria::IN);
         foreach ((array) $values as $singleval) {
             // we can invalidate the cache for this single object
             NagiosTimeperiodPeer::removeInstanceFromPool($singleval);
         }
     }
     // Set the correct dbName
     $criteria->setDbName(self::DATABASE_NAME);
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     try {
         // use transaction because $criteria could contain info
         // for more than one table or we could emulating ON DELETE CASCADE, etc.
         $con->beginTransaction();
         $affectedRows += NagiosTimeperiodPeer::doOnDeleteCascade($criteria, $con);
         NagiosTimeperiodPeer::doOnDeleteSetNull($criteria, $con);
         // Because this db requires some delete cascade/set null emulation, we have to
         // clear the cached instance *after* the emulation has happened (since
         // instances get re-added by the select statement contained therein).
         if ($values instanceof Criteria) {
             NagiosTimeperiodPeer::clearInstancePool();
         } else {
             // it's a PK or object
             NagiosTimeperiodPeer::removeInstanceFromPool($values);
         }
         $affectedRows += BasePeer::doDelete($criteria, $con);
         // invalidate objects in NagiosTimeperiodEntryPeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         NagiosTimeperiodEntryPeer::clearInstancePool();
         // invalidate objects in NagiosTimeperiodExcludePeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         NagiosTimeperiodExcludePeer::clearInstancePool();
         // invalidate objects in NagiosTimeperiodExcludePeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         NagiosTimeperiodExcludePeer::clearInstancePool();
         // invalidate objects in NagiosContactPeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         NagiosContactPeer::clearInstancePool();
         // invalidate objects in NagiosContactPeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         NagiosContactPeer::clearInstancePool();
         // invalidate objects in NagiosHostTemplatePeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         NagiosHostTemplatePeer::clearInstancePool();
         // invalidate objects in NagiosHostTemplatePeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         NagiosHostTemplatePeer::clearInstancePool();
         // invalidate objects in NagiosHostPeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         NagiosHostPeer::clearInstancePool();
         // invalidate objects in NagiosHostPeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         NagiosHostPeer::clearInstancePool();
         // invalidate objects in NagiosServiceTemplatePeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         NagiosServiceTemplatePeer::clearInstancePool();
         // invalidate objects in NagiosServiceTemplatePeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         NagiosServiceTemplatePeer::clearInstancePool();
         // invalidate objects in NagiosServicePeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         NagiosServicePeer::clearInstancePool();
         // invalidate objects in NagiosServicePeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         NagiosServicePeer::clearInstancePool();
         // invalidate objects in NagiosDependencyPeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         NagiosDependencyPeer::clearInstancePool();
         // invalidate objects in NagiosEscalationPeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         NagiosEscalationPeer::clearInstancePool();
         $con->commit();
         return $affectedRows;
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }
 /**
  * Selects a collection of NagiosServiceContactGroupMember objects pre-filled with all related objects except NagiosContactGroup.
  *
  * @param      Criteria  $c
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return     array Array of NagiosServiceContactGroupMember objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptNagiosContactGroup(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $c = clone $c;
     // Set the correct dbName if it has not been overridden
     // $c->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     NagiosServiceContactGroupMemberPeer::addSelectColumns($c);
     $startcol2 = NagiosServiceContactGroupMemberPeer::NUM_COLUMNS - NagiosServiceContactGroupMemberPeer::NUM_LAZY_LOAD_COLUMNS;
     NagiosServicePeer::addSelectColumns($c);
     $startcol3 = $startcol2 + (NagiosServicePeer::NUM_COLUMNS - NagiosServicePeer::NUM_LAZY_LOAD_COLUMNS);
     NagiosServiceTemplatePeer::addSelectColumns($c);
     $startcol4 = $startcol3 + (NagiosServiceTemplatePeer::NUM_COLUMNS - NagiosServiceTemplatePeer::NUM_LAZY_LOAD_COLUMNS);
     $c->addJoin(array(NagiosServiceContactGroupMemberPeer::SERVICE), array(NagiosServicePeer::ID), $join_behavior);
     $c->addJoin(array(NagiosServiceContactGroupMemberPeer::TEMPLATE), array(NagiosServiceTemplatePeer::ID), $join_behavior);
     $stmt = BasePeer::doSelect($c, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = NagiosServiceContactGroupMemberPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = NagiosServiceContactGroupMemberPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://propel.phpdb.org/trac/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $omClass = NagiosServiceContactGroupMemberPeer::getOMClass();
             $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             NagiosServiceContactGroupMemberPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined NagiosService rows
         $key2 = NagiosServicePeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = NagiosServicePeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $omClass = NagiosServicePeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 NagiosServicePeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (NagiosServiceContactGroupMember) to the collection in $obj2 (NagiosService)
             $obj2->addNagiosServiceContactGroupMember($obj1);
         }
         // if joined row is not null
         // Add objects for joined NagiosServiceTemplate rows
         $key3 = NagiosServiceTemplatePeer::getPrimaryKeyHashFromRow($row, $startcol3);
         if ($key3 !== null) {
             $obj3 = NagiosServiceTemplatePeer::getInstanceFromPool($key3);
             if (!$obj3) {
                 $omClass = NagiosServiceTemplatePeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj3 = new $cls();
                 $obj3->hydrate($row, $startcol3);
                 NagiosServiceTemplatePeer::addInstanceToPool($obj3, $key3);
             }
             // if $obj3 already loaded
             // Add the $obj1 (NagiosServiceContactGroupMember) to the collection in $obj3 (NagiosServiceTemplate)
             $obj3->addNagiosServiceContactGroupMember($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
Пример #18
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(NagiosServiceTemplatePeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(NagiosServiceTemplatePeer::DATABASE_NAME);
         $criteria->add(NagiosServiceTemplatePeer::ID, $pks, Criteria::IN);
         $objs = NagiosServiceTemplatePeer::doSelect($criteria, $con);
     }
     return $objs;
 }