Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,35 @@ Zabbix 快速安装文档
#linux 一键安装
* 运行zabbix_install.sh 一键安装脚本两种运行方法
1. ./zabbix_install.sh 参数$1 Zabbix服务器IP 参数$2 注册Agent名称
Eg:zabbix_install.sh 10.10.10.1 ZabbixAgentHostName
2. ./zabbix_install.sh 运行
#例子
./zabbix_install.sh 10.129.1.1 BJ-LIN-NGINX-GROUP-9V66
$1= zabbix服务器Ip 10.129.1.1
$2= 监控机器名称 BJ-LIN-NGINX-GROUP-9V66
# 命名规范
BJ-LIN-NGINX-GROUP-9V66
区域-系统-类型-项目组-IP (V虚拟机 P物理机 10.129.9.66虚拟机 =9V66)

2. ./zabbix_install.sh 运行-根据相关提示输入注册信息

#Zabbix Server 如果自动注册,请在动作---自动注册页面,进行监控机命名关联

```
############# Linx&Centos发行版 CMD ##############
curl -O https://raw.githubusercontent.com/net592/Zabbix-QuickInstall/gh-pages/linux/zabbix_install.sh;
curl -O https://raw.githubusercontent.com/net592/Zabbix-QuickInstall/master/linux/zabbix_install.sh;
chmod 744 zabbix_install.sh;
./zabbix_install.sh
############# AWS亚马逊&Linux CMD ##############
curl -O https://raw.githubusercontent.com/net592/Zabbix-QuickInstall/gh-pages/linux/zabbix_aws_install.sh;
curl -O https://raw.githubusercontent.com/net592/Zabbix-QuickInstall/master/linux/zabbix_aws_install.sh;
chmod 744 zabbix_aws_install.sh;
./zabbix_aws_install.sh
#机器名称会追加获取EC2机器信息: InputAgentName-local-ipv4-instance-id
############################################
############# 阿里云&Linx&Ubuntu发行版 CMD##############
curl -O https://raw.githubusercontent.com/net592/Zabbix-QuickInstall/master/linux/zabbix_ubuntu_install.sh;
chmod 744 zabbix_ubuntu_install.sh;
./zabbix_ubuntu_install.sh
#机器名称会追加获取ECS机器信息: InputAgentName-local-ipv4-instance-id
############################################
```
![mahua](images/linux_setup.png)
#Windows 一键安装
Expand All @@ -30,3 +45,4 @@ chmod 744 zabbix_aws_install.sh;

#Template 一些模版
* 后续整理
* DnsPod
88 changes: 88 additions & 0 deletions Windows/OneKeySetupZabbix/install_aws_zabbix_3.0_EnglishOS
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
setlocal enabledelayedexpansion
@echo off
@echo off
net use \\10.122.13.125 /user:administrator 9RSPWD***
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit


echo PROCESSOR_ARCHITECTURE var:
echo %PROCESSOR_ARCHITECTURE% | find /i "x86" > nul
if %errorlevel%==0 (
set netpath=\\10.122.13.125\c$\opstools\zabbix\win32\*
) else (
set netpath=\\10.122.13.125\c$\opstools\zabbix\win64\*
)

set localpath="C:\opstools\zabbix"

mkdir %localpath%
xcopy /ZYE %netpath% %localpath%\



:: Modely IP
set zabbix_server=10.122.0.253
set host_meta=%computername%.%userdomain%.COM
echo Zabbix_Server_IP %zabbix_server%
echo Local_AD_NAME %host_meta%
set /p host_name=Input_Zabbix_Auto_Name:(TJ-WIN-WEB-GROUP-1V100):
:: cp file server ip
set conf_file=%localpath%\conf\zabbix_agentd.win.conf
set conf_file_bak=%localpath%\conf\zabbix_agentd.win.conf.bak
del %conf_file%
for /f "delims=" %%a in ('type "%conf_file_bak%"') do (
set str=%%a
set "str=!str:127.0.0.1=%zabbix_server%!"
set "str=!str:HOSTMETATEMP=%host_meta%!"
set "str=!str:Windows host=%host_name%!"
echo !str!>>"%conf_file%"
)



%localpath%\zabbix_agentd.exe --stop
%localpath%\zabbix_agentd.exe --config %localpath%\conf\zabbix_agentd.win.conf --uninstall

%localpath%\zabbix_agentd.exe --config %localpath%\conf\zabbix_agentd.win.conf --install
%localpath%\zabbix_agentd.exe --start

endlocal
echo "Setup Zabbinx....."
#setting powershell
#powershell -noprofile Set-ExecutionPolicy RemoteSigned
for /f "skip=3 tokens=4" %%i in ('sc query "Zabbix Agent"') do set "zt=%%i" &goto :next
:next
if /i "%zt%"=="RUNNING" (
echo install Zabbix Success
) else (
echo Uninstall Zabbix Success Or Zabbix Agent Service no Stop
)
echo ------------------------------------------------------------------------
: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%
)
echo.
echo End
pause>nul
63 changes: 63 additions & 0 deletions linux/scripts/check_hadoop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash
#scripts for hadoop status By Zeming
function namenode {
NUM=$(su - hadoop -c "/usr/local/java/bin/jps |grep -i namenode|wc -l")
if [[ $NUM -eq 1 ]];then
echo "$NUM"
else
echo "$NUM"
(su - hadoop -c "/usr/local/hadoop/sbin/hadoop-daemon.sh start namenode")
fi
#/usr/sbin/ss -ant | awk '{++s[$1]} END {for(k in s) print k,s[k]}' | grep 'SYN-RECV' | awk '{print $2}'
}
function datanode {
NUM=$(su - hadoop -c "/usr/local/java/bin/jps |grep -i datanode|wc -l")
if [[ $NUM -eq 1 ]];then
echo "$NUM"
else
echo "$NUM"
(su - hadoop -c "/usr/local/hadoop/sbin/hadoop-daemon.sh start datanode")
fi
#/usr/sbin/ss -ant | awk '{++s[$1]} END {for(k in s) print k,s[k]}' | grep 'SYN-RECV' | awk '{print $2}'
}
function resourcemanager {
NUM=$(su - hadoop -c "/usr/local/java/bin/jps |grep -i datanode|wc -l")
if [[ $NUM -eq 1 ]];then
echo "$NUM"
else
echo "$NUM"
(su - hadoop -c "/usr/local/hadoop/sbin/yarn-daemon.sh start resourcemanager")
fi
#/usr/sbin/ss -ant | awk '{++s[$1]} END {for(k in s) print k,s[k]}' | grep 'SYN-RECV' | awk '{print $2}'
}
function nodemanager {
NUM=$(su - hadoop -c "/usr/local/java/bin/jps |grep -i nodemanager|wc -l")
if [[ $NUM -eq 1 ]];then
echo "$NUM"
else
echo "$NUM"
(su - hadoop -c "/usr/local/hadoop/sbin/yarn-daemon.sh start resourcemanager")
fi
#/usr/sbin/ss -ant | awk '{++s[$1]} END {for(k in s) print k,s[k]}' | grep 'SYN-RECV' | awk '{print $2}'
}
function master {
NUM=$(su - hadoop -c "/usr/local/java/bin/jps |grep -i HMaster|wc -l")
if [[ $NUM -eq 1 ]];then
echo "$NUM"
else
echo "$NUM"
(su - hadoop -c "/usr/local/hbase/bin/hbase-daemon.sh start master")
fi
#/usr/sbin/ss -ant | awk '{++s[$1]} END {for(k in s) print k,s[k]}' | grep 'SYN-RECV' | awk '{print $2}'
}
function regionserver {
NUM=$(su - hadoop -c "/usr/local/java/bin/jps |grep -i regionserver|wc -l")
if [[ $NUM -eq 1 ]];then
echo "$NUM"
else
echo "$NUM"
(su - hadoop -c "/usr/local/hbase/bin/hbase-daemon.sh start regionserver")
fi
#/usr/sbin/ss -ant | awk '{++s[$1]} END {for(k in s) print k,s[k]}' | grep 'SYN-RECV' | awk '{print $2}'
}
$1
2 changes: 2 additions & 0 deletions linux/zabbix_agentd.conf.d/iptables.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
UserParameter=firewall-enabled, sudo /sbin/iptables -L INPUT -n |grep -ci '.'
UserParameter=firewall-md5, sudo /sbin/iptables -L INPUT -n | cksum | cut -d " " -f 1
2 changes: 2 additions & 0 deletions linux/zabbix_agentd.conf.d/userparameter_check_hadoop.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#monitor tcp
UserParameter=checkhadoop[*],/usr/local/zabbix/etc/scripts/check_hadoop.sh $1
11 changes: 6 additions & 5 deletions linux/zabbix_aws_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ sleep 1
echo -e "\033[42;37m Part 1:Setup envurment \033[0m"

zabbixdir=`pwd`
zabbix_version=3.0.3
zabbix_version=3.2.5
ip=`ip addr |grep inet |egrep -v "inet6|127.0.0.1" |awk '{print $2}' |awk -F "/" '{print $1}'`

EC2LOCALIPV4=`curl -s http://169.254.169.254/latest/meta-data/local-ipv4`
Expand Down Expand Up @@ -80,7 +80,8 @@ sleep 2

if [ ! -f "$zabbixdir/zabbix-${zabbix_version}.tar.gz" ]; then
#wget http://netix.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/$zabbix_version/zabbix-${zabbix_version}.tar.gz
wget http://120.52.73.48/jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/$zabbix_version/zabbix-${zabbix_version}.tar.gz
#wget --no-check-certificate https://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/$zabbix_version/zabbix-${zabbix_version}.tar.gz
wget http://omwdjgaw1.bkt.clouddn.com/zabbix/zabbix-${zabbix_version}.tar.gz
#wget http://tenet.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/$zabbix_version/zabbix-${zabbix_version}.tar.gz
#wget http://$ServerIP/zabbix/zabbix-${zabbix_version}.tar.gz
else
Expand Down Expand Up @@ -108,10 +109,10 @@ sed -i "s/# HostMetadataItem=/HostMetadataItem=system.uname/g" /usr/local/zabbix
sed -i "s/# Include=$/Include=\/usr\/local\/zabbix\/etc\/zabbix_agentd.conf.d\/*.conf/g" /usr/local/zabbix/etc/zabbix_agentd.conf
echo -ne "\033[32m Down GitHUB Config \033[0m"
cd $zabbixdir
wget https://github.com/net592/Zabbix-QuickInstall/archive/gh-pages.zip
wget https://github.com/net592/Zabbix-QuickInstall/archive/master.zip

unzip -o gh-pages.zip
\cp -fr $zabbixdir/Zabbix-QuickInstall-gh-pages/linux/* /usr/local/zabbix/etc/
unzip -o master.zip
\cp -fr $zabbixdir/Zabbix-QuickInstall-master/linux/* /usr/local/zabbix/etc/
chown zabbix:zabbix /usr/local/zabbix/etc/scripts/*
chmod 744 /usr/local/zabbix/etc/scripts/*

Expand Down
12 changes: 7 additions & 5 deletions linux/zabbix_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ sleep 1
echo -e "\033[42;37m Part 1:Setup envurment \033[0m"

zabbixdir=`pwd`
zabbix_version=3.0.3
zabbix_version=3.2.5
ip=`ip addr |grep inet |egrep -v "inet6|127.0.0.1" |awk '{print $2}' |awk -F "/" '{print $1}'`


Expand Down Expand Up @@ -80,8 +80,9 @@ if [ ! -f "$zabbixdir/zabbix-${zabbix_version}.tar.gz" ]; then
#wget http://120.52.73.48/jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/$zabbix_version/zabbix-${zabbix_version}.tar.gz
#wget http://tenet.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/$zabbix_version/zabbix-${zabbix_version}.tar.gz
#wget https://jaist.dl.sourceforge.net/project/zabbix/ZABBIX Latest Stable/$zabbix_version/zabbix-${zabbix_version}.tar.gz
wget --no-check-certificate https://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/$zabbix_version/zabbix-${zabbix_version}.tar.gz
#wget --no-check-certificate https://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/$zabbix_version/zabbix-${zabbix_version}.tar.gz
#wget http://$ServerIP/zabbix/zabbix-${zabbix_version}.tar.gz
wget http://omwdjgaw1.bkt.clouddn.com/zabbix/zabbix-${zabbix_version}.tar.gz
else
echo -ne "\033[32m zabbix-${zabbix_version}.tar.gz文件已存在 \033[0m"
tar zxvf $zabbixdir/zabbix-${zabbix_version}.tar.gz
Expand All @@ -101,16 +102,17 @@ echo "配置zabbix server ip为 $ServerIP"
echo "配置zabbix HostName ip为 $HostName"
sed -i "s/Hostname=Zabbix server/Hostname=$HostName/g" /usr/local/zabbix/etc/zabbix_agentd.conf #设置主机名
sed -i "s/Server=127.0.0.1/Server=$ServerIP/g" /usr/local/zabbix/etc/zabbix_agentd.conf #设置Server地址
sed -i "s/# AllowRoot=0/AllowRoot=1/g" /usr/local/zabbix/etc/zabbix_agentd.conf #开启root权限
sed -i "s/ServerActive=127.0.0.1/ServerActive=$ServerIP/g" /usr/local/zabbix/etc/zabbix_agentd.conf #设置Active服务器地址
sed -i "s/# EnableRemoteCommands=0/EnableRemoteCommands=1/g" /usr/local/zabbix/etc/zabbix_agentd.conf #设置启用远程命令功能
sed -i "s/# HostMetadataItem=/HostMetadataItem=system.uname/g" /usr/local/zabbix/etc/zabbix_agentd.conf #设置HostMetadataItem
sed -i "s/# Include=$/Include=\/usr\/local\/zabbix\/etc\/zabbix_agentd.conf.d\/*.conf/g" /usr/local/zabbix/etc/zabbix_agentd.conf
echo -ne "\033[32m Down GitHUB Config \033[0m"
cd $zabbixdir
wget https://github.com/net592/Zabbix-QuickInstall/archive/gh-pages.zip
wget https://github.com/net592/Zabbix-QuickInstall/archive/master.zip

unzip -o gh-pages.zip
\cp -fr $zabbixdir/Zabbix-QuickInstall-gh-pages/linux/* /usr/local/zabbix/etc/
unzip -o master.zip
\cp -fr $zabbixdir/Zabbix-QuickInstall-master/linux/* /usr/local/zabbix/etc/
chown zabbix:zabbix /usr/local/zabbix/etc/scripts/*
chmod 744 /usr/local/zabbix/etc/scripts/*

Expand Down
Loading