This is an old revision of the document!
gate# cat /etc/zabbix/zabbix_agentd.conf.d/corpX.conf
... ServerActive=server
gate# ps axu | grep zabbix gate# ls -l /var/log/syslog gate# usermod -aG adm zabbix gate# service zabbix-agent restart
Host: gate.corpX.un Item: Name: High|Error log in syslog Type: Zabbix Agent(active) Key: log[/var/log/syslog,(?i)error,,,skip] Key: log[/var/log/syslog,^(?!.*(?i:test|debug|vmwgfx)).*(?i:error|abandon|fail|expire),,,skip] Key: log[/var/log/syslog.high,,,,skip] Update interval: 10s History: 1d
Preprocessing:
Name: Does not match regular expression
Parameters: LPM|ehci_hcd|collector initialized
Custom on fail: Discard Value
Name: Does not match regular expression
Parameters: fail to add MMCONFIG information
Custom on fail: Discard Value
Trigger:
Name: High|Error log in syslog on {HOST.NAME}
Severity: Warning
Expression: nodata(/gate.corpX.un/log[/var/log/syslog..., ... ],1m)=0
# cat /etc/default/zabbix-server YANDEX_API_KEY=... YANDEX_FOLDER_ID=... # chmod 600 /etc/default/zabbix-server
(zabbix_venv) server.corp13.un:/usr/lib/zabbix/alertscripts# cat llm_context_enrichment.py
#!/opt/zabbix_venv/bin/python3
import sys
import smtplib
import re
from email.header import Header
from email.mime.text import MIMEText
import request_to_agent
SMTP_SERVER = "localhost"
SENDER_EMAIL = "zabbix-llm@corp13.un"
SYSTEM_PROMPT = (
"Ты - IT эксперт.\n"
"Оцени важность сообщения и уточни, почему.\n"
"Первое слово в ответе должно быть да или нет.\n"
)
alert_sendto = sys.argv[1]
alert_subject = sys.argv[2]
alert_message = sys.argv[3]
#agent_response = request_to_agent.request_to_agent(alert_message, SYSTEM_PROMPT, "")
agent_response = alert_message
match = re.search(r'^\s*([a-zA-Zа-яА-Я1-9]+)', agent_response)
first_word = match.group(1)
remaining_text = agent_response[match.end():]
'''
print(first_word)
print(alert_sendto)
print(alert_message)
#print(agent_response)
print(remaining_text)
'''
msg = MIMEText(alert_message + remaining_text, "plain", "utf-8")
if first_word.lower() == 'да':
msg["Subject"] = Header("ВНИМАНИЕ! " + alert_subject, "utf-8")
else:
msg["Subject"] = Header(alert_subject, "utf-8")
msg["From"] = SENDER_EMAIL
msg["To"] = alert_sendto
with smtplib.SMTP(SMTP_SERVER) as server:
server.sendmail(SENDER_EMAIL, [alert_sendto], msg.as_string())