Developing lightweight computation at the DSG edge

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

[monitor-snmp] Save monitoring data to AntidoteDB



For devices not reachable, or not reporting data, nothing is saved.
Signed-off-by: Roger Pueyo Centelles's avatarRoger Pueyo Centelles <rpueyo@ac.upc.edu>
parent 5fe97abd
......@@ -147,10 +147,8 @@ func performPingChecks() {
if len(snmpData) > 0 {
fmt.Println(snmpData)
saveMeasurement(v.Device.ID, snmpData)
}
// saveMeasurement(v.Device.ID, maxTTL(pingStats.Ttls), pingStats.Rtts)
}
}
......@@ -318,22 +316,21 @@ func maxTTL(ttls []int) int {
return max
}
func saveMeasurement(DeviceID int, ttl int, rtts []time.Duration) {
func saveMeasurement(DeviceID int, data []SNMPInterfaceData) {
var roundTime = 60 * time.Second
var pingStart = time.Now().UTC().Truncate(roundTime)
var pingDate = pingStart.Format("2006-01-02")
var pingTime = pingStart.Format("15-04-05")
var ttlAndRtts []string
var queryStart = time.Now().UTC().Truncate(roundTime)
var queryDate = queryStart.Format("2006-01-02")
var queryTime = queryStart.Format("15-04-05")
ttlAndRtts = append(ttlAndRtts, string(ttl))
var arrayData []string
//TODO: deduplicate rtts
for _, v := range rtts {
ttlAndRtts = append(ttlAndRtts, string(v))
for _, v := range data {
arrayData = append(arrayData, v.Name, fmt.Sprintf("%d", v.RxBytes), fmt.Sprintf("%d", v.TxBytes))
}
fmt.Println(goclidote.AntidoteAddArrayToSetInMapInMapInBucket(fmt.Sprintf("device-%d", DeviceID), "rawping", pingDate, fmt.Sprint(pingTime, "-", ID), ttlAndRtts, dbHost, dbPort))
if len(arrayData) > 0 {
fmt.Println(goclidote.AntidoteAddArrayToSetInMapInMapInBucket(fmt.Sprintf("device-%d", DeviceID), "rawsnmp", queryDate, fmt.Sprint(queryTime, "-", ID), arrayData, 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