Skip to content

Instantly share code, notes, and snippets.

@luxifer
Forked from videlalvaro/graphite_index.php
Created September 7, 2012 13:58
Show Gist options
  • Save luxifer/3666463 to your computer and use it in GitHub Desktop.
Save luxifer/3666463 to your computer and use it in GitHub Desktop.
<?php
$start_request = microtime(true);
require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php');
$configuration = ProjectConfiguration::getApplicationConfiguration('front', 'dev', true);
sfContext::createInstance($configuration)->dispatch();
$enable_graphite = sfConfig::get('app_enable_graphite');
if($enable_graphite)
{
$fp = @fsockopen('127.0.0.1', 2003, $errno, $errstr, 1);
if($fp)
{
$out = array();
$out[] = sprintf('symfony.%s.%s.%s.memory %s %d%s',
gethostname(),
sfContext::getInstance()->getModuleName(),
sfContext::getInstance()->getActionName(),
memory_get_usage(true),
time(), "\n");
$out[] = sprintf('symfony.%s.%s.%s.requesttime %s %d%s',
gethostname(),
sfContext::getInstance()->getModuleName(),
sfContext::getInstance()->getActionName(),
microtime(true) - $start_request,
time(), "\n");
foreach($out as $o)
{
@fwrite($fp, $o);
}
@fclose($fp);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment