예제 #1
0
 public function valid()
 {
     $values = $this->getSegment()->getValues();
     $job = $this->getEngine()->getJob();
     // Check contact existence
     if (isset($values['members'])) {
         $members = explode(",", $values['members'][0]['value']);
         for ($counter = 0; $counter < count($members); $counter += 2) {
             // Get Service
             $service = NagiosServicePeer::getByHostAndDescription($members[$counter], $members[$counter + 1]);
             if (!$service) {
                 $job->addNotice("The member specified by " . $members[$counter] . ":" . $members[$counter + 1] . " was not found.  Setting this service group as queued.");
                 return false;
             }
         }
     }
     if (isset($values['servicegroup_members'])) {
         foreach ($values['servicegroup_members'] as $serviceGroupValues) {
             $c = new Criteria();
             $c->add(NagiosServiceGroupPeer::NAME, $serviceGroupValues['value']);
             $servicegroup = NagiosServiceGroupPeer::doSelectOne($c);
             if (empty($servicegroup)) {
                 $job->addNotice("The service group specified by " . $serviceGroupValues['value'] . " was not found.  Setting this service group as queued.");
                 return false;
             }
         }
     }
     return true;
 }
예제 #2
0
 public function getByName($name)
 {
     $c = new Criteria();
     $c->add(NagiosServiceGroupPeer::NAME, $name);
     $c->setIgnoreCase(true);
     $servicegroup = NagiosServiceGroupPeer::doSelectOne($c);
     if (!$servicegroup) {
         return false;
     }
     return $servicegroup;
 }
예제 #3
0
 /**
  * Get the associated NagiosServiceGroup object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     NagiosServiceGroup The associated NagiosServiceGroup object.
  * @throws     PropelException
  */
 public function getNagiosServiceGroup(PropelPDO $con = null)
 {
     if ($this->aNagiosServiceGroup === null && $this->service_group !== null) {
         $c = new Criteria(NagiosServiceGroupPeer::DATABASE_NAME);
         $c->add(NagiosServiceGroupPeer::ID, $this->service_group);
         $this->aNagiosServiceGroup = NagiosServiceGroupPeer::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->aNagiosServiceGroup->addNagiosServiceGroupMembers($this);
         		 */
     }
     return $this->aNagiosServiceGroup;
 }
예제 #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;
 }
