NAME
Proc::PidFile::Info - gather proces info from PID files
VERSION
version 0.02
SYNOPSIS
use Proc::PidFile::Info;
my $info = Proc::PidFile::Info->new(
locations => [
'/var/run',
'/my/own/rundir/'
],
info_level => 1,
);
foreach my $pidfile ( $info->pidfiles() ) {
print "Service $pidfile->{name} running with PID $pidfile->{pid}, started on " . scalar( localtime ( $pidfile->{ctime} ) ) . "\n";
}
DESCRIPTION
This module scans a list of PID file locations and/or directories containing PID files (such as /var/run
) and gathers information from the PID files it finds. The PID files must have a .pid
extension.
The name of the file (with the .pid
extension stripped) is assumed to be the name of the service or daemon that created the PID file. The creation time of the PID file is assumed to be the timestamp when the service or daemon was last (re)started. The module can also read the PID from the PID file. The information gathered is returned as an array of hashes. Each hash describes the information for a PID file and it's associated service or daemon.
ATTRIBUTES
locations
Stores the locations in which the scanner searches for PID files. PID files must have a .pid
extension.
Default value: /var/run
info_level
Specifies how much information the scanner will gather from the PID files
- level 0
-
Scans only file name and creation time. The info hashes will contain only the
name
andctime
keys. - level 1
-
Also opens each PID file and reads the PID from it. The info hashes will also contain the
pid
key, in addition to level 0 keys.
Default value: 0
autoscan
A boolean flag which causes the scanner to automatically initiate a scan after object construction.
Default value: 1
METHODS
new
Creates a new PID file scanner objects. Arguments are:
- locations
-
A list of files and directories to scan. See
locations
- info_level
-
How much detail to extract from PID files. See
info_level
- autoscan
-
If true, the scanner will perform a scan right after it is constructed. See
autoscan
scan
Scans all the locations and gathers PID file information. This method is automatically called on object initialization, if the autoscan
property is set to true.
pidfiles
Returns the information gathered from the PID files. If the autoscan
property is set to false, you must call the "scan" method to gather the information first. Depending upon the calling context a list ot an array reference is returned.
AUTHOR
Christian-Rolf Gruen <kixx@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Christian-Rolf Gruen.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.