Procedure to send email upon ping status


Please refer below procedure to send email based on ping test in machine.

This procedure report full ping result to specified email address if ping test takes more than specified milliseconds time.

#Required inputs
# from == the sender's email address
# to == the recipient's email address
#Username- Set username if it is different from email address
#s_server= smtp server's host name( sender mail settings)
#s_port=smtp server's port number (sender mail settings)
#pingip - Ip to execute ping command;



#procedure function
import smtplib
from email.mime.text import MIMEText

import os;
import re;
import ctypes
import time;

class disable_file_system_redirection:
    _disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirection
    _revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirection
    def __enter__(self):
        self.old_value = ctypes.c_long()
        self.success = self._disable(ctypes.byref(self.old_value))
    def __exit__(self, type, value, traceback):
        if self.success:

command='ping  '+pingip+'>C:\pingstatus.txt' ;
with disable_file_system_redirection():
    print (out);
    average=os.popen('findstr "Average" C:\pingstatus.txt').read();

a = re.findall('Average = [0-9]+ms', average)[0]
get = a.split()[-1][0:-2]

with open('C:\pingstatus.txt','r+') as fb:
    msg = MIMEText(
#fp = open('pingsta', 'r+')

msg['Subject'] = 'Ping status for'+pingip  ;
msg['From'] = sendfrom
msg['To'] = sendto

if int(get) >=  threshold_in_ms:
        print('Successfully sent email');
    except Exception as e:

20170104-Latest–Send_email_upon_ping_status.json (2.73 KB)

Is there a way to pull the site / customer email address and use that as the FROM email address?

Hello @MathewTaylor
Good day to you. We feel happy for your presence again. We regret to say that it’s not possible because your security is more valuable for us. However if it’s available to retrieve email and use it as from address, we need correct password, SMTP etc to manage it. That will deviate from secure track if we autoamte it.

Thank you very much.

Hi Aravind;

I don’t really understand what you mean; What I am asking is as follows; The client account in Itarian should have an email address associated with it; So the script should be able to see that email address, and we should be able to use it to send the email so it appears to come from that email address, which is helpful for integration with other solutions.

Hello @MathewTaylor

Sorry for the inconvenience. Let me give you the brief discussion. So far, our script procedure doesn’t have availability to communicate with the logged in client account email address. But considering your request, we could create a feature request that even only if client email address is set to be a recepient mail address (i.e) “To Address” instead “From address”.
Because in our script procedure we do follow certain mail procedures to avail the mail communication part. We need appropriate SMTP mail address, Password etc to it. The path way may varry accroding to SMTP address. So, we could raise feature request only if it is ok to use client mail as “Recepient mail”.

Thank you.