process-metrics 0.2.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - checksums.yaml.gz.sig +0 -0
 - data/bin/process-metrics +1 -1
 - data/lib/process/metrics/command/summary.rb +51 -46
 - data/lib/process/metrics/command/top.rb +11 -26
 - data/lib/process/metrics/command.rb +5 -20
 - data/lib/process/metrics/general.rb +68 -67
 - data/lib/process/metrics/memory/darwin.rb +100 -0
 - data/lib/process/metrics/memory/linux.rb +98 -0
 - data/lib/process/metrics/memory.rb +27 -70
 - data/lib/process/metrics/version.rb +3 -20
 - data/lib/process/metrics.rb +4 -19
 - data/license.md +22 -0
 - data/readme.md +31 -0
 - data.tar.gz.sig +0 -0
 - metadata +48 -68
 - metadata.gz.sig +2 -0
 - data/.gitignore +0 -14
 - data/.rspec +0 -3
 - data/.travis.yml +0 -22
 - data/Gemfile +0 -4
 - data/README.md +0 -184
 - data/Rakefile +0 -6
 - data/command-line.png +0 -0
 - data/process-metrics.gemspec +0 -33
 
    
        data/README.md
    DELETED
    
    | 
         @@ -1,184 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # Process::Metrics
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            Extract performance and memory metrics from running processes.
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            [](https://travis-ci.com/socketry/process-metrics)
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
            ## Installation
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
            To add it to your current project:
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
            	bundle add process-metrics
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
            ## Usage
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
            Memory is measured in kilobytes and time is measured in seconds.
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
            ### Command Line
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
            You can use the `process-metrics` command line to print data about a running process and it's children:
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
            
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
            ### Capturing for Specific Process
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
            You can capture the metrics for a single process:
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
            ```ruby
         
     | 
| 
       28 
     | 
    
         
            -
            #!/usr/bin/env ruby
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
            require 'process/metrics'
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
            metrics = Process::Metrics.capture(pid: Process.pid)
         
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
            pp metrics
         
     | 
| 
       35 
     | 
    
         
            -
            # [{:pid=>282195,
         
     | 
| 
       36 
     | 
    
         
            -
            #   :ppid=>230572,
         
     | 
| 
       37 
     | 
    
         
            -
            #   :pgid=>282195,
         
     | 
| 
       38 
     | 
    
         
            -
            #   :pcpu=>0.0,
         
     | 
| 
       39 
     | 
    
         
            -
            #   :time=>0,
         
     | 
| 
       40 
     | 
    
         
            -
            #   :vsz=>78800,
         
     | 
| 
       41 
     | 
    
         
            -
            #   :rss=>14360,
         
     | 
| 
       42 
     | 
    
         
            -
            #   :etime=>0,
         
     | 
| 
       43 
     | 
    
         
            -
            #   :command=>"ruby /tmp/6b35f421-4595-45d6-b444-754a50636daf",
         
     | 
| 
       44 
     | 
    
         
            -
            #   :memory=>
         
     | 
| 
       45 
     | 
    
         
            -
            #    {:total=>78804,
         
     | 
| 
       46 
     | 
    
         
            -
            #     :rss=>14600,
         
     | 
| 
       47 
     | 
    
         
            -
            #     :pss=>9208,
         
     | 
| 
       48 
     | 
    
         
            -
            #     :shared_clean=>5728,
         
     | 
| 
       49 
     | 
    
         
            -
            #     :shared_dirty=>0,
         
     | 
| 
       50 
     | 
    
         
            -
            #     :private_clean=>16,
         
     | 
| 
       51 
     | 
    
         
            -
            #     :private_dirty=>8856,
         
     | 
| 
       52 
     | 
    
         
            -
            #     :referenced=>14600,
         
     | 
| 
       53 
     | 
    
         
            -
            #     :anonymous=>8856,
         
     | 
| 
       54 
     | 
    
         
            -
            #     :swap=>0,
         
     | 
| 
       55 
     | 
    
         
            -
            #     :swap_pss=>0,
         
     | 
| 
       56 
     | 
    
         
            -
            #     :maps=>150}}]
         
     | 
| 
       57 
     | 
    
         
            -
            ```
         
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
            ### Capturing for Process Hierarchy
         
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
            You can capture the metrics for a process and all it's children:
         
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
            ```ruby
         
     | 
| 
       64 
     | 
    
         
            -
            #!/usr/bin/env ruby
         
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
            require 'process/metrics'
         
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
            ppid = ENV["PPID"].to_i
         
     | 
| 
       69 
     | 
    
         
            -
            metrics = Process::Metrics.capture(pid: ppid, ppid: ppid)
         
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
            pp metrics
         
     | 
| 
       72 
     | 
    
         
            -
            # [{:pid=>68536,
         
     | 
| 
       73 
     | 
    
         
            -
            #   :ppid=>46295,
         
     | 
| 
       74 
     | 
    
         
            -
            #   :pgid=>68536,
         
     | 
| 
       75 
     | 
    
         
            -
            #   :pcpu=>0.0,
         
     | 
| 
       76 
     | 
    
         
            -
            #   :time=>0,
         
     | 
| 
       77 
     | 
    
         
            -
            #   :vsz=>94516,
         
     | 
| 
       78 
     | 
    
         
            -
            #   :rss=>29688,
         
     | 
| 
       79 
     | 
    
         
            -
            #   :etime=>41057,
         
     | 
| 
       80 
     | 
    
         
            -
            #   :command=>
         
     | 
| 
       81 
     | 
    
         
            -
            #    "/home/samuel/.rbenv/versions/2.7.0/bin/ruby /home/samuel/.rbenv/versions/2.7.0/bin/falcon-host ./falcon.rb",
         
     | 
| 
       82 
     | 
    
         
            -
            #   :memory=>
         
     | 
| 
       83 
     | 
    
         
            -
            #    {:total=>94520,
         
     | 
| 
       84 
     | 
    
         
            -
            #     :rss=>29696,
         
     | 
| 
       85 
     | 
    
         
            -
            #     :pss=>8912,
         
     | 
| 
       86 
     | 
    
         
            -
            #     :shared_clean=>9528,
         
     | 
| 
       87 
     | 
    
         
            -
            #     :shared_dirty=>14588,
         
     | 
| 
       88 
     | 
    
         
            -
            #     :private_clean=>924,
         
     | 
| 
       89 
     | 
    
         
            -
            #     :private_dirty=>4656,
         
     | 
| 
       90 
     | 
    
         
            -
            #     :referenced=>29696,
         
     | 
| 
       91 
     | 
    
         
            -
            #     :anonymous=>19244,
         
     | 
| 
       92 
     | 
    
         
            -
            #     :swap=>0,
         
     | 
| 
       93 
     | 
    
         
            -
            #     :swap_pss=>0,
         
     | 
| 
       94 
     | 
    
         
            -
            #     :maps=>294}},
         
     | 
| 
       95 
     | 
    
         
            -
            #  {:pid=>68558,
         
     | 
| 
       96 
     | 
    
         
            -
            #   :ppid=>68536,
         
     | 
| 
       97 
     | 
    
         
            -
            #   :pgid=>68558,
         
     | 
| 
       98 
     | 
    
         
            -
            #   :pcpu=>0.0,
         
     | 
| 
       99 
     | 
    
         
            -
            #   :time=>0,
         
     | 
| 
       100 
     | 
    
         
            -
            #   :vsz=>94516,
         
     | 
| 
       101 
     | 
    
         
            -
            #   :rss=>23612,
         
     | 
| 
       102 
     | 
    
         
            -
            #   :etime=>41057,
         
     | 
| 
       103 
     | 
    
         
            -
            #   :command=>"supervisor",
         
     | 
| 
       104 
     | 
    
         
            -
            #   :memory=>
         
     | 
| 
       105 
     | 
    
         
            -
            #    {:total=>94520,
         
     | 
| 
       106 
     | 
    
         
            -
            #     :rss=>23612,
         
     | 
| 
       107 
     | 
    
         
            -
            #     :pss=>7551,
         
     | 
| 
       108 
     | 
    
         
            -
            #     :shared_clean=>4416,
         
     | 
| 
       109 
     | 
    
         
            -
            #     :shared_dirty=>14448,
         
     | 
| 
       110 
     | 
    
         
            -
            #     :private_clean=>0,
         
     | 
| 
       111 
     | 
    
         
            -
            #     :private_dirty=>4748,
         
     | 
| 
       112 
     | 
    
         
            -
            #     :referenced=>11184,
         
     | 
| 
       113 
     | 
    
         
            -
            #     :anonymous=>19196,
         
     | 
| 
       114 
     | 
    
         
            -
            #     :swap=>0,
         
     | 
| 
       115 
     | 
    
         
            -
            #     :swap_pss=>0,
         
     | 
| 
       116 
     | 
    
         
            -
            #     :maps=>294}},
         
     | 
| 
       117 
     | 
    
         
            -
            #  {:pid=>68559,
         
     | 
| 
       118 
     | 
    
         
            -
            #   :ppid=>68536,
         
     | 
| 
       119 
     | 
    
         
            -
            #   :pgid=>68558,
         
     | 
| 
       120 
     | 
    
         
            -
            #   :pcpu=>0.0,
         
     | 
| 
       121 
     | 
    
         
            -
            #   :time=>0,
         
     | 
| 
       122 
     | 
    
         
            -
            #   :vsz=>95000,
         
     | 
| 
       123 
     | 
    
         
            -
            #   :rss=>25136,
         
     | 
| 
       124 
     | 
    
         
            -
            #   :etime=>41057,
         
     | 
| 
       125 
     | 
    
         
            -
            #   :command=>"Falcon Host for hello.localhost",
         
     | 
| 
       126 
     | 
    
         
            -
            #   :memory=>
         
     | 
| 
       127 
     | 
    
         
            -
            #    {:total=>95004,
         
     | 
| 
       128 
     | 
    
         
            -
            #     :rss=>25136,
         
     | 
| 
       129 
     | 
    
         
            -
            #     :pss=>9308,
         
     | 
| 
       130 
     | 
    
         
            -
            #     :shared_clean=>5504,
         
     | 
| 
       131 
     | 
    
         
            -
            #     :shared_dirty=>11784,
         
     | 
| 
       132 
     | 
    
         
            -
            #     :private_clean=>0,
         
     | 
| 
       133 
     | 
    
         
            -
            #     :private_dirty=>7848,
         
     | 
| 
       134 
     | 
    
         
            -
            #     :referenced=>17596,
         
     | 
| 
       135 
     | 
    
         
            -
            #     :anonymous=>19632,
         
     | 
| 
       136 
     | 
    
         
            -
            #     :swap=>0,
         
     | 
| 
       137 
     | 
    
         
            -
            #     :swap_pss=>0,
         
     | 
| 
       138 
     | 
    
         
            -
            #     :maps=>295}},
         
     | 
| 
       139 
     | 
    
         
            -
            # ... snip ...
         
     | 
| 
       140 
     | 
    
         
            -
            ```
         
     | 
| 
       141 
     | 
    
         
            -
             
     | 
| 
       142 
     | 
    
         
            -
            ### Metrics
         
     | 
| 
       143 
     | 
    
         
            -
             
     | 
| 
       144 
     | 
    
         
            -
            On some platforms (currently only Linux), additional memory metrics are captured.
         
     | 
| 
       145 
     | 
    
         
            -
             
     | 
| 
       146 
     | 
    
         
            -
            #### Proportional Set Size
         
     | 
| 
       147 
     | 
    
         
            -
             
     | 
| 
       148 
     | 
    
         
            -
            The total private memory usage + shared memory usage divided by the number of processes sharing said data.
         
     | 
| 
       149 
     | 
    
         
            -
             
     | 
| 
       150 
     | 
    
         
            -
            #### Unique Set Size
         
     | 
| 
       151 
     | 
    
         
            -
             
     | 
| 
       152 
     | 
    
         
            -
            The total private memory usage.
         
     | 
| 
       153 
     | 
    
         
            -
             
     | 
| 
       154 
     | 
    
         
            -
            ## Contributing
         
     | 
| 
       155 
     | 
    
         
            -
             
     | 
| 
       156 
     | 
    
         
            -
            1. Fork it
         
     | 
| 
       157 
     | 
    
         
            -
            2. Create your feature branch (`git checkout -b my-new-feature`)
         
     | 
| 
       158 
     | 
    
         
            -
            3. Commit your changes (`git commit -am 'Add some feature'`)
         
     | 
| 
       159 
     | 
    
         
            -
            4. Push to the branch (`git push origin my-new-feature`)
         
     | 
| 
       160 
     | 
    
         
            -
            5. Create new Pull Request
         
     | 
| 
       161 
     | 
    
         
            -
             
     | 
| 
       162 
     | 
    
         
            -
            ## License
         
     | 
| 
       163 
     | 
    
         
            -
             
     | 
| 
       164 
     | 
    
         
            -
            Released under the MIT license.
         
     | 
| 
       165 
     | 
    
         
            -
             
     | 
| 
       166 
     | 
    
         
            -
            Copyright, 2019, by [Samuel G. D. Williams](https://www.codeotaku.com).
         
     | 
| 
       167 
     | 
    
         
            -
             
     | 
| 
       168 
     | 
    
         
            -
            Permission is hereby granted, free of charge, to any person obtaining a copy
         
     | 
| 
       169 
     | 
    
         
            -
            of this software and associated documentation files (the "Software"), to deal
         
     | 
| 
       170 
     | 
    
         
            -
            in the Software without restriction, including without limitation the rights
         
     | 
| 
       171 
     | 
    
         
            -
            to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         
     | 
| 
       172 
     | 
    
         
            -
            copies of the Software, and to permit persons to whom the Software is
         
     | 
| 
       173 
     | 
    
         
            -
            furnished to do so, subject to the following conditions:
         
     | 
| 
       174 
     | 
    
         
            -
             
     | 
| 
       175 
     | 
    
         
            -
            The above copyright notice and this permission notice shall be included in
         
     | 
| 
       176 
     | 
    
         
            -
            all copies or substantial portions of the Software.
         
     | 
| 
       177 
     | 
    
         
            -
             
     | 
| 
       178 
     | 
    
         
            -
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         
     | 
| 
       179 
     | 
    
         
            -
            IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         
     | 
| 
       180 
     | 
    
         
            -
            FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         
     | 
| 
       181 
     | 
    
         
            -
            AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         
     | 
| 
       182 
     | 
    
         
            -
            LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         
     | 
| 
       183 
     | 
    
         
            -
            OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
         
     | 
| 
       184 
     | 
    
         
            -
            THE SOFTWARE.
         
     | 
    
        data/Rakefile
    DELETED
    
    
    
        data/command-line.png
    DELETED
    
    | 
         Binary file 
     | 
    
        data/process-metrics.gemspec
    DELETED
    
    | 
         @@ -1,33 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require_relative 'lib/process/metrics/version'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            Gem::Specification.new do |spec|
         
     | 
| 
       4 
     | 
    
         
            -
            	spec.name = "process-metrics"
         
     | 
| 
       5 
     | 
    
         
            -
            	spec.version = Process::Metrics::VERSION
         
     | 
| 
       6 
     | 
    
         
            -
            	spec.authors = ["Samuel Williams"]
         
     | 
| 
       7 
     | 
    
         
            -
            	spec.email = ["samuel.williams@oriontransfer.co.nz"]
         
     | 
| 
       8 
     | 
    
         
            -
            	
         
     | 
| 
       9 
     | 
    
         
            -
            	spec.summary = "Provide detailed OS-specific process metrics."
         
     | 
| 
       10 
     | 
    
         
            -
            	spec.homepage = "https://github.com/socketry/process-metrics"
         
     | 
| 
       11 
     | 
    
         
            -
            	spec.license = "MIT"
         
     | 
| 
       12 
     | 
    
         
            -
            	
         
     | 
| 
       13 
     | 
    
         
            -
            	spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
         
     | 
| 
       14 
     | 
    
         
            -
            	
         
     | 
| 
       15 
     | 
    
         
            -
            	spec.metadata["funding_uri"] = "https://github.com/sponsors/ioquatix"
         
     | 
| 
       16 
     | 
    
         
            -
            	
         
     | 
| 
       17 
     | 
    
         
            -
            	# Specify which files should be added to the gem when it is released.
         
     | 
| 
       18 
     | 
    
         
            -
            	# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
         
     | 
| 
       19 
     | 
    
         
            -
            	spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
         
     | 
| 
       20 
     | 
    
         
            -
            		`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
         
     | 
| 
       21 
     | 
    
         
            -
            	end
         
     | 
| 
       22 
     | 
    
         
            -
            	
         
     | 
| 
       23 
     | 
    
         
            -
            	spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
         
     | 
| 
       24 
     | 
    
         
            -
            	spec.require_paths = ["lib"]
         
     | 
| 
       25 
     | 
    
         
            -
            	
         
     | 
| 
       26 
     | 
    
         
            -
            	spec.add_dependency "console", "~> 1.8"
         
     | 
| 
       27 
     | 
    
         
            -
            	spec.add_dependency "samovar", "~> 2.1"
         
     | 
| 
       28 
     | 
    
         
            -
            	
         
     | 
| 
       29 
     | 
    
         
            -
            	spec.add_development_dependency "covered"
         
     | 
| 
       30 
     | 
    
         
            -
            	spec.add_development_dependency "bundler"
         
     | 
| 
       31 
     | 
    
         
            -
            	spec.add_development_dependency "rake", "~> 12.0"
         
     | 
| 
       32 
     | 
    
         
            -
            	spec.add_development_dependency "rspec", "~> 3.8"
         
     | 
| 
       33 
     | 
    
         
            -
            end
         
     |