Mercurial > code > home > repos > homeauto
changeset 1112:03b4882517dd
audiolevels output to influxdb
Ignore-this: e5f3559928a638bb311eb70dc751ef87
darcs-hash:e419b63c2335d1dd2a5267440bf73ee9b1bf3291
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Fri, 16 Sep 2016 01:22:11 -0700 |
parents | aa70001ea0c9 |
children | 0a864b90a0b4 |
files | service/audioInputLevels/audioInputLevelsPulse.py |
diffstat | 1 files changed, 14 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/service/audioInputLevels/audioInputLevelsPulse.py Fri Sep 16 01:21:19 2016 -0700 +++ b/service/audioInputLevels/audioInputLevelsPulse.py Fri Sep 16 01:22:11 2016 -0700 @@ -1,9 +1,9 @@ # based on http://freshfoo.com/blog/pulseaudio_monitoring from __future__ import division -import socket, argparse +import socket, argparse, time from Queue import Queue from ctypes import POINTER, c_ubyte, c_void_p, c_ulong, cast -import galena +from influxdb import InfluxDBClient # From https://github.com/Valodim/python-pulseaudio from pulseaudio import lib_pulseaudio as P @@ -102,13 +102,21 @@ args = parser.parse_args() - - out = galena.Galena(host='bang') - prefix = 'system.house.audio.%s' % socket.gethostname() + def ipv6Init(self, host="localhost", port=2003): + self._addr = (host, port, 0, 0) + self._sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) + self._sock.connect(self._addr) + + influx = InfluxDBClient('bang6', 9060, 'root', 'root', 'main') + + hostname = socket.gethostname() monitor = PeakMonitor(args.source, METER_RATE) for sample in monitor: #print ' %3d %s' % (sample, '>' * sample) - out.send(prefix + ".max", sample / 128) + influx.write_points([{'measurement': 'audioLevel', + "tags": dict(stat='max', location=hostname), + "fields": {"value": sample / 128}, + "time": int(time.time())}], time_precision='s') if __name__ == '__main__': main()