Skip to content

sysadmin perfmonitor

Violet edited this page Nov 12, 2010 · 5 revisions

MSAG: Monitoring and Logging Plugin and Application Performance

Melody has a built in framework for monitoring every aspect of a request's lifecycle. Throughout this process, Melody will log detailed information to a file expounding upon the actions performed, template tags processed, and so forth.

This information can be used to easily identify those aspects of your application that are taking a long time to process or run. You can then in turn use this information to optimize your plugin and eliminate bottlenecks and inefficient code.

Related Configuration Directives

Performance logging is turned on by adding a set of configuration directives to your config.cgi file. The supported directives are:

  • PerformanceLogging (boolean) - Turns performance logging on and off
  • PerformanceLoggingThreshold (float) - Sets the threshold at which events will be logged. The value is expressed in seconds and fractions of a second. Any task that takes less then the threshold will not be logged.
  • PerformanceLoggingPath (string) - Allows you to specify where you would like your log files to place on your local filesystem.
  • ProcessMemoryCommand (string) - Allows you to specify a command that can be run that will show the memory utilization of a process. For example, in Mac OS X the following command can be used (the $$ will be automatically substituted with the relevant process ID or "pid"): ProcessMemoryCommand ps $$ - o rss=

Example Configuration

PerformanceLogging 1
PerformanceLoggingPath /var/log/mt/
PerformanceLoggingThreshold 0.5

Process Memory Commands

The ProcessMemoryCommand default setting should work fine on Mac OS, Linux and Windows environments. If you are seeing errors, you may need to customize it for your environment. The default command for each environment is as follows. The command is expected to return the process memory "RSS" size, expressed in kilobytes. If this is set to "0", this command will not be issued and output in the logs.

Linux

ProcessMemoryCommand   ps - p $$ - o rss=

Mac OS X

ProcessMemoryCommand   ps $$ - o rss=

Windows

ProcessMemoryCommand    tasklist /FI 'PID eq $$' /FO TABLE /NH

Log Format

When performance logging is enabled, Melody will attempt to log as much information as it can during the life-cycle of a request. Doing so will provide valuable information regarding specific areas of the application that could benefit from performance tuning, and will allow users to more easily analyze what within their system may be contributing to poor performance.

Melody will attempt to log:

  • Information about your operating system, installed software, etc. (this information is logged only once)
  • How much memory is being utilized by the process at the beginning and at the end of the request.
  • How long it takes to process each template tag, both within the application and on the published blog.
  • The URL of the request
  • The process ID of the request for easier correlation and log analysis.

Log Rotation

Log files will be rotated automatically each day to ensure that files do not get needlessly large and to make it easier on admins to archive older log files.

Sample Output

# Operating System: darwin/9.1.0
# Platform: darwin
# Perl Version: v5.10.0
# Web Server: Apache/2.2.6 (Unix) mod_ssl/2.2.6 OpenSSL/0.9.7l DAV/2  
    PHP/5.2.4 mod_fastcgi/2.4.2
# Database: MySQL/5.0.45
# Database Library: DBI/1.601; DBD/4.005
# App Mode: CGI
[Wed Mar 5 10:12:54 2008] localhost pt-times: pid=14596, uri=[/cgi-bin/mt/index.cgi?__mode=view&_type=entry&id=2733&blog_id=4], mem_start=24327, mem_end=26428, MT::Template::build[include/header.tmpl]=0.04259, MT::Template::build[include/actions_bar.tmpl]=0.01165, MT::Template::build[include/actions_bar.tmpl]=0.01149, MT::Template::build[include/footer.tmpl]=0.01177, MT::Template::build[edit_entry.tmpl]=0.21346, MT::App::CMS::run=0.48057, Total=0.79270
[Wed Mar 5 10:13:12 2008] mtbook.local pt-times: pid=14601, uri=[/cgi-bin/mt/index.cgi?__mode=view&_type=entry&id=2734&blog_id=4], mem_start=24468, mem_end=26412, MT::Template::build[include/header.tmpl]=0.04200, MT::Template::build[include/actions_bar.tmpl]=0.01175, MT::Template::build[include/actions_bar.tmpl]=0.01143, MT::Template::build[include/footer.tmpl]=0.01069, MT::Template::build[edit_entry.tmpl]=0.15787, MT::App::CMS::run=0.46547, Total=0.72004


Questions, comments, can't find something? Let us know at our community outpost on Get Satisfaction.

Credits

  • Authors: Byrne Reese
  • Edited by: Violet Bliss Dietz
Clone this wiki locally