Пример #1
0
func multipleEvents(eventRPC *Outgoing.RPCInterface) {
	for i := 0; i < 3; i++ {
		var event = []byte(fmt.Sprintf(`{"hostname":"localhost-%d", "type":"ALERT", "time":%d}`, i, time.Now().Unix()))
		err := eventRPC.CreateEvent(event)
		if err != nil {
			panic(err)
		}
		time.Sleep(time.Duration(1) * time.Second)
	}
	time.Sleep(time.Duration(6) * time.Second)
	for i := 0; i < 6; i++ {
		var event = []byte(fmt.Sprintf(`{"hostname":"localhost-%d", "type":"ALERT", "time":%d}`, i, time.Now().Unix()))
		err := eventRPC.CreateEvent(event)
		if err != nil {
			panic(err)
		}
		time.Sleep(time.Duration(500) * time.Millisecond)
	}
	time.Sleep(time.Duration(10) * time.Second)
}
Пример #2
0
func delayed(eventRPC *Outgoing.RPCInterface, wait int) {
	delay := time.Duration(wait) * time.Second
	var event = []byte(`{"Hallo": "Delayed", "Start":"` + time.Now().Format(time.RFC3339) + `", "hostname":"localhost", "type":"ALERT", "time":` + fmt.Sprintf("%d", time.Now().Unix()) + `}`)
	eventRPC.CreateDelayedEvent(event, &delay)
	time.Sleep(delay * 2)
}