Skip to main content
removeu 3 caracteres do conteúdo
Fonte Link
Syzoth
  • 100,5mil
  • 23
  • 169
  • 361

import subprocess import os import time import tkinter as tk import matplotlib.pyplot as plt from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg

ips = ['10.0.0.1', '10.0.0.100', '10.0.0.110', '10.0.0.111', '10.0.0.112', '10.0.0.113', '10.0.0.116']

def check_ips(): for ip in ips: try: result = subprocess.check_output(["ping", "-n", "3", "-w", "3", ip]) ip_status[ip] = "ativo" except subprocess.CalledProcessError: ip_status[ip] = "inativo"

import subprocess
import os
import time
import tkinter as tk
import matplotlib.pyplot as plt
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg

ips = ['10.0.0.1', '10.0.0.100', '10.0.0.110', '10.0.0.111', '10.0.0.112', '10.0.0.113', '10.0.0.116']


def check_ips():
    for ip in ips:
        try:
            result = subprocess.check_output(["ping", "-n", "3", "-w", "3", ip])
            ip_status[ip] = "ativo"
        except subprocess.CalledProcessError:
            ip_status[ip] = "inativo"

    update_dashboard()

    root.after(5000, check_ips)  # Executar a cada 5 segundos

def update_dashboard(): for ip, status in ip_status.items(): label = ip_labels[ip] label.config(text=f"{ip}: {status}")



def update_dashboard():
    for ip, status in ip_status.items():
        label = ip_labels[ip]
        label.config(text=f"{ip}: {status}")

    plot_graph()


def plot_graph():
    plt.clf()
    statuses = list(ip_status.values())
    plt.bar(ips, statuses, color=['green' if status == 'ativo' else 'red' for status in statuses])
    plt.xlabel('IPs')
    plt.ylabel('Status')
    plt.title('Status dos IPs')
    canvas = FigureCanvasTkAgg(plt.gcf(), master=frame)
    canvas_widget = canvas.get_tk_widget()
    canvas_widget.pack()


root = tk.Tk()
root.title("Exemplo")

ip_status = {}
ip_labels = {}

frame = tk.Frame(root)
frame.pack()

for ip in ips:
    label = tk.Label(frame, text=f"{ip}: Verificando...", padx=10)
    label.pack()
    ip_labels[ip] = label
    ip_status[ip] = "Verificando..."

check_ips()

root.mainloop()

def plot_graph(): plt.clf() statuses = list(ip_status.values()) plt.bar(ips, statuses, color=['green' if status == 'ativo' else 'red' for status in statuses]) plt.xlabel('IPs') plt.ylabel('Status') plt.title('Status dos IPs') canvas = FigureCanvasTkAgg(plt.gcf(), master=frame) canvas_widget = canvas.get_tk_widget() canvas_widget.pack()

root = tk.Tk() root.title("MONITORAMENTO FRIBAL")

ip_status = {} ip_labels = {}

frame = tk.Frame(root) frame.pack()

for ip in ips: label = tk.Label(frame, text=f"{ip}: Verificando...", padx=10) label.pack() ip_labels[ip] = label ip_status[ip] = "Verificando..."

check_ips()

root.mainloop()

import subprocess import os import time import tkinter as tk import matplotlib.pyplot as plt from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg

ips = ['10.0.0.1', '10.0.0.100', '10.0.0.110', '10.0.0.111', '10.0.0.112', '10.0.0.113', '10.0.0.116']

def check_ips(): for ip in ips: try: result = subprocess.check_output(["ping", "-n", "3", "-w", "3", ip]) ip_status[ip] = "ativo" except subprocess.CalledProcessError: ip_status[ip] = "inativo"

update_dashboard()

root.after(5000, check_ips)  # Executar a cada 5 segundos

def update_dashboard(): for ip, status in ip_status.items(): label = ip_labels[ip] label.config(text=f"{ip}: {status}")

plot_graph()

