Help us understand the problem. What is going on with this article?

GetWildの信号強度を解析し、音の大きさをMackerelでグラフ化する

More than 3 years have passed since last update.

Mackerel Advent Calendar 2016の18日目です。

概要

内容

①flac2floatを使って、1分間に/tmp/soud_decode.logに値を出力させるコード(flac2float.go)を書く

package main

import (
  "io/ioutil"
  "log"
  "os"
  "strconv"
  "time"

  "github.com/sioncojp/flac2float"
)

const (
  filename = "/tmp/sound_decode.log"
)

func main() {
  decode := flac2float.New(os.Stdin, 1)
  values, err := decode.ReadSound()
  if err != nil {
    log.Fatalf("Error: %s", err)
  }
  for _, value := range values {
    ioutil.WriteFile(filename, []byte(strconv.FormatFloat(value, 'f', 12, 64)), 0644)
    time.Sleep(60 * time.Second)
  }
}

②Mackerel監視用スクリプトを書く

### 初期データ投入
$ echo 0 > /tmp/sound_decode.log

### 計測用スクリプトを書く
$ vim /tmp/get_wild_and_tough.sh

#!/bin/bash

name="GetWild"
monitor_time=`date +%s`
count=`cat /tmp/sound_decode.log`
echo -e "${name}\t${count}\t${monitor_time}"

③mackerel-agent.confを書いてreload。そのあとビルドしたコマンドを走らせる

### 書く
$ vim /etc/mackerel-agent/mackerel-agent.conf
[plugin.metrics.Playing_GetWild]
command = "/bin/bash /tmp/get_wild_and_tough.sh"

### reloadする
$ service mackerel-agent reload

### build後、走らせる
$ go build flac2float.go
$ nohup cat GET_WILD.flac | ./flac2float &

④結果

スクリーンショット 2016-12-15 1.18.54.png
* 音楽の秒数だけ足しました

Mackerelの良いところ

  • 先ほどみたいに全体を見ることもできるし、ポイント毎に細かくチェック出来るところが良いですね スクリーンショット 2016-12-15 1.34.47.png

最後に

  • なんでも可視化出来るMackerelすごい!
sion_cojp
元プロゲーマーのインフラエンジニアです。 好きなことは音楽、ギター、食べ歩き、GetWild。
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした