cacti一鍵安裝指令碼V1.1
cacti一鍵安裝指令碼V1.1
- #!/bin/bash
- #function +++++++++++++cacti auto install scripts+++++++++++++++++++
- #author itnihao
- #version 1.1
- #date 2012-08-17 v1.0
- #date 2012-08-18 v1.1更新增加syslog-ng等內容
- #mail itnihao@qq.com
- #轉載請註明http://itnihao.blog.51cto.com,謝謝合作
- #source http://code.google.com/p/auto-task-pe/
- green=`e[0;32m`
- red=`e[0;31m`
- blue=`e[0;36m`
- blue1=`e[5;31m`
- NC=`e[0m`
- path_soft=$(pwd)
- function base {
- #rpm -e lrzsz&& yum -y install lrzsz*
- #[ “$?” != “0” ] && echo “yum is badly,please check” && exit 1
- for i in $(rpm -q gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel bison bison-devel readline readline-devel libmcrypt libmcrypt-devel net-snmp-devel gcc gcc-c++ apr apr-util postgresql-libs openssl openssl-devel autoconf automake fiex* libxml* ncurses* libtool* libxslt libxslt-devel curl* bzip2* gd gd-devel freetype freetype-devel libpng*|grep `not installed` | awk `{print $2}`)
- do
- yum -y install $i;
- done
- }
- function lamp {
- yum -y install httpd mysql-server mysql php* net-snmp* rrdtool*
- sed -i “s/;date.timezone =/date.timezone = Asia/Chongqing/g” /etc/php.ini
- #start lamp services
- for name in httpd mysqld snmpd
- do
- service ${name} restart
- chkconfig –add ${name}
- chkconfig –level 345 ${name} on
- done
- for name1 in nfslock rpcbind
- do
- service ${name1} stop
- chkconfig –del ${name1}
- done
- echo -e “<?php
phpinfo();
?>“>/var/www/html/test.php - }
- #add php_type
- #echo “AddType application/x-httpd-php .php” >>/etc/httpd/conf/httpd.conf
- #sed -i “s/AddType application/x-gzip .gz .tgz/AddType application/x-gzip .gz .tgz AddType application/x-httpd-php .php/g” /etc/httpd/conf/httpd.conf
- #sed -i “s/DirectoryIndex index.html index.html.var/DirectoryIndex index.php index.html index.html.var/g” /etc/httpd/conf/httpd.conf
- #install cacti
- function install_cacti {
- cd ${path_soft}
- [ ! -e cacti*.tar.gz ]; stats=$?
- [ “$stats” == 0 ] && echo -e “${red} there is not cacti*.tar.gz file${NC}” && wget –no-check-certificate http://www.cacti.net/downloads/cacti-0.8.8a.tar.gz
- tar zxvf cacti*.tar.gz
- cp -rf cacti-0.8.8a /var/www/html/cacti
- restorecon -R -v `/var/www/html/cacti`
- chown apache.apache -R /var/www/html/cacti/
- sed -i “s/$database_username = “cactiuser”/$database_username = “cacti”/g” /var/www/html/cacti/include/config.php
- sed -i “s/$database_password = “cactiuser”/$database_password = “cacti123″/g” /var/www/html/cacti/include/config.php
- #database password setting
- mysqladmin -uroot password `itnihao`
- mysqladmin -uroot -pitnihao flush-privileges
- mysqladmin -uroot -pitnihao create cacti
- mysql -uroot -pitnihao cacti </var/www/html/cacti/cacti.sql
- mysql -uroot -pitnihao -e “grant all on cacti.* to cacti@localhost identified by `cacti123`”
- mysql -uroot -pitnihao -e “FLUSH PRIVILEGES”
- #add crontab
- chmod 777 -R /var/www/html/cacti/rra
- chmod 777 -R /var/www/html/cacti/log
- echo “*/5 * * * * /usr/bin/php /var/www/html/cacti/poller.php > /dev/null 2&1″ >/tmp/cron.cacti
- crontab -l|sort|uniq >> /tmp/cron.cacti
- crontab -uroot /tmp/cron.cacti && rm -rf /tmp/cron.cacti
- #setsebool -P httpd_unified=1
- #chcon -t httpd_sys_content_t /usr/local/rrdtool -R
- echo -e “${green}++++++++++++++++++++++++cacti installed OK,path is http://ip/cacti++++++++++++++++++++${NC}”
- }
- function plugin {
- cd ${path_soft}/plugin
- [ ! -e cacti-spine-0.8.8a.tar.gz ]; stats=$?
- [ “$stats” == 0 ] && echo -e “${red} there is not cacti-spine*.tar.gz file${NC}” && wget –no-check-certificate http://www.cacti.net/downloads/spine/cacti-spine-0.8.8a.tar.gz
- tar zxvf cacti-spine-0.8.8a.tar.gz
- cd cacti-spine-0.8.8a
- ./configure
- make && make install
- cd ../
- mv /usr/local/spine/etc/spine.conf.dist /usr/local/spine/etc/spine.conf
- #wget http://docs.cacti.net/_media/plugin:docs-v0.4-1.tgz
- #wget http://docs.cacti.net/_media/plugin:boost-v5.0-1.tgz
- #wget http://docs.cacti.net/_media/plugin:discovery-v1.5-1.tgz
- #wget http://docs.cacti.net/_media/plugin:monitor-v1.2-1.tgz
- #wget http://docs.cacti.net/_media/plugin:monitor-v1.3-1.tgz
- #wget http://docs.cacti.net/_media/plugin:mobile-latest.tgz
- #wget http://docs.cacti.net/_media/plugin:settings-v0.7-1.tgz
- #wget http://docs.cacti.net/_media/plugin:syslog-v1.22-2.tgz
- #wget http://docs.cacti.net/_media/plugin:thold-v0.4.9-3.tgz
- #wget http://docs.cacti.net/_media/plugin:clog-v1.7-1.tgz
- #wget http://docs.cacti.net/_media/plugin:ntop-v0.2-1.tgz
- #wget http://docs.cacti.net/_media/plugin:domains-v0.1-1.tgz
- #wget http://docs.cacti.net/_media/userplugin:manage-0.6.2.zip
- #wget http://wotsit.thingy.com/haj/cacti/quicktree-0.2.zip
- #wget http://www.network-weathermap.com/files/php-weathermap-0.97a.zip
- #wget http://docs.cacti.net/_media/plugin:timeshift-latest.zip
- #wget http://docs.cacti.net/_media/plugin:loginmod-latest.tgz
- #wget http://docs.cacti.net/_media/plugin:realtime-v0.5-2.tgz
- for name in `ls|sed -e “s/plugin://g” -e “s/.tgz//g”`
- do
- mv plugin:${name}.tgz ${name}.tar.gz
- done
- for name1 in boost discovery docs domains loginmod-latest manage monitor quicktree realtime settings syslog thold timeshift weathermap
- do
- tar zxvf ${name1}*.tar.gz
- mv ${name1} /var/www/html/cacti/plugins/
- done
- chown apache.apache -R /var/www/html/cacti/plugins
- }
- function config_apache {
- cat >> /etc/httpd/conf/httpd.conf << EOF
- Alias /cacti “/var/www/html/cacti”
- <Directory “/var/www/html/cacti”>
- Options -Indexes MultiViews -FollowSymLinks
- DirectoryIndex index.php
- AllowOverride None
- Order allow,deny
- Allow from all
- </Directory>
- <Directory /var/www/html/cacti/plugin/weathermap>
- <Files editor.php>
- Order Deny,Allow
- Deny from all
- Allow from 127.0.0.1
- </Files>
- </Directory>
- EOF
- }
- function syslog {
- #syslog_mysql
- yum install -y rsyslog rsyslog-mysql
- cat >> /etc/rsyslog.conf << EOF
- $ModLoad imudp.so
- $UDPServerRun 514
- $ModLoad ommysql
- $template cacti_syslog,”INSERT INTO syslog_incoming(facility, priority, date, time, host, message) values (%syslogfacility%,
- %syslogpriority%, `%timereported:::date-mysql%`, `%timereported:::date-mysql%`, `%HOSTNAME%`, `%msg%`)”, SQL
- *.* >localhost,syslog,cacti_log,cacti_log_pass;cacti_syslog
- EOF
- sed -i “s/SYSLOGD_OPTIONS=”-c 4″/SYSLOGD_OPTIONS=”-c 4 -r -m 1″/g” /etc/sysconfig/rsyslog
- chkconfig rsyslog on
- service rsyslog restart
- #syslog_database
- mysqladmin -uroot -pitnihao create syslog
- mysql -uroot -pitnihao syslog </var/www/html/cacti/plugins/syslog/syslog.sql
- mysql -uroot -pitnihao -e “grant all on syslog.* to cacti_log@localhost identified by `cacti_log_pass`”
- mysql -uroot -pitnihao -e “FLUSH PRIVILEGES”
- #cacti_syslog
- sed -i “s/use_cacti_db = true;/use_cacti_db = false;/g” /var/www/html/cacti/plugins/syslog/config.php
- sed -i “s/syslogdb_username = `cactiuser`/syslogdb_username = `cacti_log`/g” /var/www/html/cacti/plugins/syslog/config.php
- sed -i “s/syslogdb_password = `cactiuser`/syslogdb_password = `cacti_log_pass`/g” /var/www/html/cacti/plugins/syslog/config.php
- #client_syslog or rsyslog
- #echo “*.* @192.168.16.200” >> /etc/syslog.conf
- #echo “*.* @192.168.16.200” >> /etc/rsyslog.conf
- }
- function syslog_ng {
- service rsyslog stop
- chkconfig –del rsyslog
- service syslog stop
- chkconfig –del syslog
- cd ${path_soft}/syslog
- #############################download####################################
- #wget wget http://dl.fedoraproject.org/pub/epel/6/x86_64/libnet-1.1.5-1.el6.x86_64.rpm
- #wget http://dl.fedoraproject.org/pub/epel/6/x86_64/eventlog-0.2.12-1.el6.x86_64.rpm
- #wget ftp://fr2.rpmfind.net/linux/epel/6/x86_64/syslog-ng-3.2.5-3.el6.x86_64.rpm
- #wget http://dl.fedoraproject.org/pub/epel/6/x86_64/syslog-ng-libdbi-3.2.5-3.el6.x86_64.rpm
- ########################################################################
- rpm -ivh libnet-1.1.5-1.el6.x86_64.rpm
- rpm -ivh eventlog-0.2.12-1.el6.x86_64.rpm
- rpm -ivh syslog-ng-3.2.5-3.el6.x86_64.rpm
- rpm -ivh libdbi-0.8.3-3.1.el6.x86_64.rpm
- rpm -ivh syslog-ng-libdbi-3.2.5-3.el6.x86_64.rpm
- cat >> /etc/syslog-ng/syslog-ng.conf << EOF
- source s_rsc {
- unix-stream(“/dev/log”);
- udp(ip(“192.168.16.200”) port(514));
- };
- #destination r_mesg { file(“/var/log/warn”);};
- destination d_mysql {
- program(“mysql -ucacti_log -pcacti_log_pass syslog < /var/log/mysql.pipe”);
- pipe(“/var/log/mysql.pipe”
- template(“INSERT INTO syslog_incoming (host, facility, priority, status, date, time, seq, message) VALUES( `$FULLHOST`, `$FACILITY`, `$PRIORITY`, `$STATUS`, `$YEAR-$MONTH-$DAY`, `$HOUR:$MIN:$SEC`,`$SEQ`, `$MESSAGE` );
“) - template-escape(yes));
- };
- log { source(s_rsc); destination(d_mysql); };
- log { source(s_sys); destination(d_mysql); };
- EOF
- }
- function client_config {
- #client syslog-ng,you should install syslog-ng
- cat >> /etc/syslog-ng/syslog-ng.conf << EOF
- destination d_udp {udp(“192.168.16.200” port(514));};
- log { source(s_sys); destination(d_udp);};
- EOF
- #client_syslog or rsyslog
- #rhel5.X use syslog
- echo “*.* @192.168.16.200” >> /etc/syslog.conf
- #rhel6.X use rsyslog
- echo “*.* @192.168.16.200” >> /etc/rsyslog.conf
- #clietn snmpd configuration
- sed -i s”/^/#/g” /etc/snmp/snmpd.conf
- cat >> /etc/snmp/snmpd.conf << EOF
- com2sec mynetwork 192.168.16.200 public
- com2sec mynetwork 127.0.0.1 public
- group MyROGroup v2c mynetwork
- access MyROGroup “” any noauth prefix all none none
- view all included .1 80
- EOF
- }
- function main {
- base
- lamp
- install_cacti
- plugin
- config_apache
- syslog
- #syslog_ng
- #client_config
- }
- main
配置完成,截圖如下
軟體包有以下下資料夾和檔案
plugin資料夾內內容
syslog檔案內容(住e15為多餘,本環境用的是el6)
本文轉自it你好 51CTO部落格,原文連結:http://blog.51cto.com/itnihao/965308,如需轉載請自行聯絡原作者
相關文章
- LAMPorLNMP一鍵安裝指令碼LAMPLNMP指令碼
- shell指令碼:一鍵安裝LAMP、LNMP指令碼指令碼LAMPLNMP
- shell指令碼一鍵安裝nginx指令碼Nginx
- golang一鍵自動安裝指令碼Golang指令碼
- LNMP一鍵自動安裝指令碼LNMP指令碼
- mysql8.0原始碼一鍵安裝指令碼MySql原始碼指令碼
- Shell指令碼 | 一鍵解除安裝安卓App指令碼安卓APP
- centos7 mysql 一鍵安裝指令碼CentOSMySql指令碼
- CentOS下LAMP一鍵yum安裝指令碼CentOSLAMP指令碼
- LNMP一鍵自動安裝指令碼薦LNMP指令碼
- 使用shell指令碼實現LANMP一鍵安裝指令碼
- MySQL5.6一鍵編譯安裝指令碼MySql編譯指令碼
- easy-hiphop一鍵安裝hiphop指令碼薦指令碼
- shell指令碼一鍵安裝nginx-1.18.0指令碼Nginx
- rsync客戶端一鍵安裝rsync指令碼(原始碼)客戶端指令碼原始碼
- Jumpserver v0.2.0 一鍵安裝指令碼薦Server指令碼
- k3s單機版安裝部署 附一鍵安裝指令碼指令碼
- [SHELL]LNMP一鍵安裝指令碼設計(v1.0)LNMP指令碼
- DSS+Linkis Ansible 單機一鍵安裝指令碼指令碼
- cacti安裝紀實
- cacti自定義監控指令碼指令碼
- 整理了cacti安裝和plugin安裝Plugin
- Cacti的安裝之CentOSCentOS
- Ubuntu安裝cacti步驟Ubuntu
- ubuntu下cacti安裝配置Ubuntu
- Cacti和Zabbix所需Nginx安裝配置(一)薦Nginx
- httpd 一鍵編譯安裝指令碼(centos6&7_httpd2.2&2.4)httpd編譯指令碼CentOS
- [SHELL]LAMP一鍵安裝指令碼設計(v1,v2)LAMP指令碼
- 一鍵部署指令碼指令碼
- pyenv 安裝指令碼指令碼
- lnmp安裝指令碼LNMP指令碼
- 通過 shell 指令碼完成 GitLab11.9.11 的一鍵安裝指令碼Gitlab
- cacti安裝thold外掛
- Cacti安裝磁碟IO監控
- 利用Vultr VPS皮膚自帶指令碼一鍵安裝WordPress網站程式指令碼網站
- Docker的指令碼安裝Docker指令碼
- Tomcat安裝指令碼Tomcat指令碼
- LNMP安裝shell指令碼LNMP指令碼