Jifty::Plugin::Monitoring - Provides a framework for profiling and monitoring services
In your config.yml:
Plugins: - Monitoring: {}
By writing modules, and scheduling the running of jifty cron, repeating events can be scheduled at various frequencies. It also provides functionality for sampling and recording profiling or usage statistics from your jifty application.
jifty cron
The configuration in config.yml accepts one possible parameter, path, which should be the base class under which all monitoring classes are found. This defaults to AppName::Monitor. path may also be an array refence of classes to search under.
path
AppName::Monitor
Each class monitoring class should use Jifty::Plugin::Monitoring. This will import several functions, which allow you to write monitoring code as follows:
use Jifty::Plugin::Monitoring
use Jifty::Plugin::Monitoring; monitor users => every 30 => minutes, sub { my $monitor = shift; my $collection = AppName::Model::UserCollection->new; $collection->unlimit; data_point all => $collection->count; data_point yaks => int(rand(100)); };
Monitors must have distinct names. Time units supported by this syntax include the singular and plural forms of minute, hour, day, week, month, and year.
minute
hour
day
week
month
year
These methods are used in your monitoring classes to define monitors.
Syntactic sugar helper method, which allows you to write:
every 3 => minutes, sub { ... };
or
every qw/3 minutes/, sub { ... };
Syntactic sugar which defines a monitor. Use it in conjunction with "every":
monitor "name", every qw/3 minutes/ => sub { ... };
Records a data point, associating NAME to VALUE at the current time. CATEGORY defaults to the name of the monitor that the data point is inside of.
NAME
VALUE
CATEGORY
Returns the most recent valeu for the data point of the given NAME and CATEGORY. CATEGORY defaults to the name of the current monitor.
Uses Time::HiRes to time how long it takes the given WWW::Mechanize object MECH to retrueve the given URL. Returns the number of seconds elapsed.
MECH
URL
The following methods simply return themselves:
These are primarily used by Jifty::Plugin::Monitoring::Command::Cron; you will not need to call these in most uses of this plugin.
Looks for and loads all monitoring classes. During the loading process, the monitors defined in each class are found and stored for later reference.
A class method used to add a monitor with the given NAME and SUB, which is scheduled to be run every COUNT UNITs.
SUB
COUNT
UNIT
Looks up and returns the Jifty::Plugin::Monitoring::Model::LastRun object for this monitor; creates one if one does not exist, and sets it to the previous round time it would have run.
Monitors presumable run as superuser; thus, this method returns the application's superuser object.
Returns a hashref, with keys of name, sub, count, and units, which describe the monitor which is crrently running, if any.
name
sub
count
units
For consistency, the current concept of "now" is fixed while the monitor is running. Use this method to determine when "now" is.
For each monitor that we know of, checks to see if it is due to be run, and runs it if it is.
Attempt to determine if there are other monitoring processes running. If there are, we return false. This keeps a long-running monitor from making later jobs pile up.
On destruction, remove the lockfile.
To install Jifty, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Jifty
CPAN shell
perl -MCPAN -e shell install Jifty
For more information on module installation, please visit the detailed CPAN module installation guide.