Version fonctionnelle
This commit is contained in:
parent
36ce5e31a8
commit
8219cd1126
37
README.md
37
README.md
|
|
@ -1,22 +1,33 @@
|
|||
# Dépendance
|
||||
jq & bc
|
||||
|
||||
# Droits
|
||||
> Si besoin ajouter les +x
|
||||
|
||||
# Creation du token
|
||||
|
||||
1. Connecte-toi en SSH sur ton serveur Zabbix.
|
||||
|
||||
2. Exécute cette commande cURL pour demander une autorisation :
|
||||
> ***\# Bash***
|
||||
>
|
||||
# Creation du token api Freebox
|
||||
> ./freebox_token.sh
|
||||
|
||||
3. Regarde l'afficheur en façade de ta Freebox Pop : Elle va te demander si tu acceptes l'application. Appuie sur le bouton pour Valider.
|
||||
|
||||
4. Dans ton terminal, la commande va te renvoyer un JSON contenant un "app_token". Copie ce token précieusement, on va en avoir besoin tout de suite.
|
||||
|
||||
# Appel
|
||||
|
||||
> freebox_pop.sh\[\"\{\$FREEBOX.URL\}\",\"\{\$FREEBOX.TOKEN\}\",\"\{\$FREEBOX.ID\}\"\]
|
||||
> frogg_freebox_check.sh <APP_ID> <APP_TOKEN> <HOST> <METRIC>
|
||||
|
||||
# Test
|
||||
> /usr/lib/zabbix/externalscripts/freebox_pop.sh "http://mafreebox.freebox.fr/api/v8" "TON_TOKEN" "zabbix.frogg.fr"
|
||||
> bash /usr/lib/zabbix/externalscripts/frogg_freebox_check.sh "zabbix.frogg.fr" "/q9X4Lo3xlMndJKTTqoIwzppRYd9i+dgfLSL7dUD0zNNXbbsnDZDiz5FcCjbBbRE" "mafreebox.freebox.fr" cpu_percent
|
||||
|
||||
# Template Zabbix 7.0
|
||||
|
||||
## Macros configurables :
|
||||
|
||||
| Macro | Défaut | Description |
|
||||
|------------------------|----------------------|---------------------------|
|
||||
| {$FREEBOX_APP_ID} | (vide) | App ID enregistré |
|
||||
| {$FREEBOX_APP_TOKEN} | (secret)Token d'app | (stocké chiffré) |
|
||||
| {$FREEBOX_HOST} | mafreebox.freebox.fr | Hostname de la Freebox |
|
||||
| {$CPU_WARN_THRESHOLD} | 80 | Seuil warning CPU (%) |
|
||||
| {$CPU_HIGH_THRESHOLD} | 95 | Seuil critique CPU (%) |
|
||||
| {$RAM_WARN_THRESHOLD} | 80 | Seuil warning RAM (%) |
|
||||
| {$RAM_HIGH_THRESHOLD} | 95 | Seuil critique RAM (%) |
|
||||
| {$HDD_WARN_THRESHOLD} | 80 | Seuil warning disque (%) |
|
||||
| {$HDD_HIGH_THRESHOLD} | 90 | Seuil critique disque (%) |
|
||||
| {$TEMP_WARN_THRESHOLD} | 70 | Seuil warning temp (°C) |
|
||||
| {$TEMP_HIGH_THRESHOLD} | 85 | Seuil critique temp (°C) |
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
APP_ID="zabbix.frogg.fr"
|
||||
APP_TOKEN="/q9X4Lo3xlMndJKTTqoIwzppRYd9i+dgfLSL7dUD0zNNXbbsnDZDiz5FcCjbBbRE"
|
||||
FREEBOX_URL="http://mafreebox.freebox.fr"
|
||||
247
freebox_token.sh
247
freebox_token.sh
|
|
@ -1 +1,246 @@
|
|||
curl -s -X POST -d '{"app_id": "fr.frogg.zabbix", "app_name": "Zabbix Monitoring", "app_version": "1.0", "device_name": "ZabbixServer"}' http://mafreebox.freebox.fr/api/v8/login/authorize/
|
||||
#!/bin/bash
|
||||
#
|
||||
# freebox_create_token.sh
|
||||
#
|
||||
# Crée une nouvelle application sur la Freebox et génère un App Token
|
||||
# utilisable ensuite dans vos scripts API.
|
||||
#
|
||||
# Usage :
|
||||
# ./freebox_create_token.sh
|
||||
#
|
||||
# Prérequis :
|
||||
# - curl
|
||||
# - jq
|
||||
#
|
||||
# Installation :
|
||||
# apt install curl jq
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# CONSTANTES GLOBALES
|
||||
# ─────────────────────────────────────────────
|
||||
readonly FREEBOX_URL="http://mafreebox.freebox.fr"
|
||||
readonly CONFIG_FILE="freebox_api.conf"
|
||||
readonly DEFAULT_APP_ID="zabbix.frogg.fr"
|
||||
readonly DEFAULT_APP_NAME="FroggBox API"
|
||||
readonly DEFAULT_APP_VERSION="1.0"
|
||||
readonly DEFAULT_DEVICE_NAME="zabbix.frogg.fr"
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# COULEURS & STYLES
|
||||
# ─────────────────────────────────────────────
|
||||
readonly C_RESET='\033[0m'
|
||||
readonly C_BOLD='\033[1m'
|
||||
readonly C_DIM='\033[2m'
|
||||
readonly C_CYAN='\033[0;36m'
|
||||
readonly C_GREEN='\033[0;32m'
|
||||
readonly C_YELLOW='\033[0;33m'
|
||||
readonly C_RED='\033[0;31m'
|
||||
readonly C_WHITE='\033[0;97m'
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# FONCTIONS D'AFFICHAGE
|
||||
# ─────────────────────────────────────────────
|
||||
|
||||
print_banner() {
|
||||
echo
|
||||
echo -e "${C_CYAN}${C_BOLD}"
|
||||
echo " ╔══════════════════════════════════════════════╗"
|
||||
echo " ║ 🟠 FREEBOX TOKEN GENERATOR ║"
|
||||
echo " ║ Autorisation d'application via API ║"
|
||||
echo " ╚══════════════════════════════════════════════╝"
|
||||
echo -e "${C_RESET}"
|
||||
}
|
||||
|
||||
print_step() {
|
||||
local step="$1"
|
||||
local label="$2"
|
||||
echo
|
||||
echo -e "${C_CYAN}${C_BOLD} ┌─ ÉTAPE ${step} ─────────────────────────────────${C_RESET}"
|
||||
echo -e "${C_CYAN}${C_BOLD} │ ${C_WHITE}${label}${C_RESET}"
|
||||
echo -e "${C_CYAN}${C_BOLD} └────────────────────────────────────────────${C_RESET}"
|
||||
echo
|
||||
}
|
||||
|
||||
print_info() {
|
||||
local label="$1"
|
||||
local value="$2"
|
||||
printf " ${C_DIM}%-18s${C_RESET} ${C_WHITE}%s${C_RESET}\n" "${label}" "${value}"
|
||||
}
|
||||
|
||||
print_success() {
|
||||
echo -e " ${C_GREEN}${C_BOLD}✔ $1${C_RESET}"
|
||||
}
|
||||
|
||||
print_warning() {
|
||||
echo -e " ${C_YELLOW}${C_BOLD}⚠ $1${C_RESET}"
|
||||
}
|
||||
|
||||
print_error() {
|
||||
echo -e " ${C_RED}${C_BOLD}✘ $1${C_RESET}"
|
||||
}
|
||||
|
||||
print_waiting() {
|
||||
echo -e " ${C_CYAN}⟳ $1${C_RESET}"
|
||||
}
|
||||
|
||||
print_separator() {
|
||||
echo -e " ${C_DIM}────────────────────────────────────────────${C_RESET}"
|
||||
}
|
||||
|
||||
print_token_box() {
|
||||
local app_id="$1"
|
||||
local app_token="$2"
|
||||
echo
|
||||
echo -e "${C_GREEN}${C_BOLD}"
|
||||
echo " ╔══════════════════════════════════════════════╗"
|
||||
echo " ║ ✅ TOKEN GÉNÉRÉ ║"
|
||||
echo " ╚══════════════════════════════════════════════╝"
|
||||
echo -e "${C_RESET}"
|
||||
echo -e " ${C_DIM}APP_ID ${C_RESET} ${C_YELLOW}${C_BOLD}${app_id}${C_RESET}"
|
||||
echo -e " ${C_DIM}APP_TOKEN ${C_RESET} ${C_GREEN}${C_BOLD}${app_token}${C_RESET}"
|
||||
echo
|
||||
}
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# SAISIE UTILISATEUR
|
||||
# ─────────────────────────────────────────────
|
||||
|
||||
collect_app_info() {
|
||||
echo -e " ${C_DIM}Appuyez sur Entrée pour utiliser la valeur par défaut.${C_RESET}"
|
||||
echo
|
||||
|
||||
read -rp "$(echo -e " ${C_BOLD}App ID${C_RESET} ${C_DIM}[${DEFAULT_APP_ID}]${C_RESET} : ")" APP_ID
|
||||
APP_ID="${APP_ID:-$DEFAULT_APP_ID}"
|
||||
|
||||
read -rp "$(echo -e " ${C_BOLD}App Name${C_RESET} ${C_DIM}[${DEFAULT_APP_NAME}]${C_RESET} : ")" APP_NAME
|
||||
APP_NAME="${APP_NAME:-$DEFAULT_APP_NAME}"
|
||||
|
||||
read -rp "$(echo -e " ${C_BOLD}App Version${C_RESET} ${C_DIM}[${DEFAULT_APP_VERSION}]${C_RESET} : ")" APP_VERSION
|
||||
APP_VERSION="${APP_VERSION:-$DEFAULT_APP_VERSION}"
|
||||
|
||||
read -rp "$(echo -e " ${C_BOLD}Device Name${C_RESET} ${C_DIM}[${DEFAULT_DEVICE_NAME}]${C_RESET} : ")" DEVICE_NAME
|
||||
DEVICE_NAME="${DEVICE_NAME:-$DEFAULT_DEVICE_NAME}"
|
||||
|
||||
echo
|
||||
print_separator
|
||||
echo
|
||||
print_info "App ID" "$APP_ID"
|
||||
print_info "App Name" "$APP_NAME"
|
||||
print_info "Version" "$APP_VERSION"
|
||||
print_info "Device" "$DEVICE_NAME"
|
||||
print_info "Freebox URL" "$FREEBOX_URL"
|
||||
echo
|
||||
}
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# LOGIQUE FREEBOX API
|
||||
# ─────────────────────────────────────────────
|
||||
|
||||
request_authorization() {
|
||||
# Retourne APP_TOKEN et TRACK_ID via les variables globales
|
||||
local response
|
||||
response=$(curl -s -X POST "${FREEBOX_URL}/api/v10/login/authorize/" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"app_id\": \"${APP_ID}\",
|
||||
\"app_name\": \"${APP_NAME}\",
|
||||
\"app_version\": \"${APP_VERSION}\",
|
||||
\"device_name\": \"${DEVICE_NAME}\"
|
||||
}")
|
||||
|
||||
local success
|
||||
success=$(echo "$response" | jq -r '.success')
|
||||
|
||||
if [ "$success" != "true" ]; then
|
||||
print_error "Échec de la demande d'autorisation :"
|
||||
echo "$response" | jq . >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
APP_TOKEN=$(echo "$response" | jq -r '.result.app_token')
|
||||
TRACK_ID=$(echo "$response" | jq -r '.result.track_id')
|
||||
}
|
||||
|
||||
wait_for_user_approval() {
|
||||
print_info "Track ID" "$TRACK_ID"
|
||||
echo
|
||||
print_warning "Une notification est apparue sur votre Freebox Delta / Player."
|
||||
echo -e " ${C_DIM}Acceptez-la, puis appuyez sur ${C_BOLD}Entrée${C_RESET}${C_DIM} pour continuer...${C_RESET}"
|
||||
read -r
|
||||
}
|
||||
|
||||
poll_authorization_status() {
|
||||
while true; do
|
||||
local status_response
|
||||
status_response=$(curl -s "${FREEBOX_URL}/api/v10/login/authorize/${TRACK_ID}")
|
||||
|
||||
local status
|
||||
status=$(echo "$status_response" | jq -r '.result.status')
|
||||
|
||||
case "$status" in
|
||||
granted)
|
||||
print_success "Autorisation accordée !"
|
||||
return 0
|
||||
;;
|
||||
denied)
|
||||
print_error "Autorisation refusée par l'utilisateur."
|
||||
exit 1
|
||||
;;
|
||||
timeout)
|
||||
print_error "Délai d'autorisation expiré."
|
||||
exit 1
|
||||
;;
|
||||
pending)
|
||||
print_waiting "En attente de validation..."
|
||||
sleep 2
|
||||
;;
|
||||
*)
|
||||
print_error "Statut inattendu : ${status}"
|
||||
echo "$status_response" | jq . >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
save_config() {
|
||||
cat > "$CONFIG_FILE" <<EOF
|
||||
APP_ID="${APP_ID}"
|
||||
APP_TOKEN="${APP_TOKEN}"
|
||||
FREEBOX_URL="${FREEBOX_URL}"
|
||||
EOF
|
||||
chmod 600 "$CONFIG_FILE"
|
||||
print_success "Configuration sauvegardée dans : ${C_BOLD}${CONFIG_FILE}${C_RESET}"
|
||||
echo -e " ${C_DIM}Permissions : 600 (lecture propriétaire uniquement)${C_RESET}"
|
||||
}
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# POINT D'ENTRÉE
|
||||
# ─────────────────────────────────────────────
|
||||
|
||||
main() {
|
||||
print_banner
|
||||
|
||||
print_step "1" "Informations de l'application"
|
||||
collect_app_info
|
||||
|
||||
print_step "2" "Demande d'autorisation à la Freebox"
|
||||
request_authorization
|
||||
print_success "Requête envoyée avec succès."
|
||||
|
||||
wait_for_user_approval
|
||||
|
||||
print_step "3" "Vérification du statut d'autorisation"
|
||||
poll_authorization_status
|
||||
|
||||
print_token_box "$APP_ID" "$APP_TOKEN"
|
||||
|
||||
print_step "4" "Sauvegarde de la configuration"
|
||||
save_config
|
||||
echo
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
|
@ -1,177 +1,468 @@
|
|||
#!/bin/bash
|
||||
|
||||
# @copyright GEMINI & Frogg
|
||||
|
||||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# FONCTIONS REQUISITIONS & AUTHENTIFICATION
|
||||
# frogg_freebox_check.sh
|
||||
# Script Zabbix - Métriques Freebox via API V10
|
||||
# Compatible : Zabbix 7.0 / ExternalCheck
|
||||
# Auteur : frogg (généré)
|
||||
# Répertoire : /usr/lib/zabbix/externalscripts/
|
||||
# Usage : frogg_freebox_check.sh <APP_ID> <APP_TOKEN> <HOST> <METRIC>
|
||||
# ==============================================================================
|
||||
|
||||
# Récupère le challenge d'authentification unique
|
||||
get_challenge() {
|
||||
local -r url="$1"
|
||||
local challenge_req
|
||||
challenge_req=$(curl -s --max-time 10 "$url/login/")
|
||||
echo "$challenge_req" | grep -oP '"challenge":"\K[^"]+'
|
||||
}
|
||||
set -uo pipefail
|
||||
# Note: -e retiré volontairement pour gérer les erreurs curl manuellement
|
||||
|
||||
# Génère le mot de passe de session sécurisé (HMAC-SHA1)
|
||||
generate_password() {
|
||||
local -r challenge="$1"
|
||||
local -r token="$2"
|
||||
echo -n "$challenge" | openssl dgst -sha1 -hmac "$token" | awk '{print $2}'
|
||||
}
|
||||
|
||||
# Ouvre la session et retourne le Token de Session unique
|
||||
open_session() {
|
||||
local -r url="$1"
|
||||
local -r app_id="$2"
|
||||
local -r password="$3"
|
||||
local session_req
|
||||
|
||||
session_req=$(curl -s --max-time 10 -X POST \
|
||||
-d "{\"app_id\": \"$app_id\", \"password\": \"$password\"}" \
|
||||
"$url/login/session/")
|
||||
|
||||
echo "$session_req" | grep -oP '"session_token":"\K[^"]+'
|
||||
}
|
||||
|
||||
# Ferme la session proprement sur la Freebox
|
||||
close_session() {
|
||||
local -r url="$1"
|
||||
local -r session_token="$2"
|
||||
curl -s --max-time 5 -X POST \
|
||||
-H "X-Fbx-App-Auth: $session_token" \
|
||||
"$url/login/logout/" > /dev/null 2>&1
|
||||
}
|
||||
|
||||
# ==============================================================================
|
||||
# FONCTION COLLECTE ET EXTRACTION (MOTEUR PRINCIPAL)
|
||||
# ==============================================================================
|
||||
collect_freebox_metrics() {
|
||||
local -r url="$1"
|
||||
local -r token="$2"
|
||||
|
||||
# Récupération brute des blocs de données de l'API
|
||||
local sys_data
|
||||
local conn_data
|
||||
sys_data=$(curl -s --max-time 10 -H "X-Fbx-App-Auth: $token" "$url/system/")
|
||||
conn_data=$(curl -s --max-time 10 -H "X-Fbx-App-Auth: $token" "$url/connection/")
|
||||
|
||||
# --- Extraction et calculs locaux ---
|
||||
local -i cpu_usage
|
||||
local -i ram_total
|
||||
local -i ram_free
|
||||
local -i ram_usage
|
||||
local -i temp_cpu
|
||||
local -i temp_switch
|
||||
local -i fan_rpm
|
||||
local -i uptime
|
||||
|
||||
cpu_usage=$(echo "$sys_data" | grep -oP '"cpu_usage":\K[0-9]+' || echo "0")
|
||||
ram_total=$(echo "$sys_data" | grep -oP '"mem_total":\K[0-9]+' || echo "0")
|
||||
ram_free=$(echo "$sys_data" | grep -oP '"mem_free":\K[0-9]+' || echo "0")
|
||||
|
||||
if [ "$ram_total" -gt 0 ]; then
|
||||
ram_usage=$(( 100 - (ram_free * 100 / ram_total) ))
|
||||
else
|
||||
ram_usage=0
|
||||
fi
|
||||
|
||||
temp_cpu=$(echo "$sys_data" | grep -oP '"temp_cpub":\K[0-9]+' || echo "0")
|
||||
temp_switch=$(echo "$sys_data" | grep -oP '"temp_sw":\K[0-9]+' || echo "0")
|
||||
fan_rpm=$(echo "$sys_data" | grep -oP '"fan_rpm":\K[0-9]+' || echo "0")
|
||||
uptime=$(echo "$sys_data" | grep -oP '"uptime_val":\K[0-9]+' || echo "0")
|
||||
|
||||
# Extraction Disque
|
||||
local -i disk_total
|
||||
local -i disk_free
|
||||
local -i disk_usage
|
||||
disk_total=$(echo "$sys_data" | grep -oP '"disk_total":\K[0-9]+' || echo "0")
|
||||
disk_free=$(echo "$sys_data" | grep -oP '"disk_free":\K[0-9]+' || echo "0")
|
||||
|
||||
if [ "$disk_total" -gt 0 ]; then
|
||||
disk_usage=$(( 100 - (disk_free * 100 / disk_total) ))
|
||||
else
|
||||
disk_usage=0
|
||||
fi
|
||||
|
||||
# Extraction Réseau
|
||||
local -i bw_down
|
||||
local -i bw_up
|
||||
local -i rate_down
|
||||
local -i rate_up
|
||||
local net_status
|
||||
local vpn_alive
|
||||
|
||||
bw_down=$(echo "$conn_data" | grep -oP '"bandwidth_down":\K[0-9]+' || echo "0")
|
||||
bw_up=$(echo "$conn_data" | grep -oP '"bandwidth_up":\K[0-9]+' || echo "0")
|
||||
rate_down=$(echo "$conn_data" | grep -oP '"rate_down":\K[0-9]+' || echo "0")
|
||||
rate_up=$(echo "$conn_data" | grep -oP '"rate_up":\K[0-9]+' || echo "0")
|
||||
net_status=$(echo "$conn_data" | grep -oP '"state":"\K[^"]+' || echo "unknown")
|
||||
vpn_alive=$(echo "$conn_data" | grep -oP '"ipv4_vpn_routed":\K[^, ]+' || echo "false")
|
||||
|
||||
# --- Sortie du JSON final ---
|
||||
cat <<EOF
|
||||
{
|
||||
"cpu_usage": $cpu_usage,
|
||||
"ram_usage": $ram_usage,
|
||||
"disk_usage": $disk_usage,
|
||||
"bandwidth_down": $bw_down,
|
||||
"bandwidth_up": $bw_up,
|
||||
"rate_down": $rate_down,
|
||||
"rate_up": $rate_up,
|
||||
"temp_cpu": $temp_cpu,
|
||||
"temp_switch": $temp_switch,
|
||||
"fan_rpm": $fan_rpm,
|
||||
"uptime": $uptime,
|
||||
"net_status": "$net_status",
|
||||
"vpn_alive": $vpn_alive
|
||||
}
|
||||
EOF
|
||||
}
|
||||
|
||||
# ==============================================================================
|
||||
# LOGIQUE PRINCIPALE (MAIN)
|
||||
# ==============================================================================
|
||||
main() {
|
||||
# Récupération des paramètres passés par Zabbix
|
||||
local -r freebox_url="$1"
|
||||
local -r app_token="$2"
|
||||
local -r app_id="$3"
|
||||
|
||||
# Contrôle strict de la présence des arguments requis
|
||||
if [ -z "$freebox_url" ] || [ -z "$app_token" ] || [ -z "$app_id" ]; then
|
||||
echo '{"error": "missing_arguments", "details": "Usage: freebox_pop.sh <URL> <TOKEN> <APP_ID>"}'
|
||||
# ------------------------------------------------------------------------------
|
||||
# Dépendances requises : curl, jq, openssl
|
||||
# ------------------------------------------------------------------------------
|
||||
for cmd in curl jq openssl bc; do
|
||||
if ! command -v "$cmd" &>/dev/null; then
|
||||
echo "ERREUR: '$cmd' est requis mais introuvable." >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Paramètres (fournis par Zabbix via macros du template)
|
||||
# ------------------------------------------------------------------------------
|
||||
APP_ID="${1:-}"
|
||||
APP_TOKEN="${2:-}"
|
||||
FREEBOX_HOST="${3:-mafreebox.freebox.fr}"
|
||||
METRIC="${4:-}"
|
||||
# Mode debug : passer DEBUG=1 en variable d'environnement pour voir les erreurs curl
|
||||
DEBUG="${DEBUG:-0}"
|
||||
|
||||
if [[ -z "$APP_ID" || -z "$APP_TOKEN" || -z "$FREEBOX_HOST" || -z "$METRIC" ]]; then
|
||||
echo "Usage: $0 <APP_ID> <APP_TOKEN> <HOST> <METRIC>" >&2
|
||||
echo "Métriques disponibles:" >&2
|
||||
echo " cpu_percent - Utilisation CPU (%)" >&2
|
||||
echo " ram_percent - Utilisation RAM (%)" >&2
|
||||
echo " ram_used - RAM utilisée (bytes)" >&2
|
||||
echo " ram_total - RAM totale (bytes)" >&2
|
||||
echo " hdd_percent - Utilisation HDD (%)" >&2
|
||||
echo " hdd_used - HDD utilisé (bytes)" >&2
|
||||
echo " hdd_total - HDD total (bytes)" >&2
|
||||
echo " net_rate_down - Débit descendant actuel (bit/s)" >&2
|
||||
echo " net_rate_up - Débit montant actuel (bit/s)" >&2
|
||||
echo " net_bytes_down - Total octets reçus" >&2
|
||||
echo " net_bytes_up - Total octets envoyés" >&2
|
||||
echo " net_bw_down - Bande passante max descendante (bit/s)" >&2
|
||||
echo " net_bw_up - Bande passante max montante (bit/s)" >&2
|
||||
echo " temp_cpum - Température CPU mère (°C)" >&2
|
||||
echo " temp_cpub - Température CPU box (°C)" >&2
|
||||
echo " temp_sw - Température switch (°C)" >&2
|
||||
echo " temp_hdd - Température HDD (°C)" >&2
|
||||
echo " fan_rpm - Vitesse ventilateur (RPM)" >&2
|
||||
echo " uptime - Uptime système (secondes)" >&2
|
||||
echo " disk_status - Statut disque (ok=1 / problem=0)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BASE_URL="https://${FREEBOX_HOST}/api/v10"
|
||||
SESSION_FILE="/tmp/.freebox_session_${APP_ID}.cache"
|
||||
SESSION_MAX_AGE=1800 # 30 min en secondes
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Options curl communes
|
||||
# --insecure : La Freebox utilise un certificat Free (CA non reconnu par défaut)
|
||||
# Si tu veux valider le certificat, télécharge le CA Free :
|
||||
# curl -O https://raw.githubusercontent.com/freebox/ssl/main/freebox_root_ca.pem
|
||||
# puis remplace --insecure par --cacert /etc/ssl/freebox_root_ca.pem
|
||||
# ------------------------------------------------------------------------------
|
||||
CURL_OPTS=(
|
||||
--insecure # Certificat SSL Free (CA non standard)
|
||||
--silent # Pas de barre de progression
|
||||
--max-time 15 # Timeout global
|
||||
--connect-timeout 5 # Timeout connexion
|
||||
--retry 2 # 2 tentatives en cas d'échec réseau
|
||||
--retry-delay 1
|
||||
)
|
||||
# En mode debug, on affiche les erreurs curl sur stderr
|
||||
if [[ "$DEBUG" == "1" ]]; then
|
||||
CURL_OPTS+=(--show-error)
|
||||
fi
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Fonctions utilitaires
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
log_error() {
|
||||
echo "ERREUR: $*" >&2
|
||||
}
|
||||
|
||||
log_debug() {
|
||||
if [[ "$DEBUG" == "1" ]]; then
|
||||
echo "DEBUG: $*" >&2
|
||||
fi
|
||||
}
|
||||
|
||||
# Requête API Freebox (sans session, pour login)
|
||||
api_request_noauth() {
|
||||
local method="$1"
|
||||
local endpoint="$2"
|
||||
local data="${3:-}"
|
||||
local response
|
||||
local http_code
|
||||
local tmp_body
|
||||
tmp_body=$(mktemp)
|
||||
|
||||
if [[ "$method" == "POST" && -n "$data" ]]; then
|
||||
http_code=$(curl "${CURL_OPTS[@]}" \
|
||||
-o "$tmp_body" \
|
||||
-w "%{http_code}" \
|
||||
-X POST \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$data" \
|
||||
"${BASE_URL}${endpoint}" 2>&1)
|
||||
else
|
||||
http_code=$(curl "${CURL_OPTS[@]}" \
|
||||
-o "$tmp_body" \
|
||||
-w "%{http_code}" \
|
||||
"${BASE_URL}${endpoint}" 2>&1)
|
||||
fi
|
||||
|
||||
local curl_exit=$?
|
||||
response=$(cat "$tmp_body")
|
||||
rm -f "$tmp_body"
|
||||
|
||||
if [[ $curl_exit -ne 0 ]]; then
|
||||
log_error "curl a échoué (exit=$curl_exit) sur ${BASE_URL}${endpoint}"
|
||||
log_error "Conseil : vérifiez la connectivité et le certificat SSL (mode DEBUG=1 pour détails)"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [[ "$http_code" != "200" && "$http_code" != "201" ]]; then
|
||||
log_error "Réponse HTTP inattendue : $http_code sur ${endpoint}"
|
||||
log_debug "Corps de la réponse : $response"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
log_debug "Réponse ${endpoint} [HTTP $http_code] : $response"
|
||||
echo "$response"
|
||||
}
|
||||
|
||||
# Requête API Freebox avec session token
|
||||
api_request() {
|
||||
local method="$1"
|
||||
local endpoint="$2"
|
||||
local session_token="$3"
|
||||
local data="${4:-}"
|
||||
local response
|
||||
local http_code
|
||||
local tmp_body
|
||||
tmp_body=$(mktemp)
|
||||
|
||||
if [[ "$method" == "POST" && -n "$data" ]]; then
|
||||
http_code=$(curl "${CURL_OPTS[@]}" \
|
||||
-o "$tmp_body" \
|
||||
-w "%{http_code}" \
|
||||
-X POST \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-Fbx-App-Auth: ${session_token}" \
|
||||
-d "$data" \
|
||||
"${BASE_URL}${endpoint}" 2>&1)
|
||||
else
|
||||
http_code=$(curl "${CURL_OPTS[@]}" \
|
||||
-o "$tmp_body" \
|
||||
-w "%{http_code}" \
|
||||
-H "X-Fbx-App-Auth: ${session_token}" \
|
||||
"${BASE_URL}${endpoint}" 2>&1)
|
||||
fi
|
||||
|
||||
local curl_exit=$?
|
||||
response=$(cat "$tmp_body")
|
||||
rm -f "$tmp_body"
|
||||
|
||||
if [[ $curl_exit -ne 0 ]]; then
|
||||
log_error "curl a échoué (exit=$curl_exit) sur ${endpoint}"
|
||||
# Session peut être expirée : supprimer le cache pour forcer un nouveau login
|
||||
rm -f "$SESSION_FILE"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [[ "$http_code" != "200" && "$http_code" != "201" ]]; then
|
||||
log_error "Réponse HTTP inattendue : $http_code sur ${endpoint}"
|
||||
log_debug "Corps de la réponse : $response"
|
||||
# Si 403, la session est invalide, on purge le cache
|
||||
if [[ "$http_code" == "403" || "$http_code" == "401" ]]; then
|
||||
log_error "Session invalide, suppression du cache. Relancez la commande."
|
||||
rm -f "$SESSION_FILE"
|
||||
fi
|
||||
exit 2
|
||||
fi
|
||||
|
||||
log_debug "Réponse ${endpoint} [HTTP $http_code] : $response"
|
||||
echo "$response"
|
||||
}
|
||||
|
||||
# Génère le mot de passe de session via HMAC-SHA1
|
||||
generate_password() {
|
||||
local token="$1"
|
||||
local challenge="$2"
|
||||
echo -n "$challenge" | openssl dgst -sha1 -hmac "$token" | awk '{print $NF}'
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Gestion de la session (cache pour éviter trop de logins)
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
get_session_token() {
|
||||
# Vérification du cache
|
||||
if [[ -f "$SESSION_FILE" ]]; then
|
||||
local file_age
|
||||
file_age=$(( $(date +%s) - $(stat -c %Y "$SESSION_FILE" 2>/dev/null || echo 0) ))
|
||||
if [[ $file_age -lt $SESSION_MAX_AGE ]]; then
|
||||
cat "$SESSION_FILE"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Récupération du challenge
|
||||
local login_resp
|
||||
login_resp=$(api_request_noauth "GET" "/login")
|
||||
|
||||
local success
|
||||
success=$(echo "$login_resp" | jq -r '.success // false')
|
||||
if [[ "$success" != "true" ]]; then
|
||||
log_error "Impossible de récupérer le challenge de login"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
local challenge
|
||||
challenge=$(echo "$login_resp" | jq -r '.result.challenge')
|
||||
if [[ -z "$challenge" || "$challenge" == "null" ]]; then
|
||||
log_error "Challenge vide reçu de la Freebox"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# Génération du mot de passe
|
||||
local password
|
||||
password=$(generate_password "$APP_TOKEN" "$challenge")
|
||||
|
||||
# Ouverture de session
|
||||
local session_payload
|
||||
session_payload=$(jq -nc \
|
||||
--arg app_id "$APP_ID" \
|
||||
--arg password "$password" \
|
||||
'{"app_id": $app_id, "password": $password}')
|
||||
|
||||
local session_resp
|
||||
session_resp=$(api_request_noauth "POST" "/login/session" "$session_payload")
|
||||
|
||||
local session_success
|
||||
session_success=$(echo "$session_resp" | jq -r '.success // false')
|
||||
if [[ "$session_success" != "true" ]]; then
|
||||
local err_msg
|
||||
err_msg=$(echo "$session_resp" | jq -r '.msg // "Erreur inconnue"')
|
||||
log_error "Échec d'ouverture de session : $err_msg"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
local session_token
|
||||
|
||||
# 1. Étape du Challenge
|
||||
challenge=$(get_challenge "$freebox_url")
|
||||
if [ -z "$challenge" ]; then
|
||||
echo '{"error": "api_unreachable"}'
|
||||
exit 1
|
||||
session_token=$(echo "$session_resp" | jq -r '.result.session_token')
|
||||
if [[ -z "$session_token" || "$session_token" == "null" ]]; then
|
||||
log_error "Session token vide"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# 2. Sécurité & Calcul d'empreinte
|
||||
password=$(generate_password "$challenge" "$app_token")
|
||||
|
||||
# 3. Récupération de la Session
|
||||
session_token=$(open_session "$freebox_url" "$app_id" "$password")
|
||||
if [ -z "$session_token" ]; then
|
||||
echo '{"error": "authentication_failed"}'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 4. Traitement et extraction
|
||||
collect_freebox_metrics "$freebox_url" "$session_token"
|
||||
|
||||
# 5. Nettoyage de la session active sur la Box
|
||||
close_session "$freebox_url" "$session_token"
|
||||
# Mise en cache
|
||||
echo "$session_token" > "$SESSION_FILE"
|
||||
chmod 600 "$SESSION_FILE"
|
||||
echo "$session_token"
|
||||
}
|
||||
|
||||
# Lancement du script en lui injectant tous les arguments reçus par le processus d'appel
|
||||
main "$@"
|
||||
# ------------------------------------------------------------------------------
|
||||
# Récupération des métriques système (CPU, RAM, Temp, Fan)
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
get_system_metrics() {
|
||||
local session_token="$1"
|
||||
api_request "GET" "/system/" "$session_token"
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Récupération des métriques réseau (WAN stats)
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
get_connection_metrics() {
|
||||
local session_token="$1"
|
||||
api_request "GET" "/connection/" "$session_token"
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Récupération des métriques stockage
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
get_storage_metrics() {
|
||||
local session_token="$1"
|
||||
api_request "GET" "/storage/disk/" "$session_token"
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Calcul du pourcentage HDD
|
||||
# Parcourt tous les disques et agrège used/total
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
compute_hdd_stats() {
|
||||
local storage_json="$1"
|
||||
local metric="$2"
|
||||
|
||||
local total used percent
|
||||
total=$(echo "$storage_json" | jq '[.result[]? | .partitions[]? | .total_bytes // 0] | add // 0')
|
||||
used=$(echo "$storage_json" | jq '[.result[]? | .partitions[]? | .used_bytes // 0] | add // 0')
|
||||
|
||||
if [[ "$total" -gt 0 ]]; then
|
||||
percent=$(echo "scale=2; ($used * 100) / $total" | bc)
|
||||
else
|
||||
percent=0
|
||||
fi
|
||||
|
||||
case "$metric" in
|
||||
hdd_percent) echo "$percent" ;;
|
||||
hdd_used) echo "$used" ;;
|
||||
hdd_total) echo "$total" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# MAIN - Sélection de la métrique
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
SESSION_TOKEN=$(get_session_token)
|
||||
|
||||
case "$METRIC" in
|
||||
|
||||
# ---- CPU ------------------------------------------------------------------
|
||||
cpu_percent)
|
||||
|
||||
######## NON DISPONIBLE ATM
|
||||
|
||||
SYS=$(get_system_metrics "$SESSION_TOKEN")
|
||||
echo "$SYS" | jq -r '.result.cpu_usage // 0'
|
||||
;;
|
||||
|
||||
# ---- RAM ------------------------------------------------------------------
|
||||
ram_percent)
|
||||
|
||||
######## NON DISPONIBLE ATM
|
||||
|
||||
SYS=$(get_system_metrics "$SESSION_TOKEN")
|
||||
TOTAL=$(echo "$SYS" | jq -r '.result.total_mem // 1')
|
||||
USED=$(echo "$SYS" | jq -r '.result.used_mem // 0')
|
||||
if [[ "$TOTAL" -gt 0 ]]; then
|
||||
echo "scale=2; ($USED * 100) / $TOTAL" | bc
|
||||
else
|
||||
echo "0"
|
||||
fi
|
||||
;;
|
||||
|
||||
ram_used)
|
||||
|
||||
######## NON DISPONIBLE ATM
|
||||
|
||||
SYS=$(get_system_metrics "$SESSION_TOKEN")
|
||||
echo "$SYS" | jq -r '.result.used_mem // 0'
|
||||
;;
|
||||
|
||||
ram_total)
|
||||
|
||||
######## NON DISPONIBLE ATM
|
||||
|
||||
SYS=$(get_system_metrics "$SESSION_TOKEN")
|
||||
echo "$SYS" | jq -r '.result.total_mem // 0'
|
||||
;;
|
||||
|
||||
# ---- HDD ------------------------------------------------------------------
|
||||
hdd_percent|hdd_used|hdd_total)
|
||||
STORAGE=$(get_storage_metrics "$SESSION_TOKEN")
|
||||
compute_hdd_stats "$STORAGE" "$METRIC"
|
||||
;;
|
||||
|
||||
# ---- RÉSEAU ---------------------------------------------------------------
|
||||
net_rate_down)
|
||||
CONN=$(get_connection_metrics "$SESSION_TOKEN")
|
||||
echo "$CONN" | jq -r '.result.rate_down // 0'
|
||||
;;
|
||||
|
||||
net_rate_up)
|
||||
CONN=$(get_connection_metrics "$SESSION_TOKEN")
|
||||
echo "$CONN" | jq -r '.result.rate_up // 0'
|
||||
;;
|
||||
|
||||
net_bytes_down)
|
||||
CONN=$(get_connection_metrics "$SESSION_TOKEN")
|
||||
echo "$CONN" | jq -r '.result.bytes_down // 0'
|
||||
;;
|
||||
|
||||
net_bytes_up)
|
||||
CONN=$(get_connection_metrics "$SESSION_TOKEN")
|
||||
echo "$CONN" | jq -r '.result.bytes_up // 0'
|
||||
;;
|
||||
|
||||
net_bw_down)
|
||||
CONN=$(get_connection_metrics "$SESSION_TOKEN")
|
||||
echo "$CONN" | jq -r '.result.bandwidth_down // 0'
|
||||
;;
|
||||
|
||||
net_bw_up)
|
||||
CONN=$(get_connection_metrics "$SESSION_TOKEN")
|
||||
echo "$CONN" | jq -r '.result.bandwidth_up // 0'
|
||||
;;
|
||||
|
||||
# ---- TEMPÉRATURES ---------------------------------------------------------
|
||||
temp_cpum)
|
||||
# Note : Sur la Pop (r1), il n'y a pas de 'temp_cpum', c'est 'temp_t1' et 'temp_t2'
|
||||
# Je te mets 'temp_t1' par défaut, ou adapte selon ce que tu veux remonter
|
||||
SYS=$(get_system_metrics "$SESSION_TOKEN")
|
||||
echo "$SYS" | jq -r '.result.sensors[]? | select(.id=="temp_t1") | .value // 0'
|
||||
;;
|
||||
|
||||
temp_cpub)
|
||||
SYS=$(get_system_metrics "$SESSION_TOKEN")
|
||||
echo "$SYS" | jq -r '.result.sensors[]? | select(.id=="temp_cpub") | .value // 0'
|
||||
;;
|
||||
|
||||
temp_sw)
|
||||
# Note : Pas de 'temp_sw' (Switch) dans ton JSON Pop, on se rabat sur 'temp_t2'
|
||||
SYS=$(get_system_metrics "$SESSION_TOKEN")
|
||||
echo "$SYS" | jq -r '.result.sensors[]? | select(.id=="temp_t2") | .value // 0'
|
||||
;;
|
||||
|
||||
temp_hdd)
|
||||
# Ton JSON confirme 'customer_hdd_slots': 0 et internal_hdd_size: 0 (Pas de HDD)
|
||||
# On laisse la sécurité à 0 au cas où tu branches un disque USB SMART plus tard
|
||||
STORAGE=$(get_storage_metrics "$SESSION_TOKEN")
|
||||
echo "$STORAGE" | jq -r '[.result[]? | .smart_data.temperature // 0] | first // 0'
|
||||
;;
|
||||
|
||||
# ---- VENTILATEUR ----------------------------------------------------------
|
||||
fan_rpm)
|
||||
SYS=$(get_system_metrics "$SESSION_TOKEN")
|
||||
# L'ID dans ton JSON est 'fan0_speed' au lieu de 'fan_rpm'
|
||||
echo "$SYS" | jq -r '.result.fans[]? | select(.id=="fan0_speed") | .value // 0'
|
||||
;;
|
||||
|
||||
# ---- UPTIME ---------------------------------------------------------------
|
||||
uptime)
|
||||
SYS=$(get_system_metrics "$SESSION_TOKEN")
|
||||
echo "$SYS" | jq -r '.result.uptime_val // 0'
|
||||
;;
|
||||
|
||||
# ---- STATUT DISQUE --------------------------------------------------------
|
||||
disk_status)
|
||||
STORAGE=$(get_storage_metrics "$SESSION_TOKEN")
|
||||
# Retourne 1 si tous les disques sont ok, 0 sinon
|
||||
ALL_OK=$(echo "$STORAGE" | jq '[.result[]? | select(.state != "ok" and .state != "enabled")] | length == 0')
|
||||
if [[ "$ALL_OK" == "true" ]]; then
|
||||
echo "1"
|
||||
else
|
||||
echo "0"
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
log_error "Métrique inconnue : $METRIC"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
|
|
|||
|
|
@ -0,0 +1,492 @@
|
|||
{
|
||||
"zabbix_export": {
|
||||
"version": "7.0",
|
||||
"template_groups": [
|
||||
{
|
||||
"uuid": "7df96b18c230490a9a0a9e2307226338",
|
||||
"name": "Templates"
|
||||
},
|
||||
{
|
||||
"uuid": "57b7ae836ca64446ba2c296389c009b7",
|
||||
"name": "Templates/Modules"
|
||||
}
|
||||
],
|
||||
"templates": [
|
||||
{
|
||||
"uuid": "205fb168705047bda6a14ba96b445f1b",
|
||||
"template": "Template Frogg Freebox API V10",
|
||||
"name": "Template Frogg Freebox API V10",
|
||||
"description": "Monitoring Freebox Revolution/Delta/Ultra via API V10\nMétriques : CPU, RAM, HDD, Réseau, Températures, Ventilateur, Uptime\nScript requis : /usr/lib/zabbix/externalscripts/frogg_freebox_check.sh",
|
||||
"groups": [
|
||||
{
|
||||
"name": "Templates/Modules"
|
||||
}
|
||||
],
|
||||
"macros": [
|
||||
{
|
||||
"macro": "{$FREEBOX_APP_ID}",
|
||||
"value": "",
|
||||
"type": "TEXT",
|
||||
"description": "App ID enregistré sur la Freebox (ex: zabbix_monitor). Obtenu lors de l'enregistrement de l'application via /api/v10/login/authorize"
|
||||
},
|
||||
{
|
||||
"macro": "{$FREEBOX_APP_TOKEN}",
|
||||
"value": "",
|
||||
"type": "SECRET_TEXT",
|
||||
"description": "Token d'application fourni par la Freebox lors de l'autorisation. Stocké de façon sécurisée (secret)."
|
||||
},
|
||||
{
|
||||
"macro": "{$FREEBOX_HOST}",
|
||||
"value": "mafreebox.freebox.fr",
|
||||
"type": "TEXT",
|
||||
"description": "Hostname ou IP de la Freebox. Par défaut : mafreebox.freebox.fr (réseau local uniquement)"
|
||||
},
|
||||
{
|
||||
"macro": "{$CPU_WARN_THRESHOLD}",
|
||||
"value": "80",
|
||||
"type": "TEXT",
|
||||
"description": "Seuil d'alerte WARNING pour le CPU (%)"
|
||||
},
|
||||
{
|
||||
"macro": "{$CPU_HIGH_THRESHOLD}",
|
||||
"value": "95",
|
||||
"type": "TEXT",
|
||||
"description": "Seuil d'alerte HIGH pour le CPU (%)"
|
||||
},
|
||||
{
|
||||
"macro": "{$RAM_WARN_THRESHOLD}",
|
||||
"value": "80",
|
||||
"type": "TEXT",
|
||||
"description": "Seuil d'alerte WARNING pour la RAM (%)"
|
||||
},
|
||||
{
|
||||
"macro": "{$RAM_HIGH_THRESHOLD}",
|
||||
"value": "95",
|
||||
"type": "TEXT",
|
||||
"description": "Seuil d'alerte HIGH pour la RAM (%)"
|
||||
},
|
||||
{
|
||||
"macro": "{$HDD_WARN_THRESHOLD}",
|
||||
"value": "80",
|
||||
"type": "TEXT",
|
||||
"description": "Seuil d'alerte WARNING pour l'espace disque (%)"
|
||||
},
|
||||
{
|
||||
"macro": "{$HDD_HIGH_THRESHOLD}",
|
||||
"value": "90",
|
||||
"type": "TEXT",
|
||||
"description": "Seuil d'alerte HIGH pour l'espace disque (%)"
|
||||
},
|
||||
{
|
||||
"macro": "{$TEMP_WARN_THRESHOLD}",
|
||||
"value": "70",
|
||||
"type": "TEXT",
|
||||
"description": "Seuil d'alerte WARNING pour les températures (°C)"
|
||||
},
|
||||
{
|
||||
"macro": "{$TEMP_HIGH_THRESHOLD}",
|
||||
"value": "85",
|
||||
"type": "TEXT",
|
||||
"description": "Seuil d'alerte HIGH pour les températures (°C)"
|
||||
}
|
||||
],
|
||||
"items": [
|
||||
{
|
||||
"uuid": "60749a2fe17049cfbc0bf2163b7849cc",
|
||||
"name": "Freebox - CPU Utilisation",
|
||||
"type": "EXTERNAL",
|
||||
"key": "frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},cpu_percent]",
|
||||
"delay": "60s",
|
||||
"value_type": "FLOAT",
|
||||
"units": "%",
|
||||
"description": "Pourcentage d'utilisation CPU de la Freebox",
|
||||
"tags": [
|
||||
{ "tag": "component", "value": "cpu" },
|
||||
{ "tag": "source", "value": "freebox-api" }
|
||||
],
|
||||
"triggers": [
|
||||
{
|
||||
"uuid": "8be7f54b1f4c4059ad6293cb8bf262ff",
|
||||
"expression": "last(/Template Frogg Freebox API V10/frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},cpu_percent])>{$CPU_HIGH_THRESHOLD}",
|
||||
"name": "Freebox - CPU critique (> {$CPU_HIGH_THRESHOLD}%)",
|
||||
"priority": "HIGH",
|
||||
"description": "L'utilisation CPU de la Freebox dépasse le seuil critique."
|
||||
},
|
||||
{
|
||||
"uuid": "df8a14b53ce142a1b942fe27bf54cd60",
|
||||
"expression": "last(/Template Frogg Freebox API V10/frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},cpu_percent])>{$CPU_WARN_THRESHOLD} and last(/Template Frogg Freebox API V10/frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},cpu_percent])<={$CPU_HIGH_THRESHOLD}",
|
||||
"name": "Freebox - CPU élevé (> {$CPU_WARN_THRESHOLD}%)",
|
||||
"priority": "WARNING",
|
||||
"description": "L'utilisation CPU de la Freebox est élevée."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"uuid": "14f29ee5ac834920b75a1e27fc41b520",
|
||||
"name": "Freebox - RAM Utilisation",
|
||||
"type": "EXTERNAL",
|
||||
"key": "frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},ram_percent]",
|
||||
"delay": "60s",
|
||||
"value_type": "FLOAT",
|
||||
"units": "%",
|
||||
"description": "Pourcentage d'utilisation de la mémoire RAM",
|
||||
"tags": [
|
||||
{ "tag": "component", "value": "memory" },
|
||||
{ "tag": "source", "value": "freebox-api" }
|
||||
],
|
||||
"triggers": [
|
||||
{
|
||||
"uuid": "ab75cf14e21649bda532fe17049cfbc0",
|
||||
"expression": "last(/Template Frogg Freebox API V10/frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},ram_percent])>{$RAM_HIGH_THRESHOLD}",
|
||||
"name": "Freebox - RAM critique (> {$RAM_HIGH_THRESHOLD}%)",
|
||||
"priority": "HIGH",
|
||||
"description": "L'utilisation RAM de la Freebox dépasse le seuil critique."
|
||||
},
|
||||
{
|
||||
"uuid": "4bf45cf2a3b44f2da6cb8ef14115e3b0",
|
||||
"expression": "last(/Template Frogg Freebox API V10/frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},ram_percent])>{$RAM_WARN_THRESHOLD} and last(/Template Frogg Freebox API V10/frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},ram_percent])<={$RAM_HIGH_THRESHOLD}",
|
||||
"name": "Freebox - RAM élevée (> {$RAM_WARN_THRESHOLD}%)",
|
||||
"priority": "WARNING"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"uuid": "d4fe1415e3b04bf4b2da6cb8ef14115e",
|
||||
"name": "Freebox - RAM Utilisée",
|
||||
"type": "EXTERNAL",
|
||||
"key": "frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},ram_used]",
|
||||
"delay": "60s",
|
||||
"value_type": "UNSIGNED",
|
||||
"units": "B",
|
||||
"description": "Mémoire RAM utilisée en bytes",
|
||||
"tags": [
|
||||
{ "tag": "component", "value": "memory" },
|
||||
{ "tag": "source", "value": "freebox-api" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"uuid": "9c12b7a42f614bb59a3c8e43ef1907d4",
|
||||
"name": "Freebox - RAM Totale",
|
||||
"type": "EXTERNAL",
|
||||
"key": "frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},ram_total]",
|
||||
"delay": "3600s",
|
||||
"value_type": "UNSIGNED",
|
||||
"units": "B",
|
||||
"description": "Mémoire RAM totale en bytes",
|
||||
"tags": [
|
||||
{ "tag": "component", "value": "memory" },
|
||||
{ "tag": "source", "value": "freebox-api" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"uuid": "43e8bb81de534d0b986e74cf9783f982",
|
||||
"name": "Freebox - HDD Utilisation",
|
||||
"type": "EXTERNAL",
|
||||
"key": "frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},hdd_percent]",
|
||||
"delay": "300s",
|
||||
"value_type": "FLOAT",
|
||||
"units": "%",
|
||||
"description": "Pourcentage d'espace disque utilisé (agrégé sur toutes les partitions)",
|
||||
"tags": [
|
||||
{ "tag": "component", "value": "storage" },
|
||||
{ "tag": "source", "value": "freebox-api" }
|
||||
],
|
||||
"triggers": [
|
||||
{
|
||||
"uuid": "b2f63810f54546419f9490184f93282b",
|
||||
"expression": "last(/Template Frogg Freebox API V10/frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},hdd_percent])>{$HDD_HIGH_THRESHOLD}",
|
||||
"name": "Freebox - Disque critique (> {$HDD_HIGH_THRESHOLD}%)",
|
||||
"priority": "HIGH",
|
||||
"description": "L'espace disque de la Freebox est presque saturé."
|
||||
},
|
||||
{
|
||||
"uuid": "713df211832049e487560824b61d6bc0",
|
||||
"expression": "last(/Template Frogg Freebox API V10/frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},hdd_percent])>{$HDD_WARN_THRESHOLD} and last(/Template Frogg Freebox API V10/frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},hdd_percent])<={$HDD_HIGH_THRESHOLD}",
|
||||
"name": "Freebox - Disque plein (> {$HDD_WARN_THRESHOLD}%)",
|
||||
"priority": "WARNING"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"uuid": "20cf786b361a49dfbf76ba50f63a0332",
|
||||
"name": "Freebox - HDD Espace Utilisé",
|
||||
"type": "EXTERNAL",
|
||||
"key": "frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},hdd_used]",
|
||||
"delay": "300s",
|
||||
"value_type": "UNSIGNED",
|
||||
"units": "B",
|
||||
"description": "Espace disque utilisé en bytes",
|
||||
"tags": [
|
||||
{ "tag": "component", "value": "storage" },
|
||||
{ "tag": "source", "value": "freebox-api" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"uuid": "14f09d8be8d54d24a9e9a4f4105c3127",
|
||||
"name": "Freebox - HDD Espace Total",
|
||||
"type": "EXTERNAL",
|
||||
"key": "frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},hdd_total]",
|
||||
"delay": "3600s",
|
||||
"value_type": "UNSIGNED",
|
||||
"units": "B",
|
||||
"description": "Espace disque total en bytes",
|
||||
"tags": [
|
||||
{ "tag": "component", "value": "storage" },
|
||||
{ "tag": "source", "value": "freebox-api" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"uuid": "55f52ce8ec8a4df7a192f153a7b67b14",
|
||||
"name": "Freebox - Statut Disque",
|
||||
"type": "EXTERNAL",
|
||||
"key": "frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},disk_status]",
|
||||
"delay": "300s",
|
||||
"value_type": "UNSIGNED",
|
||||
"description": "Statut des disques : 1=OK, 0=Problème détecté",
|
||||
"tags": [
|
||||
{ "tag": "component", "value": "storage" },
|
||||
{ "tag": "source", "value": "freebox-api" }
|
||||
],
|
||||
"triggers": [
|
||||
{
|
||||
"uuid": "a82348ff98f645399cc1b8163f4b4550",
|
||||
"expression": "last(/Template Frogg Freebox API V10/frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},disk_status])=0",
|
||||
"name": "Freebox - Problème disque détecté",
|
||||
"priority": "HIGH",
|
||||
"description": "Un ou plusieurs disques de la Freebox sont en état anormal."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"uuid": "f295b95420f14d878d65e25287e0fa19",
|
||||
"name": "Freebox - Débit Descendant",
|
||||
"type": "EXTERNAL",
|
||||
"key": "frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},net_rate_down]",
|
||||
"delay": "60s",
|
||||
"value_type": "UNSIGNED",
|
||||
"units": "bps",
|
||||
"description": "Débit de téléchargement actuel en bits par seconde",
|
||||
"preprocessing": [
|
||||
{
|
||||
"type": "MULTIPLIER",
|
||||
"parameters": ["8"]
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
{ "tag": "component", "value": "network" },
|
||||
{ "tag": "source", "value": "freebox-api" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"uuid": "ea4fa7a4968840c9ae647575cc84ff5d",
|
||||
"name": "Freebox - Débit Montant",
|
||||
"type": "EXTERNAL",
|
||||
"key": "frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},net_rate_up]",
|
||||
"delay": "60s",
|
||||
"value_type": "UNSIGNED",
|
||||
"units": "bps",
|
||||
"description": "Débit d'upload actuel en bits par seconde",
|
||||
"preprocessing": [
|
||||
{
|
||||
"type": "MULTIPLIER",
|
||||
"parameters": ["8"]
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
{ "tag": "component", "value": "network" },
|
||||
{ "tag": "source", "value": "freebox-api" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"uuid": "e0e23fa271cb46bcba710640d2105e19",
|
||||
"name": "Freebox - Total Octets Reçus",
|
||||
"type": "EXTERNAL",
|
||||
"key": "frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},net_bytes_down]",
|
||||
"delay": "300s",
|
||||
"value_type": "UNSIGNED",
|
||||
"units": "B",
|
||||
"description": "Nombre total d'octets reçus depuis le démarrage",
|
||||
"tags": [
|
||||
{ "tag": "component", "value": "network" },
|
||||
{ "tag": "source", "value": "freebox-api" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"uuid": "996e36d4df924b17b2b6fbe147b40742",
|
||||
"name": "Freebox - Total Octets Envoyés",
|
||||
"type": "EXTERNAL",
|
||||
"key": "frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},net_bytes_up]",
|
||||
"delay": "300s",
|
||||
"value_type": "UNSIGNED",
|
||||
"units": "B",
|
||||
"description": "Nombre total d'octets envoyés depuis le démarrage",
|
||||
"tags": [
|
||||
{ "tag": "component", "value": "network" },
|
||||
{ "tag": "source", "value": "freebox-api" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"uuid": "36ef970c0ba149959666fdbd424b3c9a",
|
||||
"name": "Freebox - Bande Passante Max Descendante",
|
||||
"type": "EXTERNAL",
|
||||
"key": "frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},net_bw_down]",
|
||||
"delay": "3600s",
|
||||
"value_type": "UNSIGNED",
|
||||
"units": "bps",
|
||||
"description": "Bande passante maximale descendante négociée (bit/s)",
|
||||
"tags": [
|
||||
{ "tag": "component", "value": "network" },
|
||||
{ "tag": "source", "value": "freebox-api" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"uuid": "60ee6e3cbcf14e9f906f369ee62ef8bf",
|
||||
"name": "Freebox - Bande Passante Max Montante",
|
||||
"type": "EXTERNAL",
|
||||
"key": "frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},net_bw_up]",
|
||||
"delay": "3600s",
|
||||
"value_type": "UNSIGNED",
|
||||
"units": "bps",
|
||||
"description": "Bande passante maximale montante négociée (bit/s)",
|
||||
"tags": [
|
||||
{ "tag": "component", "value": "network" },
|
||||
{ "tag": "source", "value": "freebox-api" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"uuid": "62bfb9fb8ae841bc8f04f2f4cb63901b",
|
||||
"name": "Freebox - Température CPU Mère",
|
||||
"type": "EXTERNAL",
|
||||
"key": "frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},temp_cpum]",
|
||||
"delay": "120s",
|
||||
"value_type": "UNSIGNED",
|
||||
"units": "°C",
|
||||
"description": "Température du CPU de la carte mère",
|
||||
"tags": [
|
||||
{ "tag": "component", "value": "temperature" },
|
||||
{ "tag": "source", "value": "freebox-api" }
|
||||
],
|
||||
"triggers": [
|
||||
{
|
||||
"uuid": "bfd7e979d0314051a89c92257d0f9839",
|
||||
"expression": "last(/Template Frogg Freebox API V10/frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},temp_cpum])>{$TEMP_HIGH_THRESHOLD}",
|
||||
"name": "Freebox - Température CPU mère critique (> {$TEMP_HIGH_THRESHOLD}°C)",
|
||||
"priority": "HIGH"
|
||||
},
|
||||
{
|
||||
"uuid": "f295b920bf014c628e8557b77ee0fa91",
|
||||
"expression": "last(/Template Frogg Freebox API V10/frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},temp_cpum])>{$TEMP_WARN_THRESHOLD} and last(/Template Frogg Freebox API V10/frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},temp_cpum])<={$TEMP_HIGH_THRESHOLD}",
|
||||
"name": "Freebox - Température CPU mère élevée (> {$TEMP_WARN_THRESHOLD}°C)",
|
||||
"priority": "WARNING"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"uuid": "569ea25f16954b41b8061df8974ee0f1",
|
||||
"name": "Freebox - Température CPU Box",
|
||||
"type": "EXTERNAL",
|
||||
"key": "frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},temp_cpub]",
|
||||
"delay": "120s",
|
||||
"value_type": "UNSIGNED",
|
||||
"units": "°C",
|
||||
"description": "Température du CPU de la box",
|
||||
"tags": [
|
||||
{ "tag": "component", "value": "temperature" },
|
||||
{ "tag": "source", "value": "freebox-api" }
|
||||
],
|
||||
"triggers": [
|
||||
{
|
||||
"uuid": "c3e5904d0fa34e8590c5fe39a4897ff3",
|
||||
"expression": "last(/Template Frogg Freebox API V10/frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},temp_cpub])>{$TEMP_HIGH_THRESHOLD}",
|
||||
"name": "Freebox - Température CPU box critique (> {$TEMP_HIGH_THRESHOLD}°C)",
|
||||
"priority": "HIGH"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"uuid": "d4fe9ca18bb04cf09d31fe5a6d7f8d02",
|
||||
"name": "Freebox - Température Switch",
|
||||
"type": "EXTERNAL",
|
||||
"key": "frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},temp_sw]",
|
||||
"delay": "120s",
|
||||
"value_type": "UNSIGNED",
|
||||
"units": "°C",
|
||||
"description": "Température du switch intégré",
|
||||
"tags": [
|
||||
{ "tag": "component", "value": "temperature" },
|
||||
{ "tag": "source", "value": "freebox-api" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"uuid": "672bbce24b174fa9809cbce2441db1b2",
|
||||
"name": "Freebox - Température HDD",
|
||||
"type": "EXTERNAL",
|
||||
"key": "frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},temp_hdd]",
|
||||
"delay": "300s",
|
||||
"value_type": "UNSIGNED",
|
||||
"units": "°C",
|
||||
"description": "Température du disque dur interne",
|
||||
"tags": [
|
||||
{ "tag": "component", "value": "temperature" },
|
||||
{ "tag": "source", "value": "freebox-api" }
|
||||
],
|
||||
"triggers": [
|
||||
{
|
||||
"uuid": "ea52c36203c5499cbce2442d531b1a33",
|
||||
"expression": "last(/Template Frogg Freebox API V10/frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},temp_hdd])>{$TEMP_HIGH_THRESHOLD}",
|
||||
"name": "Freebox - Température HDD critique (> {$TEMP_HIGH_THRESHOLD}°C)",
|
||||
"priority": "HIGH"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"uuid": "f4b17a79409f49128da060d6ae51b333",
|
||||
"name": "Freebox - Vitesse Ventilateur",
|
||||
"type": "EXTERNAL",
|
||||
"key": "frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},fan_rpm]",
|
||||
"delay": "120s",
|
||||
"value_type": "UNSIGNED",
|
||||
"units": "RPM",
|
||||
"description": "Vitesse de rotation du ventilateur interne",
|
||||
"tags": [
|
||||
{ "tag": "component", "value": "hardware" },
|
||||
{ "tag": "source", "value": "freebox-api" }
|
||||
],
|
||||
"triggers": [
|
||||
{
|
||||
"uuid": "cbde43ef19074d4ea52c36203c5499cb",
|
||||
"expression": "last(/Template Frogg Freebox API V10/frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},fan_rpm])=0 and last(/Template Frogg Freebox API V10/frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},temp_cpum])>40",
|
||||
"name": "Freebox - Ventilateur arrêté (température > 40°C)",
|
||||
"priority": "HIGH",
|
||||
"description": "Le ventilateur ne tourne plus alors que la température est élevée."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"uuid": "bcce2442d53141a2ba50f63a0332f295",
|
||||
"name": "Freebox - Uptime",
|
||||
"type": "EXTERNAL",
|
||||
"key": "frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},uptime]",
|
||||
"delay": "300s",
|
||||
"value_type": "UNSIGNED",
|
||||
"units": "uptime",
|
||||
"description": "Durée de fonctionnement de la Freebox depuis le dernier redémarrage",
|
||||
"tags": [
|
||||
{ "tag": "component", "value": "system" },
|
||||
{ "tag": "source", "value": "freebox-api" }
|
||||
],
|
||||
"triggers": [
|
||||
{
|
||||
"uuid": "8b061df8974e40f1a89c92257d0f9839",
|
||||
"expression": "change(/Template Frogg Freebox API V10/frogg_freebox_check.sh[{$FREEBOX_APP_ID},{$FREEBOX_APP_TOKEN},{$FREEBOX_HOST},uptime])<0",
|
||||
"name": "Freebox - Redémarrage détecté",
|
||||
"priority": "INFO",
|
||||
"description": "L'uptime a diminué, la Freebox a redémarré."
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue