windows上一键自动安装zabbix-agent

简介:

一、简介

       zabbix是开源界流行的监控程序,C/S架构,运行多种系统平台安装,个人认为windows平台的 zabbix-agent安装最为烦琐,unix及linux平台通过自动化运维工具可一键远程安装,而windows目前没有好的方法,所以就参考网上写了一个脚本(包含zabbix-agent 2.4.5客户端),一键安装并配置好防火墙。


二、安装脚本(配置文件)

请先修改脚本中zabbbix_server 为自己的zabbix服务器ip

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
@Echo off
setlocal enabledelayedexpansion
:: 需要修改IP(填写自己zabbix服务器IP地址)
set  zabbix_server=10.168.118.91
:: 替换配置文件中的server ip
set  conf_file=%~dp0\zabbix_agents_2.4.4.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.4.4.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.4.4.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.4.4.win"
del %0

三、安装包及安装说明

安装包名zabbix_agents_auto_installer.win.zip 见附件

安装包中包含32和64位zabbix-agent和一份配置文件,以及自动安装脚本。

解压出来后找到AutoInstall.bat 脚本工具,双击就可以!会自动把zabbix-agent注册为系统服务并运行,添加10050被动端口。










本文转自 dyc2005 51CTO博客,原文链接:http://blog.51cto.com/dyc2005/1942149,如需转载请自行联系原作者
目录
相关文章
|
2天前
|
并行计算 TensorFlow 算法框架/工具
Windows10下CUDA9.0+CUDNN7.0.5的完美安装教程
该文介绍了如何在Windows 10上安装CUDA 9.0和cuDNN 7.0.5以支持Tensorflow-gpu 1.10.0。首先,解释了安装CUDA的原因,然后详细步骤包括:从NVIDIA官网下载CUDA 9.0,选择自定义安装并关闭不必要的组件,检查显卡驱动版本以决定是否安装Display Driver,最后确认安装成功。接着,下载cuDNN需要注册NVIDIA账户,解压后将文件复制到CUDA安装目录。整个过程旨在确保与Tensorflow-gpu 1.10.0的兼容性。
16 2
|
3天前
|
Windows
Windows 系统下安装
在Windows上安装Julia,从官网下载安装程序。32位版本兼容32/64位系统,但64位仅用于64位Windows。运行安装向导,简单点击Next,建议选中添加到PATH选项。完成后,Julia将可在终端使用,默认路径如C:\Users\BAIDU\AppData\Local\Programs\Julia 1.7.2。
|
3天前
|
并行计算 Windows
23.10.02更新 Windows下CUDA和CUDNN的安装和配置(图多详细)
23.10.02更新 Windows下CUDA和CUDNN的安装和配置(图多详细)
11 1
|
3天前
|
并行计算 Ubuntu TensorFlow
23.10.02更新 windows系统下的Tensorflow安装(图多详细)
23.10.02更新 windows系统下的Tensorflow安装(图多详细)
11 0
23.10.02更新 windows系统下的Tensorflow安装(图多详细)
|
4天前
|
安全 测试技术 数据库
达梦数据库Windows安装教程:从准备到完成
达梦数据库Windows安装教程:从准备到完成
|
4天前
|
安全 虚拟化 Windows
手把手教你如何在虚拟机上安装Windows 10
手把手教你如何在虚拟机上安装Windows 10
|
4天前
|
NoSQL Linux Redis
Redis的介绍,以及Redis的安装(本机windows版,虚拟机Linux版)和Redis常用命令的介绍
Redis的介绍,以及Redis的安装(本机windows版,虚拟机Linux版)和Redis常用命令的介绍
17 0
|
4天前
|
编解码 安全 关系型数据库
祝福CSDN的小伙伴2024年快乐!Windows7安装MySQL
祝福CSDN的小伙伴2024年快乐!Windows7安装MySQL
|
5天前
|
SQL Windows
保姆级:Windows Server 2012上安装.NET Framework 3.5
保姆级:Windows Server 2012上安装.NET Framework 3.5
|
9天前
|
Oracle Java 关系型数据库
windows 下 win11 JDK17安装与环境变量的配置(配置简单详细,包含IJ中java文件如何使用命令运行)
本文介绍了Windows 11中安装JDK 17的步骤,包括从官方网站下载JDK、配置环境变量以及验证安装是否成功。首先,下载JDK 17的安装文件,如果没有Oracle账户,可以直接解压缩文件到指定目录。接着,配置系统环境变量,新建`JAVA_HOME`变量指向JDK安装路径,并在`Path`变量中添加。然后,通过命令行(cmd)验证安装,分别输入`java -version`和`javac -version`检查版本信息。最后,作者分享了如何在任意位置运行Java代码,包括在IntelliJ IDEA(IJ)中创建的Java文件,只需去掉包声明,就可以通过命令行直接运行。

推荐镜像

更多