Name: sas-metering-client
Owner: Fred Hutchinson Cancer Research Center
Description: Windows service to report SAS utilization metrics to Prometheus
Created: 2017-11-18 00:21:10.0
Updated: 2017-11-27 20:57:53.0
Pushed: 2017-11-28 23:37:43.0
Homepage: null
Size: 3817
Language: Go
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Windows service to report the utilization of SAS on the desktop for license metering.
metering-client.exe install
metering-client.exe start
xe config "sas-metering-client" start=auto
xe failure "sas-metering-client" actions=restart/600000/restart/600000/restart/41400000 reset=86400
xe description "sas-metering-client" "Sends SAS utilization metrics to the FredHutch metrics server"
To see what version of the agent you are running run the following command:
metering-client.exe version
ion: 0.1
To see the configuration that the agent is using run the following command:
metering-client.exe print-config
theus server: yourserver.yourdomain.org
etheus port: someport-number
name: someuser
word: '*******fi$'
true
To remove the SAS metering client service from your system run the following commands (assuming you installed it to “C\Program Files\sas-metering-client”):
rogram Files\sas-metering-client\sas-metering-client.exe stop
rogram Files\sas-metering-client\sas-metering-client.exe remove
After the service is stopped and removed, simply delete the binary from your system.
SAS is not free and obtaining a trial version for testing is not trivial, so to test this monitoring agent, I?ve written a SAS simulator.
To run it just download “sas-simulator/binary/sas.exe” from this repo to your windows computer and run it via the command-line of double-click in Windows explorer.
Dependencies
Dependencies are vendored in the repo using the “godep” tool. If you add any additional dependencies, vendor them by running “godep save” and committing the dependencies.
Binary information
To include information and an icon in the compiled binary we are using “goversioninfo” (https://github.com/josephspurrier/goversioninfo). To use it, download in and istall it:
et github.com/josephspurrier/goversioninfo/cmd/goversioninfo
Edit the “versioninfo.json” file in this repo to include the required changes. Make sure that “//go:generate goversioninfo -icon=icon.ico” build instructions are at the top of the “main.go” source file. Run the following command in the root of the repo to generate/update the “resource.syso” file:
enerate
The code is now read to compile.
Reducing binary size
To reduce the binary size, build with the following flags:
uild -ldflags="-s -w"
Hacks
I had to hack the wmi.go source file vendored in this repo at “vendor\github.com\StackExchange\wmi\wmi.go” because it would file with a type error (can't assigned nil to string) is any of the processes properties were empty. The following hack fixes this issue (need to do an upstream PR):
efaultClient is the default Client and is used by Query, QueryNamespace
r DefaultClient = &Client{} <--- this was the default
cdermo: the ^above^ line is the default, the line below replaces it, changes required
processes with nil valumes don't raise errors when loading into Win32_Process struct
DefaultClient = &Client{NonePtrZero: true, PtrNil: false} // <----- this is my hack
If you need to update the wmi packgage for any reason, you'll need to re-implement this hack if it's not fixed upstream yet.