一.问题的提出
如何在最短的时间,让非在线运维人员得到服务器运行情况?如何在服务器宕机后,在第一时间能通知非在线运维人员
?
二.问题的初步解决
移动办公(移动终端运维支持)很重要,通过手机短信报警,可以在更短时间得到服务器的运行情况,从而更快排除故障,解决问题,使企业损失降到最低。
三.如何实现
1.可以通过购买移动、联通、电信的短信网关服务器或者相应接口来实现短信报警。(不免费)
2.可以通过(手机)飞信,发送飞信到指定手机账号,实现报警。(在第一次发飞信,需要填写认证码) (免费)
3.可以通过139邮箱绑定手机,用sendEmail发送邮件到139邮箱,然后139邮箱免费发送该邮件的短信到手机上。(免费)
四.实现上述第三种方案
1.注册 139邮箱 http://mail.10086.cn 按提示操作,注意一定绑定手机,并开设邮件的短信提示服务。
2.注册 163邮箱 http://mail.163.com
3.下载,并使用sendEmail ,请查看 步骤 五.
五.下载,使用sendEmail
#!/bin/bash
#author longxibendi
#blog http://blog.csdn.net/longxibendi
#function to use sendEmail
cd
mkdir data/
cd data
wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz
tar zxvf sendEmail-v1.56.tar.gz
cd sendEmail-v1.56
cp sendEmail /usr/local/bin
chmod a+x /usr/local/bin/sendEmail
/usr/local/bin/sendEmail -f monitor_sys@163.com -t longxibendi@139.com -s smtp.163.com -u "test" -xu monitor_sys -xp 123456789 -m "hello longxibendi"
六.程序解释
sendEmail-1.56 by Brandon Zehm <caspian@dotconf.net>
Synopsis: sendEmail -f ADDRESS [options]
Required:
-f ADDRESS from (sender) email address 使用哪个email作为发送方
* At least one recipient required via -t, -cc, or -bcc
* Message body required via -m, STDIN, or -o message-file=FILE
Common:
-t ADDRESS [ADDR ...] to email address(es) 发送到哪个邮件(这里就是139邮件)
-u SUBJECT message subject 邮件主题
-m MESSAGE message body 邮件内容
-s SERVER[:PORT] smtp mail relay, default is localhost:25
Optional:
-a FILE [FILE ...] file attachment(s)
-cc ADDRESS [ADDR ...] cc email address(es)
-bcc ADDRESS [ADDR ...] bcc email address(es)
-xu USERNAME username for SMTP authentication 发送方(邮件)的用户名
-xp PASSWORD password for SMTP authentication 发送方(邮件)的密码
七.注意问题
如果出现什么问题,比如segmentation fault 可能是内存太小,或者内核参数问题
下面是 我的 内核参数 可以,参考这个参数,修改你的参数
cat /etc/sysctl.conf
# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and
# sysctl.conf(5) for more details.
# Controls IP packet forwarding
net.ipv4.ip_forward = 0
# Controls source route verification
net.ipv4.conf.default.rp_filter = 1
# Do not accept source routing
net.ipv4.conf.default.accept_source_route = 0
# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 0
# Controls whether core dumps will append the PID to the core filename
# Useful for debugging multi-threaded applications
kernel.core_uses_pid = 1
# Controls the use of TCP syncookies
net.ipv4.tcp_syncookies = 1
# Controls the maximum size of a message, in bytes
kernel.msgmnb = 65536
# Controls the default maxmimum size of a mesage queue
kernel.msgmax = 65536
# Controls the maximum shared segment size, in bytes
kernel.shmmax = 4294967295
# Controls the maximum number of shared memory segments, in pages
kernel.shmall = 268435456
#http://blog.csdn.net/longxibendi 修改内核参数
net.ipv4.tcp_max_syn_backlog = 65536
net.core.netdev_max_backlog = 32768
net.core.somaxconn = 32768
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_tw_recycle = 1
#net.ipv4.tcp_tw_len = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_max_orphans = 3276800
#net.ipv4.tcp_fin_timeout = 30
#net.ipv4.tcp_keepalive_time = 120
net.ipv4.ip_local_port_range = 1024 65535
#http://blog.csdn.net/longxibendi 修改结束
修改完之后,
sysctl -p 配置生效
声明:本文档可以随意更改,但必须署名原作者
作者:凤凰舞者 qq:578989855