diff --git a/env/prod/nut.cue b/env/prod/nut.cue index 64894b0..8ae03d9 100644 --- a/env/prod/nut.cue +++ b/env/prod/nut.cue @@ -55,3 +55,9 @@ nut: n.#Nut & { } } } + +let _nut = nut + +collectd: nut: n.#CollectdNut & { + ups: [for k, v in _nut.ups {k + "@localhost"}] +} diff --git a/host/nut0.pyrocufflink.blue.cue b/host/nut0.pyrocufflink.blue.cue index 32c6df8..b8543f1 100644 --- a/host/nut0.pyrocufflink.blue.cue +++ b/host/nut0.pyrocufflink.blue.cue @@ -5,3 +5,5 @@ import ( ) nut: prod.nut + +collectd: prod.collectd diff --git a/instructions/nut0.pyrocufflink.blue.cue b/instructions/nut0.pyrocufflink.blue.cue index bd3b5d2..2f0fa8a 100644 --- a/instructions/nut0.pyrocufflink.blue.cue +++ b/instructions/nut0.pyrocufflink.blue.cue @@ -4,4 +4,4 @@ import ( "du5t1n.me/cfg/schema/app/nut" ) -render: nut.templates +render: nut.templates + nut.collectd.templates diff --git a/schema/app/nut/collectd.cue b/schema/app/nut/collectd.cue new file mode 100644 index 0000000..cf9b50d --- /dev/null +++ b/schema/app/nut/collectd.cue @@ -0,0 +1,20 @@ +package nut + +#CollectdNut: { + ups: [...string] + load_plugin: bool | *true +} + +collectd: { + templates: [ + { + template: "nut/collectd.conf" + dest: "/etc/collectd.d/nut.conf" + hooks: { + changed: [ + {run: "systemctl try-restart collectd"}, + ] + } + }, + ] +} diff --git a/templates/nut/collectd.conf b/templates/nut/collectd.conf new file mode 100644 index 0000000..6cd5e65 --- /dev/null +++ b/templates/nut/collectd.conf @@ -0,0 +1,8 @@ +{% if collectd.nut.load_plugin -%} +LoadPlugin nut +{% endif %} + +{%- for ups in collectd.nut.ups %} + UPS "{{ ups }}" +{%- endfor %} +