def plot_graph(): plt.clf() statuses = list(ip_status.values()) plt.bar(ips, statuses, color=['green' if status == 'ativo' else 'red' for status in statuses]) plt.xlabel('IPs') plt.ylabel('Status') plt.title('Status dos IPs') canvas = FigureCanvasTkAgg(plt.gcf(), master=frame) canvas_widget = canvas.get_tk_widget() canvas_widget.pack()

root = tk.Tk() root.title("MONITORAMENTO FRIBAL")

ip_status = {} ip_labels = {}

frame = tk.Frame(root) frame.pack()

for ip in ips: label = tk.Label(frame, text=f"{ip}: Verificando...", padx=10) label.pack() ip_labels[ip] = label ip_status[ip] = "Verificando..."

check_ips()

root.mainloop()

import subprocess
import os
import time
import tkinter as tk
import matplotlib.pyplot as plt
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg

ips = ['10.0.0.1', '10.0.0.100', '10.0.0.110', '10.0.0.111', '10.0.0.112', '10.0.0.113', '10.0.0.116']


def check_ips():
    for ip in ips:
        try:
            result = subprocess.check_output(["ping", "-n", "3", "-w", "3", ip])
            ip_status[ip] = "ativo"
        except subprocess.CalledProcessError:
            ip_status[ip] = "inativo"

    update_dashboard()

    root.after(5000, check_ips)  # Executar a cada 5 segundos


def update_dashboard():
    for ip, status in ip_status.items():
        label = ip_labels[ip]
        label.config(text=f"{ip}: {status}")

    plot_graph()


def plot_graph():
    plt.clf()
    statuses = list(ip_status.values())
    plt.bar(ips, statuses, color=['green' if status == 'ativo' else 'red' for status in statuses])
    plt.xlabel('IPs')
    plt.ylabel('Status')
    plt.title('Status dos IPs')
    canvas = FigureCanvasTkAgg(plt.gcf(), master=frame)
    canvas_widget = canvas.get_tk_widget()
    canvas_widget.pack()


root = tk.Tk()
root.title("Exemplo")

ip_status = {}
ip_labels = {}

frame = tk.Frame(root)
frame.pack()

for ip in ips:
    label = tk.Label(frame, text=f"{ip}: Verificando...", padx=10)
    label.pack()
    ip_labels[ip] = label
    ip_status[ip] = "Verificando..."

check_ips()

root.mainloop()
Fonte Link

Agradeço pelo post de vocês e gostaria de por minha contribuição

import subprocess import os import time import tkinter as tk import matplotlib.pyplot as plt from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg

ips = ['10.0.0.1', '10.0.0.100', '10.0.0.110', '10.0.0.111', '10.0.0.112', '10.0.0.113', '10.0.0.116']

def check_ips(): for ip in ips: try: result = subprocess.check_output(["ping", "-n", "3", "-w", "3", ip]) ip_status[ip] = "ativo" except subprocess.CalledProcessError: ip_status[ip] = "inativo"

update_dashboard()

root.after(5000, check_ips)  # Executar a cada 5 segundos

def update_dashboard(): for ip, status in ip_status.items(): label = ip_labels[ip] label.config(text=f"{ip}: {status}")

plot_graph()

def plot_graph(): plt.clf() statuses = list(ip_status.values()) plt.bar(ips, statuses, color=['green' if status == 'ativo' else 'red' for status in statuses]) plt.xlabel('IPs') plt.ylabel('Status') plt.title('Status dos IPs') canvas = FigureCanvasTkAgg(plt.gcf(), master=frame) canvas_widget = canvas.get_tk_widget() canvas_widget.pack()

root = tk.Tk() root.title("MONITORAMENTO FRIBAL")

ip_status = {} ip_labels = {}

frame = tk.Frame(root) frame.pack()

for ip in ips: label = tk.Label(frame, text=f"{ip}: Verificando...", padx=10) label.pack() ip_labels[ip] = label ip_status[ip] = "Verificando..."

check_ips()

root.mainloop()