2015-11-20 17:11:36 +01:00
|
|
|
// options
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
2015-11-26 09:19:16 +01:00
|
|
|
// "gopkg.in/mgo.v2"
|
2015-11-20 17:11:36 +01:00
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
"path"
|
|
|
|
"path/filepath"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Options struct {
|
|
|
|
MongoSrc string
|
|
|
|
MongoDst string
|
|
|
|
StartDate string
|
|
|
|
Duration time.Duration
|
|
|
|
Interval time.Duration
|
|
|
|
LogFile string
|
2016-02-19 10:48:55 +01:00
|
|
|
Influxdb string
|
|
|
|
Hostname string
|
2015-11-20 17:11:36 +01:00
|
|
|
Version bool
|
|
|
|
Debug bool
|
|
|
|
}
|
|
|
|
|
|
|
|
func usage() {
|
2016-02-19 10:48:55 +01:00
|
|
|
fmt.Println("Usage: lastlogin_consolidate -ms <mongo source mongodb://IP:PORT> -md <mongo destination mongodb://IP:PORT> -l <logfile> -d <date> -dd <duration> -i <interval> -I <influxdb uri> -v\n")
|
2015-11-20 17:11:36 +01:00
|
|
|
os.Exit(0)
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
current, err := filepath.Abs(filepath.Dir(os.Args[0]))
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
opts.LogFile = path.Join(current, opts.LogFile)
|
|
|
|
|
|
|
|
flag.StringVar(&opts.MongoSrc, "ms", opts.MongoSrc, "Mongodb Source")
|
|
|
|
flag.StringVar(&opts.MongoDst, "md", "", "Mongodb Destination")
|
2016-02-19 10:48:55 +01:00
|
|
|
flag.StringVar(&opts.Influxdb, "I", "", "Influxdb uri")
|
|
|
|
flag.StringVar(&opts.Hostname, "H", "", "Hostname")
|
2015-11-20 17:11:36 +01:00
|
|
|
flag.StringVar(&opts.LogFile, "l", opts.LogFile, "Logs filename")
|
|
|
|
flag.StringVar(&opts.StartDate, "d", opts.StartDate, "Date")
|
|
|
|
flag.DurationVar(&opts.Duration, "dd", opts.Duration, "Duration")
|
|
|
|
flag.DurationVar(&opts.Interval, "i", opts.Interval, "Duration")
|
|
|
|
flag.BoolVar(&opts.Version, "v", false, "Version")
|
|
|
|
flag.BoolVar(&opts.Debug, "debug", false, "Debug")
|
|
|
|
}
|