標籤:agent zabbix 一鍵安裝zabbix-agent
一、簡介
zabbix是開源界流行的監控程式,C/S架構,運行多種系統平台安裝,個人認為windows平台的 zabbix-agent安裝最為煩瑣,unix及linux平台通過自動化營運工具可一鍵遠程安裝,而windows目前沒有好的方法,所以就參考網上寫了一個指令碼(包含zabbix-agent 2.4.5用戶端),一鍵安裝並配置好防火牆。
二、安裝指令碼(設定檔)
請先修改指令碼中zabbbix_server 為自己的zabbix伺服器ip
@Echo offsetlocal enabledelayedexpansion:: 需要修改IP(填寫自己zabbix伺服器IP地址)set zabbix_server=10.168.118.91:: 替換設定檔中的server ipset conf_file=%~dp0\zabbix_agents_2.4.4.win\conf\zabbix_agentd.win.conffor /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.txtmove "%conf_file%"_tmp.txt "%conf_file%":: 32 bit or 64 bit process detectionIF "%PROCESSOR_ARCHITECTURE%%PROCESSOR_ARCHITEW6432%"=="x86" ( set _processor_architecture=32bit goto x86) ELSE ( set _processor_architecture=64bit goto x64):x86xcopy "%~dp0\zabbix_agents_2.4.4.win\bin\win32" c:\zabbix_x86 /e /i /ycopy "%conf_file%" c:\zabbix_x86\zabbix_agentd.conf /ysc stop "Zabbix Agent" >nul 2>nulsc delete "Zabbix Agent" >nul 2>nulc:\zabbix_x86\zabbix_agentd.exe -c c:\zabbix_x86\zabbix_agentd.conf -ic:\zabbix_x86\zabbix_agentd.exe -c c:\zabbix_x86\zabbix_agentd.conf -sgoto firewall:x64xcopy "%~dp0\zabbix_agents_2.4.4.win\bin\win64" c:\zabbix_x64 /e /i /ycopy "%conf_file%" c:\zabbix_x64\zabbix_agentd.conf /ysc stop "Zabbix Agent" >nul 2>nulsc delete "Zabbix Agent" >nul 2>nulc:\zabbix_x64\zabbix_agentd.exe -c c:\zabbix_x64\zabbix_agentd.conf -ic:\zabbix_x64\zabbix_agentd.exe -c c:\zabbix_x64\zabbix_agentd.conf -sgoto firewall:firewall:: Get windows Version numbersFor /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 detectionIF "%_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%)pauserd /s /q "%~dp0\zabbix_agents_2.4.4.win"del %0
三、安裝包及安裝說明
安裝包名zabbix_agents_auto_installer.win.zip 見附件
安裝包中包含32和64位zabbix-agent和一份設定檔,以及自動安裝指令碼。
解壓出來後找到AutoInstall.bat 指令碼工具,雙擊就可以!會自動把zabbix-agent註冊為系統服務並運行,添加10050被動連接埠。
本文出自 “學地止境” 部落格,請務必保留此出處http://dyc2005.blog.51cto.com/270872/1942149
windows上一鍵自動安裝zabbix-agent