Developing lightweight computation at the DSG edge

Commit d159cfd2 authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[monitor-ping] Write max TTL before ping RTTs



This way, nodes which are down are written just a zero
Signed-off-by: Roger Pueyo Centelles's avatarRoger Pueyo Centelles <rpueyo@ac.upc.edu>
parent f6fdab11
......@@ -144,7 +144,12 @@ func performPingChecks() {
}
pingStats := pingAddress(v.Device.Addresses[0])
saveMeasurement(v.Device.ID, pingStats.Rtts, maxTTL(pingStats.Ttls))
if (len(pingStats.Rtts) == 0) && (len(pingStats.Ttls) == 0) {
pingStats.Ttls = append(pingStats.Ttls, 0)
}
saveMeasurement(v.Device.ID, maxTTL(pingStats.Ttls), pingStats.Rtts)
}
}
......@@ -167,10 +172,10 @@ func pingAddress(IPAddress string) *ping.Statistics {
func refreshAssignationList() {
localAssign = getLocalAssignationList()
fmt.Println("Assigned devices:")
for _, v := range localAssign {
fmt.Println(v.Device.ID)
}
// fmt.Println("Assigned devices:")
// for _, v := range localAssign {
// fmt.Println(v.Device.ID)
// }
}
//Import all the monitor=>device assignations
......@@ -234,15 +239,19 @@ func maxTTL(ttls []int) int {
return max
}
func saveMeasurement(DeviceID int, rtts []time.Duration, ttl int) {
func saveMeasurement(DeviceID int, ttl int, rtts []time.Duration) {
var pingTime = time.Now().UTC().Format("2006-01-02-15-04-05")
var srtts []string
var ttlAndRtts []string
ttlAndRtts = append(ttlAndRtts, string(ttl))
//TODO: deduplicate rtts
for _, v := range rtts {
srtts = append(srtts, string(v))
ttlAndRtts = append(ttlAndRtts, string(v))
}
fmt.Println(goclidote.AntidoteAddArrayToSetInMapInBucket(fmt.Sprintf("device-%d", DeviceID), "rawping", pingTime, srtts, dbHost, dbPort))
fmt.Println(goclidote.AntidoteAddArrayToSetInMapInBucket(fmt.Sprintf("device-%d", DeviceID), "rawping", pingTime, ttlAndRtts, dbHost, dbPort))
}
func errCheck(e error, level int, message string) {
......
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