mirror of
https://github.com/Oxalide/vsphere-influxdb-go.git
synced 2023-10-10 13:36:51 +02:00
Added support for config file command line
This commit is contained in:
parent
b656d6be88
commit
4856b75ea3
BIN
vsphere-influxdb
Executable file
BIN
vsphere-influxdb
Executable file
Binary file not shown.
@ -21,8 +21,6 @@ import (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"golang.org/x/net/context"
|
||||
"log"
|
||||
"math"
|
||||
"net/url"
|
||||
@ -32,6 +30,9 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"golang.org/x/net/context"
|
||||
|
||||
influxclient "github.com/influxdata/influxdb/client/v2"
|
||||
"github.com/vmware/govmomi"
|
||||
"github.com/vmware/govmomi/property"
|
||||
@ -613,6 +614,7 @@ func queryVCenter(vcenter VCenter, config Configuration, InfluxDBClient influxcl
|
||||
func main() {
|
||||
|
||||
flag.BoolVar(&debug, "debug", false, "Debug mode")
|
||||
var cfgFile = flag.String("config", "/etc/"+path.Base(os.Args[0])+".json", "Config file to use. Default is /etc/"+path.Base(os.Args[0])+".json")
|
||||
flag.Parse()
|
||||
|
||||
stdlog = log.New(os.Stdout, "", log.Ldate|log.Ltime)
|
||||
@ -620,9 +622,9 @@ func main() {
|
||||
|
||||
stdlog.Println("Starting :", path.Base(os.Args[0]))
|
||||
// read the configuration
|
||||
file, err := os.Open("/etc/" + path.Base(os.Args[0]) + ".json")
|
||||
file, err := os.Open(*cfgFile)
|
||||
if err != nil {
|
||||
errlog.Println("Could not open configuration file")
|
||||
errlog.Println("Could not open configuration file" + *cfgFile)
|
||||
errlog.Println(err)
|
||||
}
|
||||
jsondec := json.NewDecoder(file)
|
||||
|
Loading…
Reference in New Issue
Block a user