首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 系统运维 >

newlisp获取并计算内存储器负载

2013-10-29 
newlisp获取并计算内存负载下面的代码计算Linux下的内存负载#!/usr/bin/newlisp(set cur-path /opt/dete

newlisp获取并计算内存负载

下面的代码计算Linux下的内存负载

#!/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 "/mem.log") (append "\n" (string (now 480)) " "))  (append-file (append cur-path "/mem.log") (append  ": " msg))  )(define (check-mem)  (set 'in-file (open "/proc/meminfo" "read"))  (set 'line1 (read-line in-file))  (set 'line2 (read-line in-file))  (set 'line3 (read-line in-file))  (set 'line4 (read-line in-file))  (add-log line1)  (add-log line2)  (add-log line3)  (add-log line4)  (set 'total-mem (int ((parse line1) 1)))  (set 'free-mem (int ((parse line2) 1)))  (set 'buffer-mem (int ((parse line3) 1)))  (set 'cached-mem (int ((parse line4) 1)))  (set 'll (div (- (- (- total-mem free-mem) buffer-mem) cached-mem) (int total-mem)))  (add-log (string ll)))(check-mem)(exit)


热点排行