Logo Search packages:      
Sourcecode: nagat version File versions  Download package

nagioscfg.php

<?php
# $Id: nagioscfg.php,v 1.7 2002/06/14 21:59:31 kemuri Exp $

/*
 * Copyright (c) 2002 Ypsilon.Net AG, Germany
 *
 * This file is part of Nagat.
 * 
 * Nagat is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * Nagat is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Nagat; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

# Page variables
define("PAGE_ID","hosts");
define("PAGE_TITLE","Nagios main configuration");
define("OBJECTTYPE",'nagioscfg');

require_once("local.inc");

$action = @strtolower($action);
$message = '';

# Actions before output is send
$action = @strtolower($action);
switch($action) {
      case 'save':

            # Handle the check_command attributes
            $checkcommand = $cfg['ocsp_command'][0]['cmd'];
            $param = trim($cfg['ocsp_command'][0]['param']);
            if( !empty($param) ) $checkcommand .= "!".$param;
            settype($cfg['ocsp_command'][0],"string");
            $cfg['ocsp_command'][0] = $checkcommand;

            $checkcommand = $cfg['global_host_event_handler'][0]['cmd'];
            $param = trim($cfg['global_host_event_handler'][0]['param']);
            if( !empty($param) ) $checkcommand .= "!".$param;
            settype($cfg['global_host_event_handler'][0],"string");
            $cfg['global_host_event_handler'][0] = $checkcommand;

            $checkcommand = $cfg['global_service_event_handler'][0]['cmd'];
            $param = trim($cfg['global_service_event_handler'][0]['param']);
            if( !empty($param) ) $checkcommand .= "!".$param;
            settype($cfg['global_service_event_handler'][0],"string");
            $cfg['global_service_event_handler'][0] = $checkcommand;

            $result = PluginSaveConfig("nagioscfg",$cfg);
            if( $result != NULL ) {
                  ErrorMsg($result);
            } else {
                  header("Location: nagioscfg.php?lastact=saved");
                  exit();
            }
            break;
}
include_once(NGT_LIB."head.inc");

if( @$lastact == "saved" ) {
  $message = "Configuration has been saved.";
}

$nagioscfg = PluginGetConfig("nagioscfg");

$alter = "alter2";

foreach($confobjects[OBJECTTYPE] as $key => $propconf) {

      $values = isset($nagioscfg[$key]) ? $nagioscfg[$key] : array();
      $count = count($values);
      
      $required = $propconf[2] == TRUE ? 'required' : 'label';

      # Add an extra entry field when multi values are possible
      if( $propconf[0] == 'multistring' || $count == 0 ) {
            $count++;
      }

      # Set the default value if needed and if there is one
      if( isset($values[0]) == FALSE && $propconf[1] != '' ) {
            $values[0] = $propconf[1];
      }

      for($i = 0; $i < $count; $i++) {
            $value = isset($values[$i]) ? $values[$i] : '';
            $show = NagiosObjPropEdit(OBJECTTYPE,$key,
                  "cfg[$key][$i]",$value);
            $rows[] = <<<HTML
<tr>
  <td class="label">$key</td>
  <td class="$required" with="3">&nbsp;</td>
  <td class="value">
  $show
  </td>
</tr>
HTML;
      }
}

?>
<form action="nagioscfg.php" method="post">
<table cellpadding="3" border="0">
<tr>
  <td colspan="3" align="left">
  <b><?=$message?>&nbsp;</b>
  </td>
</tr>
<tr>
  <td colspan="3" align="right">
  <input type="submit" name="action" value="Save">
  </td>
</tr>
<tr class="rowsep">
  <td colspan="3">Nagios.Cfg properties</td>
</tr>
<?=implode("\n", $rows)?>
</table>
</form>

<?php
include_once(NGT_LIB."tail.inc");
?>

Generated by  Doxygen 1.6.0   Back to index