exeにコンパイルはこちら


準備するもの

・Windows用mackerelAgent
mackerel002

GOインストーラ

Git for windows






とりあえずmackerelAgentインストール
mackerel004


とりあえずで入れると
mackerel005


processor queue length
cpu
memory
disk
interface
filesystem

はシステムメトリックとしてデフォで取得。


プラグインとして用意されているもので使いたいものは使う。

中身見てみると、GOやんけ

とりあえず試すか、で


GOインストール
mackerel001

次へ次へってやっていくだけでいいので、適当に

環境変数GOROOTと
mackerel006

PATHの中にGoディレクトリは勝手に追加されている。
mackerel007


GOPATHは自分で設定。
適当にディレクトリ作って設定。
mackerel008



Git for Windowsをインストール
mackerel003

こちらもこだわりがなければ"次へ" "次へ"で



mackerelプラグイン一式落とす
go get github.com/mackerelio/mackerel-agent-plugins
mackerel009


いっぱい落ちてきたので、
とりあえずmackerel-plugin-windows-process-statsを使ってみる
mackerel010


とりあえず
直接実行
cannot find package "github.com/StackExchange/wmi"
が出た
mackerel011


足りないらしいので
落とす
go get github.com/StackExchange/wmi
mackerel012

きた
mackerel013


再実行
何も出ない。
リターンコード見てみると0なので動いてはいたっぽい
mackerel014

パラメータで渡すプロセス名に.exeは要らんかったぽい
-process bashで渡したら出てきた。
C:\Users\Administrator>go run C:\Work\GO\src\github.com\mackerelio\mackerel-agent-plugins\mackerel-plugin-windows-process-stats\main.go -process bash
mackerel015


mackerelに送るために
mackerel-agent.confに追記

[plugin.metrics.windows-process-stats]
command = "go run C:\\Work\\GO\\src\\github.com\\mackerelio\\mackerel-agent-plugins\\mackerel-plugin-windows-process-stats\\main.go -process bash  -metric-key-prefix=GithubBash"
mackerel016


Agent再起動

mackerelを見てみると
値送れてる。
mackerel017




でもWindowsServer全台にGOをインストールするかっていうと
それもどうなのってなるので、
exeにコンパイルする手順を書く