Zabbix monitoring build script
Last Update:2014-05-21
Source: Internet
Author: User
Zabbix monitoring build script #! /Bin/bashwww.2cto.com #1.0 install zabbix depending on the lazy package yuminstall-yhttpdphpmysqlmysql-servergcc * php-mysqlhttpd-manualmod_sslmod_perlmod_auth_mysqlphp-gdphp-... zabbix monitoring build script #! /Bin/bash www.2cto.com #1.0 install zabbix in the lazy package yum install-y httpd php mysql-server gcc * php-mysql httpd-manual mod_ssl mod_perl mod_auth_mysql php-gd php-xml php -mbstring php-ldap php-pear php-xmlrpc php-bcmath mysql-connector-odbc mysql-devel libdbi-dbd-mysql net-snmp-devel curl-devel>/dev/null #1.1 load phpcat <OK>/etc/httpd/conf/httpd. confDirectoryIndex index. phpok #1.2 start the web service and database service/etc/ini T. d/httpd restartchkconfig httpd on/etc/init. d/mysqld restartchkconfig mysqld on #1.3 set the database password mysqladmin-uroot-password 'anfenghu' #1.4 test php, apache, mysql connection cat <ceshi>/var/www/html/index. phpit works! Ceshi #2.0 start zabbix #2.1 first create zabbix user and group groupadd zabbixuseradd-g zabbix-s/sbin/nologintar-zxvf/root/zabbix-2.0.3.tar.gz-C/usr/srccd /usr/src/zabbix-2.0.3 #2.2 create database for zabbix and add user/etc/init. d/mysqld restartmysql-uroot-p 'anfenghu' create database zabbix character set utf8; grant all privileges on zabbix. * to zabbix @ localhost identified by 'redhat'; flush privileges; exit #2.3 import the data in the zabbix source package to the newly created zabbix database mysql-uzabbix-p' anfenghu 'zabbix </usr/src/zabbix-2.0.3/database/mysql/schema. SQL mysql-uzabbix-p 'anfenghu' zabbix </usr/src/zabbix-2.0.3/database/mysql/images. sqlmysql-uzabbix-p 'anfenghu' zabbix </usr/src/zabbix-2.0.3/database/mysql/data. SQL # create the zabbix installation directory and initialize zabbixmkdir/usr/local/zabbix/usr/src/zabbix-2.0.3/configure -- prefix =/usr/local/zabix -- enable-server -- enable- proxy -- enable-agent -- with-mysql =/usr/bin/mysql_config -- with-net-snmp -- with-libcurlmake>/dev/nullmake install>/dev/nullln-s/ usr/local/zabbix/etc/zabbix #2.4 change the user name and password of the database in the configuration file sed-I's/DBName = zabbix/g'/etc/ zabbix/zabbix_server.confsed-I's/DBUser = zabbix/g'/etc/zabbix/Alibaba-I's/# DBPassword =/DBPassword = anfenghu/g'/etc /zabbix/zabbix_server.confzjm = hostnamesed-I's/Hostname = $ zjm/g'/etc/zabbix/zabbix_agentd.confip = ifconfig | head-2 | awk-F ": "'{print $2}' | awk-F" "'{print $1}' | tail-1sed-I's/ServerActive = $ ip /'/ etc/zabbix/zabbix_agentd.conf #2.5 soft link to the zabbix server program for I in *; do ln-s/usr/local/zabbix/bin/$ {I}/usr/bin/$ {I}; done for I in *; do ln-s/usr/local/zabbix/sbin/$ {I}/usr/sbin/$ {I }; done #2.6 add the database Lib file location to/etc/ld. so. conf, and make it take effect echo "/usr/local/mysql-5.1.48/lib/mysql/">/etc/ld. so. conf ldconfig #2.7 copy the corresponding web program to the relevant WEB service directory cp-r/usr/src/zabbix-2.0.3/frontends/php // var/www/html/zabbix/chown- R zabbix. zabbix/var/www/html/zabbix #2.8 copy the startup step of zabbix to/etc/init. d/cp/usr/src/zabbix-2.0.3/misc/init. d/fedora/core5/zabbix_server/etc/init. dcp/usr/src/zabbix-2.0.3/misc/init. d/fedora/core5/zabbix_agentd/etc/init. d #2.9 modify the startup script sed-I's/ZABBIX_BIN = "/usr/local/sbin/zabbix_server"/ZABBIX_BIN = "/usr/local/zabbix/sbin/zabbix_server "/ g'/etc/init. d/zabbix_server/etc/init. d/zabbix_server restartsed-I's/ZABBIX_BIN = "/usr/local/sbin/Hangzhou"/ZABBIX_BIN = "/usr/local/zabbix/sbin/zabbix_agentd"/g '/ etc/init. d/zabbix_agentd/etc/init. d/zabbix_agentd restartchkconfig zabbix_server onchkconfig zabbix_agentd onsed-I's/date. timezone =/date. timezone = Asia/Shanghai/'/etc/php. inised-I's/post_max_size = 32 M/'/etc/php. inised-I's/max_execution_time = 300/'/etc/php. inised-I's/max_input_time = 300/'/etc/php. inised-I's/memory_limit = 128 M/'/etc/php. inised-I's/mbstring. func_overload =/mbstring. func_overload = 2/'/etc/php. ini/etc/init. d/httpd restartchkconfig httpd on