7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

StatsDをインストールしてみた (debパッケージ編)

Last updated at Posted at 2016-01-28

StatsD

StatsDとは、Node.js上で稼働するデータ収集デーモンである。
https://github.com/etsy/statsd

StatsDは公式にdebパッケージが存在しない。今回は、debパッケージ作成をした上でインストールする手順を記す。サーバはUbuntu 14.04を使用している。

依存パッケージのインストール

debパッケージ作成に必要なコンポーネントやNode.jsをインストールする。此処から先の作業はすべてrootユーザによる作業とする。

# apt-get install npm nodejs-legacy git nodejs devscripts debhelper

StatsD取得

# mkdir ~/build
# cd ~/build

StatsDをGitHubから取得する。

# git clone https://github.com/etsy/statsd.git

debパッケージ作成

# cd statsd
# dpkg-buildpackage

以下の通り、debパッケージが出来上がる。今日時点(2016/01/28)でのバージョンは、0.7.2らしい。

# cd ../
# ls -l
total 844
drwxr-xr-x 13 root root   4096 Jan 28 13:42 statsd
-rw-r--r--  1 root root  45070 Jan 28 13:43 statsd_0.7.2_all.deb
-rw-r--r--  1 root root   1368 Jan 28 13:43 statsd_0.7.2_amd64.changes
-rw-r--r--  1 root root    494 Jan 28 13:43 statsd_0.7.2.dsc
-rw-r--r--  1 root root 801078 Jan 28 13:43 statsd_0.7.2.tar.gz

StatsDインストール

dpkgコマンドでインストールする。この際、npmコマンドで依存パッケージが一緒にインストールされる。もし、外部接続のためにProxyが必要な環境で実施するなら、事前にexport http_proxy="http://{myproxy}:{myport}"みたいな感じでProxyの設定をしておく必要がある。

# dpkg -i statsd*.deb
Selecting previously unselected package statsd.
(Reading database ... 152932 files and directories currently installed.)
Preparing to unpack statsd_0.7.2_all.deb ...
Unpacking statsd (0.7.2) ...
Setting up statsd (0.7.2) ...
npm WARN package.json statsd@0.7.2 No README data
npm http GET https://registry.npmjs.org/winser/0.1.6
npm http GET https://registry.npmjs.org/generic-pool/2.2.0
...

Upstartの設定ファイルも導入されるためserviceコマンドで起動が可能である。

# service statsd status
statsd stop/waiting
# service statsd start
statsd start/running, process 29184

設定ファイルは、/etc/statsd/localConfig.jsにある。

# cat /etc/statsd/localConfig.js
{
  graphitePort: 2003
, graphiteHost: "localhost"
, port: 8125
}

モジュールを追加する方法

debパッケージを使ってインストールした場合、node_modules/usr/share/statsd/node_modulesに配置される。これについては、このdebパッケージのpostinstから確認が可能である。
https://github.com/etsy/statsd/blob/master/debian/postinst#L7

よって、インストール後に追加でモジュールを追加する際には、このディレクトリに移動した上で、npm installコマンドを実行する。

例えば、statsd-influxdb-backendを追加する場合には、以下のようにコマンドを実行すればよい。

# cd /usr/share/statsd/node_modules
# npm install statsd-influxdb-backend
7
7
0

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
7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?