backup script completed, all backup taken for 23-Feb
This commit is contained in:
313
wsl/scripts/ops-snaps/capture_screenshot.py
Normal file
313
wsl/scripts/ops-snaps/capture_screenshot.py
Normal file
@@ -0,0 +1,313 @@
|
||||
"""
|
||||
Playwright Automation Script for Screenshot Captures
|
||||
---------------------------------------------------
|
||||
|
||||
This script automates login and screenshot capturing from multiple services:
|
||||
- RabbitMQ
|
||||
- Observium
|
||||
- Firewall
|
||||
- SFSSD
|
||||
- NVMe
|
||||
- Ceph (Cockpit) & OwnCloud
|
||||
- Zimbra Mail Admin
|
||||
|
||||
Each service has a dedicated function for login, navigation, and screenshot capture.
|
||||
"""
|
||||
|
||||
from playwright.sync_api import sync_playwright, TimeoutError as PWTimeout
|
||||
import time
|
||||
import re
|
||||
|
||||
|
||||
def rabbitmq_screenshot(url, username, password, selector, service):
|
||||
"""
|
||||
Capture RabbitMQ dashboard screenshot.
|
||||
|
||||
Args:
|
||||
url (str): RabbitMQ login page URL
|
||||
username (str): RabbitMQ username
|
||||
password (str): RabbitMQ password
|
||||
selector (str): CSS selector of main element to capture
|
||||
service (str): Service name for screenshot filename
|
||||
"""
|
||||
output = f"service_{service}.png"
|
||||
|
||||
with sync_playwright() as pw:
|
||||
# Launch browser context
|
||||
ctx = pw.chromium.launch(headless=True).new_context(ignore_https_errors=True)
|
||||
page = ctx.new_page()
|
||||
page.goto(url)
|
||||
print("Current URL:", page.url)
|
||||
|
||||
# Fill login form
|
||||
page.fill('input[name="username"]', username)
|
||||
page.fill('input[name="password"]', password)
|
||||
|
||||
# Try <input>, fallback to <button>
|
||||
try:
|
||||
page.click('input[type="submit"]')
|
||||
except:
|
||||
page.click('button[type="submit"]')
|
||||
|
||||
# Wait for main page to load
|
||||
page.wait_for_selector(selector)
|
||||
time.sleep(2) # give extra stability before capture
|
||||
|
||||
# Capture dashboard screenshot
|
||||
page.locator(selector).screenshot(path=output)
|
||||
print(f"Saved screenshot: {output}")
|
||||
|
||||
|
||||
def observium_screenshot(url, username, password, service):
|
||||
"""
|
||||
Capture Observium memory utilization page screenshot.
|
||||
"""
|
||||
output = f"service_{service}.png"
|
||||
|
||||
with sync_playwright() as pw:
|
||||
ctx = pw.chromium.launch(
|
||||
headless=True
|
||||
).new_context(ignore_https_errors=True, viewport={"width": 1920, "height": 1080})
|
||||
page = ctx.new_page()
|
||||
page.goto(url)
|
||||
|
||||
# Login to Observium
|
||||
page.fill('input[name="username"]', username)
|
||||
page.fill('input[name="password"]', password)
|
||||
page.click('button[id="submit"]')
|
||||
|
||||
# Wait for home container to confirm login success
|
||||
page.wait_for_selector(".container")
|
||||
|
||||
# Navigate directly to memory health detail page
|
||||
memory_url = (
|
||||
"http://observium.brilliant.com.bd/health/metric=mempool/view=detail/"
|
||||
"device_id=37,40,67,70,72,77,83,84,86,87,95,96,99,103,105,52,106,107,"
|
||||
"115,31,85,108,50,121/mempool_descr=physical/"
|
||||
"requesttoken=f092f74f574a9770add7846d444d8ebc6af52ae93e958d41b252c439b48262b1/"
|
||||
)
|
||||
page.goto(memory_url, wait_until="networkidle")
|
||||
|
||||
# Wait for metrics table
|
||||
page.wait_for_selector("table.table", timeout=20000)
|
||||
|
||||
# Capture screenshot of condensed table
|
||||
page.locator("table.table-condensed").screenshot(path="service_observium_memory.png")
|
||||
|
||||
|
||||
def firewall_screenshot(url, username, password, service="firewall"):
|
||||
"""
|
||||
Capture Firewall dashboard screenshot.
|
||||
"""
|
||||
output = f"service_{service}.png"
|
||||
|
||||
with sync_playwright() as pw:
|
||||
ctx = pw.chromium.launch(
|
||||
headless=True
|
||||
).new_context(ignore_https_errors=True, viewport={"width": 1920, "height": 1080})
|
||||
page = ctx.new_page()
|
||||
page.goto(url)
|
||||
|
||||
# Login to firewall
|
||||
page.fill('input[name="username"]', username)
|
||||
page.fill('input[name="secretkey"]', password)
|
||||
page.click('button[type="button"]')
|
||||
time.sleep(5) # wait for login redirect
|
||||
|
||||
# Navigate to dashboard
|
||||
dashboard_url = "https://118.67.210.46/ng/system/dashboard/2?vdom=IC-CLOUD"
|
||||
page.goto(dashboard_url, wait_until="networkidle")
|
||||
|
||||
# Ensure dashboard is loaded
|
||||
page.wait_for_selector("ul.module-list", timeout=20000)
|
||||
|
||||
# Capture full page screenshot
|
||||
page.screenshot(path=output, full_page=True)
|
||||
|
||||
|
||||
def sfssd_screenshot(url, username="admin", password="sL1dSt0gE719", service="sfssd"):
|
||||
"""
|
||||
Capture SFSSD system overview screenshot (uses basic auth).
|
||||
"""
|
||||
output = f"service_{service}.png"
|
||||
|
||||
with sync_playwright() as pw:
|
||||
ctx = pw.chromium.launch(
|
||||
headless=True
|
||||
).new_context(
|
||||
ignore_https_errors=True,
|
||||
viewport={"width": 1920, "height": 1080},
|
||||
http_credentials={"username": username, "password": password}
|
||||
)
|
||||
page = ctx.new_page()
|
||||
page.goto(url)
|
||||
|
||||
# Wait for overview report to load
|
||||
page.wait_for_selector("#reporting-overview", timeout=20000)
|
||||
time.sleep(15) # allow rendering
|
||||
|
||||
# Capture full-page screenshot
|
||||
page.screenshot(path=output, full_page=True)
|
||||
|
||||
|
||||
def NVMe_screenshot(url, username='admin', password='sL1dSt0gE2022', service="nvme"):
|
||||
"""
|
||||
Capture NVMe (NetApp) system capacity screenshot.
|
||||
"""
|
||||
output = f"service_{service}.png"
|
||||
|
||||
with sync_playwright() as pw:
|
||||
browser = pw.chromium.launch(headless=True)
|
||||
ctx = browser.new_context(ignore_https_errors=True, viewport={"width": 1920, "height": 1080})
|
||||
page = ctx.new_page()
|
||||
page.goto(url)
|
||||
|
||||
# Login to NVMe portal
|
||||
page.fill('input[name="username"]', username)
|
||||
page.fill('input[name="password"]', password)
|
||||
page.click('button[type="submit"]')
|
||||
|
||||
# Navigate to capacity bar
|
||||
page.locator('[data-netapp-id="capacity-bar"]').click()
|
||||
|
||||
# Capture system capacity screenshot
|
||||
page.screenshot(path=output, full_page=True)
|
||||
time.sleep(10)
|
||||
|
||||
|
||||
def ceph_df_screenshot(ip, username='mosiur', password="123Rashik456", service="ceph"):
|
||||
"""
|
||||
Capture Ceph dashboard and OwnCloud disk usage from Cockpit terminal.
|
||||
"""
|
||||
output = f"service_{service}.png"
|
||||
url = f"https://{ip}:9090"
|
||||
|
||||
with sync_playwright() as pw:
|
||||
ctx = pw.chromium.launch(
|
||||
headless=True
|
||||
).new_context(ignore_https_errors=True, viewport={"width": 1920, "height": 1080})
|
||||
page = ctx.new_page()
|
||||
page.goto(url)
|
||||
|
||||
# Login to Cockpit
|
||||
page.fill('input[id="login-user-input"]', username)
|
||||
page.fill('input[id="login-password-input"]', password)
|
||||
page.click('button[type="submit"]')
|
||||
time.sleep(5)
|
||||
|
||||
# Open system terminal
|
||||
page.goto(f"https://{ip}:9090/system/terminal")
|
||||
|
||||
# Switch to terminal iframe
|
||||
terminal = page.frame_locator(
|
||||
"iframe[title='Terminal'], iframe[name='cockpit1:localhost/system/terminal']"
|
||||
)
|
||||
terminal.locator("body").click()
|
||||
time.sleep(2)
|
||||
|
||||
# Run Ceph commands
|
||||
page.keyboard.type('source controller_creds')
|
||||
page.keyboard.press("Enter")
|
||||
page.keyboard.type('clear')
|
||||
page.keyboard.press("Enter")
|
||||
page.keyboard.type('scon1 ceph df && scon1 ceph -s')
|
||||
page.keyboard.press("Enter")
|
||||
time.sleep(5)
|
||||
|
||||
# Capture Ceph output
|
||||
terminal.locator("body").screenshot(path=output)
|
||||
|
||||
# Run OwnCloud disk usage
|
||||
page.keyboard.type('clear')
|
||||
page.keyboard.press("Enter")
|
||||
page.keyboard.type('owncloud df -h')
|
||||
time.sleep(2)
|
||||
page.keyboard.press("Enter")
|
||||
time.sleep(2)
|
||||
|
||||
# Capture OwnCloud output
|
||||
terminal.locator("body").screenshot(path="service_owncloud.png")
|
||||
|
||||
|
||||
def mail_screenshot(url, username, password, service="mail"):
|
||||
"""
|
||||
Capture screenshots from Zimbra Mail Admin:
|
||||
- Monitor dashboard
|
||||
- Mail Queue
|
||||
"""
|
||||
output = f"service_{service}.png"
|
||||
|
||||
with sync_playwright() as pw:
|
||||
ctx = pw.chromium.launch(
|
||||
headless=True
|
||||
).new_context(ignore_https_errors=True, viewport={"width": 1920, "height": 1080})
|
||||
page = ctx.new_page()
|
||||
page.goto(url)
|
||||
|
||||
# Login to Zimbra Admin
|
||||
page.fill('input[name="ZLoginUserName"]', username)
|
||||
page.fill('input[name="ZLoginPassword"]', password)
|
||||
page.click('input[id="ZLoginButton"]')
|
||||
|
||||
# Navigate to Monitor dashboard
|
||||
monitor_tile = page.locator("div[id^='zti__AppAdmin__Home__monHV__']").get_by_text("Monitor")
|
||||
monitor_tile.wait_for(state="visible", timeout=20000)
|
||||
monitor_tile.click()
|
||||
page.screenshot(path=f"1. {output}", full_page=True)
|
||||
|
||||
time.sleep(5)
|
||||
|
||||
# Navigate to Mail Queue
|
||||
mail_queue_tile = page.locator("div[id^='zti__AppAdmin__monHV__']").get_by_text("Mail Queue")
|
||||
mail_queue_tile.click()
|
||||
time.sleep(5)
|
||||
page.screenshot(path=output, full_page=True)
|
||||
|
||||
|
||||
################################################################################################
|
||||
# Main script execution
|
||||
################################################################################################
|
||||
if __name__ == "__main__":
|
||||
# Ask user for WSL IP (required for Ceph Cockpit)
|
||||
wsl_ip = input("Enter WSL IP address: ")
|
||||
|
||||
print("Starting screenshot capture...")
|
||||
|
||||
# RabbitMQ
|
||||
print("Capturing RabbitMQ screenshot...")
|
||||
rabbitmq_screenshot("http://118.67.215.11:15672/#/", "guest", "guest", "#main", "rmq")
|
||||
print("RabbitMQ screenshot captured.")
|
||||
|
||||
# Observium
|
||||
print("Capturing Observium screenshot...")
|
||||
observium_screenshot("http://observium.brilliant.com.bd/", "admin", "0ObBs5e3rv!iuUm@#@!", "observium")
|
||||
print("Observium screenshot captured.")
|
||||
|
||||
# Firewall
|
||||
print("Capturing Firewall screenshot...")
|
||||
firewall_screenshot("https://118.67.210.46/login", "mosiur", "AD^%$bhy34Fw26@mnf234@97tr45")
|
||||
print("Firewall screenshot captured.")
|
||||
|
||||
# SFSSD
|
||||
print("Capturing SFSSD screenshot...")
|
||||
sfssd_screenshot("https://192.168.12.2/")
|
||||
print("SFSSD screenshot captured.")
|
||||
|
||||
# NVMe
|
||||
print("Capturing NVMe screenshot...")
|
||||
NVMe_screenshot("https://192.168.12.20/sysmgr/v4/")
|
||||
print("NVMe screenshot captured.")
|
||||
|
||||
# Ceph & OwnCloud
|
||||
print("Capturing Ceph and OwnCloud screenshot...")
|
||||
ceph_df_screenshot(wsl_ip)
|
||||
print("Ceph and OwnCloud screenshot captured.")
|
||||
|
||||
# Mail
|
||||
print("Capturing Mail screenshot...")
|
||||
mail_screenshot(
|
||||
"https://mail.brilliant.com.bd:9071/zimbraAdmin/",
|
||||
"admin",
|
||||
"A@dDmMI!N5#$%@B@6NW@#45#$%HGZI!MBbR@A"
|
||||
)
|
||||
print("Mail screenshot captured.")
|
||||
160
wsl/scripts/ops-snaps/capture_screenshot.py.bkp.23.09.25
Normal file
160
wsl/scripts/ops-snaps/capture_screenshot.py.bkp.23.09.25
Normal file
@@ -0,0 +1,160 @@
|
||||
from playwright.sync_api import sync_playwright
|
||||
import time
|
||||
import re
|
||||
from playwright.sync_api import sync_playwright, TimeoutError as PWTimeout
|
||||
|
||||
|
||||
|
||||
|
||||
def rabbitmq_screenshot(url, username, password, selector, service):
|
||||
|
||||
output = "service_" + service + ".png"
|
||||
|
||||
with sync_playwright() as pw:
|
||||
ctx = pw.chromium.launch(headless=True).new_context(ignore_https_errors=True)
|
||||
page = ctx.new_page()
|
||||
page.goto(url)
|
||||
print("Current URL:", page.url)
|
||||
|
||||
page.fill('input[name="username"]', username)
|
||||
page.fill('input[name="password"]', password)
|
||||
try:
|
||||
page.click('input[type="submit"]')
|
||||
except:
|
||||
page.click('button[type="submit"]')
|
||||
|
||||
page.wait_for_selector(selector)
|
||||
|
||||
time.sleep(2)
|
||||
page.locator(selector).screenshot(path=output)
|
||||
print(f"Saved screenshot: {output}")
|
||||
|
||||
|
||||
def observium_screenshot(url, username, password,service):
|
||||
output = "service_" + service + ".png"
|
||||
|
||||
with sync_playwright() as pw:
|
||||
ctx = pw.chromium.launch(headless=True).new_context(ignore_https_errors=True, viewport={"width": 1920, "height": 1080})
|
||||
page = ctx.new_page()
|
||||
page.goto(url)
|
||||
|
||||
page.fill('input[name="username"]', username)
|
||||
page.fill('input[name="password"]', password)
|
||||
page.click('button[id="submit"]')
|
||||
|
||||
|
||||
|
||||
|
||||
page.wait_for_selector(".container")
|
||||
|
||||
memory_url = "http://observium.brilliant.com.bd/health/metric=mempool/view=detail/device_id=37,40,67,70,72,77,83,84,86,87,95,96,99,103,105,52,106,107,115,31,85,108,50,121/mempool_descr=physical/requesttoken=f092f74f574a9770add7846d444d8ebc6af52ae93e958d41b252c439b48262b1/"
|
||||
page.goto(memory_url, wait_until="networkidle")
|
||||
|
||||
page.wait_for_selector("table.table", timeout=20000)
|
||||
|
||||
page.locator("table.table-condensed").screenshot(path="service_observium_memory.png")
|
||||
|
||||
|
||||
def firewall_screenshot(url, username, password, service="firewall"):
|
||||
output = "service_" + service + ".png"
|
||||
with sync_playwright() as pw:
|
||||
ctx = pw.chromium.launch(headless=True).new_context(ignore_https_errors=True, viewport={"width": 1920, "height": 1080})
|
||||
page = ctx.new_page()
|
||||
page.goto(url)
|
||||
|
||||
page.fill('input[name="username"]', username)
|
||||
page.fill('input[name="secretkey"]', password)
|
||||
page.click('button[type="button"]')
|
||||
time.sleep(5)
|
||||
dashbaord_url = "https://118.67.210.46/ng/system/dashboard/2?vdom=IC-CLOUD"
|
||||
page.goto(dashbaord_url, wait_until="networkidle")
|
||||
page.wait_for_selector("ul.module-list", timeout=20000)
|
||||
|
||||
page.screenshot(path=output, full_page=True)
|
||||
|
||||
def sfssd_screenshot(url, username="admin", password="sL1dSt0gE719", service="sfssd"):
|
||||
output = "service_" + service + ".png"
|
||||
with sync_playwright() as pw:
|
||||
ctx = pw.chromium.launch(headless=True).new_context(ignore_https_errors=True, viewport={"width": 1920, "height": 1080}, http_credentials={"username": username, "password": password})
|
||||
page = ctx.new_page()
|
||||
page.goto(url)
|
||||
|
||||
page.wait_for_selector("#reporting-overview", timeout=20000)
|
||||
time.sleep(15)
|
||||
|
||||
page.screenshot(path=output, full_page=True)
|
||||
|
||||
def NVMe_screenshot(url, username='admin', password='sL1dSt0gE2022', service="nvme"):
|
||||
output = "service" + service + ".png"
|
||||
with sync_playwright() as pw:
|
||||
browser = pw.chromium.launch(headless=True)
|
||||
ctx = browser.new_context(ignore_https_errors=True, viewport={"width": 1920, "height": 1080})
|
||||
page = ctx.new_page()
|
||||
page.goto(url)
|
||||
|
||||
page.fill('input[name="username"]', username)
|
||||
page.fill('input[name="password"]', password)
|
||||
page.click('button[type="submit"]')
|
||||
page.locator('[data-netapp-id="capacity-bar"]').click()
|
||||
|
||||
page.screenshot(path=output, full_page=True)
|
||||
|
||||
time.sleep(10)
|
||||
|
||||
def ceph_df_screenshot(ip, username='mosiur', password="123Rashik456", service="ceph"):
|
||||
output = "service_" + service + ".png"
|
||||
url = f"https://{ip}:9090"
|
||||
with sync_playwright() as pw:
|
||||
ctx = pw.chromium.launch(headless=True).new_context(ignore_https_errors=True, viewport={"width": 1920, "height": 1080})
|
||||
page = ctx.new_page()
|
||||
page.goto(url)
|
||||
|
||||
page.fill('input[id="login-user-input"]', username)
|
||||
page.fill('input[id="login-password-input"]', password)
|
||||
page.click('button[type="submit"]')
|
||||
# page.wait_for_load_state("networkidle")
|
||||
time.sleep(5)
|
||||
page.goto("https://172.20.151.21:9090/system/terminal")
|
||||
# page.wait_for_selector("#content iframe", timeout=20000)
|
||||
terminal = page.frame_locator("iframe[title='Terminal'], iframe[name='cockpit1:localhost/system/terminal']")
|
||||
# terminal.locator("#the-terminal").click()
|
||||
terminal.locator("body").click()
|
||||
time.sleep(2)
|
||||
|
||||
page.keyboard.type('source controller_creds')
|
||||
page.keyboard.press("Enter")
|
||||
page.keyboard.type('clear')
|
||||
page.keyboard.press("Enter")
|
||||
page.keyboard.type('scon1 ceph df && scon1 ceph -s')
|
||||
page.keyboard.press("Enter")
|
||||
time.sleep(5)
|
||||
|
||||
terminal.locator("body").screenshot(path=output)
|
||||
|
||||
################################################################################################
|
||||
wsl_ip = input("Enter WSL IP address: ")
|
||||
url = "http://118.67.215.11:15672/#/"
|
||||
username = "guest"
|
||||
password = "guest"
|
||||
selector = "#main"
|
||||
print("Starting screenshot capture...")
|
||||
print("Capturing RabbitMQ screenshot...")
|
||||
rabbitmq_screenshot(url, username, password, selector, "rmq")
|
||||
print("RabbitMQ screenshot captured.")
|
||||
print("Capturing Observium screenshot...")
|
||||
observium_screenshot("http://observium.brilliant.com.bd/", "admin", "0ObBs5e3rv!iuUm@#@!", "observium")
|
||||
print("Observium screenshot captured.")
|
||||
print("Capturing Firewall screenshot...")
|
||||
firewall_screenshot("https://118.67.210.46/login", "mosiur", "AD^%$bhy34Fw26@mnf234@97tr45")
|
||||
print("Firewall screenshot captured.")
|
||||
print("Capturing SFSSD screenshot...")
|
||||
sfssd_screenshot("https://192.168.12.2/")
|
||||
print("SFSSD screenshot captured.")
|
||||
print("Capturing NVMe screenshot...")
|
||||
NVMe_screenshot("https://192.168.12.20/sysmgr/v4/")
|
||||
print("NVMe screenshot captured.")
|
||||
print("Capturing Ceph screenshot...")
|
||||
ceph_df_screenshot(wsl_ip)
|
||||
# mail
|
||||
# cPanel
|
||||
# ownCloud
|
||||
194
wsl/scripts/ops-snaps/capture_screenshot.py.lastworking.23.09
Normal file
194
wsl/scripts/ops-snaps/capture_screenshot.py.lastworking.23.09
Normal file
@@ -0,0 +1,194 @@
|
||||
from playwright.sync_api import sync_playwright
|
||||
import time
|
||||
import re
|
||||
from playwright.sync_api import sync_playwright, TimeoutError as PWTimeout
|
||||
|
||||
|
||||
|
||||
|
||||
def rabbitmq_screenshot(url, username, password, selector, service):
|
||||
|
||||
output = "service_" + service + ".png"
|
||||
|
||||
with sync_playwright() as pw:
|
||||
ctx = pw.chromium.launch(headless=True).new_context(ignore_https_errors=True)
|
||||
page = ctx.new_page()
|
||||
page.goto(url)
|
||||
print("Current URL:", page.url)
|
||||
|
||||
page.fill('input[name="username"]', username)
|
||||
page.fill('input[name="password"]', password)
|
||||
try:
|
||||
page.click('input[type="submit"]')
|
||||
except:
|
||||
page.click('button[type="submit"]')
|
||||
|
||||
page.wait_for_selector(selector)
|
||||
|
||||
time.sleep(2)
|
||||
page.locator(selector).screenshot(path=output)
|
||||
print(f"Saved screenshot: {output}")
|
||||
|
||||
|
||||
def observium_screenshot(url, username, password,service):
|
||||
output = "service_" + service + ".png"
|
||||
|
||||
with sync_playwright() as pw:
|
||||
ctx = pw.chromium.launch(headless=True).new_context(ignore_https_errors=True, viewport={"width": 1920, "height": 1080})
|
||||
page = ctx.new_page()
|
||||
page.goto(url)
|
||||
|
||||
page.fill('input[name="username"]', username)
|
||||
page.fill('input[name="password"]', password)
|
||||
page.click('button[id="submit"]')
|
||||
|
||||
|
||||
|
||||
|
||||
page.wait_for_selector(".container")
|
||||
|
||||
memory_url = "http://observium.brilliant.com.bd/health/metric=mempool/view=detail/device_id=37,40,67,70,72,77,83,84,86,87,95,96,99,103,105,52,106,107,115,31,85,108,50,121/mempool_descr=physical/requesttoken=f092f74f574a9770add7846d444d8ebc6af52ae93e958d41b252c439b48262b1/"
|
||||
page.goto(memory_url, wait_until="networkidle")
|
||||
|
||||
page.wait_for_selector("table.table", timeout=20000)
|
||||
|
||||
page.locator("table.table-condensed").screenshot(path="service_observium_memory.png")
|
||||
|
||||
|
||||
def firewall_screenshot(url, username, password, service="firewall"):
|
||||
output = "service_" + service + ".png"
|
||||
with sync_playwright() as pw:
|
||||
ctx = pw.chromium.launch(headless=True).new_context(ignore_https_errors=True, viewport={"width": 1920, "height": 1080})
|
||||
page = ctx.new_page()
|
||||
page.goto(url)
|
||||
|
||||
page.fill('input[name="username"]', username)
|
||||
page.fill('input[name="secretkey"]', password)
|
||||
page.click('button[type="button"]')
|
||||
time.sleep(5)
|
||||
dashbaord_url = "https://118.67.210.46/ng/system/dashboard/2?vdom=IC-CLOUD"
|
||||
page.goto(dashbaord_url, wait_until="networkidle")
|
||||
page.wait_for_selector("ul.module-list", timeout=20000)
|
||||
|
||||
page.screenshot(path=output, full_page=True)
|
||||
|
||||
def sfssd_screenshot(url, username="admin", password="sL1dSt0gE719", service="sfssd"):
|
||||
output = "service_" + service + ".png"
|
||||
with sync_playwright() as pw:
|
||||
ctx = pw.chromium.launch(headless=True).new_context(ignore_https_errors=True, viewport={"width": 1920, "height": 1080}, http_credentials={"username": username, "password": password})
|
||||
page = ctx.new_page()
|
||||
page.goto(url)
|
||||
|
||||
page.wait_for_selector("#reporting-overview", timeout=20000)
|
||||
time.sleep(15)
|
||||
|
||||
page.screenshot(path=output, full_page=True)
|
||||
|
||||
def NVMe_screenshot(url, username='admin', password='sL1dSt0gE2022', service="nvme"):
|
||||
output = "service" + service + ".png"
|
||||
with sync_playwright() as pw:
|
||||
browser = pw.chromium.launch(headless=True)
|
||||
ctx = browser.new_context(ignore_https_errors=True, viewport={"width": 1920, "height": 1080})
|
||||
page = ctx.new_page()
|
||||
page.goto(url)
|
||||
|
||||
page.fill('input[name="username"]', username)
|
||||
page.fill('input[name="password"]', password)
|
||||
page.click('button[type="submit"]')
|
||||
page.locator('[data-netapp-id="capacity-bar"]').click()
|
||||
|
||||
page.screenshot(path=output, full_page=True)
|
||||
|
||||
time.sleep(10)
|
||||
|
||||
def ceph_df_screenshot(ip, username='mosiur', password="123Rashik456", service="ceph"):
|
||||
output = "service_" + service + ".png"
|
||||
url = f"https://{ip}:9090"
|
||||
with sync_playwright() as pw:
|
||||
ctx = pw.chromium.launch(headless=True).new_context(ignore_https_errors=True, viewport={"width": 1920, "height": 1080})
|
||||
page = ctx.new_page()
|
||||
page.goto(url)
|
||||
|
||||
page.fill('input[id="login-user-input"]', username)
|
||||
page.fill('input[id="login-password-input"]', password)
|
||||
page.click('button[type="submit"]')
|
||||
# page.wait_for_load_state("networkidle")
|
||||
time.sleep(5)
|
||||
page.goto("https://172.20.151.21:9090/system/terminal")
|
||||
# page.wait_for_selector("#content iframe", timeout=20000)
|
||||
terminal = page.frame_locator("iframe[title='Terminal'], iframe[name='cockpit1:localhost/system/terminal']")
|
||||
# terminal.locator("#the-terminal").click()
|
||||
terminal.locator("body").click()
|
||||
time.sleep(2)
|
||||
|
||||
page.keyboard.type('source controller_creds')
|
||||
page.keyboard.press("Enter")
|
||||
page.keyboard.type('clear')
|
||||
page.keyboard.press("Enter")
|
||||
page.keyboard.type('scon1 ceph df && scon1 ceph -s')
|
||||
page.keyboard.press("Enter")
|
||||
time.sleep(5)
|
||||
|
||||
terminal.locator("body").screenshot(path=output)
|
||||
|
||||
page.keyboard.type('clear')
|
||||
page.keyboard.press("Enter")
|
||||
page.keyboard.type('owncloud df -h')
|
||||
terminal.locator("body").screenshot(path="service_owncloud.png")
|
||||
|
||||
|
||||
def mail_screenshot(url, username, password, service="mail"):
|
||||
output = "service_" + service + ".png"
|
||||
with sync_playwright() as pw:
|
||||
ctx = pw.chromium.launch(headless=True).new_context(ignore_https_errors=True, viewport={"width": 1920, "height": 1080})
|
||||
page = ctx.new_page()
|
||||
page.goto(url)
|
||||
|
||||
page.fill('input[name="ZLoginUserName"]', username)
|
||||
page.fill('input[name="ZLoginPassword"]', password)
|
||||
page.click('input[id="ZLoginButton"]')
|
||||
|
||||
# page.wait_for_selector("#zti__AppAdmin__Home__monHV__DWT101_textCell", timeout=20000)
|
||||
monitor_tile = page.locator("div[id^='zti__AppAdmin__Home__monHV__']").get_by_text("Monitor")
|
||||
monitor_tile.wait_for(state="visible", timeout=20000)
|
||||
monitor_tile.click()
|
||||
# page.click('div[id^="zti__AppAdmin__Home__monHV__DWT101_div"]')
|
||||
page.screenshot(path="1. "+output, full_page=True)
|
||||
|
||||
time.sleep(5)
|
||||
mail_queue_tile = page.locator("div[id^='zti__AppAdmin__monHV__']").get_by_text("Mail Queue")
|
||||
# mail_queue_tile.wait_for(state="visible", timeout=20000)
|
||||
mail_queue_tile.click()
|
||||
time.sleep(5)
|
||||
page.screenshot(path=output, full_page=True)
|
||||
|
||||
################################################################################################
|
||||
wsl_ip = input("Enter WSL IP address: ")
|
||||
url = "http://118.67.215.11:15672/#/"
|
||||
username = "guest"
|
||||
password = "guest"
|
||||
selector = "#main"
|
||||
print("Starting screenshot capture...")
|
||||
print("Capturing RabbitMQ screenshot...")
|
||||
rabbitmq_screenshot(url, username, password, selector, "rmq")
|
||||
print("RabbitMQ screenshot captured.")
|
||||
print("Capturing Observium screenshot...")
|
||||
observium_screenshot("http://observium.brilliant.com.bd/", "admin", "0ObBs5e3rv!iuUm@#@!", "observium")
|
||||
print("Observium screenshot captured.")
|
||||
print("Capturing Firewall screenshot...")
|
||||
firewall_screenshot("https://118.67.210.46/login", "mosiur", "AD^%$bhy34Fw26@mnf234@97tr45")
|
||||
print("Firewall screenshot captured.")
|
||||
print("Capturing SFSSD screenshot...")
|
||||
sfssd_screenshot("https://192.168.12.2/")
|
||||
print("SFSSD screenshot captured.")
|
||||
print("Capturing NVMe screenshot...")
|
||||
NVMe_screenshot("https://192.168.12.20/sysmgr/v4/")
|
||||
print("NVMe screenshot captured.")
|
||||
print("Capturing Ceph and observium screenshot...")
|
||||
ceph_df_screenshot(wsl_ip)
|
||||
print("Ceph screenshot captured.")
|
||||
print("Capturing Mail screenshot...")
|
||||
mail_screenshot("https://mail.brilliant.com.bd:9071/zimbraAdmin/", "admin", "A@dDmMI!N5#$%@B@6NW@#45#$%HGZI!MBbR@A")
|
||||
print("Mail screenshot captured.")
|
||||
# cPanel
|
||||
# ownCloud
|
||||
185
wsl/scripts/ops-snaps/capture_screenshot.py.v2
Normal file
185
wsl/scripts/ops-snaps/capture_screenshot.py.v2
Normal file
@@ -0,0 +1,185 @@
|
||||
from playwright.sync_api import sync_playwright
|
||||
import time
|
||||
import re
|
||||
from playwright.sync_api import sync_playwright, TimeoutError as PWTimeout
|
||||
|
||||
|
||||
|
||||
|
||||
def rabbitmq_screenshot(url, username, password, selector, service):
|
||||
|
||||
output = "service_" + service + ".png"
|
||||
|
||||
with sync_playwright() as pw:
|
||||
ctx = pw.chromium.launch(headless=True).new_context(ignore_https_errors=True)
|
||||
page = ctx.new_page()
|
||||
page.goto(url)
|
||||
print("Current URL:", page.url)
|
||||
|
||||
page.fill('input[name="username"]', username)
|
||||
page.fill('input[name="password"]', password)
|
||||
try:
|
||||
page.click('input[type="submit"]')
|
||||
except:
|
||||
page.click('button[type="submit"]')
|
||||
|
||||
page.wait_for_selector(selector)
|
||||
|
||||
time.sleep(2)
|
||||
page.locator(selector).screenshot(path=output)
|
||||
print(f"Saved screenshot: {output}")
|
||||
|
||||
|
||||
def observium_screenshot(url, username, password,service):
|
||||
output = "service_" + service + ".png"
|
||||
|
||||
with sync_playwright() as pw:
|
||||
ctx = pw.chromium.launch(headless=True).new_context(ignore_https_errors=True, viewport={"width": 1920, "height": 1080})
|
||||
page = ctx.new_page()
|
||||
page.goto(url)
|
||||
|
||||
page.fill('input[name="username"]', username)
|
||||
page.fill('input[name="password"]', password)
|
||||
page.click('button[id="submit"]')
|
||||
|
||||
|
||||
|
||||
|
||||
page.wait_for_selector(".container")
|
||||
|
||||
memory_url = "http://observium.brilliant.com.bd/health/metric=mempool/view=detail/device_id=37,40,67,70,72,77,83,84,86,87,95,96,99,103,105,52,106,107,115,31,85,108,50,121/mempool_descr=physical/requesttoken=f092f74f574a9770add7846d444d8ebc6af52ae93e958d41b252c439b48262b1/"
|
||||
page.goto(memory_url, wait_until="networkidle")
|
||||
|
||||
page.wait_for_selector("table.table", timeout=20000)
|
||||
|
||||
page.locator("table.table-condensed").screenshot(path="service_observium_memory.png")
|
||||
|
||||
|
||||
def firewall_screenshot(url, username, password, service="firewall"):
|
||||
output = "service_" + service + ".png"
|
||||
with sync_playwright() as pw:
|
||||
ctx = pw.chromium.launch(headless=True).new_context(ignore_https_errors=True, viewport={"width": 1920, "height": 1080})
|
||||
page = ctx.new_page()
|
||||
page.goto(url)
|
||||
|
||||
page.fill('input[name="username"]', username)
|
||||
page.fill('input[name="secretkey"]', password)
|
||||
page.click('button[type="button"]')
|
||||
time.sleep(5)
|
||||
dashbaord_url = "https://118.67.210.46/ng/system/dashboard/2?vdom=IC-CLOUD"
|
||||
page.goto(dashbaord_url, wait_until="networkidle")
|
||||
page.wait_for_selector("ul.module-list", timeout=20000)
|
||||
|
||||
page.screenshot(path=output, full_page=True)
|
||||
|
||||
def sfssd_screenshot(url, username="admin", password="sL1dSt0gE719", service="sfssd"):
|
||||
output = "service_" + service + ".png"
|
||||
with sync_playwright() as pw:
|
||||
ctx = pw.chromium.launch(headless=True).new_context(ignore_https_errors=True, viewport={"width": 1920, "height": 1080}, http_credentials={"username": username, "password": password})
|
||||
page = ctx.new_page()
|
||||
page.goto(url)
|
||||
|
||||
page.wait_for_selector("#reporting-overview", timeout=20000)
|
||||
time.sleep(15)
|
||||
|
||||
page.screenshot(path=output, full_page=True)
|
||||
|
||||
def NVMe_screenshot(url, username='admin', password='sL1dSt0gE2022', service="nvme"):
|
||||
output = "service" + service + ".png"
|
||||
with sync_playwright() as pw:
|
||||
browser = pw.chromium.launch(headless=True)
|
||||
ctx = browser.new_context(ignore_https_errors=True, viewport={"width": 1920, "height": 1080})
|
||||
page = ctx.new_page()
|
||||
page.goto(url)
|
||||
|
||||
page.fill('input[name="username"]', username)
|
||||
page.fill('input[name="password"]', password)
|
||||
page.click('button[type="submit"]')
|
||||
page.locator('[data-netapp-id="capacity-bar"]').click()
|
||||
|
||||
page.screenshot(path=output, full_page=True)
|
||||
|
||||
time.sleep(10)
|
||||
|
||||
def ceph_df_screenshot(ip, username='mosiur', password="123Rashik456", service="ceph"):
|
||||
output = "service_" + service + ".png"
|
||||
url = f"https://{ip}:9090"
|
||||
with sync_playwright() as pw:
|
||||
ctx = pw.chromium.launch(headless=True).new_context(ignore_https_errors=True, viewport={"width": 1920, "height": 1080})
|
||||
page = ctx.new_page()
|
||||
page.goto(url)
|
||||
|
||||
page.fill('input[id="login-user-input"]', username)
|
||||
page.fill('input[id="login-password-input"]', password)
|
||||
page.click('button[type="submit"]')
|
||||
# page.wait_for_load_state("networkidle")
|
||||
time.sleep(5)
|
||||
page.goto("https://172.20.151.21:9090/system/terminal")
|
||||
# page.wait_for_selector("#content iframe", timeout=20000)
|
||||
terminal = page.frame_locator("iframe[title='Terminal'], iframe[name='cockpit1:localhost/system/terminal']")
|
||||
# terminal.locator("#the-terminal").click()
|
||||
terminal.locator("body").click()
|
||||
time.sleep(2)
|
||||
|
||||
page.keyboard.type('source controller_creds')
|
||||
page.keyboard.press("Enter")
|
||||
page.keyboard.type('clear')
|
||||
page.keyboard.press("Enter")
|
||||
page.keyboard.type('scon1 ceph df && scon1 ceph -s')
|
||||
page.keyboard.press("Enter")
|
||||
time.sleep(5)
|
||||
|
||||
terminal.locator("body").screenshot(path=output)
|
||||
|
||||
def mail_screenshot(url, username, password, service="mail"):
|
||||
output = "service_" + service + ".png"
|
||||
with sync_playwright() as pw:
|
||||
ctx = pw.chromium.launch(headless=True).new_context(ignore_https_errors=True, viewport={"width": 1920, "height": 1080})
|
||||
page = ctx.new_page()
|
||||
page.goto(url)
|
||||
|
||||
page.fill('input[name="ZLoginUserName"]', username)
|
||||
page.fill('input[name="ZLoginPassword"]', password)
|
||||
page.click('input[id="ZLoginButton"]')
|
||||
|
||||
# page.wait_for_selector("#zti__AppAdmin__Home__monHV__DWT101_textCell", timeout=20000)
|
||||
monitor_tile = page.locator("div[id^='zti__AppAdmin__Home__monHV__']").get_by_text("Monitor")
|
||||
monitor_tile.wait_for(state="visible", timeout=20000)
|
||||
monitor_tile.click()
|
||||
# page.click('div[id^="zti__AppAdmin__Home__monHV__DWT101_div"]')
|
||||
page.screenshot(path=output+"-1", full_page=True)
|
||||
|
||||
time.sleep(5)
|
||||
mail_queue_tile = page.locator("div[id^='zti__AppAdmin__monHV__']").get_by_text("Mail Queue")
|
||||
# mail_queue_tile.wait_for(state="visible", timeout=20000)
|
||||
mail_queue_tile.click()
|
||||
time.sleep(5)
|
||||
page.screenshot(path=output, full_page=True)
|
||||
|
||||
################################################################################################
|
||||
wsl_ip = input("Enter WSL IP address: ")
|
||||
url = "http://118.67.215.11:15672/#/"
|
||||
username = "guest"
|
||||
password = "guest"
|
||||
selector = "#main"
|
||||
print("Starting screenshot capture...")
|
||||
print("Capturing RabbitMQ screenshot...")
|
||||
rabbitmq_screenshot(url, username, password, selector, "rmq")
|
||||
print("RabbitMQ screenshot captured.")
|
||||
print("Capturing Observium screenshot...")
|
||||
observium_screenshot("http://observium.brilliant.com.bd/", "admin", "0ObBs5e3rv!iuUm@#@!", "observium")
|
||||
print("Observium screenshot captured.")
|
||||
print("Capturing Firewall screenshot...")
|
||||
firewall_screenshot("https://118.67.210.46/login", "mosiur", "AD^%$bhy34Fw26@mnf234@97tr45")
|
||||
print("Firewall screenshot captured.")
|
||||
print("Capturing SFSSD screenshot...")
|
||||
sfssd_screenshot("https://192.168.12.2/")
|
||||
print("SFSSD screenshot captured.")
|
||||
print("Capturing NVMe screenshot...")
|
||||
NVMe_screenshot("https://192.168.12.20/sysmgr/v4/")
|
||||
print("NVMe screenshot captured.")
|
||||
print("Capturing Ceph screenshot...")
|
||||
ceph_df_screenshot(wsl_ip)
|
||||
mail_screenshot("https://mail.brilliant.com.bd:9071/zimbraAdmin/", "admin", "A@dDmMI!N5#$%@B@6NW@#45#$%HGZI!MBbR@A")
|
||||
# cPanel
|
||||
# ownCloud
|
||||
4
wsl/scripts/ops-snaps/requirements.txt
Normal file
4
wsl/scripts/ops-snaps/requirements.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
greenlet==3.2.4
|
||||
playwright==1.54.0
|
||||
pyee==13.0.0
|
||||
typing_extensions==4.15.0
|
||||
1
wsl/scripts/ops-snaps/session_rmq.json
Normal file
1
wsl/scripts/ops-snaps/session_rmq.json
Normal file
@@ -0,0 +1 @@
|
||||
{"cookies": [{"name": "m", "value": "2258:Z3Vlc3Q6Z3Vlc3Q%253D", "domain": "118.67.215.11", "path": "/", "expires": 1756409453, "httpOnly": false, "secure": false, "sameSite": "Lax"}], "origins": [{"origin": "http://118.67.215.11:15672", "localStorage": [{"name": "rabbitmq.vhost", "value": ""}]}]}
|
||||
16
wsl/scripts/ops-snaps/session_rmq.py
Normal file
16
wsl/scripts/ops-snaps/session_rmq.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from playwright.sync_api import sync_playwright
|
||||
|
||||
url = "http://118.67.215.11:15672/#/"
|
||||
|
||||
with sync_playwright() as pw:
|
||||
browser = pw.chromium.launch(headless=False)
|
||||
ctx = browser.new_context(ignore_https_errors=True)
|
||||
page = ctx.new_page()
|
||||
page.goto(url)
|
||||
print("\nA browser window is open. Log in to RabbitMQ as you normally do.")
|
||||
print("After you see the Overview (or main dashboard) fully loaded, come back here.")
|
||||
input("Press Enter to continue...")
|
||||
ctx.storage_state(path="session_rmq.json")
|
||||
print("Session saved to session_rmq.json")
|
||||
browser.close()
|
||||
|
||||
Reference in New Issue
Block a user