Notification when service stops

Hello,

Would it be possible to receive a notification (an email) when a service stops? Even better, with the log attached?

(Sometimes the service ihatemoney stops on my server and I have to restart it. I also have to understand why it stops but that’s another problem.)

Thanks a lot!

2 Likes

You should receive an email from diagnosis in this situationBut the issue is it’s mix with a lot of alert and some of them could be false positive (like port detection).

The solution could be:

  • Improve the remote diagnosis to support more server
  • Send an email per alert instead of an email with all problems detected
  • or send an email per problem criticity level (one for all warning, one for error, one for critical issues)
2 Likes

Thanks @ljf I’ll look into that. It should send an email to the email address of the admin, right?

You can write a bash script on a cron with this base :slight_smile:

As root

systemctl list-units --failed && echo "OK" || echo "NOK"

And do a test on his ouput and send a mail to the address mail you want if some services failed.

1 Like

Thanks!

Despite trying I’m not sure to perfectly understand what you mean. Anyway, I seem to have an error here. Could you point me in which way my yunohost is misconfigured? Should it reflect in the diagnostic admin area?

(A clarification: I don’t use my server as an email server, I just want to receive administration email from it)

~# systemctl list-units --failed && echo "OK" || echo "NOK"                                                                           
  UNIT             LOAD   ACTIVE SUB    DESCRIPTION
● user@126.service loaded failed failed User Manager for UID 126
                                                                                                                                               
LOAD   = Reflects whether the unit definition was properly loaded.                                                                             
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.                                                                     
SUB    = The low-level unit activation state, values depend on unit type.                                                                      
1 loaded units listed.                                                                                                                         
OK
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.