/** * 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(NagiosServiceContactGroupMemberPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(NagiosServiceContactGroupMemberPeer::DATABASE_NAME); $criteria->add(NagiosServiceContactGroupMemberPeer::ID, $pks, Criteria::IN); $objs = NagiosServiceContactGroupMemberPeer::doSelect($criteria, $con); } return $objs; }
?> <?php echo $lilac->element_desc("contact_groups", "nagios_hosts_desc"); ?> <br /> <br /> </form> </td> </tr> </table> <?php $inherited_list = $service->getInheritedContactGroups(); $numOfInheritedGroups = count($inherited_list); $c = new Criteria(); $c->add(NagiosServiceContactGroupMemberPeer::SERVICE, $_GET['id']); $contactgroups_list = NagiosServiceContactGroupMemberPeer::doSelect($c); $numOfContactGroups = count($contactgroups_list); ?> <table width="100%" border="0"> <tr> <td width="100" align="center" valign="top"> <img src="<?php echo $path_config['image_root']; ?> contact.gif" /> </td> <td valign="top"> <?php if ($numOfInheritedGroups) { ?> <table width="100%" align="center" cellspacing="0" cellpadding="2" border="0">
private function _exportService($service, $type, $targetObj) { global $lilac; $fp = $this->getOutputFile(); fputs($fp, "define service {\n"); $finalArray = array(); switch ($type) { case 'host': fputs($fp, "\thost_name\t" . $targetObj->getName() . "\n"); break; case 'hostgroup': fputs($fp, "\thostgroup_name\t" . $targetObj->getName() . "\n"); break; } $values = $service->getValues(); foreach ($values as $key => $valArray) { $value = $valArray['value']; if ($key == 'id' || $key == 'name' || $key == 'host' || $key == 'host_template' || $key == 'hostgroup' || $key == 'notification_on_warning' || $key == 'notification_on_unknown' || $key == 'notification_on_critical' || $key == 'notification_on_recovery' || $key == 'notification_on_flapping' || $key == 'notification_on_scheduled_downtime' || $key == 'flap_detection_on_ok' || $key == 'flap_detection_on_warning' || $key == 'flap_detection_on_unknown' || $key == 'flap_detection_on_critical' || $key == 'stalking_on_ok' || $key == 'stalking_on_warning' || $key == 'stalking_on_unknown' || $key == 'stalking_on_critical' || $key == '' || $key == "parent_host") { continue; } if ($key == 'description') { $key = 'service_description'; } if ($key == 'maximum_check_attempts') { $key = 'max_check_attempts'; } if ($key == "check_period" || $key == "notification_period") { $timeperiod = NagiosTimeperiodPeer::retrieveByPK($value); if (!$timeperiod) { $job->addError("Unable to find timeperiod with id: " . $value . " for " . $key); return false; } $value = $timeperiod->getName(); } if ($key == "check_command" || $key == "event_handler") { $command = NagiosCommandPeer::retrieveByPK($value); if (!$command) { $job->addError("Unable to find command with id: " . $value . " for " . $key); } $value = $command->getName(); if ($key == "check_command") { $cmdObj = $service->getInheritedCommandWithParameters(); foreach ($cmdObj['parameters'] as $parameterArray) { $value .= "!" . $parameterArray['parameter']->getParameter(); } } } if ($value === null) { continue; } if ($value === false) { $value = '0'; } $finalArray[$key] = $value; } foreach ($finalArray as $key => $val) { fputs($fp, "\t" . $key . "\t" . (string) $val . "\n"); } // Notifications if (isset($values['notification_on_warning']['value'])) { if (!$values['notification_on_warning']['value'] && !$values['notification_on_unknown']['value'] && !$values['notification_on_critical']['value'] && !$values['notification_on_recovery']['value'] && !$values['notification_on_flapping']['value']) { fputs($fp, "\tnotification_options\tn\n"); } else { fputs($fp, "\tnotification_options\t"); $tempValues = array(); if ($values['notification_on_warning']['value']) { $tempValues[] = "w"; } if ($values['notification_on_unknown']['value']) { $tempValues[] = "u"; } if ($values['notification_on_critical']['value']) { $tempValues[] = "c"; } if ($values['notification_on_recovery']['value']) { $tempValues[] = "r"; } if ($values['notification_on_flapping']['value']) { $tempValues[] = "f"; } if ($values['notification_on_scheduled_downtime']['value']) { $tempValues[] = "s"; } fputs($fp, implode(",", $tempValues)); fputs($fp, "\n"); } } // Stalking if ($values['flap_detection_on_ok']['value'] || $values['flap_detection_on_warning']['value'] || $values['flap_detection_on_unknown']['value'] || $values['flap_detection_on_critical']['value']) { fputs($fp, "\tflap_detection_options\t"); if ($values['flap_detection_on_ok']['value']) { fputs($fp, "o"); if ($values['flap_detection_on_warning']['value'] || $values['flap_detection_on_unknown']['value'] || $values['flap_detection_on_critical']['value']) { fputs($fp, ","); } } if ($values['flap_detection_on_warning']['value']) { fputs($fp, "w"); if ($values['flap_detection_on_unknown']['value'] || $values['flap_detection_on_critical']['value']) { fputs($fp, ","); } } if ($values['flap_detection_on_unknown']['value']) { fputs($fp, "u"); if ($values['flap_detection_on_critical']['value']) { fputs($fp, ","); } } if ($values['flap_detection_on_critical']['value']) { fputs($fp, "c"); } fputs($fp, "\n"); } // Stalking if ($values['stalking_on_ok']['value'] || $values['stalking_on_warning']['value'] || $values['stalking_on_unknown']['value'] || $values['stalking_on_critical']['value']) { fputs($fp, "\tstalking_options\t"); if ($values['stalking_on_ok']['value']) { fputs($fp, "o"); if ($values['stalking_on_warning']['value'] || $values['stalking_on_unknown']['value'] || $values['stalking_on_critical']['value']) { fputs($fp, ","); } } if ($values['stalking_on_warning']['value']) { fputs($fp, "w"); if ($values['stalking_on_unknown']['value'] || $values['stalking_on_critical']['value']) { fputs($fp, ","); } } if ($values['stalking_on_unknown']['value']) { fputs($fp, "u"); if ($values['stalking_on_critical']['value']) { fputs($fp, ","); } } if ($values['stalking_on_critical']['value']) { fputs($fp, "c"); } fputs($fp, "\n"); } // Contacts $contactList = array(); $inherited_list = $service->getInheritedContacts(); $contact_list = $service->getNagiosServiceContactMembers(); foreach ($inherited_list as $group) { if (!key_exists($group->getName(), $contactList)) { $contactList[$group->getName()] = $group; } } foreach ($contact_list as $contact) { $contact = $contact->getNagiosContact(); if (!key_exists($contact->getName(), $contactList)) { $contactList[$contact->getName()] = $contact; } } if (count($contactList)) { fputs($fp, "\tcontacts\t"); $first = true; foreach ($contactList as $contact) { if (!$first) { fputs($fp, ","); } else { $first = false; } fputs($fp, $contact->getName()); } fputs($fp, "\n"); } // Contact Groups $groupList = array(); $inherited_list = $service->getInheritedContactGroups(); $c = new Criteria(); $c->add(NagiosServiceContactGroupMemberPeer::SERVICE, $service->getId()); $contactgroups_list = NagiosServiceContactGroupMemberPeer::doSelect($c); foreach ($inherited_list as $group) { if (!key_exists($group->getName(), $groupList)) { $groupList[$group->getName()] = $group; } } foreach ($contactgroups_list as $group) { $group = $group->getNagiosContactgroup(); if (!key_exists($group->getName(), $groupList)) { $groupList[$group->getName()] = $group; } } if (count($groupList)) { fputs($fp, "\tcontact_groups\t"); $first = true; foreach ($groupList as $group) { if (!$first) { fputs($fp, ","); } else { $first = false; } fputs($fp, $group->getName()); } fputs($fp, "\n"); } // Service Groups $groupList = array(); $inherited_list = $service->getInheritedServiceGroups(); $hostgroups_list = $service->getNagiosServiceGroupMembers(); foreach ($inherited_list as $group) { if (!key_exists($group->getName(), $groupList)) { $groupList[$group->getName()] = $group; } } foreach ($hostgroups_list as $group) { $group = $group->getNagiosServiceGroup(); if (!key_exists($group->getName(), $groupList)) { $groupList[$group->getName()] = $group; } } if (count($groupList)) { fputs($fp, "\tservicegroups\t"); $first = true; foreach ($groupList as $group) { if (!$first) { fputs($fp, ","); } else { $first = false; } fputs($fp, $group->getName()); } fputs($fp, "\n"); } fputs($fp, "}\n"); fputs($fp, "\n"); }
/** * Gets an array of NagiosServiceContactGroupMember 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 NagiosServiceTemplate has previously been saved, it will retrieve * related NagiosServiceContactGroupMembers from storage. If this NagiosServiceTemplate 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 NagiosServiceContactGroupMember[] * @throws PropelException */ public function getNagiosServiceContactGroupMembers($criteria = null, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(NagiosServiceTemplatePeer::DATABASE_NAME); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collNagiosServiceContactGroupMembers === null) { if ($this->isNew()) { $this->collNagiosServiceContactGroupMembers = array(); } else { $criteria->add(NagiosServiceContactGroupMemberPeer::TEMPLATE, $this->id); NagiosServiceContactGroupMemberPeer::addSelectColumns($criteria); $this->collNagiosServiceContactGroupMembers = NagiosServiceContactGroupMemberPeer::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(NagiosServiceContactGroupMemberPeer::TEMPLATE, $this->id); NagiosServiceContactGroupMemberPeer::addSelectColumns($criteria); if (!isset($this->lastNagiosServiceContactGroupMemberCriteria) || !$this->lastNagiosServiceContactGroupMemberCriteria->equals($criteria)) { $this->collNagiosServiceContactGroupMembers = NagiosServiceContactGroupMemberPeer::doSelect($criteria, $con); } } } $this->lastNagiosServiceContactGroupMemberCriteria = $criteria; return $this->collNagiosServiceContactGroupMembers; }