| Server IP : 3.111.61.48 / Your IP : 216.73.216.67 Web Server : Apache System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64 User : ubuntu ( 1000) PHP Version : 8.2.31 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /etc/script/ServerMonitor/ |
Upload File : |
import requests
import smtplib
import json
import os
import threading
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
# ==============================
# CONFIG
# ==============================
websites_to_check = [
{"url": "https://nirikshan-cron.tatacapital.com/", "name": "nirikshan-cron.tatacapital.com"},
{"url": "https://nirikshan.tatacapital.com/", "name": "nirikshan.tatacapital.com"},
{"url": "https://hr.arukustech.com/", "name": "hr.arukustech.com"},
{"url": "https://frontier.tatacapital.com/", "name": "frontier.tatacapital.com"},
{"url": "https://frontier-cron.tatacapital.com/", "name": "frontier-cron.tatacapital.com"},
{"url": "https://mbmoms.com/", "name": "mbmoms.com"},
{"url": "https://nirikshan-stg.tatacapital.com/", "name": "nirikshan-stg.tatacapital.com"},
{"url": "https://engageu.tatacapital.com/", "name": "engageu.tatacapital.com"},
{"url": "https://audituat.midlandmicrofin.co.in/", "name": "audituat.midlandmicrofin.co.in"},
{"url": "https://auditprod.midlandmicrofin.co.in/", "name": "auditprod.midlandmicrofin.co.in"},
{"url": "https://arukustech.com/", "name": "arukustech.com"},
{"url": "https://engage.tatacapital.com/", "name": "engage.tatacapital.com"},
{"url": "https://engage-cron.tatacapital.com/", "name": "engage-cron.tatacapital.com"},
{"url": "https://murphybusiness.com/", "name": "murphybusiness.com"}
]
MAIL_FROM_NAME = "UpTime Website Status"
sender_email = "uptime@arukustech.com"
receiver_email = "hosting@arukustech.com"
SMTP_SERVER = "email-smtp.ap-south-1.amazonaws.com"
SMTP_PORT = 587
CRED_FILE = "/etc/secure/ses_credentials.json"
LOGO_PATH = "/etc/script/ServerMonitor/ArukusTech.png"
# ==============================
# LOAD CREDENTIALS
# ==============================
if not os.path.exists(CRED_FILE):
raise Exception(f"Credential file not found: {CRED_FILE}")
with open(CRED_FILE, "r") as f:
creds = json.load(f)
SMTP_USER = creds.get("username")
SMTP_PASS = creds.get("password")
if not SMTP_USER or not SMTP_PASS:
raise Exception("SMTP credentials missing!")
# ==============================
# GLOBALS
# ==============================
lock = threading.Lock()
website_statuses = []
# ==============================
# EMAIL FUNCTION
# ==============================
def send_email(subject, message):
msg = MIMEMultipart()
msg['From'] = f'{MAIL_FROM_NAME} <{sender_email}>'
msg['To'] = receiver_email
msg['Subject'] = subject
# Attach logo safely
if os.path.exists(LOGO_PATH):
with open(LOGO_PATH, 'rb') as logo_file:
logo_image = MIMEImage(logo_file.read())
logo_image.add_header('Content-ID', '<company_logo>')
msg.attach(logo_image)
else:
print("Logo not found, skipping...")
msg.attach(MIMEText(message, 'html'))
try:
server = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
server.starttls()
server.login(SMTP_USER, SMTP_PASS)
server.sendmail(sender_email, receiver_email, msg.as_string())
server.quit()
print("UP Summary Email sent!")
except Exception as e:
print("Email error:", str(e))
# ==============================
# WEBSITE CHECK
# ==============================
def check_website_status(website):
url = website["url"]
name = website["name"]
for attempt in range(2):
try:
response = requests.get(url, timeout=5)
if 200 <= response.status_code < 400:
status = "Up"
else:
status = "Down"
break
except:
if attempt == 1:
status = "Down"
with lock:
website_statuses.append((name, status))
# ==============================
# MAIN
# ==============================
threads = []
for website in websites_to_check:
t = threading.Thread(target=check_website_status, args=(website,))
t.start()
threads.append(t)
for t in threads:
t.join()
# Prepare HTML
rows = ""
for i, (site, status) in enumerate(website_statuses):
color = "green" if status == "Up" else "red"
rows += f"<tr><td>{i+1}. {site}</td><td style='color:{color};'>{status}</td></tr>"
html_message = f"""
<html>
<body>
<h2>Website Status Summary</h2>
<img src="cid:company_logo">
<table border="1" cellpadding="5">
<tr><th>Website</th><th>Status</th></tr>
{rows}
</table>
</body>
</html>
"""
send_email("Website Status Summary", html_message)