We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import pandas as pd import numpy as np import requests
def collect_data(api_url): response = requests.get(api_url) data = response.json() df = pd.DataFrame(data) return df
api_url = "https://example.com/api/system_status" data = collect_data(api_url)from sklearn.ensemble import IsolationForest
def detect_anomalies(data): model = IsolationForest(contamination=0.01) model.fit(data) data['anomaly'] = model.predict(data) anomalies = data[data['anomaly'] == -1] return anomalies
anomalies = detect_anomalies(data)from twilio.rest import Client
def send_alert(anomalies): if not anomalies.empty: account_sid = 'your_account_sid' auth_token = 'your_auth_token' client = Client(account_sid, auth_token) message = client.messages.create( body=f"Anomalias detectadas: {anomalies}", from_='+1234567890', to='+0987654321' ) print(message.sid)
send_alert(anomalies) from flask import Flask, render_template import pandas as pd
app = Flask(name)
@app.route('/') def index(): data = collect_data(api_url) anomalies = detect_anomalies(data) return render_template('index.html', tables=[data.to_html(classes='data', header="true"), anomalies.to_html(classes='data', header="true")])
if name == 'main': app.run(debug=True)from apscheduler.schedulers.blocking import BlockingScheduler
scheduler = BlockingScheduler()
@scheduler.scheduled_job('interval', minutes=5) def scheduled_job(): data = collect_data(api_url) anomalies = detect_anomalies(data) send_alert(anomalies)
scheduler.start()
The text was updated successfully, but these errors were encountered:
No branches or pull requests
import pandas as pd
import numpy as np
import requests
def collect_data(api_url):
response = requests.get(api_url)
data = response.json()
df = pd.DataFrame(data)
return df
Exemplo de URL de API para coleta de dados
api_url = "https://example.com/api/system_status"
data = collect_data(api_url)from sklearn.ensemble import IsolationForest
def detect_anomalies(data):
model = IsolationForest(contamination=0.01)
model.fit(data)
data['anomaly'] = model.predict(data)
anomalies = data[data['anomaly'] == -1]
return anomalies
anomalies = detect_anomalies(data)from twilio.rest import Client
def send_alert(anomalies):
if not anomalies.empty:
account_sid = 'your_account_sid'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)
message = client.messages.create(
body=f"Anomalias detectadas: {anomalies}",
from_='+1234567890',
to='+0987654321'
)
print(message.sid)
send_alert(anomalies)
from flask import Flask, render_template
import pandas as pd
app = Flask(name)
@app.route('/')
def index():
data = collect_data(api_url)
anomalies = detect_anomalies(data)
return render_template('index.html', tables=[data.to_html(classes='data', header="true"), anomalies.to_html(classes='data', header="true")])
if name == 'main':
app.run(debug=True)from apscheduler.schedulers.blocking import BlockingScheduler
scheduler = BlockingScheduler()
@scheduler.scheduled_job('interval', minutes=5)
def scheduled_job():
data = collect_data(api_url)
anomalies = detect_anomalies(data)
send_alert(anomalies)
scheduler.start()
<title>TechGuardian Dashboard</title>Status dos Sistemas
Dados Coletados
Anomalias Detectadas
The text was updated successfully, but these errors were encountered: