MRTG 批处理交互式添加主机

MRTG使用了一段时间,偷懒写了个bat,MRTG安装在了C:\MRTG,安装了perl语言,www目录为C:\inetpub\wwwroot\MRTG\,可以用以下批处理文件执行交互式安装,自动化添加服务,自动化添加注册表,只需要在添加完毕后手动启动服务即可。

需要用管理员权限运行!!!

批处理代码如下

set "mrtg_path=C:\mrtg"  
set /p host="Enter host IP: " 
set /p hostname="Enter hostname:"
set /p community="Enter community: "
set service_name=%hostname%
set reg_key=%hostname%
mkdir C:\inetpub\wwwroot\MRTG\%hostname%\
echo make a new configfile for %hostname% > C:\inetpub\wwwroot\MRTG\%hostname%\%hostname%.cfg
perl C:\mrtg\bin\cfgmaker %community%@%host%:::::2 --global "WorkDir: C:\inetpub\wwwroot\MRTG\%hostname%" --ifref=ip,eth --ifdesc=descr --global "options[_]: growright,bits"  --output C:\inetpub\wwwroot\MRTG\%hostname%\%hostname%.cfg
echo runasDaemon:yes>>C:\inetpub\wwwroot\MRTG\%hostname%\%hostname%.cfg
echo interval:5>>C:\inetpub\wwwroot\MRTG\%hostname%\%hostname%.cfg
echo language:chinese>>C:\inetpub\wwwroot\MRTG\%hostname%\%hostname%.cfg
echo Creating %hostname% webpage... 
perl C:\mrtg\bin\indexmaker C:\inetpub\wwwroot\MRTG\%hostname%\%hostname%.cfg>C:\inetpub\wwwroot\MRTG\%hostname%\%hostname%.html
echo Creating %hostname% webpage done
echo Creating %hostname% service... 
C:\mrtg\bin\instsrv %hostname% c:\mrtg\bin\srvany.exe
echo Creating %hostname% service done
echo Writing %hostname% registry key...  
echo make a new registry for %hostname% > C:\inetpub\wwwroot\MRTG\%hostname%\%hostname%.reg
echo Windows Registry Editor Version 5.00 > C:\inetpub\wwwroot\MRTG\%hostname%\%hostname%.reg
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\%hostname%\Parameters] >> C:\inetpub\wwwroot\MRTG\%hostname%\%hostname%.reg
echo  "Application"="c:\\perl64\\bin\\wperl.exe" >> C:\inetpub\wwwroot\MRTG\%hostname%\%hostname%.reg
echo  "AppParameters"="c:\\mrtg\\bin\\mrtg --logging=C:\\inetpub\\wwwroot\\MRTG\\%hostname%\\%hostname%.log C:\\inetpub\\wwwroot\\MRTG\\%hostname%\\%hostname%.cfg" >> C:\inetpub\wwwroot\MRTG\%hostname%\%hostname%.reg
echo  "AppDirectory"="c:\\mrtg\\bin\\" >> C:\inetpub\wwwroot\MRTG\%hostname%\%hostname%.reg
 
regedit /s "C:\inetpub\wwwroot\MRTG\%hostname%\%hostname%.reg"

pause

  • 18
    点赞
  • 36
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值