Proactive Monitoring software for DietPi

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
Post Reply
Jack Sabbath
Posts: 3
Joined: Tue Sep 01, 2020 12:12 pm

Proactive Monitoring software for DietPi

Post by Jack Sabbath »

Hello everybody,

I'm setting up my new RasPi and decided to not use OpenMediaVault this time, since it's quite bloated and since DietPi offers alternatives for most of the functionality already.

Yet what I am really missing is some kind of monitoring software that informs me via email if something is wrong. Things like:
- A Cron job fails
- A file system is nearly full
- S.M.A.R.T. values of a drive are getting bad
- RasPi feeling sad or hungry
- other catastrophes

Can you recommend an appropriate software that does that? It should also:
- work well with DietPi
- be reasonably easy to setup
- consume only a reasonable amount of resources -> not super bloated
- be free of charge (ideally Open Source)

Thank you!
User avatar
Joulinar
Posts: 5087
Joined: Sat Nov 16, 2019 12:49 am

Re: Proactive Monitoring software for DietPi

Post by Joulinar »

Hi,

many thanks for your message. Not sure if there is a tool who covers all your needs but you could have a look to the system managemanet tools that are offered by dietpi-software catalogue.
Or you have a look to Debian Wiki https://wiki.debian.org/SystemMonitoring
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Jack Sabbath
Posts: 3
Joined: Tue Sep 01, 2020 12:12 pm

Re: Proactive Monitoring software for DietPi

Post by Jack Sabbath »

Thank you for these resources, and of course for this awesome disto!

I will take a look at them in the next days and post an update which one I'd suggest.
cc13
Posts: 27
Joined: Wed Mar 13, 2019 1:31 pm

Re: Proactive Monitoring software for DietPi

Post by cc13 »

Hello @Jack Sabbath,

Have you tried the different solutions? I'm not sure how far you will go, just for example: I installed Telegraf+InfluxDB+Grafana in a Docker env last days on my RPi4 to have a dashboard available. Next step is to define alarms in Grafana to notify me.
User avatar
WarHawk
Posts: 732
Joined: Thu Jul 20, 2017 8:55 am

Re: Proactive Monitoring software for DietPi

Post by WarHawk »

daemontools?

https://www.techrepublic.com/article/te ... emontools/

https://cr.yp.to/daemontools.html

Ah you want it to alert you if something is wrong
Doing some googling shows a bash script that will run every 5 min and check if the services are working and alert if down
https://unix.stackexchange.com/question ... ted-alerts

This one starts the service if it goes down
http://www.akamaras.com/linux/linux-scr ... s-stopped/

also looked at monit
https://mmonit.com/monit/documentation/ ... -OPERATION

I had to go into the /etc/monitrc config file and comment out the only allow localhost so I could see the webpage it generates (the howto below shows how to add a network to be allowed in)...not sure what it takes to configure the rest, but it's an option
Configuration howto for monit
https://www.digitalocean.com/community/ ... gure-monit

I was able to install it, and setup a "docker" monitor using this at the end of the monitrc file in /etc

Code: Select all

check process apache with pidfile /run/docker.pid
    start program = "/etc/init.d/docker start" with timeout 60 seconds
    stop program  = "/etc/init.d/docker stop"
