Skip to content

Instantly share code, notes, and snippets.

@cwjohnston
Last active April 25, 2019 01:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cwjohnston/d0196fe857e3653e2667689074b17b8a to your computer and use it in GitHub Desktop.
Save cwjohnston/d0196fe857e3653e2667689074b17b8a to your computer and use it in GitHub Desktop.
Configure Sensu Go Agent as a Windows service with WinSW

Configure Sensu Go Agent as a Windows service with WinSW

NOTE: These instructions are provided as a temporary workaround due to current lack of an official Windows package for Sensu Go. Should you follow these instructions, you may need to take manual steps prior to installing the planned official Windows package.

  1. Follow Windows installation instructions to obtain the binary-only distribution
  2. Create directories %PROGRAMDATA%\sensu\config and %PROGRAMFILES%\sensu
  3. Download the example agent.yml, edit as needed, and place in %PROGRAMDATA%\sensu\config
  4. Unpack binary-only distribution (e.g. using 7zip) and copy executables into C:\Program Files\sensu\
  5. Download appropriate WinSW release, this will be WinSW.NET4.exe for most recent Windows versions.
  6. Place WinSW executable in %PROGRAMFILES%\sensu\ and rename to sensu-agent-service.exe
  7. Create %PROGRAMFILES%\sensu\sensu-agent-service.xml with the following content:
<!--
  Windows service definition for Sensu Go Agent
-->
<service>
  <id>sensu-agent</id>
  <name>Sensu Go Agent</name>
  <description>This service runs a Sensu agent</description>
  <executable>%PROGRAMFILES%\sensu\sensu-agent.exe</executable>
  <argument>start</argument>
  <argument>-c</argument>
  <argument>%PROGRAMDATA%/sensu/config/agent.yml</argument>
  <logpath>%PROGRAMDATA%\sensu\logs\</logpath>
  <log mode="roll-by-size">
    <sizeThreshold>102400</sizeThreshold>
    <keepFiles>10</keepFiles>
  </log>
</service>
  1. Install a Windows service definition to run sensu-agent-service.exe:
sc create sensu-go-agent start= delayed-auto binPath= "%PROGRAMFILES%\sensu\sensu-agent-service.exe" DisplayName= "Sensu Go Agent"
  1. Use services.msc snap-in to start the Sensu Go Agent service.
  2. Observe logs in %PROGRAMDATA%\sensu\logs for any errors.
@Kukunga
Copy link

Kukunga commented Apr 25, 2019

Great write-up! I ran into one typo related issue in step 7. where forward slashes are present but need to be back slashes in the following line:

%PROGRAMDATA%/sensu/config/agent.yml

Once I updated the slash, no errors in log and service is running! Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment