This is an old revision of the document!
Настраиваем необходимый для мониторинга минимум из курса Администрирование сервисов и сетей Linux
Запустите с правами Administrator C:\cmder\cmder.exe bash cd test -d conf && rm -rf conf git clone http://val.bmstu.ru/unix/conf.git cd conf/virtualbox/ !!! 5p - это номер курса, вместо X укажите Ваш номер стенда, если не знаете его, спросите преподавателя !!! ./setup.sh X 5p
# sh net_gate.sh # init 6
# sh net_server.sh # init 6
server:~# sh conf/dns.sh
# cat /etc/resolv.conf
search corpX.un nameserver 192.168.X.10
# nslookup ns
roundcube_login_logout_runtime[30m] quantile_over_time(0.5, (roundcube_login_logout_runtime > 0)[30m:]) quantile_over_time(0.95, (roundcube_login_logout_runtime > 0)[30m:]) avg_over_time((roundcube_login_logout_runtime > 0)[30m:])
$ runtime=66.25
дожидаемся отработки скрипта по cron
$ date
подменяем значение
$ echo "roundcube_login_logout_runtime ${runtime}" | \
curl -Ss --data-binary @- \
http://localhost:9091/metrics/job/roundcube_monitor/host/$(hostname)
# service dovecot stop; systemd-run --on-active=2m systemctl start dovecot sum_over_time((roundcube_login_logout_runtime > bool 0)[1h:1m]) / count_over_time(roundcube_login_logout_runtime[1h])
quantile_over_time(0.50, (roundcube_login_logout_runtime > 0)[$__rate_interval:$__interval]) quantile_over_time(0.95, (roundcube_login_logout_runtime > 0)[$__rate_interval:$__interval])
node_systemd_unit_state для dovecot + Data links на Explore с журналом из Loki mariadb и apache2 пишут логи сами, можно оставить как домашнее задание sum(sum_over_time((roundcube_login_logout_runtime > bool 0)[$__range:1m])) / sum(count_over_time(roundcube_login_logout_runtime[$__range]))
avg_over_time((roundcube_login_logout_runtime > 0)[1h:])
{host_name="server.corpX.un", syslog_identifier!~"prometheus.*"}
sum(
count_over_time(
{host_name=~"^$host_name$"} !~ "(?i)test|debug|temp" |~ "(?i)error|abandon|fail|expire" [1m]
)
) or vector(0)
{host_name=~"^$host_name$"} !~ "(?i)test|debug|temp" |~ "(?i)error|abandon|fail|expire" | line_format "[{{.host_name}}] {{__line__}}"
server# cat /usr/local/bin/my-prometheus-xmpp-alerts.sh
#!/bin/sh to=student@corpX.un subject=prometheus-alertmanager body=$(echo "$1" | jq) cat <<EOF | sendxmpp -f /root/.sendxmpprc "$to" $subject $body EOF
server# cat /usr/local/bin/my-prometheus-xmpp-alerts.sh
...
body=$(echo "$1" | jq)
export BASE_URL=http://val.bmstu.ru:8080/v1
export API_KEY=1234567890abcdefg
export MODEL_ID=ornith-1.5:9b
#export BASE_URL=https://ai.api.cloud.yandex.net/v1
#export API_KEY=...
#export MODEL_ID=gpt://b1gg4j6ru4esprat3uu7/deepseek-v4-flash/latest
PROMPT="Проанализируй строки журнала и кратко объясни, как исправить?"
body=${body}$(curl -s http://localhost:3100/loki/api/v1/query_range \
--data-urlencode 'query={service_name=~"server-journald|server-roundcube"}' \
--data-urlencode 'limit=10' \
| jq -r '.data.result[].values[][1]' \
| /usr/local/bin/openai_request_to_llm.py $PROMPT)
cat <<EOF | sendxmpp -f /root/.sendxmpprc "$to"
...
expr: (sum_over_time((roundcube_login_logout_runtime > bool 0)[1h:1m]) / count_over_time(roundcube_login_logout_runtime[1h])) < 0.99 for: 5m labels: severity: warning annotations: summary: "Нарушен SLO доступности Roundcube за последний час!"