To add programs you want to monitor...just edit the /etc/init.d/****** and all new blocks at the end

you will have to go thru the config file and setup your email stuff and whatnot...plenty of howto's out there
User avatar
WarHawk
Posts: 732
Joined: Thu Jul 20, 2017 8:55 am

Re: Proactive Monitoring software for DietPi

Post by WarHawk »

I just installed monitorix

It has a webgui as well...builds graphs for all sorts of apps and I think you can configure it to alert

wish I could help more
mail2rst
Posts: 135
Joined: Fri Apr 13, 2018 4:53 pm

Re: Proactive Monitoring software for DietPi

Post by mail2rst »

I am facing a unique problem with my nextcloud setup on raspaberrypi-3 with dietpi operating system with headless in my home. I have setup USB HDD & transfer ROOTfs & userdata in usb_hdd partitions. Everything is working accordingly. I have transferred about 300GB data on usbHDD through nextcloud web app & system complete that process with one day.

Now when in nextcloud app I click media tab. It will start making of thumbnail for about 25,000 images. On another computer with htop command I am able to see all cpu usage 100%, Ram usage =100% for sustain long time. I have already make swap file for 2.0GB. then system freeze. All apps are unresponsive
Nextcloud app/proftpd/dropbear ssh & overall raspberry offline. The only way to restart it by removing power & replug it. It is very cruel act for my loving raspberry pi.
Then I try to find on internet the main culprit of this situation & found that under heavy load when raspberry work under maximum load & out of its limited resources. It start crushing ongoing programs to maintained the load. So I feel may be this is the reason my raspberry not responded. So some good people already found this situation in past & found the solution “monit”. I also want to implement this thing on my machine. Please guideme/share the working config file for “monit” for all dietpi installed softwares.
# Dropbear SSH
#Pro FTP
#Nextcloud (with all it dietpi default components)
#lightTPD
#Redis
#mysql
#redis
I want “monit” monitor these programs in background after each hour. If any program not working, it will restart that program. If something un- recoverable then reboot the whole raspberry pi. This way is much better then my current way to reboot the system via removing power. Please help me to overcome this situation.
Thanks in advance.
mail2rst
Posts: 135
Joined: Fri Apr 13, 2018 4:53 pm

Re: Proactive Monitoring software for DietPi

Post by mail2rst »

I found from this help page "https://mmonit.com/wiki/Monit/Configura ... mples#cron" some examples. please help me to translate them into our dietpi system. by default i am using lightpd not apache.


check process proftpd with pidfile /var/run/proftpd.pid
start program = "/etc/init.d/proftpd start"
stop program = "/etc/init.d/proftpd stop"
if failed port 21 protocol ftp then restart

check process sshd with pidfile /var/run/sshd.pid
start program "/etc/init.d/sshd start"
stop program "/etc/init.d/sshd stop"
if failed port 22 protocol ssh then restart

check process apache with pidfile /opt/apache_misc/logs/httpd.pid
group www
start program = "/etc/init.d/apache start"
stop program = "/etc/init.d/apache stop"
if failed host localhost port 80
protocol HTTP request "/~hauk/monit/token" then restart
if failed host 127.0.0.1 port 443 type TCPSSL
certmd5 12-34-56-78-90-AB-CD-EF-12-34-56-78-90-AB-CD-EF
protocol HTTP request http://localhost/~hauk/monit/token then restart
depends on apache_bin
depends on apache_rc


check process mysql with pidfile /opt/mysql/data/myserver.mydomain.pid
group database
start program = "/etc/init.d/mysql start"
stop program = "/etc/init.d/mysql stop"
if failed host 127.0.0.1 port 3306 protocol mysql then restart
depends on mysql_bin
depends on mysql_rc

check process redis-server with pidfile "/var/run/redis/redis-server.pid"
start program = "/etc/init.d/redis-server start"
stop program = "/etc/init.d/redis-server stop"
if failed host 127.0.0.1 port 6379 then restart
User avatar
Joulinar
Posts: 5087
Joined: Sat Nov 16, 2019 12:49 am

Re: Proactive Monitoring software for DietPi

Post by Joulinar »

well this is not that simple as you would need to rewrite all the statement to use systemd instead of init.d.

For MariaDB is could look like this

Code: Select all

 check process mysqld with pidfile /var/run/mysqld/mysqld.pid
   group database
   group mysql
   start program = "/usr/bin/systemctl start mariadb.service"
   stop  program = "/usr/bin/systemctl stop mariadb.service"
   if failed host localhost port 3306 protocol mysql with timeout 15 seconds for 3 times within 4 cycles then restart
   if failed unixsocket /var/run/mysqld/mysqld.sock protocol mysql for 3 times within 4 cycles then restart
   if 5 restarts with 5 cycles then timeout
not if this will work in reality but at least it's shown up

picture.PNG

some useful links
https://unix.stackexchange.com/question ... d-services
https://superuser.com/questions/1409899 ... n-pid-file
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Post Reply