Beispiel #1
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;
 }
Beispiel #2
0
         }
     } else {
         if (!empty($_GET['contact_id'])) {
             $c = new Criteria();
             $c->add(NagiosHostContactMemberPeer::HOST, $_GET['id']);
             $c->add(NagiosHostcontactMemberPeer::CONTACT, $_GET['contact_id']);
             $membership = NagiosHostContactMemberPeer::doSelectOne($c);
             if ($membership) {
                 $membership->delete();
                 $success = "Contact deleted.";
             }
         }
     }
 }
 if ($_GET['request'] == "delete" && $_GET['section'] == 'dependencies') {
     $dependency = NagiosDependencyPeer::retrieveByPK($_GET['dependency_id']);
     if ($dependency) {
         $dependency->delete();
         $success = "Dependency deleted.";
     }
 }
 if ($_GET['request'] == "delete" && $_GET['section'] == 'escalations') {
     // !!!!!!!!!!!!!! This is where we do dependency error checking
     $lilac->delete_escalation($_GET['escalation_id']);
     $success = "Escalation Deleted";
     unset($host);
 }
 if ($_GET['request'] == "delete" && $_GET['section'] == 'checkcommand') {
     $commandParameter = NagiosHostCheckCommandParameterPeer::retrieveByPK($_GET['checkcommandparameter_id']);
     if ($commandParameter) {
         $commandParameter->delete();
Beispiel #3
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 NagiosDependencys 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 getNagiosDependencysJoinNagiosHostgroup($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->collNagiosDependencys === null) {
         if ($this->isNew()) {
             $this->collNagiosDependencys = array();
         } else {
             $criteria->add(NagiosDependencyPeer::DEPENDENCY_PERIOD, $this->id);
             $this->collNagiosDependencys = NagiosDependencyPeer::doSelectJoinNagiosHostgroup($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(NagiosDependencyPeer::DEPENDENCY_PERIOD, $this->id);
         if (!isset($this->lastNagiosDependencyCriteria) || !$this->lastNagiosDependencyCriteria->equals($criteria)) {
             $this->collNagiosDependencys = NagiosDependencyPeer::doSelectJoinNagiosHostgroup($criteria, $con, $join_behavior);
         }
     }
     $this->lastNagiosDependencyCriteria = $criteria;
     return $this->collNagiosDependencys;
 }
 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.");
 }
 /**
  * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
  * feature (like MySQL or SQLite).
  *
  * This method is not very speedy because it must perform a query first to get
  * the implicated records and then perform the deletes by calling those Peer classes.
  *
  * This method should be used within a transaction if possible.
  *
  * @param      Criteria $criteria
  * @param      PropelPDO $con
  * @return     int The number of affected rows (if supported by underlying database driver).
  */
 protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
 {
     // initialize var to track total num of affected rows
     $affectedRows = 0;
     // first find the objects that are implicated by the $criteria
     $objects = NagiosTimeperiodPeer::doSelect($criteria, $con);
     foreach ($objects as $obj) {
         // delete related NagiosDependency objects
         $c = new Criteria(NagiosDependencyPeer::DATABASE_NAME);
         $c->add(NagiosDependencyPeer::DEPENDENCY_PERIOD, $obj->getId());
         $affectedRows += NagiosDependencyPeer::doDelete($c, $con);
     }
     return $affectedRows;
 }
Beispiel #6
0
 /**
  * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
  * feature (like MySQL or SQLite).
  *
  * This method is not very speedy because it must perform a query first to get
  * the implicated records and then perform the deletes by calling those Peer classes.
  *
  * This method should be used within a transaction if possible.
  *
  * @param      Criteria $criteria
  * @param      PropelPDO $con
  * @return     int The number of affected rows (if supported by underlying database driver).
  */
 protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
 {
     // initialize var to track total num of affected rows
     $affectedRows = 0;
     // first find the objects that are implicated by the $criteria
     $objects = NagiosHostPeer::doSelect($criteria, $con);
     foreach ($objects as $obj) {
         // delete related NagiosService objects
         $c = new Criteria(NagiosServicePeer::DATABASE_NAME);
         $c->add(NagiosServicePeer::HOST, $obj->getId());
         $affectedRows += NagiosServicePeer::doDelete($c, $con);
         // delete related NagiosHostContactMember objects
         $c = new Criteria(NagiosHostContactMemberPeer::DATABASE_NAME);
         $c->add(NagiosHostContactMemberPeer::HOST, $obj->getId());
         $affectedRows += NagiosHostContactMemberPeer::doDelete($c, $con);
         // delete related NagiosDependency objects
         $c = new Criteria(NagiosDependencyPeer::DATABASE_NAME);
         $c->add(NagiosDependencyPeer::HOST, $obj->getId());
         $affectedRows += NagiosDependencyPeer::doDelete($c, $con);
         // delete related NagiosDependencyTarget objects
         $c = new Criteria(NagiosDependencyTargetPeer::DATABASE_NAME);
         $c->add(NagiosDependencyTargetPeer::TARGET_HOST, $obj->getId());
         $affectedRows += NagiosDependencyTargetPeer::doDelete($c, $con);
         // delete related NagiosEscalation objects
         $c = new Criteria(NagiosEscalationPeer::DATABASE_NAME);
         $c->add(NagiosEscalationPeer::HOST, $obj->getId());
         $affectedRows += NagiosEscalationPeer::doDelete($c, $con);
         // delete related NagiosHostContactgroup objects
         $c = new Criteria(NagiosHostContactgroupPeer::DATABASE_NAME);
         $c->add(NagiosHostContactgroupPeer::HOST, $obj->getId());
         $affectedRows += NagiosHostContactgroupPeer::doDelete($c, $con);
         // delete related NagiosHostgroupMembership objects
         $c = new Criteria(NagiosHostgroupMembershipPeer::DATABASE_NAME);
         $c->add(NagiosHostgroupMembershipPeer::HOST, $obj->getId());
         $affectedRows += NagiosHostgroupMembershipPeer::doDelete($c, $con);
         // delete related NagiosHostCheckCommandParameter objects
         $c = new Criteria(NagiosHostCheckCommandParameterPeer::DATABASE_NAME);
         $c->add(NagiosHostCheckCommandParameterPeer::HOST, $obj->getId());
         $affectedRows += NagiosHostCheckCommandParameterPeer::doDelete($c, $con);
         // delete related NagiosHostParent objects
         $c = new Criteria(NagiosHostParentPeer::DATABASE_NAME);
         $c->add(NagiosHostParentPeer::CHILD_HOST, $obj->getId());
         $affectedRows += NagiosHostParentPeer::doDelete($c, $con);
         // delete related NagiosHostParent objects
         $c = new Criteria(NagiosHostParentPeer::DATABASE_NAME);
         $c->add(NagiosHostParentPeer::PARENT_HOST, $obj->getId());
         $affectedRows += NagiosHostParentPeer::doDelete($c, $con);
         // delete related NagiosHostTemplateInheritance objects
         $c = new Criteria(NagiosHostTemplateInheritancePeer::DATABASE_NAME);
         $c->add(NagiosHostTemplateInheritancePeer::SOURCE_HOST, $obj->getId());
         $affectedRows += NagiosHostTemplateInheritancePeer::doDelete($c, $con);
     }
     return $affectedRows;
 }
 /**
  * Get the associated NagiosDependency object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     NagiosDependency The associated NagiosDependency object.
  * @throws     PropelException
  */
 public function getNagiosDependency(PropelPDO $con = null)
 {
     if ($this->aNagiosDependency === null && $this->dependency !== null) {
         $c = new Criteria(NagiosDependencyPeer::DATABASE_NAME);
         $c->add(NagiosDependencyPeer::ID, $this->dependency);
         $this->aNagiosDependency = NagiosDependencyPeer::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->aNagiosDependency->addNagiosDependencyTargets($this);
         		 */
     }
     return $this->aNagiosDependency;
 }
 /**
  * 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(NagiosDependencyPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(NagiosDependencyPeer::DATABASE_NAME);
         $criteria->add(NagiosDependencyPeer::ID, $pks, Criteria::IN);
         $objs = NagiosDependencyPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
 /**
  * Selects a collection of NagiosDependencyTarget objects pre-filled with all related objects except NagiosHostgroup.
  *
  * @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 NagiosDependencyTarget objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptNagiosHostgroup(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);
     }
     NagiosDependencyTargetPeer::addSelectColumns($c);
     $startcol2 = NagiosDependencyTargetPeer::NUM_COLUMNS - NagiosDependencyTargetPeer::NUM_LAZY_LOAD_COLUMNS;
     NagiosDependencyPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + (NagiosDependencyPeer::NUM_COLUMNS - NagiosDependencyPeer::NUM_LAZY_LOAD_COLUMNS);
     NagiosHostPeer::addSelectColumns($c);
     $startcol4 = $startcol3 + (NagiosHostPeer::NUM_COLUMNS - NagiosHostPeer::NUM_LAZY_LOAD_COLUMNS);
     NagiosServicePeer::addSelectColumns($c);
     $startcol5 = $startcol4 + (NagiosServicePeer::NUM_COLUMNS - NagiosServicePeer::NUM_LAZY_LOAD_COLUMNS);
     $c->addJoin(array(NagiosDependencyTargetPeer::DEPENDENCY), array(NagiosDependencyPeer::ID), $join_behavior);
     $c->addJoin(array(NagiosDependencyTargetPeer::TARGET_HOST), array(NagiosHostPeer::ID), $join_behavior);
     $c->addJoin(array(NagiosDependencyTargetPeer::TARGET_SERVICE), array(NagiosServicePeer::ID), $join_behavior);
     $stmt = BasePeer::doSelect($c, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = NagiosDependencyTargetPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = NagiosDependencyTargetPeer::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 = NagiosDependencyTargetPeer::getOMClass();
             $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             NagiosDependencyTargetPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined NagiosDependency rows
         $key2 = NagiosDependencyPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = NagiosDependencyPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $omClass = NagiosDependencyPeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 NagiosDependencyPeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (NagiosDependencyTarget) to the collection in $obj2 (NagiosDependency)
             $obj2->addNagiosDependencyTarget($obj1);
         }
         // if joined row is not null
         // Add objects for joined NagiosHost rows
         $key3 = NagiosHostPeer::getPrimaryKeyHashFromRow($row, $startcol3);
         if ($key3 !== null) {
             $obj3 = NagiosHostPeer::getInstanceFromPool($key3);
             if (!$obj3) {
                 $omClass = NagiosHostPeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj3 = new $cls();
                 $obj3->hydrate($row, $startcol3);
                 NagiosHostPeer::addInstanceToPool($obj3, $key3);
             }
             // if $obj3 already loaded
             // Add the $obj1 (NagiosDependencyTarget) to the collection in $obj3 (NagiosHost)
             $obj3->addNagiosDependencyTarget($obj1);
         }
         // if joined row is not null
         // Add objects for joined NagiosService rows
         $key4 = NagiosServicePeer::getPrimaryKeyHashFromRow($row, $startcol4);
         if ($key4 !== null) {
             $obj4 = NagiosServicePeer::getInstanceFromPool($key4);
             if (!$obj4) {
                 $omClass = NagiosServicePeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj4 = new $cls();
                 $obj4->hydrate($row, $startcol4);
                 NagiosServicePeer::addInstanceToPool($obj4, $key4);
             }
             // if $obj4 already loaded
             // Add the $obj1 (NagiosDependencyTarget) to the collection in $obj4 (NagiosService)
             $obj4->addNagiosDependencyTarget($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
Beispiel #10
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;
 }
 public function export()
 {
     global $lilac;
     // Grab our export job
     $engine = $this->getEngine();
     $job = $engine->getJob();
     $job->addNotice("NagiosDependencyExporter attempting to export dependency configuration.");
     $fp = $this->getOutputFile();
     fputs($fp, "# Written by NagiosDependencyExporter 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 inherited dependencies first
         $job->addNotice("Processing dependencies for host: " . $host->getName());
         $inheritedDependencies = $host->getInheritedDependencies();
         foreach ($inheritedDependencies as $dependency) {
             $targets = $dependency->getNagiosDependencyTargets();
             foreach ($targets as $target) {
                 $this->_exportDependency($dependency, "host", $target, $host);
             }
         }
         $dependencies = $host->getNagiosDependencys();
         foreach ($dependencies as $dependency) {
             $targets = $dependency->getNagiosDependencyTargets();
             foreach ($targets as $target) {
                 $this->_exportDependency($dependency, "host", $target, $host);
             }
         }
         // Get our services
         $inheritedServices = $host->getInheritedServices();
         foreach ($inheritedServices as $service) {
             $job->addNotice("Processing dependencies for service: " . $service->getDescription() . " on " . $host->getName());
             $serviceInheritedDependencies = $service->getInheritedDependencies();
             foreach ($serviceInheritedDependencies as $dependency) {
                 $targets = $dependency->getNagiosDependencyTargets();
                 foreach ($targets as $target) {
                     $this->_exportDependency($dependency, "service", $target, $service, $host);
                 }
             }
             $c = new Criteria();
             $c->add(NagiosDependencyPeer::HOST, $host->getId());
             $c->add(NagiosDependencyPeer::SERVICE, $service->getId());
             $serviceDependencies = NagiosDependencyPeer::doSelect($c);
             foreach ($serviceDependencies as $dependency) {
                 $targets = $dependency->getNagiosDependencyTargets();
                 foreach ($targets as $target) {
                     $this->_exportDependency($dependency, "service", $target, $service, $host);
                 }
             }
         }
         $services = $host->getNagiosServices();
         foreach ($services as $service) {
             $job->addNotice("Processing dependencies for service: " . $service->getDescription() . " on " . $host->getName());
             $serviceInheritedDependencies = $service->getInheritedDependencies();
             foreach ($serviceInheritedDependencies as $dependency) {
                 $targets = $dependency->getNagiosDependencyTargets();
                 foreach ($targets as $target) {
                     $this->_exportDependency($dependency, "service", $target, $service, $host);
                 }
             }
             $serviceDependencies = $service->getNagiosDependencys();
             foreach ($serviceDependencies as $dependency) {
                 $targets = $dependency->getNagiosDependencyTargets();
                 foreach ($targets as $target) {
                     $this->_exportDependency($dependency, "service", $target, $service, $host);
                 }
             }
         }
         $job->addNotice("Completed dependencies export for host: " . $host->getName());
     }
     // Get hostgroup dependencies
     $hostgroups = NagiosHostgroupPeer::doSelect(new Criteria());
     foreach ($hostgroups as $hostgroup) {
         $dependencies = $hostgroup->getNagiosDependencys();
         foreach ($dependencies as $dependency) {
             $targets = $dependency->getNagiosDependencyTargets();
             foreach ($targets as $target) {
                 $this->_exportDependency($dependency, "hostgroup", $target, $hostgroup);
             }
         }
         $job->addNotice("Completed dependencies export for hostgroup: " . $hostgroup->getName());
     }
     $job->addNotice("NagiosDependencyExporter complete.");
     return true;
 }
Beispiel #12
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 = NagiosDependencyPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setHostTemplate($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setHost($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setServiceTemplate($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setService($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setHostgroup($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setName($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setExecutionFailureCriteriaUp($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setExecutionFailureCriteriaDown($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setExecutionFailureCriteriaUnreachable($arr[$keys[9]]);
     }
     if (array_key_exists($keys[10], $arr)) {
         $this->setExecutionFailureCriteriaPending($arr[$keys[10]]);
     }
     if (array_key_exists($keys[11], $arr)) {
         $this->setExecutionFailureCriteriaOk($arr[$keys[11]]);
     }
     if (array_key_exists($keys[12], $arr)) {
         $this->setExecutionFailureCriteriaWarning($arr[$keys[12]]);
     }
     if (array_key_exists($keys[13], $arr)) {
         $this->setExecutionFailureCriteriaUnknown($arr[$keys[13]]);
     }
     if (array_key_exists($keys[14], $arr)) {
         $this->setExecutionFailureCriteriaCritical($arr[$keys[14]]);
     }
     if (array_key_exists($keys[15], $arr)) {
         $this->setNotificationFailureCriteriaOk($arr[$keys[15]]);
     }
     if (array_key_exists($keys[16], $arr)) {
         $this->setNotificationFailureCriteriaWarning($arr[$keys[16]]);
     }
     if (array_key_exists($keys[17], $arr)) {
         $this->setNotificationFailureCriteriaUnknown($arr[$keys[17]]);
     }
     if (array_key_exists($keys[18], $arr)) {
         $this->setNotificationFailureCriteriaCritical($arr[$keys[18]]);
     }
     if (array_key_exists($keys[19], $arr)) {
         $this->setNotificationFailureCriteriaPending($arr[$keys[19]]);
     }
     if (array_key_exists($keys[20], $arr)) {
         $this->setNotificationFailureCriteriaUp($arr[$keys[20]]);
     }
     if (array_key_exists($keys[21], $arr)) {
         $this->setNotificationFailureCriteriaDown($arr[$keys[21]]);
     }
     if (array_key_exists($keys[22], $arr)) {
         $this->setNotificationFailureCriteriaUnreachable($arr[$keys[22]]);
     }
     if (array_key_exists($keys[23], $arr)) {
         $this->setInheritsParent($arr[$keys[23]]);
     }
     if (array_key_exists($keys[24], $arr)) {
         $this->setDependencyPeriod($arr[$keys[24]]);
     }
 }