update influxdb URL
This commit is contained in:
commit
abedcc98d8
24
README.md
24
README.md
@ -1,16 +1,25 @@
|
||||
# fuelprices
|
||||
## Summary
|
||||
|
||||
<<<<<<< HEAD
|
||||
## Summary
|
||||
|
||||
weather is a small program that fetch weather informations, and store them to influxdb
|
||||
|
||||
## Usage
|
||||
=======
|
||||
fuelprices is a small tool designed to fetch fuel prices from France open data and send them to influxdb
|
||||
|
||||
## Howto
|
||||
|
||||
### Build
|
||||
>>>>>>> 329f1c7752d61b932e179be3884a1824a1393d6c
|
||||
|
||||
```shell
|
||||
fuelprices -configfile fuelprices.ini
|
||||
go build
|
||||
```
|
||||
|
||||
## Sample config
|
||||
### Sample config in fuelprices.ini
|
||||
|
||||
```ini
|
||||
[fuelprices]
|
||||
@ -24,14 +33,19 @@ pos=50000007
|
||||
types=Gazole,SP95,SP98
|
||||
|
||||
[influxdb]
|
||||
# Influxdb settings
|
||||
hostname=influxdb
|
||||
port=8086
|
||||
# InfluxDB settings
|
||||
url=http://influxdb:8086/
|
||||
username=influxdb
|
||||
password=password
|
||||
database=database
|
||||
```
|
||||
|
||||
### Run
|
||||
|
||||
```shell
|
||||
./fuelprices -configfile fuelprices.ini
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
```text
|
||||
|
@ -12,8 +12,7 @@ table=fuel_price
|
||||
|
||||
[influxdb]
|
||||
# Influxdb settings
|
||||
hostname=host
|
||||
database=me
|
||||
port=8086
|
||||
url=http://influxdb:8086/
|
||||
username=influx
|
||||
password=password
|
||||
database=me
|
@ -48,8 +48,7 @@ func (fpc *FuelPricesConfig) GetConfig() error {
|
||||
}
|
||||
|
||||
influxdbSection := config.Section("influxdb")
|
||||
fpc.InfluxHost = influxdbSection.Key("hostname").MustString("localhost")
|
||||
fpc.InfluxPort = influxdbSection.Key("port").MustInt(8086)
|
||||
fpc.InfluxURL = influxdbSection.Key("url").MustString("http://localhost:8086")
|
||||
fpc.InfluxUser = influxdbSection.Key("username").MustString("username")
|
||||
fpc.InfluxPass = influxdbSection.Key("password").MustString("password")
|
||||
fpc.InfluxDB = influxdbSection.Key("database").MustString("me")
|
||||
@ -74,7 +73,6 @@ func DownloadFile(fpc *FuelPricesConfig, zipfile *ZipFile) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
zipfile.Content, err = ioutil.ReadAll(resp.Body)
|
||||
@ -145,7 +143,7 @@ func GetPrices(fpc *FuelPricesConfig, prices *[]Price, xmlfile *XMLFile) error {
|
||||
// SendToInflux sends time series data to influxdb
|
||||
func SendToInflux(fpc *FuelPricesConfig, prices *[]Price) error {
|
||||
httpClient, err := client.NewHTTPClient(client.HTTPConfig{
|
||||
Addr: fmt.Sprintf("http://%s:%d", fpc.InfluxHost, fpc.InfluxPort),
|
||||
Addr: fpc.InfluxURL,
|
||||
Username: fpc.InfluxUser,
|
||||
Password: fpc.InfluxPass,
|
||||
})
|
||||
@ -153,6 +151,8 @@ func SendToInflux(fpc *FuelPricesConfig, prices *[]Price) error {
|
||||
return err
|
||||
}
|
||||
|
||||
defer httpClient.Close()
|
||||
|
||||
bp, err := client.NewBatchPoints(client.BatchPointsConfig{
|
||||
Database: fpc.InfluxDB,
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user