Skip to content

Instantly share code, notes, and snippets.

@cherts
Created January 29, 2020 15:21
Show Gist options
  • Select an option

  • Save cherts/e14bcce0f43ffd7b701fba8c6990da9a to your computer and use it in GitHub Desktop.

Select an option

Save cherts/e14bcce0f43ffd7b701fba8c6990da9a to your computer and use it in GitHub Desktop.
zabbix-agent systemd service discovery
UserParameter=systemd.service.discovery,sys_list=$(systemctl list-unit-files | grep ".service" | awk '{split($0,a,".service"); split($0,b," "); print "\"{#SERVICE}\":\""a[1]"\",\"{#STATE}\":\"" b[2]"\""}'); echo -n '['; for s in $sys_list; do echo -n "{"$s"},"; done | sed 's/.$//' ; echo -n ']'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment