zoukankan      html  css  js  c++  java
  • java 使用 spirng 监控 cpu 使用 状态。。。。

    首先。。使用 sigar ,sigar 使用  要 注意区分 是 web 还是 本地。。最好 在 WEB-INF 下 复制 dll 文件。。因为WEB-INF 不会被压缩。。。

     try {
                //如果是web方式运行。。
                WebApplicationContext web = ContextLoader.getCurrentWebApplicationContext();
                ServletContext context = web.getServletContext();
                libPath = context.getRealPath("WEB-INF/c_lib");
            } catch (NoClassDefFoundError err) {
                //非 web 方式
                // err.printStackTrace();
                try {
                    libPath = URLDecoder.decode(SigarUtil.class.getClassLoader().getResource("clib").getFile(), "utf-8");
                } catch (UnsupportedEncodingException ex) {
                    ex.printStackTrace();
                }
            } catch (Exception e) {
                throw new RuntimeException("发生了异常 : " + e.getCause() + ",原因 : " + e.getMessage());
            }

    使用@CachePut() 将   信息 放入 到 缓存中。。。。。

    使用 @Scheduled 每秒钟 执行。。放到缓存。。。

    注意: @CachePut 方法 不能 和 @Scheduled 放到 一个类下面。。。反正我放一起出错了。。。。原因不明。。。。。

  • 相关阅读:
    ES6-Object
    ES6-Iterator
    ES6-Generator
    ES6-fetch
    ES6-Function
    ES6-Array
    ES6-Class
    SQLite使用事务更新—by command
    交款功能代码
    SQLite本地事务处理
  • 原文地址:https://www.cnblogs.com/whm-blog/p/7427716.html
Copyright © 2011-2022 走看看