Exemplo n.º 1
0
 /**
  * stage - load up staging web view
  * 
  * @access public
  * @return void
  */
 public function stage()
 {
     $viewData = new ViewData();
     $deployment = $this->getDeployment('cgi_cfg_error');
     $modrevision = RevDeploy::getDeploymentNextRev($deployment);
     if (($return = RevDeploy::existsDeploymentCgiCfg($deployment, $modrevision)) === true) {
         $viewData->cgicfg = RevDeploy::getDeploymentCgiCfg($deployment, $modrevision);
     } else {
         $cfg = array();
         $cfg['main_config_file'] = base64_encode('/usr/local/nagios/etc/nagios.cfg');
         $cfg['physical_html_path'] = base64_encode('/usr/local/nagios/share');
         $cfg['url_html_path'] = base64_encode('/nagios');
         $cfg['show_context_help'] = 0;
         $cfg['use_pending_states'] = 1;
         $cfg['use_authentication'] = 1;
         $cfg['use_ssl_authentication'] = 0;
         $cfg['authorized_for_system_information'] = "*";
         $cfg['authorized_for_configuration_information'] = "*";
         $cfg['authorized_for_system_commands'] = "*";
         $cfg['authorized_for_all_services'] = "*";
         $cfg['authorized_for_all_hosts'] = "*";
         $cfg['authorized_for_all_service_commands'] = "*";
         $cfg['authorized_for_all_host_commands'] = "*";
         $cfg['authorized_for_read_only'] = "";
         $cfg['default_statusmap_layout'] = 5;
         $cfg['default_statuswrl_layout'] = 4;
         $cfg['ping_syntax'] = base64_encode('/bin/ping -n -U -c 5 $HOSTADDRESS$');
         $cfg['refresh_rate'] = 90;
         $cfg['escape_html_tags'] = 1;
         $cfg['action_url_target'] = '_blank';
         $cfg['notes_url_target'] = '_blank';
         $cfg['lock_author_names'] = 1;
         $cfg['enable_splunk_integration'] = 0;
         $cfg['splunk_url'] = base64_encode('http://127.0.0.1:8000/');
         $viewData->cgicfg = $cfg;
     }
     $viewData->contacts = RevDeploy::getCommonMergedDeploymentContacts($deployment, $modrevision);
     $viewData->deployment = $deployment;
     $this->sendResponse('cgi_cfg_stage', $viewData);
 }
Exemplo n.º 2
0
 public static function copyDeploymentRevision($deployment, $fromrev, $torev)
 {
     if (self::$init === false) {
         self::init();
     }
     self::$m_commonrepo = RevDeploy::getDeploymentCommonRepo($deployment);
     $results = array();
     $results['timeperiods'] = RevDeploy::getCommonMergedDeploymentTimeperiodswData($deployment, $fromrev);
     $results['commands'] = RevDeploy::getCommonMergedDeploymentCommands($deployment, $fromrev, false);
     $results['contacttemplates'] = RevDeploy::getCommonMergedDeploymentContactTemplates($deployment, $fromrev);
     $results['contactgroups'] = RevDeploy::getCommonMergedDeploymentContactGroups($deployment, $fromrev);
     $results['contacts'] = RevDeploy::getCommonMergedDeploymentContacts($deployment, $fromrev);
     $results['hosttemplates'] = RevDeploy::getCommonMergedDeploymentHostTemplates($deployment, $fromrev);
     $results['hostgroups'] = RevDeploy::getCommonMergedDeploymentHostGroups($deployment, $fromrev);
     $results['servicetemplates'] = RevDeploy::getCommonMergedDeploymentSvcTemplates($deployment, $fromrev);
     $results['servicegroups'] = RevDeploy::getCommonMergedDeploymentSvcGroups($deployment, $fromrev);
     $results['servicedependencies'] = RevDeploy::getCommonMergedDeploymentSvcDependencies($deployment, $fromrev);
     $results['serviceescalations'] = RevDeploy::getDeploymentSvcEscalationswInfo($deployment, $fromrev);
     $results['services'] = RevDeploy::getCommonMergedDeploymentSvcs($deployment, $fromrev);
     $results['nodetemplates'] = RevDeploy::getDeploymentNodeTemplateswInfo($deployment, $fromrev);
     $results['resourcecfg'] = RevDeploy::getDeploymentResourceCfg($deployment, $fromrev);
     $results['cgicfg'] = RevDeploy::getDeploymentCgiCfg($deployment, $fromrev);
     $results['modgearmancfg'] = RevDeploy::getDeploymentModgearmanCfg($deployment, $fromrev);
     $results['nagioscfg'] = RevDeploy::getDeploymentNagiosCfg($deployment, $fromrev);
     $results['nrpecmds'] = RevDeploy::getDeploymentNRPECmdswInfo($deployment, $fromrev);
     $results['nrpecfg'] = RevDeploy::getDeploymentNRPECfg($deployment, $fromrev);
     $results['nrpeplugins'] = RevDeploy::getDeploymentNRPEPluginswData($deployment, $fromrev);
     $results['supnrpecfg'] = RevDeploy::getDeploymentSupNRPECfg($deployment, $fromrev);
     $results['supnrpeplugins'] = RevDeploy::getDeploymentSupNRPEPluginswData($deployment, $fromrev);
     $results['nagiosplugins'] = RevDeploy::getDeploymentNagiosPluginswData($deployment, $fromrev);
     foreach ($results as $key => $value) {
         if (empty($value)) {
             continue;
         }
         switch ($key) {
             case 'timeperiods':
                 self::copyTimeperiods($deployment, $torev, $results['timeperiods']);
                 break;
             case 'commands':
                 self::copyCommands($deployment, $torev, $results['commands']);
                 break;
             case 'contacttemplates':
                 self::copyContactTemplates($deployment, $torev, $results['contacttemplates']);
                 break;
             case 'contactgroups':
                 self::copyContactGroups($deployment, $torev, $results['contactgroups']);
                 break;
             case 'contacts':
                 self::copyContacts($deployment, $torev, $results['contacts']);
                 break;
             case 'hosttemplates':
                 self::copyHostTemplates($deployment, $torev, $results['hosttemplates']);
                 break;
             case 'hostgroups':
                 self::copyHostGroups($deployment, $torev, $results['hostgroups']);
                 break;
             case 'servicetemplates':
                 self::copyServiceTemplates($deployment, $torev, $results['servicetemplates']);
                 break;
             case 'servicegroups':
                 self::copyServiceGroups($deployment, $torev, $results['servicegroups']);
                 break;
             case 'servicedependencies':
                 self::copyServiceDependencies($deployment, $torev, $results['servicedependencies']);
                 break;
             case 'serviceescalations':
                 self::copyServiceEscalations($deployment, $torev, $results['serviceescalations']);
                 break;
             case 'services':
                 self::copyServices($deployment, $torev, $results['services']);
                 break;
             case 'nodetemplates':
                 self::copyNodeTemplates($deployment, $torev, $results['nodetemplates']);
                 break;
             case 'resourcecfg':
                 self::copyResourceCfg($deployment, $torev, $results['resourcecfg']);
                 break;
             case 'cgicfg':
                 self::copyCGICfg($deployment, $torev, $results['cgicfg']);
                 break;
             case 'modgearmancfg':
                 self::copyModgearmanCfg($deployment, $torev, $results['modgearmancfg']);
                 break;
             case 'nagioscfg':
                 self::copyNagiosCfg($deployment, $torev, $results['nagioscfg']);
                 break;
             case 'nrpecmds':
                 self::copyNRPECmds($deployment, $torev, $results['nrpecmds']);
                 break;
             case 'nrpecfg':
                 self::copyNRPECfg($deployment, $torev, $results['nrpecfg']);
                 break;
             case 'nrpeplugins':
                 self::copyNRPEPlugins($deployment, $torev, $results['nrpeplugins']);
                 break;
             case 'supnrpecfg':
                 self::copySupNRPECfg($deployment, $torev, $results['supnrpecfg']);
                 break;
             case 'supnrpeplugins':
                 self::copySupNRPEPlugins($deployment, $torev, $results['supnrpeplugins']);
                 break;
             case 'nagiosplugins':
                 self::copyNagiosPlugins($deployment, $torev, $results['nagiosplugins']);
                 break;
             default:
                 break;
         }
     }
 }
Exemplo n.º 3
0
 */
$app->get('/sapi/configs/:deployment/cgi(/:staged)', function ($deployment, $staged = false) use($app) {
    check_deployment_exists($app, $deployment);
    // Load up Current Commands or Staged Commands
    if ($staged == 1) {
        $deployRev = RevDeploy::getDeploymentNextRev($deployment);
        if ($deployRev === false) {
            $apiResponse = new APIViewData(1, $deployment, "Unable to detect staged revision to reference");
            $app->halt(404, $apiResponse->returnJson());
        }
    } else {
        $deployRev = RevDeploy::getDeploymentRev($deployment);
    }
    $apiResponse = new APIViewData(0, $deployment, false);
    if (RevDeploy::existsDeploymentCgiCfg($deployment, $deployRev) === true) {
        $apiResponse->setExtraResponseData('cgi_config', RevDeploy::getDeploymentCgiCfg($deployment, $deployRev));
    } else {
        $apiResponse->setExtraResponseData('cgi_config', array('main_config_file' => base64_encode('/usr/local/nagios/etc/nagios.cfg'), 'physical_html_path' => base64_encode('/usr/local/nagios/share'), 'url_html_path' => base64_encode('/nagios'), 'show_context_help' => 0, 'use_pending_states' => 1, 'use_authentication' => 1, 'use_ssl_authentication' => 0, 'authorized_for_system_information' => "*", 'authorized_for_configuration_information' => "*", 'authorized_for_system_commands' => "*", 'authorized_for_all_services' => "*", 'authorized_for_all_hosts' => "*", 'authorized_for_all_service_commands' => "*", 'authorized_for_all_host_commands' => "*", 'authorized_for_read_only' => "", 'default_statusmap_layout' => 5, 'default_statuswrl_layout' => 4, 'ping_syntax' => base64_encode('/bin/ping -n -U -c 5 $HOSTADDRESS$'), 'refresh_rate' => 90, 'escape_html_tags' => 1, 'action_url_target' => '_blank', 'notes_url_target' => '_blank', 'lock_author_names' => 1, 'enable_splunk_integration' => 0, 'splunk_url' => base64_encode('http://127.0.0.1:8000/'), 'result_limit' => 0));
    }
    $apiResponse->printJson();
})->name('saigon-api-get-cgi-config');
$app->post('/sapi/configs/:deployment/cgi', function ($deployment) use($app) {
    check_deployment_exists($app, $deployment);
    check_auth($app, $deployment);
    $keys = array('main_config_file', 'physical_html_path', 'url_html_path', 'show_context_help', 'use_pending_states', 'use_authentication', 'use_ssl_authentication', 'result_limit', 'authorized_for_system_information', 'authorized_for_configuration_information', 'authorized_for_system_commands', 'authorized_for_all_services', 'authorized_for_all_hosts', 'authorized_for_all_service_commands', 'authorized_for_all_host_commands', 'authorized_for_read_only', 'default_statusmap_layout', 'default_statuswrl_layout', 'ping_syntax', 'refresh_rate', 'escape_html_tags', 'action_url_target', 'notes_url_target', 'lock_author_names', 'enable_splunk_integration', 'splunk_url');
    $request = $app->request();
    $contentType = $request->headers('Content-Type');
    if ($contentType == 'application/json') {
        $cgiConfigInfo = $request->getBody();
        $cgiConfigInfo = json_decode($cgiConfigInfo, true);
    } elseif (preg_match("/form-(data|urlencoded)/", $contentType)) {