Created
November 9, 2015 10:32
-
-
Save eiryu/cbc0901d9db5f97de999 to your computer and use it in GitHub Desktop.
TOPのCPU・メモリ使用率集計
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// e.g. | |
// Cpu(s): 1.1%us, 0.6%sy, 0.0%ni, 97.5%id, 0.6%wa, 0.1%hi, 0.1%si, 0.0%st | |
new File('/path/02_cpu.txt').eachLine { | |
m = (it =~ /Cpu\(s\):\ +([0-9.]+)%us,\ +([0-9.]+)%sy.+/) | |
// if(m.matches()) { | |
println "${m[0][1]}\t${m[0][2]}" | |
// } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// e.g. | |
// Mem: 1026352k total, 389288k used, 637064k free, 146228k buffers | |
new File('/path/02_mem.txt').eachLine { | |
m = (it =~ /Mem:\ +([0-9]+)k\ total,\ +([0-9.]+)k\ used,.+/) | |
// if(m.matches()) { | |
println "${m[0][2]}" | |
// } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment