I need a simple, yet effective solution to monitor two system services running on OpenWrt device. They are started as a init.d processes. I need to check whether the processes run, and if not, start them again. In case the process cannot start due to some persistent problem, I need to send notification - either e-mail or API request.
For just one or two processes, I will often just do a custom script and set it up in cron to run periodically. If you navigate to System -> Scheduled Tasks in LuCI, that is an interface to cron.
Here is a simple example on one of my devices that checks if an sshfs filesystem has dropped out and resets it if it has.
#!/bin/sh
if [ ! -f /root/Sync/syncthis ]; then
/usr/bin/sshfs kfitzner@qsy.va1der.ca:Sync /root/Sync
fi
It's more handraulic, but it lets you do anything a shell script can do. Sending e-mail this way requires a package like mailsend to be configured. When you say an API, I assume you mean through a web server? Both curl and wget can likely do this.
EDIT: I haven't used monit, but it looks like it might be a simpler solution. I mention the above, though, in case you need more versatility than monit offers.