細かいことはいいから proc_open で mkr コマンドを使えばいいんじゃないかな。
投げる = mkrコマンドでサービスメトリックを投げるときのコマンドが throw
<?php
$time = time();
$metoric = <<<_EOT_
metoric-name-1 {$value1} {$time}
metoric-name-2 {$value1} {$time}
_EOT_;
$cmd = 'mkr throw -s service-name ';
$descriptorspec = array(
0 => array("pipe", "r"),
1 => array("pipe", "w"),
);
$process = proc_open($cmd, $descriptorspec, $pipes);
if (is_resource($process)) {
fwrite($pipes[0], $metoric);
fclose($pipes[0]);
$output = stream_get_contents($pipes[1]);
fclose($pipes[1]);
$return_value = proc_close($process);
XXX
} else {
}
mackerel-agent もいれば batch の実行ユーザは root だし、余裕だったぜ。
※ヤンキーな実装は自己責任でお願いします。
追記
極秘情報によると、PHPクライアントは誕生間近とのことです!
github.com
時間と心の余裕があったらやりたいAPIをPRしたいという思いはある。
追記2
超極秘情報によると、その誕生間近のクライアントでのサービスメトリック投稿の事例もあるようです!!
github.com
俺は寝たい(AM1:40)
追記3
私はmkrコマンドを無理やりたたけば、API_KEYのことを考えなくてよいという利点があることにに気が付いた。
(AM1:46)