GithubHelp home page GithubHelp logo

zirni / sys-proctable Goto Github PK

View Code? Open in Web Editor NEW

This project forked from djberg96/sys-proctable

0.0 2.0 0.0 124 KB

A Ruby interface for gathering process information on your operating system

Ruby 74.35% C 25.65%

sys-proctable's Introduction

sys-proctable

A Ruby interface for gathering process information.

Prerequisites

  • Test::Unit 2.x (development only)

Supported Platforms

  • Windows 2000 or later
  • Linux 2.6+
  • BSD (various flavors)
  • Solaris 8+
  • HP-UX 10+
  • OS X 10.4+

Installation

gem install sys-proctable

You may need to specify a platform in some cases. For example:

gem install sys-proctable --platform mswin32 # Windows gem install sys-proctable --platform sunos # Solaris gem install sys-proctable --platform linux # Linux gem install sys-proctable --platform freebsd # BSD (any flavor)

Synopsis

  require 'sys/proctable'
  include Sys

  # Everything
  ProcTable.ps{ |p|
    puts p.pid.to_s
    puts p.comm
    # ...
  }

  # Just one process
  s = ProcTable.ps(2123)
  puts s.pid.to_s
  puts s.comm
  # ...

  # Return the results as an array of ProcTableStructs
  a = ProcTable.ps
  a.each do |p|
    puts a.pid
    # ...
  end

Notes

Windows users may pass a host name as a second argument to get process information from a different host. This relies on the WMI service running.

Known Issues

BSD

A kvm interface is used. That means the owner of the process using the sys-proctable library needs to be a member of the kvm group (or root).

Solaris

The cmdline member on Solaris is limited to 80 characters unless you (or your program) own the process. This is a Solaris design flaw/feature.

Thread Safety

I am not currently using a thread-safe version of readdir() for versions of this library that use C. I am not especially concerned about it either. If you are trying to read information out of /proc from different threads at the same time there is something seriously wrong with your code logic. Using readdir_r() still won't solve all potential thread safety issues anyway.

Future Plans

Research has indicated that the kvm approach is less favored than a sysctl approach on BSD variants. I will try to add this interface in a future release.

Acknowledgements

This library is largely based on the Perl module Proc::ProcessTable by Dan Urist. Many ideas, as well as large chunks of code, were taken from his work. So, a big THANK YOU goes out to Dan Urist.

A big thanks also goes out to Mike Hall who was very helpful with ideas, logic and testing.

Thanks also go to Sean Chittenden for providing an account on one of his FreeBSD machines. This is how the FreeBSD support was (initially) added.

Thanks go to James Hranicky for providing a patch that grabs name, eid, euid, gid and guid info in the Linux version, along with some general debugging help.

Thanks go to David Felstead for the original OS X code. Thanks also go to Matthias Zirnstein for adding cmdline support for OS X.

Finally I'd like to thank all the folks who have submitted bug reports and/or patches.

Help Wanted

I do not have access to all platforms. If your platform is not supported then you will need to either submit a patch or give me a remote account on a box with a compiler so that I can write the code.

More documentation

See the documentation under the 'doc' directory for more information, including platform specific notes and issues.

License

Artistic 2.0

Copyright

(C) 2003-2012 Daniel J. Berger All Rights Reserved.

Author

Daniel J. Berger

sys-proctable's People

Contributors

djberg96 avatar jc00ke avatar rcunning avatar zirni avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.