From f0252da9b974930cf5a097de08eee1ca25226ef4 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Thu, 13 Oct 2016 22:41:35 +0200 Subject: added s5stats --- src/daq/s5proxy/src/s5proxy/stats.go | 86 ++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 src/daq/s5proxy/src/s5proxy/stats.go (limited to 'src/daq') diff --git a/src/daq/s5proxy/src/s5proxy/stats.go b/src/daq/s5proxy/src/s5proxy/stats.go new file mode 100644 index 0000000..4a9c775 --- /dev/null +++ b/src/daq/s5proxy/src/s5proxy/stats.go @@ -0,0 +1,86 @@ +// +// sfive +// +// sfive - spreadspace streaming statistics suite is a generic +// statistic collection tool for streaming server infrastuctures. +// The system collects and stores meta data like number of views +// and throughput from a number of streaming servers and stores +// it in a global data store. +// The data acquisition is designed to be generic and extensible in +// order to support different streaming software. +// sfive also contains tools and applications to filter and visualize +// live and recorded data. +// +// +// Copyright (C) 2014-2016 Christian Pointner +// Markus Grüneis +// +// This file is part of sfive. +// +// sfive is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 3 +// as published by the Free Software Foundation. +// +// sfive is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with sfive. If not, see . +// + +package main + +import ( + "encoding/json" + "os" + "time" +) + +// TODO: this is basically a copy from src/hub.... + +type StreamId struct { + ContentId string `json:"content-id"` + Format string `json:"format"` + Quality string `json:"quality"` +} + +type ClientData struct { + Ip string `json:"ip"` + UserAgent string `json:"user-agent"` + BytesSent uint `json:"bytes-sent"` +} + +type SourceData struct { + ClientCount uint `json:"client-count"` + BytesReceived uint `json:"bytes-received"` + BytesSent uint `json:"bytes-sent"` + Clients []ClientData `json:"clients,omitempty"` +} + +type DataUpdate struct { + Version uint `json:"version"` + Hostname string `json:"hostname"` + StreamId StreamId `json:"streamer-id"` + Tags []string `json:"tags,omitempty"` + StartTime time.Time `json:"start-time"` + Duration int64 `json:"duration-ms"` + Data SourceData `json:"data"` +} + +type Stats struct { + conf *Config +} + +func NewStats(conf *Config) (s *Stats, err error) { + s = &Stats{conf: conf} + return +} + +func (s *Stats) Run() (err error) { + update := DataUpdate{Version: 1, Hostname: "hugo"} + update.Tags = append(update.Tags, "hello", "world") + err = json.NewEncoder(os.Stdout).Encode(update) + return +} -- cgit v1.2.3