• newlsip 检查磁盘分区使用情况


    主要还是用df -k这个命令,然后将输出结果全部逐行解析,最后调用REST API,发送给服务器保存。

    参考代码:

    #!/usr/bin/newlisp
    
    (set 'cur-path "/opt/detector")
    (load (append cur-path "/config.lsp"))
    (define (add-log msg)
      (println msg)
      (append-file (append cur-path "/disk.log") (append "
    " (string (now 480)) " "))
      (append-file (append cur-path "/disk.log") (append  ": " msg))
      )
    
    (define (process-record record)
      (add-log record)
      (set 'l (parse record))
      (set 'type (last l))
      (set 'a (int (l 1)))
      (set 'b (int (l 2)))
      (if (and a b)
          (begin
           (set 'll (div b a))
           ;;  (add-log (format "%lld,%lld,%f" a b ll))                                                                                                                              
           (set 'data (format "ip=%s&hostName=%s&type=fs_%s&values=%lld|%f" ip host_name type (date-value) ll))
           (add-log data)
           (set 'r3 (post-url (format "http://%s/wind_tunnel/api/post/data" server) data))
           (add-log r3))))
    
    (define (check-disk)
      (set 'r (exec "df -k"))
      (pop r)
      (dolist (x r)
        (process-record x)))
    
    (check-disk)
    
    (exit)


  • 相关阅读:
    row_number() over
    hubbledotnet 使用笔记
    Sql 递归
    aspnet_isapi.dll 和 iis
    正则题目
    Html to jsstring
    js 回车提交表单
    with as
    MSSQL 时间的操作
    php 执行mssql 里的语句,报错 The EXECUTE permission was denied on the object
  • 原文地址:https://www.cnblogs.com/riskyer/p/3395238.html
Copyright © 2020-2023  润新知