From 77b07e32ecbb56d8c6c484b4c279c9670de1ab09 Mon Sep 17 00:00:00 2001 From: battilo Date: Tue, 27 Nov 2018 22:11:22 +0100 Subject: [PATCH] remove go --- UnitCSVReceiver.go | 65 ---------------------------------------------- 1 file changed, 65 deletions(-) delete mode 100644 UnitCSVReceiver.go diff --git a/UnitCSVReceiver.go b/UnitCSVReceiver.go deleted file mode 100644 index eef0cc4..0000000 --- a/UnitCSVReceiver.go +++ /dev/null @@ -1,65 +0,0 @@ -package main - -import ( - "flag" - "fmt" - "os" - "path" - "strings" - "time" -) - -import "github.com/hpcloud/tail" - -const rectest string = "UPLOAD" - -type FtpStr struct { - wday string - month string - day string - time string - year string - pid string - user string - /*res string - act string - tromt string - fromip string - fname string - fdim string - txspeed string*/ -} - -func getTimestamp(tsfmt string) string { - t := time.Now() - f := "%04d%02d%02d%02d%02d%02d" - if tsfmt == "log" { - f = "%04d/%02d/%02d %02d:%02d:%02d" - } - return fmt.Sprintf(f, t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second()) -} - -func MySplit(r rune) bool { - return r == '[' || r == ']' || r == ' ' || r == '"' || r == ',' -} - -func main() { - pgm := os.Args[0] - filePtr := flag.String("file", "/var/log/vsftpd.log", "ftp log file") - //userPtr := flag.String("user", "asega", "ftp sender user") - flag.Parse() - fmt.Println(getTimestamp("log"), ">>", path.Base(pgm)) - fmt.Println(getTimestamp("log"), ">>", path.Dir(pgm)) - fmt.Println(getTimestamp("log"), ">>", *filePtr) - - t, _ := tail.TailFile(*filePtr, tail.Config{Follow: true}) - for line := range t.Lines { - ftpfield := strings.FieldsFunc(line.Text, MySplit) - ftp := FtpStr{ftpfield[0], ftpfield[1], ftpfield[2], ftpfield[3], ftpfield[4], ftpfield[6], ftpfield[7]} - //ftpfield[10], ftpfield[11], ftpfield[12], ftpfield[13], ftpfield[14], ftpfield[15]} - if ftp.user == "asega" && ftp.{ - fmt.Printf("%q\n", ftpfield) - } - } - -}