LoginSignup
1

More than 5 years have passed since last update.

ZabbixとMetrin

Posted at

こちらの記事を見て、Zabbixとの連携を試してみました。
* AWS CloudWatchの汎用監視プラグインMetrinの紹介 (Mackerelも対応) - Qiita
* y13i/metrin

環境

ESXiで動作している仮想マシン。Metrinは/usr/local/binにインストール済みです。

  • CentOS 7.2
  • Zabbix 3.2.0
  • Metrin 0.0.6

Metrinの動作確認

IAMロールは使用できないので、環境変数もしくは引数で必要なアクセスキー等を設定する必要があります。

試しに、使用料金を取得してみます。

$ AWS_PROFILE=default AWS_REGION=us-east-1 \
metrin --namespace AWS/Billing --metric-name EstimatedCharges \
--statistic Maximum --start-time -21600 --period 21600 --dimension Currency:USD \
print
CloudWatch.Currency.USD.EstimatedCharges.Maximum        1.480000        111111120

$1.48が取得できました。

Zabbixへの設定

/var/lib/zabbixがzabbix agentのホームディレクトリなので、こちらにAWSの認証情報を設定しておきます。

$ tree -a /var/lib/zabbix/
/var/lib/zabbix/
└── .aws
    ├── config
    └── credentials

1 directory, 2 files

ユーザーパラメータでMetrinを実行できるよう、zabbix agentの設定を変更します。

# vi /etc/zabbix/zabbix_agentd.conf
UserParameter=metrin[*],HOME=/var/lib/zabbix metrin --region $1 --namespace $2 --metric-name $3 --statistic $4 --start-time $5 --period $6 --dimension $7 print --template '{{.Datapoint.$4}}' --last-value-only

agentを再起動後、無事zabbix経由で実行できました。

 $ zabbix_get -s 127.0.0.1 -k 'metrin[us-east-1,AWS/Billing,EstimatedCharges,Maximum,-21600,21600,Currency:USD]'
1.48

後はアイテムを作って増やすだけですね。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1