Changed the Windows Config file default location
Updated the default location of the configuration file on Windows from C:\telegraf\telegraf.conf to C:\Program Files\Telegraf\telegraf.conf. With this change includes updating the directions, including directing that the executable be put into that same directory. Additionally, as noted in the instructions, the location of the config file for the service may be changed by specifying the location with the `-config` flag at install time.
This commit is contained in:
parent
a57781a3dc
commit
5b11934a1c
|
@ -78,7 +78,7 @@ The flags are:
|
|||
-debug print metrics as they're generated to stdout
|
||||
-quiet run in quiet mode
|
||||
-version print the version to stdout
|
||||
-service Control the service, ie, 'telegraf -service install'
|
||||
-service Control the service, ie, 'telegraf -service install (windows only)'
|
||||
|
||||
In addition to the -config flag, telegraf will also load the config file from
|
||||
an environment variable or default location. Precedence is:
|
||||
|
@ -110,6 +110,7 @@ var logger service.Logger
|
|||
var stop chan struct{}
|
||||
|
||||
var srvc service.Service
|
||||
var svcConfig service.Config
|
||||
|
||||
type program struct{}
|
||||
|
||||
|
@ -201,6 +202,9 @@ func reloadLoop(stop chan struct{}, s service.Service) {
|
|||
}
|
||||
|
||||
if *fService != "" && runtime.GOOS == "windows" {
|
||||
if *fConfig != "" {
|
||||
(*svcConfig).Arguments = []string{"-config", *fConfig}
|
||||
}
|
||||
err := service.Control(s, *fService)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
@ -327,15 +331,14 @@ func (p *program) Stop(s service.Service) error {
|
|||
|
||||
func main() {
|
||||
if runtime.GOOS == "windows" {
|
||||
svcConfig := &service.Config{
|
||||
svcConfig = &service.Config{
|
||||
Name: "telegraf",
|
||||
DisplayName: "Telegraf Data Collector Service",
|
||||
Description: "Collects data using a series of plugins and publishes it to" +
|
||||
"another series of plugins.",
|
||||
Arguments: []string{"-config", "C:\\Program Files\\Telegraf\\telegraf.conf"},
|
||||
}
|
||||
|
||||
svcConfig.Arguments = []string{"-config", "C:\\telegraf\\telegraf.conf"}
|
||||
|
||||
prg := &program{}
|
||||
s, err := service.New(prg, svcConfig)
|
||||
if err != nil {
|
||||
|
|
|
@ -4,15 +4,23 @@ Telegraf natively supports running as a Windows Service. Outlined below is are
|
|||
the general steps to set it up.
|
||||
|
||||
1. Obtain the telegraf windows distribution
|
||||
2. Create the directory C:\telegraf (if you install in a different location you
|
||||
will need to edit `cmd/telegraf/telegraf.go` and change the config file
|
||||
location and recompile to use your location)
|
||||
3. Place the executable and the config file into C:\telegraf
|
||||
4. Run `C:\telegraf\telegraf.exe --service install` as an administrator
|
||||
2. Create the directory `C:\Program Files\Telegraf` (if you install in a different
|
||||
location simply specify the `-config` parameter with the desired location)
|
||||
3. Place the executable and the config file into `C:\Program Files\Telegraf`
|
||||
4. To install the service into the Windows Service Manager, run (as an
|
||||
administrator):
|
||||
```ps
|
||||
C:\Program Files\Telegraf\telegraf.exe --service install
|
||||
```
|
||||
5. Edit the configuration file to meet your needs
|
||||
6. Run `C:\telegraf\telegraf.exe --config C:\telegraf\telegraf.conf --test` to
|
||||
check that it works
|
||||
7. Run `net start telegraf` to start collecting data
|
||||
6. To check that it works, run:
|
||||
```ps
|
||||
C:\Program Files\Telegraf\telegraf.exe --config C:\Program Files\Telegraf\telegraf.conf --test
|
||||
```
|
||||
7. To start collecting data, run:
|
||||
```ps
|
||||
net start telegraf
|
||||
```
|
||||
|
||||
## Other supported operations
|
||||
|
||||
|
|
Loading…
Reference in New Issue