Skip to content

Commit ce51690

Browse files
committed
add: [sshd] time parsing mishap
1 parent 9379701 commit ce51690

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

logparser/sshd.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (s *SshdParser) Set(rconn1 *redis.Conn, rconn2 *redis.Conn) {
3434
// Parse parses a line of sshd log
3535
func (s *SshdParser) Parse(logline string) error {
3636
r := *s.r1
37-
re := regexp.MustCompile(`^(?P<date>[[:alpha:]]{3}\s\d{2}\s\d{2}:\d{2}:\d{2}) (?P<host>[^ ]+) sshd\[[[:alnum:]]+\]: Invalid user (?P<username>.*) from (?P<src>.*$)`)
37+
re := regexp.MustCompile(`^(?P<date>[[:alpha:]]{3} {1,2}\d{1,2}\s\d{2}:\d{2}:\d{2}) (?P<host>[^ ]+) sshd\[[[:alnum:]]+\]: Invalid user (?P<username>.*) from (?P<src>.*$)`)
3838
n1 := re.SubexpNames()
3939
r2 := re.FindAllStringSubmatch(logline, -1)[0]
4040

@@ -47,9 +47,9 @@ func (s *SshdParser) Parse(logline string) error {
4747

4848
// Assumes the system parses logs recorded during the current year
4949
md["date"] = fmt.Sprintf("%v %v", md["date"], time.Now().Year())
50-
// Make this automatic or a config parameter
50+
// TODO Make this automatic or a config parameter
5151
loc, _ := time.LoadLocation("Europe/Luxembourg")
52-
parsedTime, _ := time.ParseInLocation("Jan 02 15:04:05 2006", md["date"], loc)
52+
parsedTime, _ := time.ParseInLocation("Jan 2 15:04:05 2006", md["date"], loc)
5353
md["date"] = string(strconv.FormatInt(parsedTime.Unix(), 10))
5454

5555
// Pushing loglines in database 0
@@ -223,8 +223,6 @@ func plotStats(s *SshdParser, v string) error {
223223
}
224224

225225
stype := strings.Split(v, ":")
226-
fmt.Println(stype[0])
227-
fmt.Println(stype[1])
228226
switch stype[1] {
229227
case "statsusername":
230228
p.Title.Text = "Usernames"

0 commit comments

Comments
 (0)