| 1 |
<html> |
| 2 |
|
| 3 |
<head> |
| 4 |
<meta http-equiv="Content-Language" content="en-us"> |
| 5 |
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> |
| 6 |
<meta name="GENERATOR" content="Microsoft FrontPage 4.0"> |
| 7 |
<meta name="ProgId" content="FrontPage.Editor.Document"> |
| 8 |
<title>MRTG New Switch configuration</title> |
| 9 |
</head> |
| 10 |
|
| 11 |
<body> |
| 12 |
|
| 13 |
<p><b><u>MRTG New Switch configuration</u></b></p> |
| 14 |
<FORM ACTION=setup.php METHOD=POST> |
| 15 |
<table border="0" width="100%"> |
| 16 |
<tr> |
| 17 |
<td width="12%">Switch IP or Hostname:</td> |
| 18 |
<td width="88%"><input type="text" name="switch_ip" size="20"></td> |
| 19 |
</tr> |
| 20 |
<tr> |
| 21 |
<td width="12%">Snmp community:</td> |
| 22 |
<td width="88%"><input type="text" name="snmp_community" size="20" value="public"></td> |
| 23 |
</tr> |
| 24 |
<tr> |
| 25 |
<td width="12%">Option:</td> |
| 26 |
<td width="88%"><input type="checkbox" name="run_cfgmaker" value="ON" checked>Generate |
| 27 |
config</td> |
| 28 |
</tr> |
| 29 |
<tr> |
| 30 |
<td width="12%"></td> |
| 31 |
<td width="88%"><input type="checkbox" name="run_mrtg" value="ON" checked>Run |
| 32 |
mrtg</td> |
| 33 |
</tr> |
| 34 |
<tr> |
| 35 |
<td width="12%"></td> |
| 36 |
<td width="88%"><input type="checkbox" name="run_indexmaker" value="ON" checked>Create |
| 37 |
html index</td> |
| 38 |
</tr> |
| 39 |
<tr> |
| 40 |
<td width="12%">Cfgmaker options:</td> |
| 41 |
<td width="88%" align="left" valign="top"> |
| 42 |
<input type="checkbox" name="nodown" value="--no-down">Query down |
| 43 |
interface (--no-down)</td> |
| 44 |
</tr> |
| 45 |
<tr> |
| 46 |
<td width="12%"></td> |
| 47 |
<td width="88%" align="left" valign="top"> |
| 48 |
<input type="checkbox" name="noreverse" value="--noreversedns">No |
| 49 |
reverse Dns (--noreversedns)</td> |
| 50 |
</tr> |
| 51 |
<tr> |
| 52 |
<td width="12%">Mrtg Options:</td> |
| 53 |
<td width="88%" align="left" valign="top"> |
| 54 |
<p align="left"><input type="checkbox" name="growright" value="growright" checked>Right |
| 55 |
starting graph (growright)</td> |
| 56 |
</tr> |
| 57 |
<tr> |
| 58 |
<td width="12%"></td> |
| 59 |
<td width="88%"><input type="checkbox" name="bits" value="bits" checked>Graph |
| 60 |
in Bits (bits)</td> |
| 61 |
</tr> |
| 62 |
<tr> |
| 63 |
<td width="12%">Interface Name:</td> |
| 64 |
<td width="88%"><select size="1" name="interface_desc"> |
| 65 |
<option selected value="nr">Interface Number</option> |
| 66 |
<option value="ip">Ip Address</option> |
| 67 |
<option value="eth">Ethernet Number</option> |
| 68 |
<option value="descr">Interface Description</option> |
| 69 |
<option value="name">Interface Name</option> |
| 70 |
<option value="alias">Interface Alias</option> |
| 71 |
<option value="type">Interface Type</option> |
| 72 |
</select></td> |
| 73 |
</tr> |
| 74 |
</table> |
| 75 |
<p><input type="submit" value="Add switch" name="B1"><input type="reset" value="Reset" name="B2"></p> |
| 76 |
</form> |
| 77 |
<hr> |
| 78 |
|
| 79 |
<? |
| 80 |
|
| 81 |
if($REQUEST_METHOD == "POST"){ |
| 82 |
|
| 83 |
// Replace this path with the path to the config.inc.php file |
| 84 |
include ("e:\\mrtg\\conf\\config.inc.php"); |
| 85 |
|
| 86 |
// Build Cfgmaker options from the html form |
| 87 |
$cfgmaker_option = " ".$nodown." ".$noreverse; |
| 88 |
|
| 89 |
// Build Cfgmaker options from the html form |
| 90 |
$cfgmaker_global_option = $growright.",".$bits; |
| 91 |
$cfgmaker_param = "--global \"WorkDir: ".$mrtg_html_dir.$switch_ip."\""." --global \"Icondir: ".$mrtg_icon_dir."\"" |
| 92 |
." --global \"Options[_]: ".$cfgmaker_global_option."\"" |
| 93 |
." --ifdesc=".$interface_desc." --community " |
| 94 |
.$snmp_community |
| 95 |
.$cfgmaker_option." --output=".$mrtg_config_dir |
| 96 |
.$switch_ip.".cfg"; |
| 97 |
$indexmaker_option = " --output=".$mrtg_html_dir.$switch_ip.".html"." --prefix=./".$switch_ip."/"." ".$mrtg_config_dir.$switch_ip.".cfg";; |
| 98 |
|
| 99 |
|
| 100 |
// Test if the host answer telnet ('cause UDP querie is always successfull :-() |
| 101 |
$fp = fsockopen ($switch_ip, 23, $errno, $errstr, 1); |
| 102 |
if (!$fp) { |
| 103 |
echo "The host:".$switch_ip." did not respond..."; |
| 104 |
echo "<hr><a href=./>Back to index</a>"; |
| 105 |
exit(); |
| 106 |
} |
| 107 |
|
| 108 |
// Creating dir for Switch config files and stats files |
| 109 |
if (!file_exists($switch_ip) && $switch_ip <> "") { |
| 110 |
mkdir ($switch_ip,700); |
| 111 |
} |
| 112 |
|
| 113 |
// Run Cfg maker and mrtg script with argument from the form |
| 114 |
if ($switch_ip <> "") { |
| 115 |
if ($run_cfgmaker == "ON") { |
| 116 |
//echo $mrtg_html_dir."<br>"; |
| 117 |
//echo $perl_exe." ".$cfgmaker_exe." ".$cfgmaker_param." ".$switch_ip; |
| 118 |
system($perl_exe." ".$cfgmaker_exe." ".$cfgmaker_param." ".$switch_ip); |
| 119 |
echo "Mrtg config for <b><a href=".$switch_ip.".html".">".$switch_ip."</a></b> created...<br>"; |
| 120 |
} |
| 121 |
if ($run_mrtg == "ON") { |
| 122 |
//echo $perl_exe." ".$mrtg_exe." ".$mrtg_config_dir.$switch_ip.".cfg"."<br>"; |
| 123 |
system ($perl_exe." ".$mrtg_exe." ".$mrtg_config_dir.$switch_ip.".cfg"); |
| 124 |
echo "1st run Mrtg stats generated...<br>"; |
| 125 |
} |
| 126 |
if ($run_indexmaker == "ON") { |
| 127 |
system ($perl_exe." ".$indexmaker_exe." ".$indexmaker_option); |
| 128 |
echo "Mrtg html index generated...<br>"; |
| 129 |
} |
| 130 |
|
| 131 |
} |
| 132 |
} |
| 133 |
echo "<br><a href=./>Back to index</a>"; |
| 134 |
?> |
| 135 |
</body> |
| 136 |
|
| 137 |
</html> |
| 138 |
|
| 139 |
|
| 140 |
|