/** * Gets an array of NagiosEscalation objects which contain a foreign key that references this object. * * If this collection has already been initialized with an identical Criteria, it returns the collection. * Otherwise if this NagiosTimeperiod has previously been saved, it will retrieve * related NagiosEscalations from storage. If this NagiosTimeperiod is new, it will return * an empty collection or the current collection, the criteria is ignored on a new object. * * @param PropelPDO $con * @param Criteria $criteria * @return array NagiosEscalation[] * @throws PropelException */ public function getNagiosEscalations($criteria = null, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(NagiosTimeperiodPeer::DATABASE_NAME); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collNagiosEscalations === null) { if ($this->isNew()) { $this->collNagiosEscalations = array(); } else { $criteria->add(NagiosEscalationPeer::ESCALATION_PERIOD, $this->id); NagiosEscalationPeer::addSelectColumns($criteria); $this->collNagiosEscalations = NagiosEscalationPeer::doSelect($criteria, $con); } } else { // criteria has no effect for a new object if (!$this->isNew()) { // 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(NagiosEscalationPeer::ESCALATION_PERIOD, $this->id); NagiosEscalationPeer::addSelectColumns($criteria); if (!isset($this->lastNagiosEscalationCriteria) || !$this->lastNagiosEscalationCriteria->equals($criteria)) { $this->collNagiosEscalations = NagiosEscalationPeer::doSelect($criteria, $con); } } } $this->lastNagiosEscalationCriteria = $criteria; return $this->collNagiosEscalations; }
/** * 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(NagiosEscalationPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(NagiosEscalationPeer::DATABASE_NAME); $criteria->add(NagiosEscalationPeer::ID, $pks, Criteria::IN); $objs = NagiosEscalationPeer::doSelect($criteria, $con); } return $objs; }
public function export() { global $lilac; // Grab our export job $engine = $this->getEngine(); $job = $engine->getJob(); $job->addNotice("NagiosEscalationExporter attempting to export escalation configuration."); $fp = $this->getOutputFile(); fputs($fp, "# Written by NagiosEscalationExporter from " . LILAC_NAME . " " . LILAC_VERSION . " on " . date("F j, Y, g:i a") . "\n\n"); $hostgroups = NagiosHostgroupPeer::doSelect(new Criteria()); foreach ($hostgroups as $hostgroup) { $job->addNotice("Processing escalations for hostgroup: " . $hostgroup->getName()); $escalations = $hostgroup->getNagiosEscalations(); foreach ($escalations as $escalation) { $this->_exportEscalation($escalation, "hostgroup", $hostgroup); } } $hosts = NagiosHostPeer::doSelect(new Criteria()); foreach ($hosts as $host) { // Got hosts // Get inherited escalations first $job->addNotice("Processing escalations for host: " . $host->getName()); $inheritedEscalations = $host->getInheritedEscalations(); foreach ($inheritedEscalations as $escalation) { $this->_exportEscalation($escalation, "host", $host); } ${$escalations} = $host->getNagiosEscalations(); foreach (${$escalations} as $escalation) { $this->_exportEscalation($escalation, "host", $host); } // Get our services $inheritedServices = $host->getInheritedServices(); foreach ($inheritedServices as $service) { $job->addNotice("Processing escalations for service: " . $service->getDescription() . " on " . $host->getName()); $serviceInheritedEscalations = $service->getInheritedEscalations(); foreach ($serviceInheritedEscalations as $escalation) { $this->_exportEscalation($escalation, "service", $service, $host); } $c = new Criteria(); $c->add(NagiosEscalationPeer::HOST, $host->getId()); $c->add(NagiosEscalationPeer::SERVICE, $service->getId()); $serviceEscalations = NagiosEscalationPeer::doSelect($c); foreach ($serviceEscalations as $escalation) { $this->_exportEscalation($escalation, "service", $service, $host); } } $services = $host->getNagiosServices(); foreach ($services as $service) { $job->addNotice("Processing escalations for service: " . $service->getDescription() . " on " . $host->getName()); $serviceInheritedEscalations = $service->getInheritedEscalations(); foreach ($serviceInheritedEscalations as $escalation) { $this->_exportEscalation($escalation, "service", $service, $host); } $serviceEscalations = $service->getNagiosEscalations(); foreach ($serviceEscalations as $escalation) { $this->_exportEscalation($escalation, "service", $service, $host); } } $job->addNotice("Completed escalations export for host: " . $host->getName()); } $job->addNotice("NagiosEscalationExporter complete."); return true; }