柔中带刚,刚中带柔,淫荡中富含柔和,刚猛中荡漾风骚,无坚不摧,无孔不入!
全部博文(1669)
分类:
2012-10-19 16:13:20
2012-10-14 15:24:36| 分类: rhel_apache | 标签: |字号大中小
1.写一个java类/jsp
Runtime run = Runtime.getRuntime();
long max = run.maxMemory()/1024/1024; //最大内存
long total = run.totalMemory()/1024/1024; //已分配内存long free = run.freeMemory()/1024/1024; //剩余空间
if((run.freeMemory()/1024/1024)<150){
JavaMailSenderImpl sender = new JavaMailSenderImpl();
sender.setHost("192.168.1.1");
MimeMessage message = sender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(message, true,
"UTF-8");
helper.setFrom("miotourerror@mic.com.tw");
helper.setTo(new String[] {"itxinmeng@gmail.com"});
helper.setSubject("miotour 异常");
String content = "mio tour 已处于宕机边缘,内存只剩下:"+free+"M";
content =content + "
";helper.setText(content, true);
sender.send(message);
}
2.linux下添加定时(fedora 11下):
/etc/crontab -e 添加如下内容(每15分钟查一次)
*/15 * * * * curl
/sbin/service crond restart