psm-ruby-stats 1.0.4 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/auto-merge.yml +31 -0
- data/.github/workflows/release.yml +1 -1
- data/.github/workflows/verify.yml +4 -1
- data/Gemfile +6 -2
- data/lib/rubystats_psm/skcript_linux.rb +41 -28
- data/lib/rubystats_psm/version.rb +1 -1
- data/psm-ruby-stats.gemspec +1 -1
- data/readme-dev.md +10 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c194154e9847bb8e0dc1b7edc30b6645e00ae8c04fda690a5c02a6a461b50b1
|
4
|
+
data.tar.gz: 19ef70063d93106351df74a777ff9ec1ade0e1701ce2d6cd81be60d5eecd29ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5e35fcc1a23234cc29e4a49197aae8661968e3fc530c2006cd51ad22c437d1d978685622d7a1ed9f0e1e9c6518f77afdabc246e8a0af4180f50771d4862845a
|
7
|
+
data.tar.gz: d2f1a41fb31e5c2ec537e86052121c602061abc70f098c1094f4e7398666a9da2cdc26176e3a410638656005b7c43ab3b4cd702786434a7d3fc7f919fa26c61e
|
@@ -0,0 +1,31 @@
|
|
1
|
+
name: Merge me!
|
2
|
+
|
3
|
+
on:
|
4
|
+
workflow_run:
|
5
|
+
types:
|
6
|
+
- completed
|
7
|
+
workflows:
|
8
|
+
- 'Verify'
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
merge-me:
|
12
|
+
name: Merge me!
|
13
|
+
runs-on: ubuntu-latest
|
14
|
+
steps:
|
15
|
+
- # It is often a desired behavior to merge only when a workflow execution
|
16
|
+
# succeeds. This can be changed as needed.
|
17
|
+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
18
|
+
name: Merge me!
|
19
|
+
uses: ridedott/merge-me-action@v2
|
20
|
+
with:
|
21
|
+
# Depending on branch protection rules, a manually populated
|
22
|
+
# `GITHUB_TOKEN_WORKAROUND` secret with permissions to push to
|
23
|
+
# a protected branch must be used. This secret can have an arbitrary
|
24
|
+
# name, as an example, this repository uses `DOTTBOTT_TOKEN`.
|
25
|
+
#
|
26
|
+
# When using a custom token, it is recommended to leave the following
|
27
|
+
# comment for other developers to be aware of the reasoning behind it:
|
28
|
+
#
|
29
|
+
# This must be used as GitHub Actions token does not support pushing
|
30
|
+
# to protected branches.
|
31
|
+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
@@ -15,7 +15,7 @@ jobs:
|
|
15
15
|
|
16
16
|
- name: Release Gem
|
17
17
|
if: contains(github.ref, 'refs/tags/v')
|
18
|
-
uses:
|
18
|
+
uses: personal-social-media/publish-rubygems-action@master
|
19
19
|
env:
|
20
20
|
GITHUB_TOKEN: ${{secrets.GH_TOKEN}}
|
21
21
|
RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
|
data/Gemfile
CHANGED
@@ -33,7 +33,7 @@ class RubyStatsPsm
|
|
33
33
|
execute_command("grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage }'").to_f
|
34
34
|
end
|
35
35
|
|
36
|
-
def
|
36
|
+
def uw_cputop
|
37
37
|
ps = `ps aux | awk '{print $11, $3}' | sort -k2nr | head -n 10`
|
38
38
|
array = []
|
39
39
|
ps.each_line do |line|
|
@@ -44,69 +44,80 @@ class RubyStatsPsm
|
|
44
44
|
end
|
45
45
|
|
46
46
|
# Show the number of TCP connections used
|
47
|
-
def
|
47
|
+
def uw_tcpused
|
48
|
+
tcp4count = nil
|
49
|
+
tcp6count = nil
|
50
|
+
|
48
51
|
if File.exist?("/proc/net/sockstat")
|
52
|
+
sockstat = nil
|
49
53
|
File.open("/proc/net/sockstat", "r") do |ipv4|
|
50
|
-
|
54
|
+
sockstat = ipv4.read
|
51
55
|
end
|
52
56
|
|
53
|
-
|
54
|
-
|
57
|
+
tcp4data = sockstat.split
|
58
|
+
tcp4count = tcp4data[5]
|
55
59
|
end
|
56
60
|
|
57
61
|
if File.exist?("/proc/net/sockstat6")
|
62
|
+
sockstat6 = nil
|
58
63
|
File.open("/proc/net/sockstat6", "r") do |ipv6|
|
59
|
-
|
64
|
+
sockstat6 = ipv6.read
|
60
65
|
end
|
61
66
|
|
62
|
-
|
63
|
-
|
67
|
+
tcp6data = sockstat6.split
|
68
|
+
tcp6count = tcp6data[2]
|
64
69
|
end
|
65
70
|
|
66
|
-
|
71
|
+
tcp4count.to_i + tcp6count.to_i
|
67
72
|
end
|
68
73
|
|
69
74
|
# Show the number of UDP connections used
|
70
|
-
def
|
75
|
+
def uw_udpused
|
76
|
+
udp4count = nil
|
77
|
+
udp6count = nil
|
78
|
+
|
71
79
|
if File.exist?("/proc/net/sockstat")
|
80
|
+
sockstat = nil
|
72
81
|
File.open("/proc/net/sockstat", "r") do |ipv4|
|
73
|
-
|
82
|
+
sockstat = ipv4.read
|
74
83
|
end
|
75
84
|
|
76
|
-
|
77
|
-
|
85
|
+
udp4data = sockstat.split
|
86
|
+
udp4count = udp4data[16]
|
78
87
|
end
|
79
88
|
|
80
89
|
if File.exist?("/proc/net/sockstat6")
|
90
|
+
sockstat6 = nil
|
81
91
|
File.open("/proc/net/sockstat6", "r") do |ipv6|
|
82
|
-
|
92
|
+
sockstat6 = ipv6.read
|
83
93
|
end
|
84
94
|
|
85
|
-
|
86
|
-
|
95
|
+
udp6data = sockstat6.split
|
96
|
+
udp6count = udp6data[5]
|
87
97
|
end
|
88
98
|
|
89
|
-
|
99
|
+
udp4count.to_i + udp6count.to_i
|
90
100
|
end
|
91
101
|
|
92
102
|
# Show the percentage of Active Memory used
|
93
|
-
def
|
103
|
+
def uw_memused
|
104
|
+
result = nil
|
94
105
|
if File.exist?("/proc/meminfo")
|
95
106
|
File.open("/proc/meminfo", "r") do |file|
|
96
|
-
|
107
|
+
result = file.read
|
97
108
|
end
|
98
109
|
end
|
99
110
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
111
|
+
memstat = result.split("\n").collect { |x| x.strip }
|
112
|
+
memtotal = memstat[0].gsub(/[^0-9]/, "")
|
113
|
+
memactive = memstat[5].gsub(/[^0-9]/, "")
|
114
|
+
memactivecalc = (memactive.to_f * 100) / memtotal.to_f
|
115
|
+
memactivecalc.round
|
105
116
|
end
|
106
117
|
|
107
118
|
# return hash of top ten proccesses by mem consumption
|
108
119
|
# example [["apache2", 12.0], ["passenger", 13.2]]
|
109
|
-
def
|
120
|
+
def uw_memtop
|
110
121
|
ps = execute_command("ps aux | awk '{print $11, $4}' | sort -k2nr | head -n 10")
|
111
122
|
array = []
|
112
123
|
ps.each_line do |line|
|
@@ -117,13 +128,15 @@ class RubyStatsPsm
|
|
117
128
|
end
|
118
129
|
|
119
130
|
# Show the average system load of the past minute
|
120
|
-
def
|
131
|
+
def uw_load
|
121
132
|
if File.exist?("/proc/loadavg")
|
133
|
+
load_data = nil
|
134
|
+
|
122
135
|
File.open("/proc/loadavg", "r") do |file|
|
123
|
-
|
136
|
+
load_data = file.read
|
124
137
|
end
|
125
138
|
|
126
|
-
|
139
|
+
load_data.split(/ /).first.to_f
|
127
140
|
end
|
128
141
|
end
|
129
142
|
|
data/psm-ruby-stats.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
-
spec.add_runtime_dependency
|
24
|
+
spec.add_runtime_dependency "usagewatch", "~> 0.0.7"
|
25
25
|
spec.add_development_dependency "rspec"
|
26
26
|
spec.add_development_dependency "rubocop-rails_config"
|
27
27
|
end
|
data/readme-dev.md
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: psm-ruby-stats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Personal Social Media
|
@@ -61,6 +61,7 @@ extensions: []
|
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
63
|
- ".github/dependabot.yml"
|
64
|
+
- ".github/workflows/auto-merge.yml"
|
64
65
|
- ".github/workflows/release.yml"
|
65
66
|
- ".github/workflows/verify.yml"
|
66
67
|
- ".gitignore"
|
@@ -78,6 +79,7 @@ files:
|
|
78
79
|
- lib/rubystats_psm/skcript_linux.rb
|
79
80
|
- lib/rubystats_psm/version.rb
|
80
81
|
- psm-ruby-stats.gemspec
|
82
|
+
- readme-dev.md
|
81
83
|
- spec/linux_spec.rb
|
82
84
|
- spec/spec_helper.rb
|
83
85
|
homepage: https://github.com/personal-social-media/ruby-stats
|
@@ -101,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
103
|
- !ruby/object:Gem::Version
|
102
104
|
version: '0'
|
103
105
|
requirements: []
|
104
|
-
rubygems_version: 3.
|
106
|
+
rubygems_version: 3.2.15
|
105
107
|
signing_key:
|
106
108
|
specification_version: 4
|
107
109
|
summary: Extended version of usagewatch_ext
|