linux_stat 0.1.4 → 0.1.6

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
  SHA256:
3
- metadata.gz: 214a2a52170b56710d91ad64ee52dc616e6dd4075c9c03640727adbdd9814b32
4
- data.tar.gz: c7e5eef64f6849823a56a62ca75dca1b0e7555908ec12234a3ffc0d06b4bb075
3
+ metadata.gz: 5b9e6e97360a33536c048dad2ef4df57d1a7973a60c77e94fa97a8ddcdfd9339
4
+ data.tar.gz: 64e14d64fa055695b41246dd526bf7bcfb1531645fcc2b7bb72b06d5f8e9aaa4
5
5
  SHA512:
6
- metadata.gz: a5e4dd2b4e9a86c6ffd3ffdfc50663594978f40c9d94a8a9af7d3c3d828f6c3c1c31f36408826844c713f35870d434b07fe6bab57b45f755a758ffa7c7ee152c
7
- data.tar.gz: 754e223628903b9d3e241d79242ab55b79bcc6b79f2b1b64e941d98f096291f84aeac433bff104e34bcddcc40527e1aef73525228dd5cb98748f669b8fdfe2a4
6
+ metadata.gz: 82b5e2129b50d290fd566e1d07251713f635d8a8866ad096005bb5cd9b495e1701a2edf6f26e9827f46952aef331cb18fb9f3da66bd1bf23face6f6dda676eb8
7
+ data.tar.gz: 6759f1379111ba1caae25d6fc8de54f61e5b15259bc7a4c744a759074fcf89f845ba07745afe67d04ced60d22fa8d458a5de0222eac46eebd4cf40bdcaf69ebf
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # LinuxStat
2
+ ![logo](https://raw.githubusercontent.com/Souravgoswami/linux_stat/master/logo.jpg)
2
3
 
3
4
  LinuxStat lets you read statistics of a Linux system. It can show you cpu stats and usages, memory stats and usages, swap stats and usages, battery usage, bios info, kernel details, local ip, os details and parse os-release + lsb-release, etc.
4
5
 
@@ -23,22 +24,25 @@ Or install it yourself as:
23
24
  ## Usage
24
25
  ### LinuxStat::BIOS
25
26
  ```
27
+ LinuxStat::BIOS.date
28
+ => "04/10/2017"
29
+
26
30
  LinuxStat::BIOS.model
27
- => Inspiron 5567
31
+ => "Inspiron 5567"
28
32
 
29
33
  LinuxStat::BIOS.vendor
30
- => Dell Inc.
31
-
32
- LinuxStat::BIOS.date
33
- => 04/10/2017
34
+ => "Dell Inc."
34
35
 
35
36
  LinuxStat::BIOS.version
36
- => 1.1.2
37
+ => "1.1.2"
37
38
 
38
39
  ```
39
40
 
40
41
  ### LinuxStat::Battery
41
42
  ```
43
+ LinuxStat::Battery.charge
44
+ => 100.0
45
+
42
46
  LinuxStat::Battery.charging?
43
47
  => true
44
48
 
@@ -48,8 +52,11 @@ LinuxStat::Battery.discharging?
48
52
  LinuxStat::Battery.full?
49
53
  => true
50
54
 
51
- LinuxStat::Battery.status
52
- => Full
55
+ LinuxStat::Battery.manufacturer
56
+ => "Samsung SDI"
57
+
58
+ LinuxStat::Battery.model
59
+ => "DELL CYMGM77"
53
60
 
54
61
  LinuxStat::Battery.present?
55
62
  => true
@@ -57,17 +64,11 @@ LinuxStat::Battery.present?
57
64
  LinuxStat::Battery.stat
58
65
  => {:model=>"DELL CYMGM77", :manufacturer=>"Samsung SDI", :technology=>"Li-ion", :status=>"Full", :charge=>100.0, :charging=>true, :discharging=>false, :full=>true}
59
66
 
60
- LinuxStat::Battery.model
61
- => DELL CYMGM77
62
-
63
- LinuxStat::Battery.manufacturer
64
- => Samsung SDI
67
+ LinuxStat::Battery.status
68
+ => "Full"
65
69
 
66
70
  LinuxStat::Battery.technology
67
- => Li-ion
68
-
69
- LinuxStat::Battery.charge
70
- => 100.0
71
+ => "Li-ion"
71
72
 
72
73
  ```
73
74
 
@@ -76,62 +77,77 @@ LinuxStat::Battery.charge
76
77
  LinuxStat::CPU.count
77
78
  => 4
78
79
 
79
- LinuxStat::CPU.stat
80
- => {0=>3.33, 1=>0.0, 2=>0.0, 3=>0.0, 4=>12.5}
81
-
82
- LinuxStat::CPU.model
83
- => Intel(R) Core(TM) i3-6006U CPU @ 2.00GHz
84
-
85
80
  LinuxStat::CPU.cur_freq
86
- => [2000064, 2000098, 2000049, 2000091]
81
+ => [1973525, 2000029, 2000168, 2000152]
87
82
 
88
83
  LinuxStat::CPU.max_freq
89
84
  => [2000000, 2000000, 2000000, 2000000]
90
85
 
86
+ LinuxStat::CPU.model
87
+ => "Intel(R) Core(TM) i3-6006U CPU @ 2.00GHz"
88
+
89
+ LinuxStat::CPU.stat
90
+ => {0=>6.45, 1=>12.5, 2=>0.0, 3=>0.0, 4=>12.5}
91
+
92
+ LinuxStat::CPU.total_usage
93
+ => 6.67
94
+
95
+ LinuxStat::CPU.usage
96
+ => 0.0
97
+
98
+ LinuxStat::CPU.usages
99
+ => {0=>9.68, 1=>0.0, 2=>12.5, 3=>0.0, 4=>12.5}
100
+
91
101
  ```
92
102
 
93
103
  ### LinuxStat::Kernel
94
104
  ```
105
+ LinuxStat::Kernel.build_date
106
+ => 2020-10-21 01:11:20 +0000
107
+
108
+ LinuxStat::Kernel.build_user
109
+ => "souravgoswami@archlinux"
110
+
95
111
  LinuxStat::Kernel.compiler
96
112
  => [:gcc, "10.2.0"]
97
113
 
98
- LinuxStat::Kernel.string
99
- => Linux version 5.9.1-xanmod1-1 (souravgoswami@archlinux) (gcc (GCC) 10.2.0, GNU ld (GNU Binutils) 2.35.1) #1 SMP PREEMPT Wed, 21 Oct 2020 01:11:20 +0000
114
+ LinuxStat::Kernel.compiler_version
115
+ => "10.2.0"
100
116
 
101
- LinuxStat::Kernel.build_date
102
- => 2020-10-21 01:11:20 +0000
117
+ LinuxStat::Kernel.string
118
+ => "Linux version 5.9.1-xanmod1-1 (souravgoswami@archlinux) (gcc (GCC) 10.2.0, GNU ld (GNU Binutils) 2.35.1) #1 SMP PREEMPT Wed, 21 Oct 2020 01:11:20 +0000"
103
119
 
104
120
  LinuxStat::Kernel.version
105
- => 5.9.1-xanmod1-1
121
+ => "5.9.1-xanmod1-1"
106
122
 
107
123
  ```
108
124
 
109
125
  ### LinuxStat::Memory
110
126
  ```
127
+ LinuxStat::Memory.available
128
+ => 496044
129
+
111
130
  LinuxStat::Memory.percent_available
112
- => 15.52
131
+ => 12.93
132
+
133
+ LinuxStat::Memory.percent_used
134
+ => 87.07
113
135
 
114
136
  LinuxStat::Memory.stat
115
- => {:total=>3836256, :used=>3240812, :available=>595444, :percent_used=>84.48, :percent_available=>15.52}
137
+ => {:total=>3836264, :used=>3340220, :available=>496044, :percent_used=>87.07, :percent_available=>12.93}
116
138
 
117
139
  LinuxStat::Memory.total
118
- => 3836256
119
-
120
- LinuxStat::Memory.available
121
- => 595444
140
+ => 3836264
122
141
 
123
142
  LinuxStat::Memory.used
124
- => 3240812
125
-
126
- LinuxStat::Memory.percent_used
127
- => 84.48
143
+ => 3340220
128
144
 
129
145
  ```
130
146
 
131
147
  ### LinuxStat::Net
132
148
  ```
133
149
  LinuxStat::Net.ipv4_private
134
- => 192.168.0.106
150
+ => "192.168.0.106"
135
151
 
136
152
  ```
137
153
 
@@ -140,73 +156,73 @@ LinuxStat::Net.ipv4_private
140
156
  LinuxStat::OS.bits
141
157
  => 64
142
158
 
143
- LinuxStat::OS.uptime
144
- => {:hour=>10, :minute=>42, :second=>33.85}
159
+ LinuxStat::OS.distribution
160
+ => "Arch Linux"
145
161
 
146
- LinuxStat::OS.os_release
147
- => {:NAME=>"Arch Linux", :PRETTY_NAME=>"Arch Linux", :ID=>"arch", :BUILD_ID=>"rolling", :ANSI_COLOR=>"38;2;23;147;209", :HOME_URL=>"https://www.archlinux.org/", :DOCUMENTATION_URL=>"https://wiki.archlinux.org/", :SUPPORT_URL=>"https://bbs.archlinux.org/"...
162
+ LinuxStat::OS.hostname
163
+ => "archlinux"
148
164
 
149
165
  LinuxStat::OS.lsb_release
150
166
  => {:LSB_VERSION=>"1.4", :DISTRIB_ID=>"Arch", :DISTRIB_RELEASE=>"rolling", :DISTRIB_DESCRIPTION=>"Arch Linux"}
151
167
 
152
- LinuxStat::OS.hostname
153
- => archlinux
168
+ LinuxStat::OS.os_release
169
+ => {:NAME=>"Arch Linux", :PRETTY_NAME=>"Arch Linux", :ID=>"arch", :BUILD_ID=>"rolling", :ANSI_COLOR=>"38;2;23;147;209", :HOME_URL=>"https://www.archlinux.org/", :DOCUMENTATION_URL=>"https://wiki.archlinux.org/", :SUPPORT_URL=>"https://bbs.archlinux.org/"...
154
170
 
155
- LinuxStat::OS.distribution
156
- => Arch Linux
171
+ LinuxStat::OS.uptime
172
+ => {:hour=>11, :minute=>33, :second=>52.62}
157
173
 
158
174
  ```
159
175
 
160
176
  ### LinuxStat::Process
161
177
  ```
162
178
  LinuxStat::Process.count
163
- => 213
164
-
165
- LinuxStat::Process.types
166
- => {1=>:sleeping, 2=>:sleeping, 3=>:idle, 4=>:idle, 6=>:idle, 9=>:idle, 10=>:sleeping, 11=>:sleeping, 12=>:idle, 13=>:sleeping, 14=>:sleeping, 15=>:sleeping, 16=>:sleeping, 17=>:sleeping, 18=>:sleeping, 19=>:sleeping, 20=>:sleeping, 21=>:sleeping, 23=>:i...
167
-
168
- LinuxStat::Process.names
169
- => {1=>"systemd", 2=>"kthreadd", 3=>"rcu_gp", 4=>"rcu_par_gp", 6=>"kworker/0:0H-kblockd", 9=>"mm_percpu_wq", 10=>"ksoftirqd/0", 11=>"rcuc/0", 12=>"rcu_preempt", 13=>"rcub/0", 14=>"migration/0", 15=>"idle_inject/0", 16=>"cpuhp/0", 17=>"cpuhp/1", 18=>"idle...
179
+ => 212
170
180
 
171
181
  LinuxStat::Process.idle
172
- => [3, 4, 6, 9, 12, 23, 30, 37, 39, 49, 102, 103, 104, 106, 107, 108, 109, 110, 117, 118, 119, 121, 131, 134, 140, 152, 153, 168, 170, 172, 173, 177, 181, 182, 183, 184, 185, 186, 220, 225, 271, 322, 326, 329, 333, 2914, 2915, 2916, 2917, 2918, 2919, 289...
182
+ => [3, 4, 6, 9, 12, 23, 30, 37, 39, 49, 102, 103, 104, 106, 107, 108, 109, 110, 117, 118, 119, 121, 131, 134, 140, 152, 153, 170, 172, 174, 177, 179, 180, 184, 185, 186, 187, 188, 189, 227, 274, 285, 293, 316, 1918, 1919, 1920, 1921, 1922, 1923, 62565, 6...
173
183
 
174
184
  LinuxStat::Process.list
175
- => [1, 2, 3, 4, 6, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27, 28, 30, 31, 32, 33, 34, 35, 37, 38, 39, 40, 41, 42, 46, 47, 48, 49, 50, 51, 52, 102, 103, 104, 106, 107, 108, 109, 110, 112, 114, 115, 117, 118, 119, 121, 131, 134,...
185
+ => [1, 2, 3, 4, 6, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27, 28, 30, 31, 32, 33, 34, 35, 37, 38, 39, 40, 41, 42, 46, 47, 48, 49, 50, 51, 52, 102, 103, 104, 106, 107, 108, 109, 110, 111, 114, 115, 117, 118, 119, 121, 131, 134,...
186
+
187
+ LinuxStat::Process.names
188
+ => {1=>"systemd", 2=>"kthreadd", 3=>"rcu_gp", 4=>"rcu_par_gp", 6=>"kworker/0:0H", 9=>"mm_percpu_wq", 10=>"ksoftirqd/0", 11=>"rcuc/0", 12=>"rcu_preempt", 13=>"rcub/0", 14=>"migration/0", 15=>"idle_inject/0", 16=>"cpuhp/0", 17=>"cpuhp/1", 18=>"idle_inject/...
189
+
190
+ LinuxStat::Process.running
191
+ => [64200]
176
192
 
177
193
  LinuxStat::Process.sleeping
178
- => [1, 2, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 24, 25, 26, 27, 28, 31, 32, 33, 34, 35, 38, 40, 41, 42, 46, 47, 48, 50, 51, 52, 112, 114, 115, 167, 169, 187, 214, 229, 314, 316, 317, 318, 319, 324, 325, 327, 340, 361, 362, 363, 364, 372, 375, 378,...
194
+ => [1, 2, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 24, 25, 26, 27, 28, 31, 32, 33, 34, 35, 38, 40, 41, 42, 46, 47, 48, 50, 51, 52, 111, 114, 115, 169, 171, 190, 217, 228, 284, 291, 311, 322, 334, 335, 336, 346, 349, 350, 353, 362, 365, 367, 369, 382,...
195
+
196
+ LinuxStat::Process.types
197
+ => {1=>:sleeping, 2=>:sleeping, 3=>:idle, 4=>:idle, 6=>:idle, 9=>:idle, 10=>:sleeping, 11=>:sleeping, 12=>:idle, 13=>:sleeping, 14=>:sleeping, 15=>:sleeping, 16=>:sleeping, 17=>:sleeping, 18=>:sleeping, 19=>:sleeping, 20=>:sleeping, 21=>:sleeping, 23=>:i...
179
198
 
180
199
  LinuxStat::Process.zombie
181
200
  => []
182
201
 
183
- LinuxStat::Process.running
184
- => [32117]
185
-
186
202
  ```
187
203
 
188
204
  ### LinuxStat::Swap
189
205
  ```
206
+ LinuxStat::Swap.available
207
+ => 3142816
208
+
209
+ LinuxStat::Swap.list
210
+ => {"/dev/zram0"=>[:partition, 4194300, 1051484, -2]}
211
+
190
212
  LinuxStat::Swap.percent_available
191
- => 68.07
213
+ => 74.93
214
+
215
+ LinuxStat::Swap.percent_used
216
+ => 25.07
192
217
 
193
218
  LinuxStat::Swap.stat
194
- => {:total=>4194300, :used=>1339328, :available=>2854972, :percent_used=>31.93, :percent_available=>68.07}
219
+ => {:total=>4194300, :used=>1051484, :available=>3142816, :percent_used=>25.07, :percent_available=>74.93}
195
220
 
196
221
  LinuxStat::Swap.total
197
222
  => 4194300
198
223
 
199
- LinuxStat::Swap.list
200
- => {"/dev/zram0"=>[:partition, 4194300, 1339328, -2]}
201
-
202
- LinuxStat::Swap.available
203
- => 2854972
204
-
205
224
  LinuxStat::Swap.used
206
- => 1339328
207
-
208
- LinuxStat::Swap.percent_used
209
- => 31.93
225
+ => 1051484
210
226
 
211
227
  ```
212
228
 
@@ -42,7 +42,7 @@ module LinuxStat
42
42
 
43
43
  time = splitted.each_slice(8).find do |x|
44
44
  x.each(&:strip!)
45
- p Time.strptime(x.join(?\s.freeze), '%d %b %Y %H:%M:%S %z'.freeze) rescue nil
45
+ Time.strptime(x.join(?\s.freeze), '%d %b %Y %H:%M:%S %z'.freeze) rescue nil
46
46
  end
47
47
 
48
48
  time ? Time.strptime(time.join(?\s.freeze), "%d %b %Y %H:%M:%S %z") : Time.new(0)
@@ -1,3 +1,3 @@
1
1
  module LinuxStat
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  # Specify which files should be added to the gem when it is released.
20
20
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
21
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
22
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|logo)/}) }
23
23
  end
24
24
 
25
25
  spec.bindir = "exe"
@@ -31,7 +31,7 @@ LinuxStat.constants.sort.each do |c|
31
31
  dis = v.length > 253 ? v[0..250].strip + '...'.freeze : v
32
32
 
33
33
  if MARKDOWN
34
- puts "#{e}.#{meth}\n=> #{dis.inspect}"
34
+ puts "#{e}.#{meth}\n=> #{dis}"
35
35
  else
36
36
  puts "\e[1;38;2;80;80;255m#{e}.#{meth}\e[0m\n=> #{dis}"
37
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linux_stat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sourav Goswami