-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
122 lines (101 loc) · 3.72 KB
/
Copy pathapp.py
File metadata and controls
122 lines (101 loc) · 3.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import streamlit as st
import sys
from ai_sre.agent import SREAgent
from ai_sre.tools import SRETools
from ai_sre.config import Config
st.set_page_config(
page_title="AI-SRE Autonomous Troubleshooting Agent",
page_icon="🛡️",
layout="wide",
initial_sidebar_state="expanded"
)
# Custom Glassmorphic Premium Stylesheet injection
st.markdown("""
<style>
.reportview-container {
background: #0e1117;
}
.metric-card {
background: rgba(255, 255, 255, 0.03);
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 12px;
padding: 20px;
transition: transform 0.2s ease-in-out;
}
.metric-card:hover {
transform: translateY(-2px);
border-color: rgba(0, 255, 128, 0.4);
}
.terminal-output {
font-family: 'Courier New', Courier, monospace;
background-color: #0b0c10;
color: #66ff66;
padding: 15px;
border-radius: 8px;
border-left: 5px solid #00ff80;
overflow-x: auto;
}
</style>
""", unsafe_allow_html=True)
st.title("🛡️ AI-SRE: Autonomous Linux Troubleshooting Agent")
st.markdown("---")
# Sidebar settings panel
with st.sidebar:
st.image("https://img.icons8.com/color/144/shield.png", width=80)
st.header("Agent Control Center")
api_provider, _ = Config.get_api_key()
st.info(f"Active Provider: **{api_provider.upper()} Mode**")
st.subheader("System Health Metrics")
st.sidebar.progress(85, text="Server Uptime: 99.8%")
st.sidebar.progress(40, text="RAM Usage: 40%")
# Layout Splitting
col_query, col_metric = st.columns([2, 1])
with col_query:
st.subheader("🤖 SRE Incident Reporter")
query = st.text_input("Enter your server issue, warning log, or diagnostic query:", placeholder="e.g. My database port 5432 is blocked and I have disk space failures")
if st.button("Launch Autonomous SRE Audit", type="primary"):
if not query:
st.warning("Please describe your system issue before auditing.")
else:
agent = SREAgent(mode="mock")
trace_placeholder = st.empty()
trace_logs = []
def render_trace(msg):
trace_logs.append(f"[AGENT] {msg}")
trace_placeholder.markdown(
f'<div class="terminal-output">{"<br>".join(trace_logs)}</div>',
unsafe_allow_html=True
)
res = agent.run(query, trace_callback=render_trace)
st.session_state["sre_results"] = res
with col_metric:
st.subheader("📊 System Vital Gauges")
st.markdown(
'''
<div class="metric-card">
<h4>Storage Cluster</h4>
<h2 style="color:#ff4d4d;">94% In Use</h2>
<p>Partition <b>/dev/sda1</b> is near capacity limits.</p>
</div>
<br>
<div class="metric-card">
<h4>Port Daemon</h4>
<h2 style="color:#ffcc00;">Warning Binding</h2>
<p>Port <b>5432</b> is not accepting connections.</p>
</div>
''',
unsafe_allow_html=True
)
if "sre_results" in st.session_state:
res = st.session_state["sre_results"]
st.markdown("---")
col_analysis, col_code = st.columns([1, 1])
with col_analysis:
st.error("🚨 Root Cause Analysis Findings")
st.write(res["analysis"])
st.warning("🛡️ Execution Safety Assurance")
st.write(res["explanation"])
with col_code:
st.success("🛠️ Recommended Bash Safe-Fix Script")
st.code(res["bash_fix"], language="bash")
st.info("💡 Copy and review the script contents before executing on production servers.")