View get-alerts-list-date-range.sh
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
#!/bin/bash | |
MACKEREL_APIKEY=<YOUR_MACKEREL_APIKEY> | |
LIMIT=100 | |
DATE_FROM=$(date -d "2020-12-15 23:00:00" +%s) #取得したいアラートの開始日時 | |
DATE_TO=$(date -d "2020-12-16 00:00:00" +%s) #取得したいアラートの終了日時 | |
# ヘッダーを出力 | |
echo -e "hostid\tstatus\tmonitorId\ttype\thostId\tvalue\tmessage\treason\topenedAt\tclosedAt" |
View post-mackerel-alerts-count.sh
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
#!/bin/bash | |
MACKEREL_APIKEY=<YOUR_MACKEREL_APIKEY> | |
SERVICE_NAME="alerts-count" | |
NOW=$(date +%s) | |
ALERT_LOG_FILE="/path/to/logfile" | |
function push_mackerel_alerts_count () { | |
curl -sS \ | |
-X POST \ |
View get-alerts-list-1day.sh
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
#!/bin/bash | |
MACKEREL_APIKEY=<YOUR_MACKEREL_APIKEY> | |
LIMIT=100 | |
DATE_FROM=$(date -d '1 day ago' +%s) | |
# 一回目 | |
JSON_FIRST=$( | |
curl -GsS \ | |
-X GET \ |