zabbix agent安裝與配置篇


 Zabbix監控windows部署安裝

 

Zabbix agent 在windows上安裝部署

(1)手工安裝zabbix agent客戶端

1、  下載與解壓

地址: http://www.zabbix.com/downloads

解壓zabbix_agents_X.X.X.win.zip

conf目錄存放是agent配置文件 bin文件存放windows下32位和64位安裝程序

2、  配置與安裝

2.1 配置zabbix agent相關配置。

   找到conf下的配置文件 zabbix_agentd.win.conf ,修改LogFile、Server、Hostname這三個參數(其他參數可根據個人需求添加),具體配置如下:

LogFile=c:\zabbix_agentd.log  #根據個人習慣配置log存放的路徑

Server=192.98.8.224  #zabbix服務器的IP地址

Hostname=f523540。#hostname的標識需要和服務器配置的一致,否則后期會出現not found hostname等錯誤

ServerActive=192.98.8.224 #zabbix server地址

其中logfile是zabbix日志存放地址。Server 是zabbix服務端ip地址。Hostname是本機機器名。

2.2 安裝agent

在windows控制台下執行以下命令:

E:\zabbix\bin\win32\zabbix_agentd.exe  -c E:\zabbix\conf\zabbix_agentd.win.conf –i 

2.3 啟動agent客戶端

啟動命令如下:

E:\zabbix\bin\win32\zabbix_agentd.exe  -c E:\zabbix\conf\zabbix_agentd.win.conf –s

參數含義:

-c    制定配置文件所在位置

-I     是安裝客戶端

-s     啟動客戶端

-x    停止客戶端

-d    卸載客戶端

2.4 在"運行"輸入 "services.msc",在里面找到"ZABBIXAGENT",並啟動服務。

批處理具體內容如下:

:: 一鍵安裝zabbix agent ,理論支持所有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.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.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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM