監控Linux系統:

安裝Zabbix YUM Repo

#yum install -y http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX

安裝 Zabbix agent套件

# yum install -y zabbix-agent

修改Zabbix agent配置文件

Server=
ServerActive=
#Hostname=
HostnameItem=system.hostname
HostMetadataItem=system.uname
  • 修改Server的IP,位址為Zabbix Server端位址
  • 修改ServerAcive的IP,位址為Zabbix Server端位址
  • Hostname修改為網頁裡面添加的Hostname,需要保持一致,若註解不用則會參考HostnameItem使用系統 ”hostname”。
  • HostnameItem : used for generating Hostname if it is undefined. Ignored if Hostname is defined.
  • HostMetadataItem: Host metadata is used at host auto-registration process.
sed -i -e 's|^Server=.*$|Server=192.168.1.1,192.168.2.1|g' -e  's|^ServerActive=.*$|ServerActive=192.168.1.1,192.168.2.1|g' -e 's|^Hostname=.*$|HostnameItem=system.hostname|g' -e 's|^#\ HostMetadataItem=.*$|HostMetadataItem=system.uname|g' /etc/zabbix/zabbix_agentd.conf

啟動zabbix-agent 設置為開機自動啟動

# systemctl enable zabbix-agent.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
# systemctl start zabbix-agent.service

設置防火牆

# firewall-cmd --permanent  --zone=public --add-port=10050/tcp  (zabbix-agent)
# firewall-cmd --reload

設置 Selinux

# ausearch -c 'zabbix_agentd' --raw| audit2allow -M zabbix_agentd
# semodule -i zabbix_agentd.pp

監控Windows系統:

(1). 下載文件: https://www.zabbix.com/downloads/3.0.10/zabbix_agents_3.0.10.win.zip

(2). 解壓到C:\,再修改設定檔:zabbix_agents_3.0.10.win/conf/zabbix_agentd.win.conf

Server=
ServerActive=
#Hostname=
HostnameItem=system.hostname
HostMetadataItem=system.uname
  • 修改Server的IP,位址為Zabbix Server端位址
  • 修改ServerAcive的IP,位址為Zabbix Server端位址
  • Hostname修改為網頁裡面添加的Hostname,需要保持一致,若註解不用則會參考HostnameItem使用系統 ”hostname”。
  • HostnameItem : used for generating Hostname if it is undefined. Ignored if Hostname is defined.
  • HostMetadataItem: Host metadata is used at host auto-registration process.

(3).修改完後,"Win+R"打開cmd命令行安裝Zabbix Agent服務

使用zabbix-agent.exe 安裝

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

使用zabbix-agent.exe 反安裝

c:\zabbix_x86\zabbix_agentd.exe -c c:\zabbix_x86\zabbix_agentd.conf -x
c:\zabbix_x86\zabbix_agentd.exe -c c:\zabbix_x86\zabbix_agentd.conf -d

使用zabbix-agent-install.bat 安裝

:: 1、修改本腳本裡的zabbix_server變量
:: 2、執行本腳本,自動安裝zabbix agent到C:\
@Echo off
setlocal enabledelayedexpansion

:: 需要修改IP
set zabbix_server=192.168.1.1,192.168.2.1

:: 替換配置文件中的server ip
set conf_file=%~dp0\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\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\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%
)
IF "%_major%"=="10" (
  IF "%_minor%"=="0" Echo OS details: Windows 10 [%_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%
) 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%]
  :: 開啟防火牆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

results matching ""

    No results matching ""