LINUX实战:Zabbix3.0/3.2/3.4自动安装脚本
发布时间:2020-05-22 16:29:12 所属栏目:Linux 来源:互联网
导读:介绍《LINUX实战:Zabbix3.0/3.2/3.4自动安装脚本》开发教程,希望对您有用。
|
《LINUX实战:Zabbix3.0/3.2/3.4自动安装脚本》要点: 一、zabbix简介 zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案.zabbix能监视各种网络参数,保证服务器系统的平安运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题. 二、zabbix特点 1.企业级的、开源的、分布式 2.灵活的告警机制、存储数据提供杰出的申报及图形 3.通过内置的绘图办法实现监控数据实时绘图 4.允许灵活地自定义问题阀值 5.支持主动与被动方式(agent、snmp、ipmi、自定义脚本) 三、自动化安装zabbix(3.0/3.2)脚本 #!/bin/bash
#Date2017/8/31
#mailxuel@anchnet.com
[$(id-u)!="0"]&&echo"Error:Youmustberoottorunthisscript"&&exit1
exportPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
sed-i"s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config
setenforce0
which ntpdate
if[$?-eq0];then
/usr/sbin/ntpdatetime1.aliyun.com
echo"*/5****/usr/sbin/ntpdate-stime1.aliyun.com">>/var/spool/cron/root
else
yuminstallntpdate-y
/usr/sbin/ntpdatetime1.aliyun.com
echo"*/5****/usr/sbin/ntpdate-stime1.aliyun.com">>/var/spool/cron/root
fi
clear
echo"##########################################"
echo"# AutoInstallzabbix. ##"
echo"# PressCtrl+Ctocancel ##"
echo"# Anykeytocontinue ##"
echo"##########################################"
echo"(1)Installzabbix3.0"
echo"(2)Installzabbix3.2"
echo"(3)Installzabbix3.4"
echo"(4)EXIT"
read-p"Pleaseinputyourchoice:"NUM
case$NUMin
1)
URL="http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm"
VER=zabbix-3.0
;;
2)
URL="http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/zabbix-release-3.2-1.el6.noarch.rpm"
VER=zabbix-3.2
;;
3)
URL="http://repo.zabbix.com/zabbix/3.4/rhel/6/x86_64/zabbix-release-3.4-1.el6.noarch.rpm"
VER=zabbix-3.4
;;
4)
echo-e" 33[41;37mYouchoicechannel! 33[0m"&&exit0
;;
*)
echo-e" 33[41;37mInputError!Placeinput{1|2|3|4} 33[0m"&&exit1
;;
esac
clear
echo-e" 33[32mYouchoiceinstall$VER.Install 33[0m"
echo-e" 33[5mPressanykeytostartinstall$VER... 33[0m"
read-n1
TDIR=/tools
IP=`ifconfigeth0|grep"inetaddr"|awk-F"[:]+"'{print$4}'`
yumremovephp*-y
rpm-Uvhhttp://mirror.webtatic.com/yum/el6/latest.rpm
ls/etc/yum.repos.d/webtatic.repo
if[$?-eq0];then
yum-yinstall`yumlist|grepphp71w|awk'{printf("%s",$1)}'`--skip-broken
fi
if[$?-eq0];then
sed-i"s/;date.timezone=/date.timezone=Asia/Shanghai/g"/etc/php.ini
sed-i"s#`grepmax_execution_time/etc/php.ini`#max_execution_time=300#g"/etc/php.ini
#max_execution_time=30
sed-i"s#`greppost_max_size/etc/php.ini`#post_max_size=32M#g"/etc/php.ini
sed-i"s#`grepmax_input_time=/etc/php.ini`#max_input_time=300#g"/etc/php.ini
sed-i"s#`grepmemory_limit/etc/php.ini`#memory_limit=128M#g"/etc/php.ini
fi
servicephp-fpmstart/tmp/php-install.log2>&1
STAT=`echo$?`
PORT=`netstat-lntup|grepphp-fpm|wc-l`
if[$STAT-eq0]&&[$PORT-eq1];then
echo-e" 33[32mPHPisinstallsuccess! 33[0m"
else
echo-e" 33[32mPHPinstallfile.pleasecheck/tmp/php-install.log 33[0m"
fi
yuminstall-yntpdatemailxdos2unixvimzcatwgetnet-snmp-utilsgccgcc-c++autoconfhttpdlibxml*mysqlmysql-server httpd-manua
lmod_sslmod_perlmod_auth_mysqlmysql-connector-odbcmysql-devellibdbi-dbd-mysqlnet-snmp-develcurl-develunixODBC-develOpenIPMI-develjava-develfpingclear
servicemysqldstart
groupaddzabbix-g201
useradd-gzabbix-u201-m-s/sbin/nologinzabbix
rpm-ivh $URL
ls/etc/yum.repos.d/zabbix.repo
ZAB=`echo$?`
if[!-d$TDIR];then
/bin/mkdir$TDIR&&cd$TDIR
fi
if["$VER"=="zabbix-3.0"];then
yuminstall-yzabbix-agent.x86_64zabbix-get.x86_64zabbix-server-mysql.x86_64zabbix-web.noarchzabbix-web-mysql.noarch
elif["$VER"=="zabbix-3.2"];then
if[-d$TDIR];then
cd$TDIR
else
/bin/mkdir$TDIR&&cd$TDIR
fi
if[$?-eq0];then
forPAGinzabbix-server-mysql-3.2.7-1.el6.x86_64.rpmzabbix-web-3.2.7-1.el6.noarch.rpmzabbix-web-mysql-3.2.7-1.el6.
noarch.rpm do
wget-c--timeout=5http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/deprecated/$PAG
done
wget-c--timeout=5http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/zabbix-agent-3.2.7-1.el6.x86_64.rpm
yumlocalinstall-yzabbix-server-mysql*zabbix-web-mysql*zabbix-agentzabbix-web*
if[$?-eq0];then
exit1&&echo"ZabbixSoftwardinstallfail,Pleasecheckdirname/tools"
fi
fi
elif["$VER"=="zabbix-3.4"];then
if[-d$TDIR];then
cd$TDIR
else
/bin/mkdir$TDIR&&cd$TDIR
fi
if[$?-eq0];then
forPAGinzabbix-server-mysql-3.4.0-1.el6.x86_64.rpmzabbix-web-3.4.0-1.el6.noarch.rpmzabbix-web-mysql-3.4.0-1.el6.
noarch.rpm do
wget-c--timeout=5--tries=35--user-agent="Mozilla/5.0(Windows;U;WindowsNT6.1;en-US)AppleWebKit/534.
16(KHTML,likeGecko)Chrome/10.0.648.204Safari/534.16"http://repo.zabbix.com/zabbix/3.4/rhel/6/x86_64/deprecated/$PAG done
wget-c--timeout=5--tries=35--user-agent="Mozilla/5.0(Windows;U;WindowsNT6.1;en-US)AppleWebKit/534.16(KHTM
L,likeGecko)Chrome/10.0.648.204Safari/534.16"http://repo.zabbix.com/zabbix/3.4/rhel/6/x86_64/zabbix-agent-3.4.0-1.el6.x86_64.rpm yumlocalinstall-yzabbix-*
if[$?-ne0];then
"ZabbixSoftwardinstallfail,Pleasecheckdirname/tools"&&exit1
fi
fi
else
echo"errorzabbixiversion"
fi
if[$?-eq0];then
mysql-uroot-e"createdatabasezabbixcharactersetutf8;"
mysql-uroot-e"grantallprivilegesonzabbix.*tozabbix@localhostidentifiedby'zabbix';"
mysql-uroot-e"flushprivileges;"
fi
cd/usr/share/doc
MYSQLDIR=`ls-l/usr/share/doc/|grepzabbix-server-mysql*|awk '{print$9}'`
cd$MYSQLDIR
zcatcreate.sql.gz|mysql-urootzabbix
mysqladmin-urootpassword"mysqladmin"
cd/usr/share/
cp-r./zabbix//var/www/html/zabbix
echo"DBPassword=zabbix">>/etc/zabbix/zabbix_server.conf
servicehttpdstart
servicezabbix-serverstart
servicezabbix-agentstart
chkconfighttpdon
chkconfigmysqldon
chkconfigphp-fpmon
chkconfigzabbix-serveron
chkconfigzabbix-agenton
/etc/init.d/iptablesstatus>/dev/null2>&1
if[$?-eq0];then
iptables-IINPUT-ptcp--dport443-jACCEPT&&
iptables-IINPUT-ptcp--dport10051-jACCEPT&&
iptables-IINPUT-ptcp--dport10050-jACCEPT&&
iptables-IINPUT-ptcp--dport3000-jACCEPT&&
#iptables-IINPUT-ptcp--dport3306-jACCEPT&&
serviceiptablessave>/dev/null2>&1
/etc/init.d/iptablesrestart
else
echo-e" 33[32miptablesisstopd 33[0m"
fi
clear
STAT=`/bin/ps-ef|grepzabbix_server|grep-vgrep|wc-l`
PORT=`/bin/netstat-lntup|grepzabbix_server|wc-l`
if[$STAT-ne0]&&[$PORT-ne0];then
echo-e" 33[42;37mZabbix$VERisInstallSuccess,Username:AdminPassword:zabbix 33[0m"
echo-e" 33[42;37mMySqlUsername:rootPassword:mysqladmin 33[0m"
echo-e" 33[42;37mrul:https://$IP/zabbix 33[0m"
fi
四、版本特性与脚本执行 升级PHP版本为7.1,可以安装最新Zabbix3.4 1.执行脚本如下: (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 正则表达式 – 如何仅使用grep / sed提取子字符串和数字
- linux – 如何在闪存设备上调试此FS错误?
- linux – 清除/ proc / meminfo中没有drop_caches的“缓存”
- linux – 我需要一个TCP选项(ioctl)来立即发送数据
- 无法使rsync在daemon-over-ssh模式下工作
- linux – 如何在编辑器中管道程序输出?
- linux – netstat -ntap没有显示某些连接的pid /进程名称?
- linux – 如何远程观看终端窗口?
- linux – 一个程序可以告诉它是在sudo下运行吗?
- apt – Debian – “警告:将安装以下软件包的不受信任版本
