Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ppabc committed Sep 6, 2016
1 parent 597b03c commit 566652c
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 35 deletions.
77 changes: 77 additions & 0 deletions cacti/cacti_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/bash
## cacti 2016-09-06
## http://www.aqzt.com
##email: [email protected]
##robert yu
##centos 6
##cacti搭建

#安装LAMP环境
yum install -y gcc make vim unzip wget install httpd mysql mysql-devel mysql-server php php-devel php-mysql php-comman php-pdo php-gd lm_sensor net-snmp php-snmp net-snmp-utils

yum install -y gcc perl-devel libxml2-devel libpng-devel pkg-config glib pixman pango pango-devel freetype freetype-devel fontconfig cairo cairo-devel libart_lgpl libart_lgpl-devel

### chkconfig mysqld on
### chkconfig httpd on
### chkconfig snmpd on
### service mysqld start
### service httpd start
### service snmpd start
### mysqladmin -u root password '123456'
### mysql -uroot -p
if false ; then
###注释start###
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.69 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database cacti;
Query OK, 1 row affected (0.00 sec)
mysql> grant all on cacti.* to cactiuser@localhost identified by '654321';
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
###注释end###
fi

tar zxvf rrdtool-1.4.5.tar.gz
cd rrdtool-1.4.5
./configure --prefix=/usr/local/rrdtool

make && make install

ln -s /usr/local/rrdtool/bin/* /usr/local/bin/


cd ..

tar zxvf net-snmp-5.3.4.tar.gz
cd net-snmp-5.3.4
./configure --prefix=/usr/local/net-snmp

make && make install

cp EXAMPLE.conf /usr/local/net-snmp/share/snmp/
ln -s /usr/local/net-snmp/bin/* /usr/local/bin/
/usr/local/net-snmp/sbin/snmpd -c /usr/local/net-snmp/share/snmp/snmpd.conf
echo "/usr/local/net-snmp/sbin/snmpd -c /usr/local/net-snmp/share/snmp/snmpd.conf" >>/etc/rc.local
cd ..

tar zxvf cacti-0.8.7g.tar.gz
cd cacti-0.8.7g
mysql -ucacti -pcactiWWW123 cacti < cacti.sql
cd include
sed -i "/cactiuser/ {29s/cactiuser/cacti/g}" config.php
sed -i "/cactiuser/ {30s/cactiuser/cactiWWW123/g}" config.php
cd ..
cd ..
mv cacti-0.8.7g /data/www/wwwroot/cacti
ln -s /usr/local/php-5.2.17/bin/php /usr/bin/php
/usr/bin/php /data/www/wwwroot/cacti/poller.php
echo "*/5 * * * * env LANG=C /usr/bin/php /data/www/wwwroot/cacti/poller.php" >>/etc/crontab

53 changes: 18 additions & 35 deletions linux-init-script/init_centos6.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ sed -i "/^ulimit -SHn.*/d" /etc/profile

cat >> /etc/profile << EOF
ulimit -u 102400
ulimit -u 1024000
ulimit -d unlimited
ulimit -m unlimited
ulimit -s unlimited
Expand Down Expand Up @@ -189,7 +189,7 @@ cat > /opt/sh/ipt.sh << EOF
/sbin/iptables -t raw -A OUTPUT -s 192.168.10.0/255.255.255.0 -p tcp --sport 80 -j NOTRACK
/sbin/iptables -t raw -A OUTPUT -s 192.168.20.0/255.255.255.0 -p tcp --sport 80 -j NOTRACK
/sbin/iptables -A INPUT -s 192.168.10.0/255.255.255.0 -p tcp --dport 22 -j ACCEPT
/sbin/iptables -A INPUT -s 192.168.20.0/255.255.255.0 -p tcp --dport 22 -j ACCEPT
/sbin/iptables -A INPUT -s 192.168.56.0/255.255.255.0 -p tcp --dport 22 -j ACCEPT
/sbin/iptables -A INPUT -s 192.168.10.0/255.255.255.0 -p icmp -j ACCEPT
/sbin/iptables -A INPUT -s 192.168.20.0/255.255.255.0 -p icmp -j ACCEPT
Expand All @@ -206,7 +206,7 @@ chmod +x /opt/sh/ipt.sh
/sbin/iptables -nL
/sbin/iptables -t raw -L -n

echo "/opt/sh/ipt.sh" >>/etc/rc.d/rc.local
#echo "/opt/sh/ipt.sh" >>/etc/rc.d/rc.local
}


Expand Down Expand Up @@ -276,6 +276,8 @@ service_config(){
chkconfig bluetooth off > /dev/null 2>&1
chkconfig cups off > /dev/null 2>&1
chkconfig ip6tables off > /dev/null 2>&1
chkconfig iptables on
chkconfig network on
chkconfig | grep -E "cups|ip6tables|bluetooth"
chmod +x /etc/rc.local
chmod +x /etc/rc.d/rc.local
Expand All @@ -284,43 +286,25 @@ chmod +x /etc/rc.d/rc.local

# 路由设置
route_config(){
localip=`ip a|grep "inet "|awk -F" " '{print $2}'|awk -F"/" '{print $1}'|egrep "^192" |head -n 1 |awk -F '[.]' '{print $3}'`
if [ "$localip" == "10" ];then
echo "/sbin/route add -net 192.168.20.0 netmask 255.255.255.0 gw 192.168.1.1">/opt/sh/route.sh
echo "/sbin/route -n">>/opt/sh/route.sh
fi
if [ "$localip" == "20" ];then
echo "/sbin/route add -net 192.168.10.0 netmask 255.255.255.0 gw 192.168.2.1">/opt/sh/route.sh
echo "/sbin/route -n">>/opt/sh/route.sh
fi
chmod +x /opt/sh/route.sh
/opt/sh/route.sh
echo "/opt/sh/route.sh" >>/etc/rc.local
#localip=`ip a|grep "inet "|awk -F" " '{print $2}'|awk -F"/" '{print $1}'|egrep "^192" |head -n 1 |awk -F '[.]' '{print $3}'`
#if [ "$localip" == "10" ];then
# echo "/sbin/route add -net 192.168.20.0 netmask 255.255.255.0 gw 192.168.1.1">/opt/sh/route.sh
# echo "/sbin/route -n">>/opt/sh/route.sh
#fi
#if [ "$localip" == "20" ];then
# echo "/sbin/route add -net 192.168.10.0 netmask 255.255.255.0 gw 192.168.2.1">/opt/sh/route.sh
# echo "/sbin/route -n">>/opt/sh/route.sh
#fi
#chmod +x /opt/sh/route.sh
#/opt/sh/route.sh
#echo "/opt/sh/route.sh" >>/etc/rc.local
echo ok
}

# VIM设置
vim_config(){
cat > /root/.vimrc << EOF
set history=1000
autocmd InsertLeave * se cul
autocmd InsertLeave * se nocul
set nu
set bs=2
syntax on
set laststatus=2
set tabstop=4
set go=
set ruler
set showcmd
set cmdheight=1
hi CursorLine cterm=NONE ctermbg=blue ctermfg=white guibg=blue guifg=white
set hls
set cursorline
set ignorecase
set hlsearch
set incsearch
set helplang=cn
EOF
}

Expand All @@ -342,7 +326,6 @@ main(){
zone_time
limits_config
sysctl_config

selinux_config
iptables_config
sshd_config
Expand Down

0 comments on commit 566652c

Please sign in to comment.