Glances as a MacOS Service

Last month, @dendric talked about Glances - An Eye on your system and I got interested in trying something that’s a bit more powerful than top and ctop. Being a MacOS user, there’s always a few extra hoops to jump through (especially for host monitoring, which never works via MacOS Docker), but I went ahead and installed via glances — Homebrew Formulae anyways.

I got interested in exporting the data to something useful, and before I knew it, I too had an influxdb set up to visualize what’s going on. However, Glances irritatingly needed to be running all the time in order to export data, and the brew formula didn’t come up a services plist to run silently in the background.

I had a hard time searching for anyone that had done this before, so here’s a copy of my plist file. After creating the file, it’s just a brew services run glances away from exporting silently in the background.

/usr/local/Cellar/glances/3.4.0.3/homebrew.mxcl.glances.plist

<plist version="1.0">
<dict>
	<key>KeepAlive</key>
	<true/>
	<key>Label</key>
	<string>homebrew.mxcl.glances</string>
	<key>LimitLoadToSessionType</key>
	<array>
		<string>Aqua</string>
		<string>Background</string>
		<string>LoginWindow</string>
		<string>StandardIO</string>
		<string>System</string>
	</array>
	<key>ProgramArguments</key>
	<array>
		<string>/usr/local/bin/glances</string>
		<string>--export</string>
		<string>influxdb2</string>
		<string>-t</string>
		<string>10</string>
        <string>--quiet</string>
	</array>
	<key>RunAtLoad</key>
	<true/>
	<key>StandardErrorPath</key>
	<string>YOUROWNDIR/glances.log</string>
	<key>StandardOutPath</key>
	<string>YOUROWNDIR/glances/glances.log</string>
	<key>WorkingDirectory</key>
	<string>YOUROWNDIR</string>
</dict>
</plist>
1 Like