Dysnomia 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/Dysnomia/linux.rb +48 -0
- data/lib/Dysnomia/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8b0f3cd947bd598a67d88c30f873f75a11178bb
|
4
|
+
data.tar.gz: e4eecb7f9d309675dc7abb39309ba20f9fb5ed3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c24628491671970962bafbca0e0ec1f7ba40a9de836ba6ebfc773dc2aa26e178dbed54d5f94235498bb7b638d59819ea130e76960f3b39ba4f06e5d93f23954d
|
7
|
+
data.tar.gz: 03d3c22cb3b07e22d105181cb9e1e7dc1e647c1de92219b10ad72787b404a9b63cc14e5268d4e3ea0fbfcae21103103c00e2ddd936deb901fa5f75b0f3f4411d
|
data/README.md
CHANGED
@@ -23,6 +23,12 @@ dys = Dysnomia
|
|
23
23
|
|
24
24
|
dys.top_memory_processes # Top ten memory processes
|
25
25
|
dys.top_cpu_processes # Top ten cpu processes
|
26
|
+
dys.disk_usage # Disk usage (gib)
|
27
|
+
dys.disk_usage_percent # Disk usage (percent)
|
28
|
+
dys.cpu_used # Cpu usage (percent)
|
29
|
+
dys.memory_used # Memory usage (percent)
|
30
|
+
dys.average_load # Get Average load past minute
|
31
|
+
dys.tcp # TCP (ipv4 and ipv6) usaged
|
26
32
|
|
27
33
|
</pre>
|
28
34
|
|
data/lib/Dysnomia/linux.rb
CHANGED
@@ -3,6 +3,11 @@ module Dysnomia
|
|
3
3
|
@@ipv4_file = "/proc/net/sockstat"
|
4
4
|
@@ipv6_file = "/proc/net/sockstat6"
|
5
5
|
|
6
|
+
@@memory_file = "/proc/meminfo"
|
7
|
+
@@load_avarange_file = "/proc/loadavg"
|
8
|
+
|
9
|
+
@@bw_file = "/proc/net/dev"
|
10
|
+
|
6
11
|
def disk_usage
|
7
12
|
|
8
13
|
# return gib
|
@@ -101,6 +106,49 @@ module Dysnomia
|
|
101
106
|
end
|
102
107
|
|
103
108
|
|
109
|
+
def memory_used
|
110
|
+
|
111
|
+
# get memory used percent
|
112
|
+
$result = nil
|
113
|
+
if File.exist?(@@memory_file)
|
114
|
+
File.open(@@memory_file, "r") do |mem|
|
115
|
+
$result = mem.read
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
if ! nil?
|
120
|
+
$m = $result.split("\n").collect{|x| x.strip}
|
121
|
+
$total = $m[0].gsub(/[^0-9]/, "")
|
122
|
+
$active = $m[5].gsub(/[^0-9]/, "")
|
123
|
+
|
124
|
+
# Calc active memory
|
125
|
+
$calc = ($active.to_f * 100) / $total.to_f
|
126
|
+
|
127
|
+
# Round calc
|
128
|
+
$calc.rond
|
129
|
+
|
130
|
+
else
|
131
|
+
$result = "Memory file not found !"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
|
136
|
+
def average_load
|
137
|
+
# get average load of the past minute
|
138
|
+
|
139
|
+
$load_data = nil
|
140
|
+
|
141
|
+
if File.exist?(@@load_avarange_file)
|
142
|
+
File.open(@@load_avarange_file,"r") do |load|
|
143
|
+
$load_data = load.read
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
$load_data = $load_data.split(/ /).first.to_s
|
148
|
+
|
149
|
+
end
|
150
|
+
|
151
|
+
|
104
152
|
def top_memory_processes
|
105
153
|
# top 10 mem processes
|
106
154
|
|
data/lib/Dysnomia/version.rb
CHANGED