Beispiel #1
0
 public function addMemberByName($name)
 {
     // Support for adding ALL hosts
     if ($name == "*") {
         $hosts = NagiosHostPeer::doSelect(new Criteria());
         foreach ($hosts as $host) {
             $this->addMemberByName($host->getName());
         }
         return true;
     }
     $host = NagiosHostPeer::getByName($name);
     if (!$host) {
         return false;
     }
     $id = $this->getId();
     if (!empty($id)) {
         $c = new Criteria();
         $c->add(NagiosHostgroupMembershipPeer::HOSTGROUP, $this->getId());
         $c->add(NagiosHostgroupMembershipPeer::HOST, $host->getId());
         $relationship = NagiosHostgroupMembershipPeer::doSelectOne($c);
         if ($relationship) {
             return true;
         }
         // Already exists.
     }
     // Create new relationship
     $relationship = new NagiosHostgroupMembership();
     $relationship->setNagiosHost($host);
     $relationship->setNagiosHostgroup($this);
     $relationship->save();
     return true;
 }
Beispiel #2
0
 public static function doCountAll()
 {
     // Get total count of services for all hosts in the system.
     // It's kind of slow, but gets the job done.
     $hosts = NagiosHostPeer::doSelect(new Criteria());
     // All hosts
     $totalCount = 0;
     foreach ($hosts as $host) {
         $services = $host->getNagiosServices();
         $inheritedServices = $host->getInheritedServices();
         $totalCount += count($inheritedServices);
         $totalCount += count($services);
     }
     return $totalCount;
 }
Beispiel #3
0
 public function export()
 {
     global $lilac;
     // Grab our export job
     $engine = $this->getEngine();
     $job = $engine->getJob();
     $job->addNotice("NagiosServiceExporter attempting to export service configuration.");
     $fp = $this->getOutputFile();
     fputs($fp, "# Written by NagiosServiceExporter from " . LILAC_NAME . " " . LILAC_VERSION . " on " . date("F j, Y, g:i a") . "\n\n");
     $hosts = NagiosHostPeer::doSelect(new Criteria());
     foreach ($hosts as $host) {
         // Got hosts
         // Get our inherited services first
         $job->addNotice("Processing services for host: " . $host->getName());
         $inheritedServices = $host->getInheritedServices();
         foreach ($inheritedServices as $service) {
             $job->addNotice("Processing service " . $service->getDescription());
             $this->_exportService($service, "host", $host);
         }
         $services = $host->getNagiosServices();
         foreach ($services as $service) {
             $job->addNotice("Processing service " . $service->getDescription());
             $this->_exportService($service, "host", $host);
         }
         $job->addNotice("Completed services export for host: " . $host->getName());
     }
     $hostgroups = NagiosHostgroupPeer::doSelect(new Criteria());
     foreach ($hostgroups as $hostgroup) {
         $job->addNotice("Processing services for hostgroup: " . $hostgroup->getName());
         $services = $hostgroup->getNagiosServices();
         foreach ($services as $service) {
             $job->addNotice("Processing service " . $service->getDescription());
             $this->_exportService($service, "hostgroup", $hostgroup);
         }
     }
     $job->addNotice("NagiosServiceExporter complete.");
     return true;
 }
 private function getAppliedHosts($hostValues, $hostgroupValues)
 {
     $appliedHosts = array();
     foreach ($hostValues as $val) {
         $val = $val['value'];
         if ($val == "*") {
             // Get all hosts
             $tempHosts = NagiosHostPeer::doSelect(new Criteria());
             foreach ($tempHosts as $tempHost) {
                 if (!array_key_exists($tempHost->getName(), $appliedHosts)) {
                     $appliedHosts[] = $tempHost;
                 }
             }
         } else {
             if (preg_match("/^!/", $val)) {
                 continue;
             } else {
                 $host = NagiosHostPeer::getByName($val);
                 if (!$host) {
                     // Give error
                     $values = $this->getSegment()->getValues();
                     $job = $this->getEngine()->getJob();
                     $job->addError("The host specified by name: " . $val . " was not found.  Setting this host ext info as queued.");
                     return false;
                 } else {
                     if (!array_key_exists($host->getName(), $appliedHosts)) {
                         $appliedHosts[] = $host;
                     }
                 }
             }
         }
     }
     foreach ($hostgroupValues as $val) {
         $val = $val['value'];
         // First check for *
         // then check for each hostgroup existence, then
         // each additional hostgroup
         if ($val == "*") {
             // Get all hostgroups
             $hostgroups = NagiosHostgroupPeer::doSelect(new Criteria());
             foreach ($hostgroups as $hg) {
                 $hosts = $hostgroup->getNagiosHosts();
                 foreach ($hosts as $tempHost) {
                     if (!array_key_exists($tempHost->getName(), $appliedHosts)) {
                         $appliedHosts[] = $tempHost;
                     }
                 }
             }
         } else {
             if (preg_match("/^!/", $val)) {
                 continue;
             } else {
                 $hg = NagiosHostgroupPeer::getByName($val);
                 if (!$hg) {
                     // Give error
                     $values = $this->getSegment()->getValues();
                     $job = $this->getEngine()->getJob();
                     $job->addError("The hostgroup specified by name: " . $val . " was not found.  Setting this host ext info as queued.");
                     return false;
                 } else {
                     $hosts = $hg->getMembers();
                     foreach ($hosts as $tempHost) {
                         if (!array_key_exists($tempHost->getName(), $appliedHosts)) {
                             $appliedHosts[] = $tempHost;
                         }
                     }
                 }
             }
         }
     }
     // Okay, do exclusions
     foreach ($hostValues as $val) {
         $val = $val['value'];
         if (preg_match("/^!/", $val)) {
             unset($appliedHosts[$val]);
         }
     }
     foreach ($hostgroupValues as $val) {
         $val = $val['value'];
         if (preg_match("/^!/", $val)) {
             $hg = NagiosHostgroupPeer::getByName($val);
             if (!$hg) {
                 // Do nothing
             } else {
                 $hosts = $hg->getMembers();
                 foreach ($hosts as $tempHost) {
                     unset($appliedHosts[$tempHost->getName()]);
                 }
             }
         }
     }
     return $appliedHosts;
 }
