Skip to content

Instantly share code, notes, and snippets.

@videlalvaro
Created February 10, 2010 12:36

Revisions

  1. videlalvaro created this gist Feb 10, 2010.
    30 changes: 30 additions & 0 deletions graphite_index.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    <?php

    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);
    }
    }