usa la collection: lastlogin.lastlogin_yymm
This commit is contained in:
parent
2778e5506b
commit
b97098e78b
2 changed files with 7 additions and 9 deletions
4
dbs.go
4
dbs.go
|
@ -54,7 +54,7 @@ type Users struct {
|
|||
Logins []IPs `json:"logins" bson:"logins"`
|
||||
}
|
||||
|
||||
func connectMongo() {
|
||||
func connectMongo(data string) {
|
||||
|
||||
if opts.MongoSrc == "" {
|
||||
log.Fatalf("Mongodb URI invalid: '%s'\n", opts.MongoSrc)
|
||||
|
@ -67,7 +67,7 @@ func connectMongo() {
|
|||
os.Exit(-3)
|
||||
}
|
||||
dbs.mdbSrc.SetSocketTimeout(0)
|
||||
dbs.ll = dbs.mdbSrc.DB("dovecot").C("lastlogin")
|
||||
dbs.ll = dbs.mdbSrc.DB("lastlogin").C("lastlogin_" + data)
|
||||
|
||||
if opts.MongoDst == "" {
|
||||
dbs.mdbDst = dbs.mdbSrc
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
_VERSION = "v1.3.7"
|
||||
_VERSION = "v1.4.0"
|
||||
_tformat = "2006-01-02"
|
||||
_24h = (time.Hour * 23) + (time.Minute * 59) + (time.Second * 59) + (time.Millisecond * 999)
|
||||
_10m = (time.Minute * 10)
|
||||
|
@ -74,24 +74,22 @@ func main() {
|
|||
fmt.Printf("Start: %+v\n", opts)
|
||||
log.Printf("Start: %+v\n", opts)
|
||||
|
||||
connectMongo()
|
||||
defer dbs.mdbSrc.Close()
|
||||
defer dbs.mdbDst.Close()
|
||||
|
||||
y, err := time.Parse(_tformat, opts.StartDate)
|
||||
if err != nil {
|
||||
log.Println("Date Error: ", err)
|
||||
os.Exit(-1)
|
||||
}
|
||||
|
||||
var ys time.Time
|
||||
var ye time.Time
|
||||
|
||||
ys = time.Date(y.Year(), y.Month(), y.Day(), 0, 0, 0, 0, time.UTC)
|
||||
ye = ys.Add(opts.Duration)
|
||||
|
||||
idb = Influxdb(start, ys)
|
||||
|
||||
connectMongo(ys.Format("0601"))
|
||||
defer dbs.mdbSrc.Close()
|
||||
defer dbs.mdbDst.Close()
|
||||
|
||||
// DEBUG
|
||||
if opts.Debug {
|
||||
fmt.Printf("Start: %+v, Stop: %+v\n\r", ys, ye)
|
||||
|
|
Loading…
Add table
Reference in a new issue