예제 #5
0
 public function valid()
 {
     $values = $this->getSegment()->getValues();
     $job = $this->getEngine()->getJob();
     if (isset($values['use'])) {
         // We need to use a template
         $job->addNotice("This Service uses a template: " . $values['use'][0]['value']);
         $template = NagiosServiceTemplatePeer::getByName($values['use'][0]['value']);
         if (empty($template)) {
             $job->addNotice("That template is not found yet. Setting this service as queued.");
             return false;
         }
         $template->clearAllReferences(true);
     }
     // Check time period existence
     if (isset($values['check_period'])) {
         $c = new Criteria();
         $c->add(NagiosTimeperiodPeer::NAME, $values['check_period'][0]['value']);
         $timePeriod = NagiosTimeperiodPeer::doSelectOne($c);
         if (empty($timePeriod)) {
             $job->addNotice("The time period specified by " . $values['check_period'][0]['value'] . " was not found.  Setting this service as queued.");
             return false;
         }
         $timePeriod->clearAllReferences(true);
     }
     if (isset($values['notification_period'])) {
         $c = new Criteria();
         $c->add(NagiosTimeperiodPeer::NAME, $values['notification_period'][0]['value']);
         $timePeriod = NagiosTimeperiodPeer::doSelectOne($c);
         if (empty($timePeriod)) {
             $job->addNotice("The time period specified by " . $values['notification_period'][0]['value'] . " was not found.  Setting this service as queued.");
             return false;
         }
         $timePeriod->clearAllReferences(true);
     }
     // Check command existence
     if (isset($values['check_command'])) {
         $params = explode('!', $values['check_command'][0]['value']);
         $c = new Criteria();
         $c->add(NagiosCommandPeer::NAME, $params[0]);
         $command = NagiosCommandPeer::doSelectOne($c);
         if (empty($command)) {
             $job->addNotice("The command specified by " . $params[0] . " was not found.  Setting this service as queued.");
             return false;
         }
         $command->clearAllReferences(true);
     }
     if (isset($values['event_handler'])) {
         $c = new Criteria();
         $c->add(NagiosCommandPeer::NAME, $values['event_handler'][0]['value']);
         $command = NagiosCommandPeer::doSelectOne($c);
         if (empty($command)) {
             $job->addNotice("The command specified by " . $values['event_handler'][0]['value'] . " was not found.  Setting this service as queued.");
             return false;
         }
         $command->clearAllReferences(true);
     }
     // Check contact groups
     if (isset($values['contact_groups'])) {
         foreach ($values['contact_groups'] as $contactGroupValues) {
             $c = new Criteria();
             $c->add(NagiosContactGroupPeer::NAME, $contactGroupValues['value']);
             $contactgroup = NagiosContactGroupPeer::doSelectOne($c);
             if (empty($contactgroup)) {
                 $job->addNotice("The contact group specified by " . $contactGroupValues['value'] . " was not found.  Setting this service as queued.");
                 return false;
             }
             $contactgroup->clearAllReferences(true);
         }
     }
     if (isset($values['contacts'])) {
         foreach ($values['contacts'] as $contactValues) {
             $c = new Criteria();
             $c->add(NagiosContactPeer::NAME, $contactValues['value']);
             $contactgroup = NagiosContactPeer::doSelectOne($c);
             if (empty($contactgroup)) {
                 $job->addNotice("The contact specified by " . $contactValues['value'] . " was not found.  Setting this service as queued.");
                 return false;
             }
             $contactgroup->clearAllReferences(true);
         }
     }
     // Check host groups
     if (isset($values['servicegroups'])) {
         foreach ($values['servicegroups'] as $serviceGroupValues) {
             $c = new Criteria();
             $c->add(NagiosServiceGroupPeer::NAME, $serviceGroupValues['value']);
             $servicegroup = NagiosServiceGroupPeer::doSelectOne($c);
             if (empty($servicegroup)) {
                 $job->addNotice("The service group specified by " . $serviceGroupValues['value'] . " was not found.  Setting this service as queued.");
                 return false;
             }
             $servicegroup->clearAllReferences(true);
         }
     }
     // Check for hosts
     if (isset($values['host_name'])) {
         foreach ($values['host_name'] as $hostValues) {
             $host = NagiosHostPeer::getByName($hostValues['value']);
             if (empty($host)) {
                 $job->addNotice("The host specified by " . $hostValues['value'] . " was not found.  Setting this service as queued.");
                 return false;
             }
             $host->clearAllReferences(true);
         }
     }
     // Check for hostgroup_name
     if (isset($values['hostgroup_name'])) {
         foreach ($values['hostgroup_name'] as $hostgroupValues) {
             $hostgroup = NagiosHostgroupPeer::getByName($hostgroupValues['value']);
             if (empty($hostgroup)) {
                 $job->addNotice("The host group specified by " . $hostgroupValues['value'] . " was not found.  Setting this service as queued.");
                 return false;
             }
             $hostgroup->clearAllReferences(true);
         }
     }
     // Check for hostgroup_name
     if (isset($values['hostgroup'])) {
         foreach ($values['hostgroup'] as $hostgroupValues) {
             $hostgroup = NagiosHostgroupPeer::getByName($hostgroupValues['value']);
             if (empty($hostgroup)) {
                 $job->addNotice("The host group specified by " . $hostgroupValues['value'] . " was not found.  Setting this service as queued.");
                 return false;
             }
             $hostgroup->clearAllReferences(true);
         }
     }
     return true;
 }