一.问题的提出

如何在最短的时间,让非在线运维人员得到服务器运行情况?如何在服务器宕机后,在第一时间能通知非在线运维人员

?  

 

二.问题的初步解决

移动办公(移动终端运维支持)很重要,通过手机短信报警,可以在更短时间得到服务器的运行情况,从而更快排除故障,解决问题,使企业损失降到最低。

 

三.如何实现

 

1.可以通过购买移动、联通、电信的短信网关服务器或者相应接口来实现短信报警。(不免费)

 

2.可以通过(手机)飞信,发送飞信到指定手机账号,实现报警。(在第一次发飞信,需要填写认证码) (免费)

 

3.可以通过139邮箱绑定手机,用sendEmail发送邮件到139邮箱,然后139邮箱免费发送该邮件的短信到手机上。(免费)

 

四.实现上述第三种方案

 

1.注册 139邮箱   http://mail.10086.cn   按提示操作,注意一定绑定手机,并开设邮件的短信提示服务。

 

2.注册 163邮箱   http://mail.163.com    

 

3.下载,并使用sendEmail   ,请查看 步骤 五.

 

 

 

五.下载,使用sendEmail

 

[c-sharp] view plaincopy
 
  1. #!/bin/bash  
  2. #author     longxibendi  
  3. #blog       http://blog.csdn.net/longxibendi  
  4. #function       to   use  sendEmail     
  5. cd   
  6. mkdir  data/  
  7. cd  data  
  8. wget  http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz  
  9. tar zxvf  sendEmail-v1.56.tar.gz  
  10. cd  sendEmail-v1.56  
  11. cp  sendEmail      /usr/local/bin  
  12. chmod   a+x     /usr/local/bin/sendEmail  
  13. /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

 

 

[c-sharp] view plaincopy
 
  1. # Kernel sysctl configuration file for Red Hat Linux  
  2. #  
  3. # For binary values, 0 is disabled, 1 is enabled.  See sysctl(8) and  
  4. # sysctl.conf(5) for more details.  
  5. # Controls IP packet forwarding  
  6. net.ipv4.ip_forward = 0  
  7. # Controls source route verification  
  8. net.ipv4.conf.default.rp_filter = 1  
  9. # Do not accept source routing  
  10. net.ipv4.conf.default.accept_source_route = 0  
  11. # Controls the System Request debugging functionality of the kernel  
  12. kernel.sysrq = 0  
  13. # Controls whether core dumps will append the PID to the core filename  
  14. # Useful for debugging multi-threaded applications  
  15. kernel.core_uses_pid = 1  
  16. # Controls the use of TCP syncookies  
  17. net.ipv4.tcp_syncookies = 1  
  18. # Controls the maximum size of a message, in bytes  
  19. kernel.msgmnb = 65536  
  20. # Controls the default maxmimum size of a mesage queue  
  21. kernel.msgmax = 65536  
  22. # Controls the maximum shared segment size, in bytes  
  23. kernel.shmmax = 4294967295  
  24. # Controls the maximum number of shared memory segments, in pages  
  25. kernel.shmall = 268435456  
  26. #http://blog.csdn.net/longxibendi      修改内核参数  
  27. net.ipv4.tcp_max_syn_backlog = 65536  
  28. net.core.netdev_max_backlog =  32768  
  29. net.core.somaxconn = 32768  
  30. net.core.wmem_default = 8388608  
  31. net.core.rmem_default = 8388608  
  32. net.core.rmem_max = 16777216  
  33. net.core.wmem_max = 16777216  
  34. net.ipv4.tcp_timestamps = 0  
  35. net.ipv4.tcp_synack_retries = 2  
  36. net.ipv4.tcp_syn_retries = 2  
  37. net.ipv4.tcp_tw_recycle = 1  
  38. #net.ipv4.tcp_tw_len = 1  
  39. net.ipv4.tcp_tw_reuse = 1  
  40. net.ipv4.tcp_mem = 94500000 915000000 927000000  
  41. net.ipv4.tcp_max_orphans = 3276800  
  42. #net.ipv4.tcp_fin_timeout = 30  
  43. #net.ipv4.tcp_keepalive_time = 120  
  44. net.ipv4.ip_local_port_range = 1024  65535  
  45. #http://blog.csdn.net/longxibendi   修改结束    

 

 

 

修改完之后,

sysctl   -p    配置生效

 

声明:本文档可以随意更改,但必须署名原作者

 

作者:凤凰舞者 qq:578989855

posted on 2014-02-13 17:47  紫菱琴  阅读(466)  评论(0编辑  收藏  举报