PHP

Interesting PHP Metrics Libraries

Sending a metric via TCP

<?
    $conn = fsockopen("YOUR-UID.carbon.hostedgraphite.com", 2003);
    fwrite($conn, "YOUR-API-KEY.foo 1.2\n");
    fclose($conn);
?>

Sending a metric via UDP

<?
    $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
    $message = "YOUR-API-KEY.foo 1.2\n";
    socket_sendto($sock, $message, strlen($message), 0, "YOUR-UID.carbon.hostedgraphite.com", 2003);
?>

Your API key can be found on your account home page.

Sending a metric via UDP on Heroku

<?

     $fp = fsockopen('udp://YOUR-UID.carbon.hostedgraphite.com', 2003);
     fwrite($fp, "YOUR-API-KEY.foo 1.2\n");
     fclose($fp);
?>