Пример #1
0
func main() {
	cs, err := procspy.Connections(true)
	if err != nil {
		panic(err)
	}
	fmt.Printf("TCP Connections:\n")
	for c := cs.Next(); c != nil; c = cs.Next() {
		fmt.Printf(" - %+v\n", c)
	}
}
Пример #2
0
func startMonitor(channel chan<- []byte, scanningSeconds int64) {
	for {
		cs, err := procspy.Connections(true)
		if err != nil {
			panic(err)
		}
		js, err := json.Marshal(cs)
		if err != nil {
			fmt.Println(err)
		}
		channel <- js
		time.Sleep(time.Second * time.Duration(scanningSeconds))
	}

}