refactor: renomear aplicação de chamado-health para health-monitor
This commit is contained in:
parent
ecfe0f544a
commit
576809577e
7 changed files with 42 additions and 19 deletions
|
|
@ -8,7 +8,7 @@ from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
def load_url_from_config():
|
def load_url_from_config():
|
||||||
config_file = Path.home() / ".config" / "chamado-health"
|
config_file = Path.home() / ".config" / "health-monitor"
|
||||||
if config_file.exists():
|
if config_file.exists():
|
||||||
for line in config_file.read_text().splitlines():
|
for line in config_file.read_text().splitlines():
|
||||||
if line.startswith("HEALTHCHECK_URL="):
|
if line.startswith("HEALTHCHECK_URL="):
|
||||||
|
|
@ -17,7 +17,7 @@ def load_url_from_config():
|
||||||
|
|
||||||
|
|
||||||
def ping(url: str, timeout: int) -> int:
|
def ping(url: str, timeout: int) -> int:
|
||||||
req = urllib.request.Request(url, method="GET", headers={"User-Agent": "chamado-health/1.0"})
|
req = urllib.request.Request(url, method="GET", headers={"User-Agent": "health-monitor/1.0"})
|
||||||
with urllib.request.urlopen(req, timeout=timeout) as response:
|
with urllib.request.urlopen(req, timeout=timeout) as response:
|
||||||
return response.getcode()
|
return response.getcode()
|
||||||
|
|
||||||
|
|
@ -25,7 +25,7 @@ def ping(url: str, timeout: int) -> int:
|
||||||
def ping_fail(url: str, timeout: int) -> None:
|
def ping_fail(url: str, timeout: int) -> None:
|
||||||
fail_url = url.rstrip("/") + "/fail"
|
fail_url = url.rstrip("/") + "/fail"
|
||||||
try:
|
try:
|
||||||
req = urllib.request.Request(fail_url, method="GET", headers={"User-Agent": "chamado-health/1.0"})
|
req = urllib.request.Request(fail_url, method="GET", headers={"User-Agent": "health-monitor/1.0"})
|
||||||
urllib.request.urlopen(req, timeout=timeout)
|
urllib.request.urlopen(req, timeout=timeout)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,17 @@
|
||||||
#!/usr/bin/env fish
|
#!/usr/bin/env fish
|
||||||
|
|
||||||
set SCRIPT_DIR (dirname (realpath (status filename)))
|
set SCRIPT_DIR (dirname (realpath (status filename)))
|
||||||
set CONFIG_FILE "$HOME/.config/chamado-health"
|
set CONFIG_FILE "$HOME/.config/health-monitor"
|
||||||
|
|
||||||
mkdir -p "$HOME/.config/systemd/user"
|
mkdir -p "$HOME/.config/systemd/user"
|
||||||
cp "$SCRIPT_DIR/systemd/chamado-health.service" "$HOME/.config/systemd/user/"
|
cp "$SCRIPT_DIR/systemd/health-monitor.service" "$HOME/.config/systemd/user/"
|
||||||
cp "$SCRIPT_DIR/systemd/chamado-health.timer" "$HOME/.config/systemd/user/"
|
cp "$SCRIPT_DIR/systemd/health-monitor.timer" "$HOME/.config/systemd/user/"
|
||||||
|
|
||||||
echo "Arquivos de unit systemd copiados para ~/.config/systemd/user/."
|
echo "Arquivos de unit systemd copiados para ~/.config/systemd/user/."
|
||||||
|
|
||||||
systemctl --user daemon-reload
|
systemctl --user daemon-reload
|
||||||
systemctl --user enable --now chamado-health.timer
|
systemctl --user enable --now health-monitor.timer
|
||||||
systemctl --user status --no-pager chamado-health.timer
|
systemctl --user status --no-pager health-monitor.timer
|
||||||
|
|
||||||
# Ping de teste imediato para confirmar que tudo funciona
|
# Ping de teste imediato para confirmar que tudo funciona
|
||||||
echo ""
|
echo ""
|
||||||
|
|
|
||||||
|
|
@ -2,17 +2,17 @@
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
CONFIG_FILE="${HOME}/.config/chamado-health"
|
CONFIG_FILE="${HOME}/.config/health-monitor"
|
||||||
|
|
||||||
mkdir -p "${HOME}/.config/systemd/user"
|
mkdir -p "${HOME}/.config/systemd/user"
|
||||||
cp "${SCRIPT_DIR}/systemd/chamado-health.service" "${HOME}/.config/systemd/user/"
|
cp "${SCRIPT_DIR}/systemd/health-monitor.service" "${HOME}/.config/systemd/user/"
|
||||||
cp "${SCRIPT_DIR}/systemd/chamado-health.timer" "${HOME}/.config/systemd/user/"
|
cp "${SCRIPT_DIR}/systemd/health-monitor.timer" "${HOME}/.config/systemd/user/"
|
||||||
|
|
||||||
echo "Arquivos de unit systemd copiados para ~/.config/systemd/user/."
|
echo "Arquivos de unit systemd copiados para ~/.config/systemd/user/."
|
||||||
|
|
||||||
systemctl --user daemon-reload
|
systemctl --user daemon-reload
|
||||||
systemctl --user enable --now chamado-health.timer
|
systemctl --user enable --now health-monitor.timer
|
||||||
systemctl --user status --no-pager chamado-health.timer
|
systemctl --user status --no-pager health-monitor.timer
|
||||||
|
|
||||||
# Ping de teste imediato para confirmar que tudo funciona
|
# Ping de teste imediato para confirmar que tudo funciona
|
||||||
echo ""
|
echo ""
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
#!/usr/bin/env fish
|
#!/usr/bin/env fish
|
||||||
|
|
||||||
set REPO_URL "https://github.com/SantosFC/chamado-health.git"
|
set REPO_URL "https://github.com/SantosFC/health-monitor.git"
|
||||||
set INSTALL_DIR "$HOME/src/chamado-health"
|
set INSTALL_DIR "$HOME/src/health-monitor"
|
||||||
set CONFIG_FILE "$HOME/.config/chamado-health"
|
set CONFIG_FILE "$HOME/.config/health-monitor"
|
||||||
|
|
||||||
# 1. Verificar pré-requisitos
|
# 1. Verificar pré-requisitos
|
||||||
for cmd in git python3 systemctl loginctl
|
for cmd in git python3 systemctl loginctl
|
||||||
|
|
|
||||||
6
setup.sh
6
setup.sh
|
|
@ -1,9 +1,9 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
REPO_URL="https://github.com/SantosFC/chamado-health.git"
|
REPO_URL="https://github.com/SantosFC/health-monitor.git"
|
||||||
INSTALL_DIR="${HOME}/src/chamado-health"
|
INSTALL_DIR="${HOME}/src/health-monitor"
|
||||||
CONFIG_FILE="${HOME}/.config/chamado-health"
|
CONFIG_FILE="${HOME}/.config/health-monitor"
|
||||||
|
|
||||||
# 1. Verificar pré-requisitos
|
# 1. Verificar pré-requisitos
|
||||||
for cmd in git python3 systemctl loginctl; do
|
for cmd in git python3 systemctl loginctl; do
|
||||||
|
|
|
||||||
14
systemd/health-monitor.service
Normal file
14
systemd/health-monitor.service
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Health Monitor check script
|
||||||
|
Wants=network-online.target
|
||||||
|
After=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
EnvironmentFile=-%h/.config/health-monitor
|
||||||
|
ExecStart=/usr/bin/env python3 %h/src/health-monitor/healthcheck.py
|
||||||
|
StandardOutput=journal
|
||||||
|
StandardError=journal
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
||||||
9
systemd/health-monitor.timer
Normal file
9
systemd/health-monitor.timer
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Run Health Monitor check every 2 minutes
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnCalendar=*:0/2
|
||||||
|
Persistent=true
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=timers.target
|
||||||
Loading…
Reference in a new issue