Beispiel #5
0
 /**
  * Gets an array of NagiosHost 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 NagiosHostsRelatedByNotificationPeriod 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 NagiosHost[]
  * @throws     PropelException
  */
 public function getNagiosHostsRelatedByNotificationPeriod($criteria = null, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(NagiosTimeperiodPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collNagiosHostsRelatedByNotificationPeriod === null) {
         if ($this->isNew()) {
             $this->collNagiosHostsRelatedByNotificationPeriod = array();
         } else {
             $criteria->add(NagiosHostPeer::NOTIFICATION_PERIOD, $this->id);
             NagiosHostPeer::addSelectColumns($criteria);
             $this->collNagiosHostsRelatedByNotificationPeriod = NagiosHostPeer::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(NagiosHostPeer::NOTIFICATION_PERIOD, $this->id);
             NagiosHostPeer::addSelectColumns($criteria);
             if (!isset($this->lastNagiosHostRelatedByNotificationPeriodCriteria) || !$this->lastNagiosHostRelatedByNotificationPeriodCriteria->equals($criteria)) {
                 $this->collNagiosHostsRelatedByNotificationPeriod = NagiosHostPeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastNagiosHostRelatedByNotificationPeriodCriteria = $criteria;
     return $this->collNagiosHostsRelatedByNotificationPeriod;
 }
Beispiel #6
0
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
/*
	Filename:	hosts.php
*/
include_once 'includes/config.inc';
// AJAX behavior
if (isset($_GET['request']) && $_GET['request'] == "search") {
    $results = array();
    switch ($_GET['type']) {
        case 'host':
            $c = new Criteria();
            $c->add(NagiosHostPeer::NAME, $_GET['q'] . "%", Criteria::LIKE);
            $c->setIgnoreCase(true);
            $results = NagiosHostPeer::doSelect($c);
            break;
        case 'hostgroup':
            $c = new Criteria();
            $c->add(NagiosHostgroupPeer::NAME, $_GET['q'] . "%", Criteria::LIKE);
            $c->setIgnoreCase(true);
            $results = NagiosHostgroupPeer::doSelect($c);
        case 'service':
            // Get the host
            $c = new Criteria();
            $c->add(NagiosHostPeer::NAME, $_GET['host']);
            $c->setIgnoreCase(true);
            $host = NagiosHostPeer::doSelectOne($c);
            $returnObj = array();
            if (!$host) {
                $returnObj['error'] = "Host " . $_GET['host'] . " not found.";
Beispiel #7
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(NagiosHostPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(NagiosHostPeer::DATABASE_NAME);
         $criteria->add(NagiosHostPeer::ID, $pks, Criteria::IN);
         $objs = NagiosHostPeer::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;
 }
Beispiel #9
0
 /**
  * Gets an array of NagiosHost 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 NagiosCommand has previously been saved, it will retrieve
  * related NagiosHostsRelatedByEventHandler from storage. If this NagiosCommand 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 NagiosHost[]
  * @throws     PropelException
  */
 public function getNagiosHostsRelatedByEventHandler($criteria = null, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(NagiosCommandPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collNagiosHostsRelatedByEventHandler === null) {
         if ($this->isNew()) {
             $this->collNagiosHostsRelatedByEventHandler = array();
         } else {
             $criteria->add(NagiosHostPeer::EVENT_HANDLER, $this->id);
             NagiosHostPeer::addSelectColumns($criteria);
             $this->collNagiosHostsRelatedByEventHandler = NagiosHostPeer::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(NagiosHostPeer::EVENT_HANDLER, $this->id);
             NagiosHostPeer::addSelectColumns($criteria);
             if (!isset($this->lastNagiosHostRelatedByEventHandlerCriteria) || !$this->lastNagiosHostRelatedByEventHandlerCriteria->equals($criteria)) {
                 $this->collNagiosHostsRelatedByEventHandler = NagiosHostPeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastNagiosHostRelatedByEventHandlerCriteria = $criteria;
     return $this->collNagiosHostsRelatedByEventHandler;
 }
Beispiel #10
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++;
         }
     }
 }
Beispiel #11
0
 public function export()
 {
     global $lilac;
     // Grab our export job
     $engine = $this->getEngine();
     $job = $engine->getJob();
     $job->addNotice("NagiosHostExporter attempting to export host configuration.");
     $fp = $this->getOutputFile();
     fputs($fp, "# Written by NagiosHostExporter from " . LILAC_NAME . " " . LILAC_VERSION . " on " . date("F j, Y, g:i a") . "\n\n");
     $hosts = NagiosHostPeer::doSelect(new Criteria());
     foreach ($hosts as $host) {
         fputs($fp, "define host {\n");
         $finalArray = array();
         $values = $host->getValues();
         foreach ($values as $key => $valArray) {
             $value = $valArray['value'];
             if ($key == 'id' || $key == 'notification_on_down' || $key == 'notification_on_unreachable' || $key == 'notification_on_recovery' || $key == 'notification_on_flapping' || $key == 'notification_on_scheduled_downtime' || $key == 'stalking_on_up' || $key == 'stalking_on_down' || $key == 'stalking_on_unreachable' || $key == 'flap_detection_on_up' || $key == 'flap_detection_on_down' || $key == 'flap_detection_on_unreachable' || $key == '' || $key == "autodiscovery_address_filter" || $key == "autodiscovery_hostname_filter" || $key == "autodiscovery_os_family_filter" || $key == "autodiscovery_os_generation_filter" || $key == "autodiscovery_os_vendor_filter" || $key == "description") {
                 continue;
             }
             if ($key == 'name') {
                 $key = 'host_name';
             }
             if ($key == 'maximum_check_attempts') {
                 $key = 'max_check_attempts';
             }
             if ($key == 'two_d_coords') {
                 $key = '2d_coords';
             }
             if ($key == 'three_d_coords') {
                 $key = '3d_coords';
             }
             if ($value === null) {
                 continue;
             }
             if ($value === false) {
                 $value = '0';
             }
             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 = $host->getInheritedCommandWithParameters();
                     foreach ($cmdObj['parameters'] as $parameterArray) {
                         $value .= "!" . $parameterArray['parameter']->getParameter();
                     }
                 }
             }
             $finalArray[$key] = $value;
         }
         foreach ($finalArray as $key => $val) {
             fputs($fp, "\t" . $key . "\t" . $val . "\n");
         }
         // Notifications
         if (isset($values['notification_on_down']['value'])) {
             if (!$values['notification_on_down']['value'] && !$values['notification_on_unreachable']['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_down']['value']) {
                     $tempValues[] = "d";
                 }
                 if ($values['notification_on_unreachable']['value']) {
                     $tempValues[] = "u";
                 }
                 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['stalking_on_up']['value'] || $values['stalking_on_down']['value'] || $values['stalking_on_unreachable']['value']) {
             fputs($fp, "\tstalking_options\t");
             if ($values['stalking_on_up']['value']) {
                 fputs($fp, "o");
                 if ($values['stalking_on_down']['value'] || $values['stalking_on_unreachable']['value']) {
                     fputs($fp, ",");
                 }
             }
             if ($values['stalking_on_down']['value']) {
                 fputs($fp, "d");
                 if ($values['stalking_on_unreachable']['value']) {
                     fputs($fp, ",");
                 }
             }
             if ($values['stalking_on_unreachable']['value']) {
                 fputs($fp, "u");
             }
             fputs($fp, "\n");
         }
         // Flap Detection
         if ($values['flap_detection_on_up']['value'] || $values['flap_detection_on_down']['value'] || $values['flap_detection_on_unreachable']['value']) {
             fputs($fp, "\tflap_detection_options\t");
             if ($values['flap_detection_on_up']['value']) {
                 fputs($fp, "o");
                 if ($values['flap_detection_on_down']['value'] || $values['flap_detection_on_unreachable']['value']) {
                     fputs($fp, ",");
                 }
             }
             if ($values['flap_detection_on_down']['value']) {
                 fputs($fp, "d");
                 if ($values['flap_detection_on_unreachable']['value']) {
                     fputs($fp, ",");
                 }
             }
             if ($values['flap_detection_on_unreachable']['value']) {
                 fputs($fp, "u");
             }
             fputs($fp, "\n");
         }
         // Parents
         $c = new Criteria();
         $c->add(NagiosHostParentPeer::CHILD_HOST, $host->getId());
         $parents = NagiosHostParentPeer::doSelectJoinNagiosHostRelatedByParentHost($c);
         if (count($parents)) {
             fputs($fp, "\tparents\t");
             $first = true;
             foreach ($parents as $parent) {
                 if (!$first) {
                     fputs($fp, ",");
                 } else {
                     $first = false;
                 }
                 fputs($fp, $parent->getNagiosHostRelatedByParentHost()->getName());
             }
             fputs($fp, "\n");
         }
         // Contact Groups
         $groupList = array();
         $inherited_list = $host->getInheritedContactGroups();
         $lilac->return_host_contactgroups_list($host->getId(), $contactgroups_list);
         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");
         }
         // Contacts
         $contactList = array();
         $inherited_list = $host->getInheritedContacts();
         $contact_list = $host->getNagiosHostContactMembers();
         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");
         }
         // Host Groups
         $groupList = array();
         $inherited_list = $host->getInheritedHostGroups();
         $hostgroups_list = $host->getNagiosHostgroupMemberships();
         foreach ($inherited_list as $group) {
             if (!key_exists($group->getName(), $groupList)) {
                 $groupList[$group->getName()] = $group;
             }
         }
         foreach ($hostgroups_list as $group) {
             $group = $group->getNagiosHostgroup();
             if (!key_exists($group->getName(), $groupList)) {
                 $groupList[$group->getName()] = $group;
             }
         }
         if (count($groupList)) {
             fputs($fp, "\thostgroups\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");
     }
     $job->addNotice("NagiosHostExporter complete.");
     return true;
 }