设为首页 收藏本站
查看: 1353|回复: 0

[经验分享] Windows系统一键安装zabbix agent

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-5-13 08:29:20 | 显示全部楼层 |阅读模式
下载附件里的zabbix_agents_auto_installer.win.rar,解压后修改AutoInstall.bat里的zabbix_server的IP,以管理员身份运行AutoInstall.bat,zabbix agent会注册为服务并启动。32位系统会安装在c:\zabbix_x86,64位会安装在c:\zabbix_x64。 QQ截图20150513082800.png
    下面献上AutoInstall.bat代码,供参考:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
:: 一键安装zabbix agent 2.2.9,理论支持所有windows系统

:: 1、修改本脚本里的zabbix_server变量
:: 2、执行本脚本,自动安装zabbix agent到C盘
@Echo off
setlocal enabledelayedexpansion

:: 需要修改IP
set zabbix_server=192.168.20.211

:: 替换配置文件中的server ip
set conf_file=%~dp0\zabbix_agents_2.2.9.win\conf\zabbix_agentd.win.conf
for /f "delims=" %%a in ('type "%conf_file%"') do (
  set str=%%a
  set "str=!str:127.0.0.1=%zabbix_server%!"
  echo !str!>>"%conf_file%"_tmp.txt
)
move "%conf_file%" "%conf_file%"_bak.txt
move "%conf_file%"_tmp.txt "%conf_file%"

:: 32 bit or 64 bit process detection
IF "%PROCESSOR_ARCHITECTURE%%PROCESSOR_ARCHITEW6432%"=="x86" (
  set _processor_architecture=32bit
  goto x86
) ELSE (
  set _processor_architecture=64bit
  goto x64
)

:x86
xcopy "%~dp0\zabbix_agents_2.2.9.win\bin\win32" c:\zabbix_x86 /e /i /y
copy "%conf_file%" c:\zabbix_x86\zabbix_agentd.conf /y
sc stop  "Zabbix Agent" >nul 2>nul
sc delete  "Zabbix Agent" >nul 2>nul
c:\zabbix_x86\zabbix_agentd.exe -c c:\zabbix_x86\zabbix_agentd.conf -i
c:\zabbix_x86\zabbix_agentd.exe -c c:\zabbix_x86\zabbix_agentd.conf -s
goto firewall

:x64
xcopy "%~dp0\zabbix_agents_2.2.9.win\bin\win64" c:\zabbix_x64 /e /i /y
copy "%conf_file%" c:\zabbix_x64\zabbix_agentd.conf /y
sc stop  "Zabbix Agent" >nul 2>nul
sc delete  "Zabbix Agent" >nul 2>nul
c:\zabbix_x64\zabbix_agentd.exe -c c:\zabbix_x64\zabbix_agentd.conf -i
c:\zabbix_x64\zabbix_agentd.exe -c c:\zabbix_x64\zabbix_agentd.conf -s
goto firewall

:firewall
:: Get windows Version numbers
For /f "tokens=2 delims=[]" %%G in ('ver') Do (set _version=%%G)
For /f "tokens=2,3,4 delims=. " %%G in ('echo %_version%') Do (set _major=%%G& set _minor=%%H& set _build=%%I)
Echo Major version: %_major%  Minor Version: %_minor%.%_build%

:: OS detection
IF "%_major%"=="5" (
  IF "%_minor%"=="0" Echo OS details: Windows 2000 [%_processor_architecture%]
  IF "%_minor%"=="1" Echo OS details: Windows XP [%_processor_architecture%]
  IF "%_minor%"=="2" IF "%_processor_architecture%"=="32bit" Echo OS details: Windows 2003 [%_processor_architecture%]
  IF "%_minor%"=="2" IF "%_processor_architecture%"=="64bit" Echo OS details: Windows 2003 or XP 64 bit [%_processor_architecture%]
  :: 开启防火墙10050端口
  netsh firewall delete portopening protocol=tcp port=10050
  netsh firewall add portopening protocol=tcp port=10050 name=zabbix_10050 mode=enable scope=custom addresses=%zabbix_server%
) ELSE IF "%_major%"=="6" (
  IF "%_minor%"=="0" Echo OS details: Windows Vista or Windows 2008 [%_processor_architecture%]
  IF "%_minor%"=="1" Echo OS details: Windows 7 or Windows 2008 R2 [%_processor_architecture%]
  IF "%_minor%"=="2" Echo OS details: Windows 8 or Windows Server 2012 [%_processor_architecture%]
  IF "%_minor%"=="3" Echo OS details: Windows 8.1 or Windows Server 2012 R2 [%_processor_architecture%]
  IF "%_minor%"=="4" Echo OS details: Windows 10 Technical Preview [%_processor_architecture%]
  :: 开启防火墙10050端口
  netsh advfirewall firewall delete rule name="zabbix_10050"
  netsh advfirewall firewall add rule name="zabbix_10050" protocol=TCP dir=in localport=10050 action=allow remoteip=%zabbix_server%
)

pause
rd /s /q "%~dp0\zabbix_agents_2.2.9.win"
del %0


zabbix_agents_auto_installer.win.rar

666.97 KB, 下载次数: 2


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-66405-1-1.html 上篇帖子: Zabbix 一个具体例子的实现 下篇帖子: 自动安装zabbix Windows
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表