Closed fzavalloni closed 8 years ago
agreed, I believe @cwegener has been doing some work on this and might have a PR available soon
Great! I will wait for that.
Tks
Hi
We are running telegraf in Windows boxes using NSSM. I even wrote a blog post about it here: https://www.ricardclau.com/2016/03/running-go-executables-consul-telegraf-as-windows-services/ (the principles apply equally to things like Consul in the Agent mode and effectively any Go binary)
So, essentially it is all about:
Hope this helps, happy to contribute to the official docs if the maintainers of the project want to!
Thanks for creating telegraf!
cool, thanks @ricardclau, I've seen NSSM before and it seems like a much better way to get a service running in Windows. What command generates the service, would it just be something like this?:
nssm install Telegraf C:\telegraf\telegraf.exe agent -config C:\telegraf\telegraf.conf
also, if you could write up a readme and submit it that would be great, you could put it in docs/WINDOWS_SERVICE.md
@sparrc the command would be
nssm install Telegraf C:\telegraf\telegraf.exe -config C:\telegraf\telegraf.conf
The agent bit is for the Consul deamon I am afraid :) (https://www.consul.io/intro/getting-started/install.html)
Will do a PR with some md this weekend, thanks!
OK, if you put that into the blog post too I can probably get our marketing folks to tweet/promote it ;-)
@sparrc Just amended my blog post with specific examples for Telegraf and mentioning the TICK stack. Hopefully good enough for your marketing folks! :)
Will work a bit now on the docs for Telegraf.
Thanks!
I have used nssm in the past with good success, for example to run the whole ELK stack. There is no need for chocolatey, can just be downloaded to the telegraf directory and run from there.
Yeah, the chocolatey bit is just to make it easier to automate in an idempotent way. Similar to using apt, yum and friends. It is nice package system for Windows but of course you can always download nssm from http://nssm.cc/ and install it yourself
I would really want to run telegraf as a Windows service as well. But since I have little or no control over the environment which telegraf will run I would STRONGLY prefer not to have to deal with nssm, which seems to be non-standard in the way that it registers itself and acts as an intermediary and relies a lot on GUI stuff which is hard to automate and use properly. So all in all NSSM might be nice but it doesn't smell that good from a reliability and compatibility point of view.
Bosun's scollector has a simple -winsvc switch that can install and remove itself as a Windows service without any dependencies ( https://godoc.org/bosun.org/cmd/scollector ).
Just found the other issue where @cwegener said he is working on getting native -service-install in the binary. Any updates? :)
Anyone just tried to use sc.exe to register the service?
@elvarb Oh yes, for an hour or two. Seems telegraf.exe refuses to start when called as a service. I also tried a trick I saw on SO about calling it like "cmd /c telegraf.exe" which in theory should launch it in some kind of command session but to no avail.
Eventually just gave up and now running it manually in the foreground, hoping someone will fix it soon :)
nssm is the only reliable way we have found to run Go binaries as Windows services as it acts as an intermediary between the Windows API and the Go signaling so that you can restart the services and so on
Plus, it seems to be getting popular and even tools like Ansible have modules to interact with it
Of course, having a native installer would be better but at the moment it seems to be the best (or least bad) way, even if it is not a Windows standard
My 2c: scollector (Go) has been running without problems here for weeks as a Windows service. Ofc, there are checks to detect if it stops sending data to detect problems, but that has not happened yet.
Interesting! We had a look at Consul and Telegraf and they did not have that option, this is why we went NSSM. I agree it is far from ideal.
https://github.com/bosun-monitor/bosun/blob/master/cmd/scollector/service_windows.go seems to be where the magic happens. It would be great to be able to remove NSSM!
FWIW there is a guide for setting up the exe as a service using NSSM here: https://github.com/influxdata/telegraf/blob/master/docs/WINDOWS_SERVICE.md
not sure if this is helpfull.. https://godoc.org/golang.org/x/sys/windows/svc/mgr
Yeah this is one of the packages being used in bosun :)
telegraf的windows版本,请问什么时候可以正式发布? 我的需求比较基础,没有什么高级需求: 1,cpu; 2,硬盘使用量; 3,硬盘读写(未实现); 4,内存; 5,网络流量监控(未实现);
最开始我打算使用bosun作云平台的监控功能,研究了几天,最后放弃了,在我的需求不是很复杂的情况下,我不想使用分布式的HBase,相对于java我更喜欢使用golang,我们公司所有软件项目也都在使用golang,非常期待telegraf的windows正式版发布。实际上bosun已经发布了windows的scollector,希望telegraf可以早日实现。我都有冲动自己改造bosun的scollector,让它支持influxdb
@aaaaa12322 sorry but we'll have to keep the conversation in English on the github page
For me using NSSM is not desirable, so I'm working on turning it into an actual Windows Service, I will submit a pull request once it is working. You can find the progress here: https://github.com/butitsnotme/telegraf/tree/windows-service
@butitsnotme Can anyone say if this made it into the latest windows binaries? (1.0.0-beta3) Couldn't get this setup as a service when I tired earlier? PS was passing telegraf --service as a parameter and returning an error.
it's not there yet, will be available in 1.0 release candidate 1
I somehow missed the development of this feature! Really nice to see it merged, will try to test from binaries ASAP!
Telegraf only keeps getting better and better! Good stuff!
release candidate 1 is now available to download from the README, please test out the new windows service functionality and open any issues that you find!
Telegraf now has native service handling which is awesome but sadly now NSSM does not work with Telegraf.
Of the binaries I have the last version that worked with NSSM is 1.0.0-Beta3 The version after that which does not work is 1.0.1
Hi,
basing on https://github.com/influxdata/telegraf/blob/master/docs/WINDOWS_SERVICE.md is there some way to specify custom name of service?
i.e.
telegraf.exe --service install --name "Telegraf custom"
It could help me to create two instances of service.
There is not currently, although it should not be too difficult to add...
My temporary fix for that is to rename it in registry via powershell:
Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\services\telegraf\" -Name "DisplayName" -Value "telegrafServiceName"
Rename-Item "HKLM:\SYSTEM\CurrentControlSet\services\telegraf" -NewName "telegrafServiceName"
Rename-Item "HKLM:\SYSTEM\CurrentControlSet\services\EventLog\Application\telegraf" -NewName "telegrafServiceName"
and restart of windows machine.
Hi,
Is it possible to use the Telegraf for windows as Windows Service?
I tried to add it as service but did not work.
C:\Windows\Microsoft.NET\Framework64\v4.0.30319>InstallUtil.exe "C:\Program File s\Telegraf\telegraf.exe" Microsoft (R) .NET Framework Installation utility Version 4.0.30319.33440 Copyright (C) Microsoft Corporation. All rights reserved.
Exception occurred while initializing the installation: System.BadImageFormatException: Could not load file or assembly 'file:///C:\Prog ram Files\Telegraf\telegraf.exe' or one of its dependencies. The module was expe cted to contain an assembly manifest..
Tks Fabrizio