Last active
October 6, 2016 08:36
-
-
Save chetth/87b75e7bd547ca286f6a348f8b88f821 to your computer and use it in GitHub Desktop.
Print syslog request per sec.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"gopkg.in/mcuadros/go-syslog.v2" | |
"time" | |
) | |
func check(e error) { | |
if e != nil { | |
panic(e) | |
} | |
} | |
func main() { | |
channel := make(syslog.LogPartsChannel) | |
handler := syslog.NewChannelHandler(channel) | |
server := syslog.NewServer() | |
server.SetFormat(syslog.RFC5424) | |
server.SetHandler(handler) | |
server.ListenUDP("0.0.0.0:514") | |
server.ListenTCP("0.0.0.0:514") | |
server.Boot() | |
go func(channel syslog.LogPartsChannel) { | |
i := 0 | |
for logParts := range channel { | |
fmt.Println(logParts) | |
timer2 := time.NewTimer(time.Second) | |
go func() { | |
<-timer2.C | |
fmt.Println("Req/sec = ", i) | |
i = 0 | |
}() | |
i = i + 1 | |
} | |
}(channel) | |
server.Wait() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment