LoginSignup
2
2

More than 5 years have passed since last update.

EdisonでInfluxDBを使う

Last updated at Posted at 2015-07-22

前提

  • ubilinux (Debian Wheezy 7.8)
  • InfluxDB 0.8.8

InfluxDBのインストール

公式サイトのインストール手順にi386 (i686)版が無いので探した。公式なファイルは見つけられなかったので、チケットの情報を頼りにS3に置いてあるファイルを直接ダウンロードしてインストール。インストール時もpackage architecture (i686) does not match system (i386)というエラーが出るので --force-architectureを付与。

wget https://s3.amazonaws.com/influxdb/influxdb_0.8.8_i686.deb
dpkg -i --force-architecture influxdb_0.8.8_i686.deb

InfluxDBをスタートする。

/etc/init.d/influxdb start

InfluxDBは8083番ポートをバインドするのでブラウザからアクセス。

kobito.1437540135.043145.png

Pythonから書き込んでみる

InfluxDBが公開している公式のinfluxdb-pythonモジュールを使用する。

pip install influxdb
influxdb_test.py
# 先ほどインストールした32bit環境用のInfluxDBは0.8.8なので、
# influxdb08モジュールのクライアントを使用する。
from influxdb.influxdb08 import InfluxDBClient

json_body = [
    {
        "name": "cpu_load_short",
        "columns": ["time", "value"],
        "points": [
            [1382819388, 0.64]
        ]
    }
]

# 接続先を決めて書き込み
client = InfluxDBClient('127.0.0.1', 8086, 'root', 'root', 'example')
client.write_points(json_body)

# 読み込んで表示
result = client.query('select value from cpu_load_short;')
print("Result: {0}".format(result))
2
2
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
2
2