nut: Configure collectd NUT plugin
infra/cfg/pipeline/head This commit looks good Details

master
Dustin 2024-01-17 07:08:45 -06:00
parent 44926c944f
commit 52642d37d9
5 changed files with 37 additions and 1 deletions

6
env/prod/nut.cue vendored
View File

@ -55,3 +55,9 @@ nut: n.#Nut & {
}
}
}
let _nut = nut
collectd: nut: n.#CollectdNut & {
ups: [for k, v in _nut.ups {k + "@localhost"}]
}

View File

@ -5,3 +5,5 @@ import (
)
nut: prod.nut
collectd: prod.collectd

View File

@ -4,4 +4,4 @@ import (
"du5t1n.me/cfg/schema/app/nut"
)
render: nut.templates
render: nut.templates + nut.collectd.templates

View File

@ -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"},
]
}
},
]
}

View File

@ -0,0 +1,8 @@
{% if collectd.nut.load_plugin -%}
LoadPlugin nut
{% endif %}
<Plugin nut>
{%- for ups in collectd.nut.ups %}
UPS "{{ ups }}"
{%- endfor %}
</Plugin>