Skip to content

Instantly share code, notes, and snippets.

@soerface
Created January 13, 2015 23:18
Show Gist options
  • Save soerface/9314e33ef1155b4d576b to your computer and use it in GitHub Desktop.
Save soerface/9314e33ef1155b4d576b to your computer and use it in GitHub Desktop.
Flipdot usercounter
import httplib
import json
from influxdb import InfluxDBClient
SERVER = 'flipdot.org'
API = {
'status': '/spacestatus/status.json',
}
INFLUXDB_HOST = 'localhost'
INFLUXDB_PORT = 8086
INFLUXDB_USER = 'flipdot'
INFLUXDB_PASSWORD = 'XXXXXX'
INFLUXDB_DB = 'flipdot'
conn = httplib.HTTPConnection(SERVER)
conn.request('GET', API['status'])
r = conn.getresponse()
data = json.loads(r.read())
conn.close()
known_users = len(data['known_users'])
unknown_users = data['unknown_users']
all_users = known_users + unknown_users
client = InfluxDBClient(INFLUXDB_HOST, INFLUXDB_PORT, INFLUXDB_USER, INFLUXDB_PASSWORD, INFLUXDB_DB)
#client.create_database('flipdot')
client.write_points([{
'points': [[all_users, known_users, unknown_users]],
'name': 'users',
'columns': ['all_users', 'known_users', 'unknown_users']
}])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment