Blame contrib/mrtg_php_portal/www/setup.php

Packit 667938
<html>
Packit 667938
Packit 667938
<head>
Packit 667938
<meta http-equiv="Content-Language" content="en-us">
Packit 667938
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
Packit 667938
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
Packit 667938
<meta name="ProgId" content="FrontPage.Editor.Document">
Packit 667938
<title>MRTG New Switch configuration</title>
Packit 667938
</head>
Packit 667938
Packit 667938
<body>
Packit 667938
Packit 667938

<u>MRTG New Switch configuration</u>

Packit 667938
<FORM ACTION=setup.php METHOD=POST>
Packit 667938
  
Packit 667938
    
Packit 667938
      Switch IP or Hostname:
Packit 667938
      <input type="text" name="switch_ip" size="20">
Packit 667938
    
Packit 667938
    
Packit 667938
      Snmp community:
Packit 667938
      <input type="text" name="snmp_community" size="20" value="public">
Packit 667938
    
Packit 667938
    
Packit 667938
      Option:
Packit 667938
      <input type="checkbox" name="run_cfgmaker" value="ON" checked>Generate
Packit 667938
        config
Packit 667938
    
Packit 667938
    
Packit 667938
      
Packit 667938
      <input type="checkbox" name="run_mrtg" value="ON" checked>Run
Packit 667938
        mrtg
Packit 667938
    
Packit 667938
    
Packit 667938
      
Packit 667938
      <input type="checkbox" name="run_indexmaker" value="ON" checked>Create
Packit 667938
        html index
Packit 667938
    
Packit 667938
    
Packit 667938
      Cfgmaker options:
Packit 667938
      
Packit 667938
        <input type="checkbox" name="nodown" value="--no-down">Query down
Packit 667938
        interface (--no-down)
Packit 667938
    
Packit 667938
    
Packit 667938
      
Packit 667938
      
Packit 667938
        <input type="checkbox" name="noreverse" value="--noreversedns">No
Packit 667938
        reverse Dns (--noreversedns)
Packit 667938
    
Packit 667938
    
Packit 667938
      Mrtg Options:
Packit 667938
      
Packit 667938
        

<input type="checkbox" name="growright" value="growright" checked>Right

Packit 667938
        starting graph (growright)
Packit 667938
    
Packit 667938
    
Packit 667938
      
Packit 667938
      <input type="checkbox" name="bits" value="bits" checked>Graph
Packit 667938
        in Bits (bits)
Packit 667938
    
Packit 667938
    
Packit 667938
      Interface Name:
Packit 667938
      <select size="1" name="interface_desc">
Packit 667938
          <option selected value="nr">Interface Number</option>
Packit 667938
          <option value="ip">Ip Address</option>
Packit 667938
          <option value="eth">Ethernet Number</option>
Packit 667938
          <option value="descr">Interface Description</option>
Packit 667938
          <option value="name">Interface Name</option>
Packit 667938
          <option value="alias">Interface Alias</option>
Packit 667938
          <option value="type">Interface Type</option>
Packit 667938
        </select>
Packit 667938
    
Packit 667938
  
Packit 667938
  

<input type="submit" value="Add switch" name="B1"><input type="reset" value="Reset" name="B2">

Packit 667938
</form>
Packit 667938

Packit 667938
Packit 667938
Packit 667938
Packit 667938
if($REQUEST_METHOD == "POST"){ 
Packit 667938
Packit 667938
// Replace this path with the path to the config.inc.php file
Packit 667938
include ("e:\\mrtg\\conf\\config.inc.php");
Packit 667938
Packit 667938
// Build Cfgmaker options from the html form
Packit 667938
$cfgmaker_option = " ".$nodown." ".$noreverse;
Packit 667938
 
Packit 667938
// Build Cfgmaker options from the html form
Packit 667938
$cfgmaker_global_option = $growright.",".$bits; 
Packit 667938
$cfgmaker_param = "--global \"WorkDir: ".$mrtg_html_dir.$switch_ip."\""." --global \"Icondir: ".$mrtg_icon_dir."\""
Packit 667938
	." --global \"Options[_]: ".$cfgmaker_global_option."\""
Packit 667938
	." --ifdesc=".$interface_desc." --community "
Packit 667938
	.$snmp_community
Packit 667938
	.$cfgmaker_option." --output=".$mrtg_config_dir
Packit 667938
	.$switch_ip.".cfg";
Packit 667938
$indexmaker_option = " --output=".$mrtg_html_dir.$switch_ip.".html"." --prefix=./".$switch_ip."/"." ".$mrtg_config_dir.$switch_ip.".cfg";;
Packit 667938
Packit 667938
Packit 667938
// Test if the host answer telnet ('cause UDP querie is always successfull :-()
Packit 667938
$fp = fsockopen ($switch_ip, 23, $errno, $errstr, 1);
Packit 667938
if (!$fp) {
Packit 667938
    echo "The host:".$switch_ip." did not respond...";
Packit 667938
    echo "
Back to index";
Packit 667938
    exit();
Packit 667938
}
Packit 667938
Packit 667938
// Creating dir for Switch config files and stats files
Packit 667938
if (!file_exists($switch_ip) && $switch_ip <> "") { 
Packit 667938
mkdir ($switch_ip,700);
Packit 667938
}
Packit 667938
Packit 667938
// Run Cfg maker and mrtg script with argument from the form
Packit 667938
if ($switch_ip <> "") {
Packit 667938
	if ($run_cfgmaker == "ON") {
Packit 667938
		//echo $mrtg_html_dir."
";
Packit 667938
		//echo $perl_exe." ".$cfgmaker_exe." ".$cfgmaker_param." ".$switch_ip;
Packit 667938
		system($perl_exe." ".$cfgmaker_exe." ".$cfgmaker_param." ".$switch_ip);
Packit 667938
		echo "Mrtg config for ".$switch_ip." created...
";
Packit 667938
	}
Packit 667938
	if ($run_mrtg == "ON") {
Packit 667938
		//echo $perl_exe." ".$mrtg_exe." ".$mrtg_config_dir.$switch_ip.".cfg"."
";
Packit 667938
		system ($perl_exe." ".$mrtg_exe." ".$mrtg_config_dir.$switch_ip.".cfg");
Packit 667938
		echo "1st run Mrtg stats generated...
";
Packit 667938
	}
Packit 667938
	if ($run_indexmaker == "ON") {
Packit 667938
		system ($perl_exe." ".$indexmaker_exe." ".$indexmaker_option);
Packit 667938
		echo "Mrtg html index generated...
";
Packit 667938
	}
Packit 667938
	
Packit 667938
}
Packit 667938
}
Packit 667938
echo "
Back to index";
Packit 667938
?>
Packit 667938
</body>
Packit 667938
Packit 667938
</html>
Packit 667938
Packit 667938
Packit 667938