Developing lightweight computation at the DSG edge

Commit 206b9c54 authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[monitor-ping] Save ping measurements fo fake AntidoteDB


Signed-off-by: Roger Pueyo Centelles's avatarRoger Pueyo Centelles <rpueyo@ac.upc.edu>
parent 68294680
package main
import (
"encoding/json"
"flag"
"fmt"
"os"
......@@ -143,21 +142,10 @@ func performPingChecks() {
for _, w := range v.Device.Addresses {
fmt.Println(w)
}
//rtts := pingAddress(v.Device.Addresses[0]).Rtts
rtts := pingAddress(v.Device.Addresses[0])
fmt.Printf("%T\n", rtts)
// fmt.Println(len(rtts))
// for l, w := range rtts {
// rtts[l] = w / 1000
// }
jrtts, err := json.Marshal(rtts)
if err != nil {
panic(err)
}
fmt.Printf("%s\n", jrtts)
pingStats := pingAddress(v.Device.Addresses[0])
saveMeasurement(v.Device.ID, pingStats.Rtts, maxTTL(pingStats.Ttls))
}
}
......@@ -236,6 +224,20 @@ func startPingCheckTimer() {
}()
}
func maxTTL(ttls []int) int {
var max int
for _, v := range ttls {
if v > max {
max = v
}
}
return max
}
func saveMeasurement(DeviceID int, rtts []time.Duration, ttl int) {
goclidote.AntidoteAddItemToSetInMapInBucket("a", "b", "c", "d", dbHost, dbPort)
}
func errCheck(e error, level int, message string) {
if message == "" {
message = "Unknown error"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment