Skip to content

Commit

Permalink
Added support for config file command line
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Liebsch committed Apr 27, 2017
1 parent b656d6b commit 4856b75
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Binary file added vsphere-influxdb
Binary file not shown.
10 changes: 6 additions & 4 deletions vsphere-influxdb.go
Expand Up @@ -21,8 +21,6 @@ import (
"encoding/json"
"flag"
"fmt"
"github.com/davecgh/go-spew/spew"
"golang.org/x/net/context"
"log"
"math"
"net/url"
Expand All @@ -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"
Expand Down Expand Up @@ -613,16 +614,17 @@ 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)
errlog = log.New(os.Stderr, "", log.Ldate|log.Ltime)

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)
Expand Down

0 comments on commit 4856b75

Please sign in to comment.