Share via

Send e-mail notification from linux machine with the metrics disk ,memory and CPU utilization.

Ashima Gupta 1 Reputation point
2020-09-24T11:39:55.167+00:00

Hi,

I'm working on one scenario in which I want to send a metrics such as (disk utilization, CPU utilization and memory utilazition) through e-mail from linux machine.

I have used the below shell script:

scpu=$(cat /proc/stat | awk '/cpu/{printf("%.2f%\n"), ($2+$4)*100/($2+$4+$5)}' | awk '{print $0}' | head -1)
smem=$(free | awk '/Mem/{printf("%.2f%"), $3/$2*100}')
sswap=$(free | awk '/Swap/{printf("%.2f%"), $3/$2*100}')
t=$(date)
echo "$(hostname -f), $scpu, $smem, $sswap, $t" >> /tmp/cpu-mem-swap.csv | mail -s "Metrics" yourmailid.domain.com

I've exceuted this script but getting the correct metrics but unable to send an email.

Please anklowedge me with your inputs.

Regards,
Ashima

Azure Virtual Machines
Azure Virtual Machines

An Azure service that is used to provision Windows and Linux virtual machines.

0 comments No comments

1 answer

Sort by: Most helpful
  1. sadomovalex 3,636 Reputation points
    2020-09-24T14:26:36.163+00:00

    you may try to use SendGrid for that. Here are some details how to use it from Linux running on Azure: How to Send Email Using SendGrid with Azure.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.