File: README.md

package info (click to toggle)
ruby-sys-proctable 1.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 396 kB
  • sloc: ruby: 3,656; makefile: 3
file content (164 lines) | stat: -rw-r--r-- 3,913 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
[![Ruby](https://github.com/djberg96/sys-proctable/actions/workflows/ruby.yml/badge.svg)](https://github.com/djberg96/sys-proctable/actions/workflows/ruby.yml)

# sys-proctable

## Description

  A Ruby interface for gathering process information.

## Prerequisites

* ffi
* rspec (development only)
* rake (development only)
* rubocop (development only)

## Supported Platforms

* Windows 2000 or later
* Linux 2.6+
* FreeBSD
* DragonflyBSD
* Solaris 8+
* OS X 10.7+
* AIX 5.3+

## Installation

```sh
gem install sys-proctable
```

For version 1.1.5 or earlier, you may need to specify a platform in some cases. For example:

```sh
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 # FreeBSD
gem install sys-proctable --platform darwin  # OS X
```

## Synopsis

```ruby
require 'sys/proctable'
include Sys

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

# Just one process
s = ProcTable.ps(pid: 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 p.pid
  # ...
end
```

## Notes

Various platforms support different options. Mostly this is to let you
skip the collection of certain bits of information in order to improve
speed and/or reduce memory. For example on Linux you can do this to
skip the collection of smaps information:

```ruby
Sys::ProcTable.ps(smaps: false)
```

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

```ruby
Sys::ProcTable.ps(host: some_host)
```

## Known Issues

### FreeBSD

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).

### Bundler

For version 1.1.5 or earlier, Bundler seems to have trouble installing the
proper gem because of the platform specific gem names. To deal with that,
run this command first:

```sh
bundle config specific_platform true
```

You should not have to do this for version 1.2.0 or later.

### 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.

### OS X

The libproc interface is used. That means you will only get list of
processes that you have access to. To get a full listing, run as root.

## Future Plans

Support for Solaris will probably be dropped in the next major release.

## Acknowledgements

This library was originally 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 the original 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

Apache-2.0

## Copyright

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

## Author

Daniel J. Berger