No commit activity in last 3 years
No release in over 3 years
Process query language (based on plucky)
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 0
 Project Readme

Process Query Language

PQL is a query language for processes running on a system. The syntax is closely related to the one used in MongoDB. This is because at heart, PQL uses Plucky. But instead of sending the queries to a MongoDB server, they are intercepted and processed by PQL.

PQL extends the Process class with four new methods:

  • find - find a process by PID
  • where - find processes which match a query
  • remove - remove (kill) processes
  • count - count processes

These where method returns a Plucky::Query object. This object can be used to further refine the query by chaining additional methods. Consult the Plucky documentation to see which methods are available.

Supported fields

There is a limited number of fields which can be used in queries. The following fields are supported:

:pid, :rss, :command

The following operators are supported

gt, gte, lt, lte, in, nin

Use of an unknown field or unknown operator will raise an exception.

Example

This will print the number of unicorn rails workers which use more than 20MB of RSS:

require 'rubygems'
require 'process-query-language'

query = Process.where(:rss.gt => 20_000_000)
query.where(:command => /unicorn_rails.worker/)
puts query.count

License

Copyright (c) 2010 by Tomas "wereHamster" Carnecky (tomas.carnecky@gmail.com)