newlisp 获取cpu信息
来源:互联网 发布:linuxmint ubuntu 编辑:程序博客网 时间:2024/05/02 12:43
紧跟前文Linux CPU 负载度量公式,用newlisp写了一个获取本机cpu信息的小程序,每次都会调用REST API将数据发送给web server.
#!/usr/bin/newlisp(load "config.lsp")(define (add-log msg) (append-file "cpu.log" (append "\n" (string (now 480)) " ")) (append-file "cpu.log" (append ": " msg)) );; return a list;; which contains total_jiffies and work_jiffies(define (check-cpu) (set 'in-file (open "/proc/stat" "read")) (set 'line (read-line in-file)) (set 'r (parse line)) (close in-file) (set 'total_jiffies 0) (println r) (set 'i 1) (do-while (< i 8) (set 'total_jiffies (+ total_jiffies (int (nth i r)))) (inc i) ) (set 'work_jiffies 0) (set 'i 1) (do-while (< i 3) (set 'work_jiffies (+ work_jiffies (int (nth i r)))) (inc i) ) (list total_jiffies work_jiffies) )(set 'r2 (check-cpu))(set 'r3 (post-url "http://localhost/wind_tunnel/api/post/cpu" (format "ip=%s&hostName=%s&epoch=%lld&totalJiffies=%lld&workJiffies=%lld" ip host_name 123456789 (nth 0 r2) (nth 1 r2))))(add-log r3)(exit)
(set 'host_name "beijinghome")(set 'ip "192.168.1.101")
- newlisp 获取cpu信息
- 获取CPU信息
- C++获取CPU信息
- 获取CPU信息
- 全面获取 CPU 信息
- DELPHI获取CPU信息
- 获取CPU信息
- 获取 CPU 信息
- 时时获取CPU信息
- linux获取Cpu信息
- c++获取cpu信息
- C# 获取CPU信息
- Qt 获取CPU信息
- android获取cpu信息
- 获取CPU信息
- newlisp 获取文件名
- 获取内存和CPU信息
- 汇编实现获取CPU信息
- 开启我的CSDN之旅!
- java基础入门----多线程1
- HBase入门学习
- 使用因果图法和判定表法设计测试用例
- java环境配置
- newlisp 获取cpu信息
- Qt 4.8.0安装 出错原因
- java 所有的异常
- 分享个链接
- 10款免费且开源的项目管理工具
- 程序员的性格(2)
- SynchronousQueue,LinkedBlockingQueue,ArrayBlockingQueue区别
- 快速学习新技术的几条建议
- java运算符