Ejemplo n.º 1
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.");
 }
 /**
  * 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      NagiosServiceCheckCommandParameter $value A NagiosServiceCheckCommandParameter object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(NagiosServiceCheckCommandParameter $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Ejemplo n.º 3
0
                    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();
                            $success = "Command Parameter added.";
                        }
                    }
                }
            }
        }
    }
}
if (isset($_GET['id'])) {
    // Load template.
    $service = NagiosServicePeer::retrieveByPK($_GET['id']);
    if (!$service) {
Ejemplo n.º 4
0
 function addCheckCommandParameter($value)
 {
     $parameter = new NagiosServiceCheckCommandParameter();
     $parameter->setNagiosServiceTemplate($this);
     $parameter->setParameter($value);
     $parameter->save();
     return true;
 }