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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3288e4d96c533465c3a127d74095537ac91768d13fe0766036b986616444ab72
4
- data.tar.gz: 2885e7171d30d6d2ac76cfd0e5aaebaf557fc355ffc6d7d22d3a676c7708dfcb
3
+ metadata.gz: 5c194154e9847bb8e0dc1b7edc30b6645e00ae8c04fda690a5c02a6a461b50b1
4
+ data.tar.gz: 19ef70063d93106351df74a777ff9ec1ade0e1701ce2d6cd81be60d5eecd29ca
5
5
  SHA512:
6
- metadata.gz: b0d51bb9aeb128a4442710159b437c84bed4e4fef46803bab463c2820d493222fef1a43d1b7168a516432dc766bee60335264925da2afaed64a69c6fc9d6e470
7
- data.tar.gz: 50ae5c94926d2d6aad54aa603240b8c61c14b4081d17acb0b2d2500d06654d4bd0566f07332f273a9970231bcef6ec66fb30b2feb41b8a1d34ee13f4b9c2090b
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: cadwallion/publish-rubygems-action@master
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}}
@@ -49,4 +49,7 @@ jobs:
49
49
  bundle clean --force
50
50
  - name: Run tests
51
51
  run: |
52
- bundle exec rspec --profile
52
+ bundle exec rspec --profile
53
+ - name: Run security checks
54
+ run: |
55
+ bundle exec bundler-audit --update
data/Gemfile CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rubocop-rails_config"
6
5
  gem "usagewatch", "~> 0.0.7"
7
- gem "rspec"
6
+
7
+ group :development, :test do
8
+ gem "rspec"
9
+ gem "bundler-audit"
10
+ gem "rubocop-rails_config"
11
+ end
@@ -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 self.uw_cputop
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 self.uw_tcpused
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
- @sockstat = ipv4.read
54
+ sockstat = ipv4.read
51
55
  end
52
56
 
53
- @tcp4data = @sockstat.split
54
- @tcp4count = @tcp4data[5]
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
- @sockstat6 = ipv6.read
64
+ sockstat6 = ipv6.read
60
65
  end
61
66
 
62
- @tcp6data = @sockstat6.split
63
- @tcp6count = @tcp6data[2]
67
+ tcp6data = sockstat6.split
68
+ tcp6count = tcp6data[2]
64
69
  end
65
70
 
66
- @totaltcpused = @tcp4count.to_i + @tcp6count.to_i
71
+ tcp4count.to_i + tcp6count.to_i
67
72
  end
68
73
 
69
74
  # Show the number of UDP connections used
70
- def self.uw_udpused
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
- @sockstat = ipv4.read
82
+ sockstat = ipv4.read
74
83
  end
75
84
 
76
- @udp4data = @sockstat.split
77
- @udp4count = @udp4data[16]
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
- @sockstat6 = ipv6.read
92
+ sockstat6 = ipv6.read
83
93
  end
84
94
 
85
- @udp6data = @sockstat6.split
86
- @udp6count = @udp6data[5]
95
+ udp6data = sockstat6.split
96
+ udp6count = udp6data[5]
87
97
  end
88
98
 
89
- @totaludpused = @udp4count.to_i + @udp6count.to_i
99
+ udp4count.to_i + udp6count.to_i
90
100
  end
91
101
 
92
102
  # Show the percentage of Active Memory used
93
- def self.uw_memused
103
+ def uw_memused
104
+ result = nil
94
105
  if File.exist?("/proc/meminfo")
95
106
  File.open("/proc/meminfo", "r") do |file|
96
- @result = file.read
107
+ result = file.read
97
108
  end
98
109
  end
99
110
 
100
- @memstat = @result.split("\n").collect { |x| x.strip }
101
- @memtotal = @memstat[0].gsub(/[^0-9]/, "")
102
- @memactive = @memstat[5].gsub(/[^0-9]/, "")
103
- @memactivecalc = (@memactive.to_f * 100) / @memtotal.to_f
104
- @memusagepercentage = @memactivecalc.round
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 self.uw_memtop
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 self.uw_load
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
- @loaddata = file.read
136
+ load_data = file.read
124
137
  end
125
138
 
126
- @load = @loaddata.split(/ /).first.to_f
139
+ load_data.split(/ /).first.to_f
127
140
  end
128
141
  end
129
142
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class RubyStatsPsm
4
- VERSION = "1.0.4"
4
+ VERSION = "1.1.0"
5
5
  OS = RUBY_PLATFORM
6
6
  end
@@ -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("usagewatch", "~> 0.0.7")
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
@@ -0,0 +1,10 @@
1
+ Enable push tags automatically
2
+ ```bash
3
+ git config --global push.followTags true
4
+ ```
5
+
6
+ How to bump version:
7
+
8
+ ```bash
9
+ bump patch -m "message" --tag
10
+ ```
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
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.0.3
106
+ rubygems_version: 3.2.15
105
107
  signing_key:
106
108
  specification_version: 4
107
109
  summary: Extended version of usagewatch_ext