アイデアがあれば何でもご相談ください。
あまりうまく行かなさそうなので、今日余力あれば整備します…
% brew install mackerelio/mackerel-agent/mackerel-agent
% mackerel-agent init -apikey={{APIKEY}} -conf=/usr/local/etc/mackerel-agent.conf
% brew services start mackerel-agent
このやり方であればいけます → http://blog.a-know.me/entry/2015/05/12/215236
どんな言語でも作れます。公式プラグイン集はGo。
標準出力の各行に次のフォーマットが期待されます。(Sensu互換)
{metric name}\t{metric value}\t{epoch seconds}
#!/bin/sh
echo "random.dice\t$((($RANDOM%6) + 1))\t$(date +%s)"
% mackerel-plugin-dice.sh
random.dice 3 1503107984
[plugin.metrics.dice]
command = "/path/to/mackerel-agent-dice.sh"
Mackerel独自の追加仕様。グラフ定義。
# mackerel-agent-plugin
{
"graphs": {
{graph}: {
"label": GRAPH_LABEL,
"unit": UNIT_TYPE
"metrics": [
{
"name": METRIC_NAME,
"label": METRIC_LABEL
},
...
]
},
GRAPH_NAME: ...
}
}
% MACKEREL_AGENT_PLUGIN_META=1 mackerel-plugin-uptime
# mackerel-agent-plugin
{
"graphs": {
"uptime": {
"label": "Uptime",
"unit": "float",
"metrics": [
{
"name": "seconds",
"label": "Seconds",
"type": "",
"stacked": false,
"scale": 0
}
]
}
}
}
#!/bin/sh
dice=$((($RANDOM%6) + 1))
echo "Roll a dice and get a $dice!"
case "$dice" in
[1-3]) exit 0;;
[45]) exit 1;;
"6") exit 2;;
esac
% check-dice.sh
Roll a dice and get a 6!
% echo $?
2
[plugin.checks.dice]
command = "/path/to/check-dice.sh"
[plugin.meta.packages]
command = "/path/to/packages.pl"
Last-Modified: ヘッダに最終更新日時が入っています
% curl -XGET https://mackerel.io/api/v0/hosts/
enjoy!