Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

email-alert for special case: ssmtp / mailutils

Featured Replies

Hello dear all, 

 

I want to make some experience with linux and my rasperry-Pi. 

 

Well - on the Raspberry Pi, (alert-) messages and notifications are a great option: These messages help in any case of automation: The ways and methods being sent are various: These messages can use a broad variety on communication channels (e.g. e-mails, SMSs and i love MQTT).  A bunch of APIs are at hand that help to collect data from sensors can be the source for alert emails.  With the Raspberry Pi and the the setting of terminal commands. The alert-messages also are able to be configured to be sent by Cron-job.

 

Sometimes using email, is called ugly it's insecure while parsing it is horrible, triggering on a message arriving is difficult? 


Sometimes much more apropiate is to send small message payloads from one computer to another like MQTT. the event and use-case:  

i want to send an email when the space on my Raspberry Pi  smd-card is on the way to get low. 


On a sidenote i would like to delete old files when disk space is very full. well this could be a great use-case for testing e-mail-alerts: 

- sending an email would be easy in python; 
- the jobs the program needs to do is to check for disk space and delete the oldest files in python also. 


Well to do this job - i guess that We can use ssmtp and mailutils to send out emails. 
but i have heard that ssmtp is depreciated and outdated:

With mailutils in python i am able to use os.system() orsubprocess().


Here i found a little  snippet: CPU, RAM and disk monitoring using python - see the snippet here: https://www.raspberrypi.org/forums/viewtopic.php?f=32&t=22180

 



import os

# Return CPU temperature as a character string                                     
def getCPUtemperature():
    res = os.popen('vcgencmd measure_temp').readline()
    return(res.replace("temp=","").replace("'C\n",""))

# Return RAM information (unit=kb) in a list                                       
# Index 0: total RAM                                                               
# Index 1: used RAM                                                                 
# Index 2: free RAM                                                                 
def getRAMinfo():
    p = os.popen('free')
    i = 0
    while 1:
        i = i + 1
        line = p.readline()
        if i==2:
            return(line.split()[1:4])

# Return % of CPU used by user as a character string                               
def getCPUuse():
    return(str(os.popen("top -n1 | awk '/Cpu\(s\):/ {print $2}'").readline().strip(\
)))

# Return information about disk space as a list (unit included)                     
# Index 0: total disk space                                                         
# Index 1: used disk space                                                         
# Index 2: remaining disk space                                                     
# Index 3: percentage of disk used                                                 
def getDiskSpace():
    p = os.popen("df -h /")
    i = 0
    while 1:
        i = i +1
        line = p.readline()
        if i==2:
            return(line.split()[1:5])


what would you suggest - which method is appropiate here!?! 

 

look forward to hear from you 

Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.