rpm -qa | grep mrtg*
yum -y install mrtg*
mrtg流量图的实现过程
1.snmp调试
2.修改mrtg配置文件
3.根据配置文件生成图片和部分网页文件
4.生成首页index.html
5.cron轮询生成流量监控软件
cd /var/www/mrtg/
/etc/mrtg/mrtg.cfg
free -k
df -k
cd /etc/cron.d/
放在这个目录下的脚本不用写计划任务了,会自动执行
LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok
生成首页
indexmaker --output /var/www/mrtg/index.html --title="lampbrother web" /etc/mrtg/mrtg.cfg
shell脚本邮件报警-web
企业邮件服务器
25 发邮件端口
110 收邮件端口
网络实验环境
一台linux服务器
安装postfix
安装webmail
一台window xp客户端
安装outlook express
首先卸载服务器上的sendmail
pstree | grep sendmail
service sendmail stop
chkconfig sendmail off
chkconfig --list sendmail
pstree | grep sendmail
yum -y install postfix*
postfix负责25端口
dovecot负责110端口
yum -y install dovecot*
修改配置文件
vi /etc/postfix/main.cf
myhostname = mail.g.cn
mydomain = g.cn
//发件人@后的后缀
myorigin = $myhostname
myorigin = $mydomain
//25号端口在所有人上监听
inet_interfaces = all
#inet_interfaces = $myhostname
#inet_interfaces = $myhostname, localhost
#inet_interfaces = localhost
//收件人的后缀
mydestination = $myhostname,$mydomain
//服务器所处的网段
mynetworks = 192.168.124.0/24, 127.0.0.0/8
//转发邮件
relay_domains = $mydestination
netstat -tunpl | grep 25
pstree | grep master
chkconfig postfix on
chkconfig --list postfix
改变邮件服务器当前选择的默认邮件服务
alternatives --config mta
输入2
netstat -tunpl | grep 110 //收邮件服务还没起来
vi /etc/dovecot.conf
把这一行的注释去掉
protocols = imap imaps pop3 pop3s
pop3就相当与110端口
service dovecot restart
!net
!ps
useradd user1
passwd user1
useradd user2
passwd user2
这样系统会默认创建两个邮箱
[email protected] [email protected]
用outlook测试发邮件 成功
在linux里面发邮件
telnet 192.168.124.130 25
[root@localhost ~]# telnet 192.168.124.130 25
Trying 192.168.124.130...
Connected to localhost (192.168.124.130).
Escape character is '^]'.
220 mail.g.cn ESMTP Postfix
mail from:
[email protected]
250 2.1.0 Ok
rcpt to:
[email protected]
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
root -> user1
.
250 2.0.0 Ok: queued as 8DE97850A8
quit
221 2.0.0 Bye
Connection closed by foreign host.
You have new mail in /var/spool/mail/root
[root@localhost ~]#
shell发送邮件脚本
#!/bin/bash
#disk.sh
echo "shell 111111111" | mail
[email protected] -s "shell..."
监控apache、mysql、磁盘空间
[root@localhost ~]# touch apache.sh
[root@localhost ~]# touch mysql.sh
[root@localhost ~]# touch disk.sh
[root@localhost ~]# chmod a+x apache.sh disk.sh mysql.sh
穿过服务器的端口
[root@localhost ~]# nc -w4 localhost 80
[root@localhost ~]# echo $? //返回上一次指令的执行状态 0表示成功 1表示未成功
vi apache.sh
#!/bin/bash
#apache.sh
nc -w2 localhost 80
if [ $? -ne 0 ]
then
echo "apache's 80 port is down,please you restart the apache process!"|mail
[email protected] -s "apache is down"
/usr/local/apache2/bin/apachectl restart
fi
vi mysql.sh
#!/bin/bash
#apache.sh
nc -w2 localhost 3306
if [ $? -ne 0 ]
then
echo "mysql's 3306 port is down,please you restart the apache process!"|mail
[email protected] -s "mysql is down"
service mysqld restart
fi
vi disk.sh
#!/bin/bash
#disk.sh
num=`df | awk 'NR==2{print int($5)}'`
if [ $num -gt 85 ]
then
echo "disk spache is ${num}%,now > 85%"|mail
[email protected] -s "disk spache > 85%"
fi
[root@localhost ~]# dd if=/dev/zero of=text.txt bs=1M count=1000