zoukankan      html  css  js  c++  java
  • 监控 monitor java 代码

    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
    package monitor;
     
    import alilibs.AliFile;
    import alilibs.AliHTTP;
    import alilibs.AliMail;
    import java.io.IOException;
    import java.text.SimpleDateFormat;
    import java.time.format.DateTimeFormatter;
    import java.time.format.DateTimeFormatterBuilder;
    import java.util.Date;
    import java.util.logging.Level;
    import java.util.logging.Logger;
     
    /**
     *
     * @author Ali
     */
    public class Monitor {
     
        /**
         * @param args the command line arguments
         */
        public static void main(String[] args) {
     
            run(args);
        }
     
        public static void run(String[] args) {
            String linuxUrl = "http://www.9hlh.com/index.php?m=kv&c=if&a=monitorx";
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss|");
            while (true) {
     
                String result = AliHTTP.getString(linuxUrl);
                try {
                    AliFile.appendString("monitor.txt", sdf.format(new Date()) + result + "
    ");
                } catch (IOException ex) {
                    //  Logger.getLogger(Monitor.class.getName()).log(Level.SEVERE, null, ex);
                }
                int x = Integer.parseInt(result);
                if (x > 300) {
     
                    System.err.println("out->" + AliHTTP.getString("http://www.9hlh.com/tools/mail/sendmail.php?email=xienaizhong@qq.com&subject=error_win&body=error_win"));
     
                } else {
                    System.err.println("in -> " + result);
                }
     
                try {
                    Thread.sleep(1000 * 60 * 5);
                } catch (InterruptedException ex) {
                }
     
            }
     
        }
     
    }
  • 相关阅读:
    第3章 对象基础
    [置顶] CSDN博客客户端(非官方)
    javascript 修改对象
    Print2Flash出现"System Error. Code:1722. RPC服务器不可用."错误解决办法
    ConfigHelper 配置文件辅助类
    多个委托方法的顺序执行
    javascript Table
    字符串拼接方式(待商榷)
    CSDN博客客户端(非官方)
    javascript 对象继承
  • 原文地址:https://www.cnblogs.com/aliblogs/p/5493708.html
Copyright © 2011-2022 走看看