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) {
                }
     
            }
     
        }
     
    }
  • 相关阅读:
    elasticsearch 数据迁移
    elasticsearch使用简介 -安装篇
    docker 使用笔记
    PHP 全局变量
    做人做事需牢记20条原则
    MYSQL 存储引擎概述
    postgresql常用命令
    ORACLE 清理SYSAUX表空间
    sqlserver数据库的启动
    postgressql启动与关闭
  • 原文地址:https://www.cnblogs.com/aliblogs/p/5493708.html
Copyright © 2011-2022 走看看