Last active
June 4, 2017 19:03
-
-
Save soudai/1519e9db370dff1264567d75bc706a2c to your computer and use it in GitHub Desktop.
yumのインストールパッケージを雑にmackerelのmetadataとして登録する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$list = explode("\n", `yum list installed`); | |
foreach ($list as $key => $val) { | |
if (empty($val)) { | |
continue; | |
} | |
$base_list = array_filter(explode(" ", $val)); | |
$json_base[$key]['name'] = array_shift($base_list); | |
$json_base[$key]['version'] = array_shift($base_list); | |
} | |
echo json_encode($json_base); | |
/** | |
add setting to/etc/mackerel-agent/mackerel-agent.conf | |
[plugin.metadata.packages] | |
command = "/usr/bin/php /usr/local/etc/mackerel/meta-rpm-packages.php" | |
get matadata sample | |
curl -H 'X-Api-Key: <API_KEY>' https://mackerel.io/api/v0/hosts/<hostID>/metadata/packages | |
**/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment