Closed Nopik closed 3 years ago
I've taken a few first tiny steps towards implementing this feature. I'm thinking we should have the ability to run both local and remote scripts, so I've currently set up the config file as such:
custom_monitors:
- name: 'CPU Temperatures'
enable: true
file_path: '/home/pi/myscript.sh'
interval: 10
remote:
remote_host: '192.168.0.2'
remote_user: 'pi'
- name: 'Disk Usage'
enable: true
interval: 600
file_path: 'c:\Users\Pi\myscript.ps1'
In terms of return signal, why not implement something a little more expressive such as a JSON string? That way you don't need to fill the config with notification messages. Would probably look something like this:
{ "event_priority": 0, "message": "CPU Core Temperature is currently above 75° (82.1°)" }
Chiadog would then take that event, slap a priority icon on it, append the monitor's name
and send it off to one or more notifiers.
Should each of these custom monitors live in its own separate thread?
Yes, definitely returning some JSON (e.g. by printing it to stdout) would be much better. I just suggested the simplest thing to not make the feature unnecessarily big - but it makes perfect sense to do more than just green/red result.
In my situation those scripts would be really short lived (read temp from /proc
, etc.), so no need for fancy parallelism here. I'm sure over time people will start demanding more and more, but one-off scripts would work for me.
Just a quick note: Careful not to over-design the tool. At some point it might make sense to have two separate tools running side-by-side, each doing their little task. Makes maintenance easier!
Could we provide a one-time notify
command that takes some input and uses the configured notifiers to send the message?
Then you could just run your custom scripts using a cronjob and still reuse your chiadog notification channels.
@greimela I think that's the way to go if there is value in easily reusing the notification channels 👍
E.g. I would wish to be able to define a number of scripts, each returning
0
or non-0
process exit code, so Chiadog could run them occasionally and send notification when non-zero return code is seen.Examples usage would be checking whether temperature is above threshold or disk space is below threshold etc. - in a pluginable way.
Alternatively, Chiadog could check the 2 conditions mentioned above, but over the time I would end up with much more checks.