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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ac2a20f81e40576da5c5e45143a469c12108bc69
4
- data.tar.gz: b9163b29cc01daae093b1188908195fa17ab4bbb
3
+ metadata.gz: d8b0f3cd947bd598a67d88c30f873f75a11178bb
4
+ data.tar.gz: e4eecb7f9d309675dc7abb39309ba20f9fb5ed3c
5
5
  SHA512:
6
- metadata.gz: e2e7692a6632adb3eb5081679b7b4d3a635f50060634614ecc5c9e99b3be80884ebb88c2b19a8f76a93ad1b5553c483be7caf066bff33820954bfe2c72d66fd2
7
- data.tar.gz: 49c6e14844dedb701aad736d432ff8b33a9e844c7f289e73c88815c90f3453f56fcf2a0994c2509ecaf950b7d77da748eb0a81b26ee3e0cf94c39d00c5d05dca
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
 
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module Dysnomia
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Dysnomia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sedat ÇİFTÇİ