slakwik commited on
Commit
6e51123
·
verified ·
1 Parent(s): 694b2e2

Upload streamlit_app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. streamlit_app.py +9 -11
streamlit_app.py CHANGED
@@ -4,7 +4,7 @@ import json
4
  from datetime import datetime, timedelta
5
  import pandas as pd
6
  import time
7
- from utils import zabbix_api, ollama_analysis
8
  from config import ZABBIX_API_URL, OLLAMA_API_URL
9
 
10
  # Set page config
@@ -76,7 +76,8 @@ with st.sidebar:
76
  if st.button("Connect to Zabbix"):
77
  with st.spinner("Connecting to Zabbix..."):
78
  try:
79
- auth_token = zabbix_api.authenticate(zabbix_url, zabbix_user, zabbix_password)
 
80
  if auth_token:
81
  st.session_state.zabbix_auth_token = auth_token
82
  st.success("Successfully connected to Zabbix!")
@@ -89,13 +90,14 @@ with st.sidebar:
89
  with st.expander("Event Filters", expanded=True):
90
  if st.session_state.zabbix_auth_token:
91
  # Get host groups
92
- host_groups = zabbix_api.get_host_groups(zabbix_url, st.session_state.zabbix_auth_token)
 
93
  selected_group = st.selectbox("Host Group", [""] + [g['name'] for g in host_groups])
94
 
95
  # Get hosts based on selected group
96
  hosts = []
97
  if selected_group:
98
- hosts = zabbix_api.get_hosts_by_group(zabbix_url, st.session_state.zabbix_auth_token, selected_group)
99
  selected_host = st.selectbox("Host", [""] + [h['name'] for h in hosts])
100
 
101
  # Time range
@@ -126,8 +128,7 @@ with st.sidebar:
126
  end_time = int(time.time())
127
  start_time = end_time - (time_range * 3600)
128
 
129
- events = zabbix_api.get_events(
130
- zabbix_url,
131
  st.session_state.zabbix_auth_token,
132
  start_time,
133
  end_time,
@@ -190,11 +191,8 @@ if st.session_state.events_data:
190
  )
191
 
192
  # Get analysis from Ollama
193
- analysis = ollama_analysis.get_analysis(
194
- ollama_url,
195
- model_name,
196
- prompt
197
- )
198
 
199
  if analysis:
200
  st.session_state.analysis_results = analysis
 
4
  from datetime import datetime, timedelta
5
  import pandas as pd
6
  import time
7
+ from utils import ZabbixAPI, OllamaAnalysis
8
  from config import ZABBIX_API_URL, OLLAMA_API_URL
9
 
10
  # Set page config
 
76
  if st.button("Connect to Zabbix"):
77
  with st.spinner("Connecting to Zabbix..."):
78
  try:
79
+ zabbix = ZabbixAPI(zabbix_url)
80
+ auth_token = zabbix.authenticate(zabbix_user, zabbix_password)
81
  if auth_token:
82
  st.session_state.zabbix_auth_token = auth_token
83
  st.success("Successfully connected to Zabbix!")
 
90
  with st.expander("Event Filters", expanded=True):
91
  if st.session_state.zabbix_auth_token:
92
  # Get host groups
93
+ zabbix = ZabbixAPI(zabbix_url)
94
+ host_groups = zabbix.get_host_groups(st.session_state.zabbix_auth_token)
95
  selected_group = st.selectbox("Host Group", [""] + [g['name'] for g in host_groups])
96
 
97
  # Get hosts based on selected group
98
  hosts = []
99
  if selected_group:
100
+ hosts = zabbix.get_hosts_by_group(st.session_state.zabbix_auth_token, selected_group)
101
  selected_host = st.selectbox("Host", [""] + [h['name'] for h in hosts])
102
 
103
  # Time range
 
128
  end_time = int(time.time())
129
  start_time = end_time - (time_range * 3600)
130
 
131
+ events = zabbix.get_events(
 
132
  st.session_state.zabbix_auth_token,
133
  start_time,
134
  end_time,
 
191
  )
192
 
193
  # Get analysis from Ollama
194
+ ollama = OllamaAnalysis(ollama_url)
195
+ analysis = ollama.get_analysis(model_name, prompt)
 
 
 
196
 
197
  if analysis:
198
  st.session_state.analysis_results = analysis