Ejemplo n.º 1
0
 public function addMembersByServiceGroup($name)
 {
     // First get servicegroup
     $servicegroup = NagiosServiceGroupPeer::getByName($name);
     if (!$servicegroup) {
         return false;
     }
     // Get the members
     $memberships = $servicegroup->getNagiosServiceGroupMembers();
     foreach ($memberships as $membership) {
         $service = $membership->getNagiosService();
         // Check to see if we already have this in our member list
         $id = $this->getId();
         if (!empty($id)) {
             $c = new Criteria();
             $c->add(NagiosServiceGroupMemberPeer::SERVICE_GROUP, $this->getId());
             $c->add(NagiosServiceGroupMemberPeer::SERVICE, $service->getId());
             $relationship = NagiosServiceGroupMemberPeer::doSelectOne($c);
             if ($relationship) {
                 continue;
             }
         }
         // Create new relationship
         $relationship = new NagiosServiceGroupMember();
         $relationship->setNagiosService($service);
         $relationship->setNagiosServiceGroup($this);
         $relationship->save();
     }
     return true;
 }
Ejemplo n.º 2
0
 public function import()
 {
     $engine = $this->getEngine();
     $job = $engine->getJob();
     $job->addNotice("FruityServiceImporter beginning to import Service Configuration.");
     // Services
     foreach ($this->dbConn->query("SELECT * FROM nagios_services", PDO::FETCH_ASSOC) as $service) {
         $this->importService($service);
     }
     // Service template check commands
     $job->addNotice("FruityServiceImporter now processing Service Check Commands.");
     foreach ($this->dbConn->query("SELECT * FROM nagios_services_check_command_parameters WHERE service_id IS NOT NULL", PDO::FETCH_ASSOC) as $commandParameterInfo) {
         $service = $this->getLilacServiceById($commandParameterInfo['service_id']);
         if (!$service) {
             $job->addNotice("Fruity Service Check Command Parameter Importer: Could not find service with id: " . $commandParameterInfo['service_id']);
             continue;
         }
         $newParameter = new NagiosServiceCheckCommandParameter();
         $newParameter->setService($service->getId());
         $newParameter->setParameter($commandParameterInfo['parameter']);
         $newParameter->save();
     }
     // Service extended information
     $job->addNotice("FruityServiceImporter now processing Service Extended Information.");
     foreach ($this->dbConn->query("SELECT * FROM nagios_services_extended_info", PDO::FETCH_ASSOC) as $extInfo) {
         $service = $this->getLilacServiceById($extInfo['service_id']);
         if (!$service) {
             $job->addNotice("Fruity Service Check Command Parameter Importer: Could not find service with id " . $extInfo['service_id']);
             continue;
         }
         // Go through the extended info, and set it on the template.
         $service->setNotes($extInfo['notes']);
         $service->setNotesUrl($extInfo['notes_url']);
         $service->setActionUrl($extInfo['action_url']);
         $service->setIconImage($extInfo['icon_image']);
         $service->setIconImageAlt($extInfo['icon_image_alt']);
         $service->save();
     }
     // Service contact group memberships
     $job->addNotice("FruityServiceImporter now processing Service Contact Group Memberships.");
     foreach ($this->dbConn->query("SELECT * FROM nagios_service_contactgroups", PDO::FETCH_ASSOC) as $membershipInfo) {
         $service = $this->getLilacServiceById($membershipInfo['service_id']);
         if (!$service) {
             $job->addNotice("Fruity Service Check Command Parameter Importer: Could not find service with id " . $membershipInfo['service_id']);
             continue;
         }
         // Now get Contact Group Name
         $contactGroupName = $this->getContactGroupNameById($membershipInfo['contactgroup_id']);
         if (!$contactGroupName) {
             $job->addNotice("Fruity Service Contact Group Importer: Could not find contact group with id: " . $membershipInfo['contactgroup_id']);
             continue;
         }
         $contactGroup = NagiosContactGroupPeer::getByName($contactGroupName);
         if (!$contactGroup) {
             $job->addNotice("Fruity Service Contact Group Importer: Could not find contact group with name: " . $contactGroupName);
             continue;
         }
         $membership = new NagiosServiceContactGroupMember();
         $membership->setService($service->getId());
         $membership->setNagiosContactGroup($contactGroup);
         $membership->save();
     }
     // Service service group memberships
     $job->addNotice("FruityServiceImporter now processing Service Service Group Memberships.");
     foreach ($this->dbConn->query("SELECT * FROM nagios_servicegroup_membership", PDO::FETCH_ASSOC) as $membershipInfo) {
         $service = $this->getLilacServiceById($membershipInfo['service_id']);
         if (!$service) {
             $job->addNotice("Fruity Service Check Command Parameter Importer: Could not find service with id " . $membershipInfo['service_id']);
             continue;
         }
         // Now get Contact Group Name
         $serviceGroupName = $this->getServiceGroupNameById($membershipInfo['servicegroup_id']);
         if (!$serviceGroupName) {
             $job->addNotice("Fruity Service Service Group Importer: Could not find service group with id: " . $membershipInfo['servicegroup_id']);
             continue;
         }
         $serviceGroup = NagiosServiceGroupPeer::getByName($serviceGroupName);
         if (!$contactGroup) {
             $job->addNotice("Fruity Service Service Group Importer: Could not find service group with name: " . $serviceGroupName);
             continue;
         }
         $membership = new NagiosServiceGroupMember();
         $membership->setService($service->getId());
         $membership->setNagiosServiceGroup($serviceGroup);
         $membership->save();
     }
     $job->addNotice("FruityServiceImporter finished importing Service Group Configuration.");
     $job->addNotice("FruityServiceImporter imported a total of " . $this->totalImported . " services.");
 }
Ejemplo n.º 3
0
             $membership->setService($_GET['id']);
             $membership->setNagiosContactGroup($tempGroup);
             $membership->save();
             $success = "New Service Contact Group Link added.";
         }
     }
 } else {
     if ($_POST['request'] == 'add_servicegroup_command') {
         $c = new Criteria();
         $c->add(NagiosServiceGroupMemberPeer::SERVICE, $service->getId());
         $c->add(NagiosServiceGroupMemberPeer::SERVICE_GROUP, $_POST['servicegroup_id']);
         $tempMembership = NagiosServiceGroupMemberPeer::doSelectOne($c);
         if ($tempMembership) {
             $error = "That service group already exists in that list!";
         } else {
             $membership = new NagiosServiceGroupMember();
             $membership->setService($service->getId());
             $membership->setServiceGroup($_POST['servicegroup_id']);
             $membership->save();
             $success = "New Service Group Link added.";
         }
     } else {
         if ($_POST['request'] == 'command_parameter_add') {
             if (trim($_POST['service_manage']['parameter']) == "") {
                 $error = "Parameter cannot be blank.";
             } else {
                 // All is well for error checking, modify the command.
                 $param = new NagiosServiceCheckCommandParameter();
                 $param->setService($service->getId());
                 $param->setParameter($_POST['service_manage']['parameter']);
                 $param->save();
Ejemplo n.º 4
0
 function addServicegroupByName($name)
 {
     $c = new Criteria();
     $c->add(NagiosServiceGroupPeer::NAME, $name);
     $c->setIgnoreCase(true);
     $servicegroup = NagiosServiceGroupPeer::doSelectOne($c);
     if (!$servicegroup) {
         return false;
     }
     // Okay, servicegroup is valid, check for relationship
     $id = $this->getId();
     if (!empty($id)) {
         $c = new Criteria();
         $c->add(NagiosServiceGroupMemberPeer::TEMPLATE, $this->getId());
         $c->add(NagiosServiceGroupMemberPeer::SERVICE_GROUP, $servicegroup->getId());
         $relationship = NagiosServiceGroupMemberPeer::doSelectOne($c);
         if ($relationship) {
             return false;
         }
     }
     $relationship = new NagiosServiceGroupMember();
     $relationship->setNagiosServiceTemplate($this);
     $relationship->setNagiosServiceGroup($servicegroup);
     $relationship->save();
     return true;
 }
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      NagiosServiceGroupMember $value A NagiosServiceGroupMember object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(NagiosServiceGroupMember $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }