{"id":100822,"date":"2026-03-29T14:29:50","date_gmt":"2026-03-29T12:29:50","guid":{"rendered":"https:\/\/dyb.fr\/?p=100822"},"modified":"2026-03-29T14:29:51","modified_gmt":"2026-03-29T12:29:51","slug":"nut-raspberry-pi-gerer-plusieurs-onduleurs-intelligemment","status":"publish","type":"post","link":"https:\/\/dyb.eu\/blog\/nut-raspberry-pi-gerer-plusieurs-onduleurs-intelligemment\/","title":{"rendered":"NUT + Raspberry Pi : g\u00e9rer plusieurs onduleurs intelligemment"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Pourquoi centraliser la gestion des onduleurs ?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Dans beaucoup d\u2019infrastructures, les onduleurs sont configur\u00e9s individuellement. R\u00e9sultat :<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>arr\u00eat brutal des machines<\/li>\n\n\n\n<li>aucune priorisation<\/li>\n\n\n\n<li>perte de donn\u00e9es possible<\/li>\n\n\n\n<li>autonomie batterie mal exploit\u00e9e<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Avec <strong>Network UPS Tools (NUT)<\/strong> install\u00e9 sur un Raspberry Pi, on peut centraliser la logique et piloter intelligemment toute l\u2019infrastructure.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Architecture typique<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>1 Raspberry Pi (ma\u00eetre NUT)<\/li>\n\n\n\n<li>2+ onduleurs connect\u00e9s en USB<\/li>\n\n\n\n<li>Plusieurs serveurs (prod, backup, stockage, etc.)<\/li>\n\n\n\n<li>Shutdown distant via SSH<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Le Raspberry devient le cerveau d\u00e9cisionnel.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Le probl\u00e8me classique<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Lors d\u2019une coupure :<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>tout reste allum\u00e9 \u2192 batterie vid\u00e9e rapidement<\/li>\n\n\n\n<li>ou tout s\u2019\u00e9teint en m\u00eame temps \u2192 gaspillage d\u2019autonomie<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Dans les deux cas, c\u2019est inefficace.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">La solution : arr\u00eat progressif<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Le principe est simple :<br><strong>adapter l\u2019arr\u00eat des machines au niveau de batterie.<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Exemple de strat\u00e9gie<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Batterie restante<\/th><th>Action<\/th><\/tr><\/thead><tbody><tr><td>90%<\/td><td>arr\u00eat des serveurs non critiques<\/td><\/tr><tr><td>50%<\/td><td>arr\u00eat du stockage<\/td><\/tr><tr><td>20%<\/td><td>arr\u00eat de la production<\/td><\/tr><tr><td>&lt;10%<\/td><td>extinction compl\u00e8te<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Pourquoi c\u2019est efficace<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. Maximiser l\u2019autonomie<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">On lib\u00e8re progressivement de la consommation. moins de charge \u2192 batterie dure plus longtemps<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. Prioriser les services<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>backup d\u2019abord<\/li>\n\n\n\n<li>stockage ensuite<\/li>\n\n\n\n<li>production en dernier<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">3. Arr\u00eat propre<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>pas de corruption disque<\/li>\n\n\n\n<li>services stopp\u00e9s correctement<\/li>\n\n\n\n<li>bases de donn\u00e9es propres<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Multi-onduleurs : un vrai plus<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Dans un setup avec plusieurs UPS :<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>on prend <strong>la batterie la plus faible comme r\u00e9f\u00e9rence<\/strong><\/li>\n\n\n\n<li>on \u00e9vite qu\u2019un seul onduleur mette tout en danger<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Ou bien mieux, si vos serveurs sont tous redond\u00e9s sur plusieurs onduleurs, on shutdown uniquement quand les deux onduleurs sont sur batterie \/ se vident<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Pourquoi un Raspberry Pi ?<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>consommation quasi nulle<\/li>\n\n\n\n<li>toujours allum\u00e9<\/li>\n\n\n\n<li>ind\u00e9pendant des serveurs<\/li>\n\n\n\n<li>co\u00fbt tr\u00e8s faible<\/li>\n\n\n\n<li>id\u00e9al comme point de contr\u00f4le<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">Script typique utilis\u00e9 par Dyb :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n\nLOGFILE=\"\/var\/log\/nut\/upssched.log\"\nmkdir -p \/var\/log\/nut\n\nlog() {\n    echo \"&#91;$(date '+%Y-%m-%d %H:%M:%S')] $1\" >> \"$LOGFILE\"\n}\n\nshutdown_host() {\n    local host=$1\n    local name=$2\n    local user=${3:-root}\n    log \"Shutdown $name ($host) via user $user\"\n    ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no \\\n        -i \/etc\/nut\/id_nut ${user}@${host} \\\n        \"sudo shutdown -h +1 'NUT: power outage'\" 2>> \"$LOGFILE\"\n}\n\nalready_shutdown() {\n    local flag=\"\/run\/nut\/shutdown_${1}.done\"\n    &#91; -f \"$flag\" ] &amp;&amp; return 0\n    touch \"$flag\"\n    return 1\n}\n\ncheck_battery_and_shutdown() {\n    CHARGE_UPS1=$(upsc ups1@localhost battery.charge 2>\/dev\/null)\n    CHARGE_UPS2=$(upsc ups2@localhost battery.charge 2>\/dev\/null)\n\n    if &#91; \"$CHARGE_UPS1\" -lt \"$CHARGE_UPS2\" ]; then\n        CHARGE=$CHARGE_UPS1\n    else\n        CHARGE=$CHARGE_UPS2\n    fi\n\n    log \"On battery - charge: ${CHARGE}% (UPS1: ${CHARGE_UPS1}%, UPS2: ${CHARGE_UPS2}%)\"\n\n    # 90% \u2192 backup server\n    if &#91; \"$CHARGE\" -le 90 ]; then\n        already_shutdown \"backup\" || shutdown_host \"10.0.0.10\" \"backup-server\" \"root\"\n    fi\n\n    # 50% \u2192 storage\n    if &#91; \"$CHARGE\" -le 50 ]; then\n        already_shutdown \"storage\" || shutdown_host \"10.0.0.20\" \"storage-server\" \"admin\"\n    fi\n\n    # 20% \u2192 production servers\n    if &#91; \"$CHARGE\" -le 20 ]; then\n        already_shutdown \"prod1\" || shutdown_host \"10.0.0.30\" \"prod-server-1\" \"root\"\n        already_shutdown \"prod2\" || shutdown_host \"10.0.0.40\" \"prod-server-2\" \"root\"\n    fi\n}\n\ncase \"$1\" in\n    onbatt_handler)\n        log \"=== Switching to battery - start monitoring ===\"\n        rm -f \/run\/nut\/shutdown_*.done\n        while true; do\n            check_battery_and_shutdown\n            sleep 30\n        done &amp;\n        echo $! > \/run\/nut\/battery_monitor.pid\n        ;;\n    online_handler)\n        log \"=== Power restored ===\"\n        if &#91; -f \/run\/nut\/battery_monitor.pid ]; then\n            kill $(cat \/run\/nut\/battery_monitor.pid) 2>\/dev\/null\n            rm -f \/run\/nut\/battery_monitor.pid\n        fi\n        rm -f \/run\/nut\/shutdown_*.done\n        ;;\nesac<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">B\u00e9n\u00e9fices concrets<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>meilleure r\u00e9silience infra<\/li>\n\n\n\n<li>z\u00e9ro arr\u00eat brutal<\/li>\n\n\n\n<li>autonomie optimis\u00e9e<\/li>\n\n\n\n<li>comportement pr\u00e9visible<\/li>\n\n\n\n<li>facile \u00e0 adapter (seuils, machines)<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Un Raspberry Pi avec NUT permet de transformer une simple protection \u00e9lectrique en <strong>syst\u00e8me de gestion intelligent de crise<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">On ne subit plus la coupure :<br>\u2192 on l\u2019anticipe, on l\u2019organise, on la contr\u00f4le.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">C\u2019est une am\u00e9lioration simple, peu co\u00fbteuse, mais avec un impact imm\u00e9diat sur la stabilit\u00e9 de l\u2019infrastructure.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Et puis, votre facture EDF ainsi que l'\u00e9cologie mondiale vous remercieront \ud83d\ude09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Pourquoi centraliser la gestion des onduleurs ? Dans beaucoup d\u2019infrastructures, les onduleurs sont configur\u00e9s individuellement. R\u00e9sultat : Avec Network UPS Tools (NUT) install\u00e9 sur un Raspberry Pi, on peut centraliser la logique et piloter intelligemment toute l\u2019infrastructure. Architecture typique Le Raspberry devient le cerveau d\u00e9cisionnel. Le probl\u00e8me classique Lors d\u2019une coupure : Dans les deux [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":100825,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[29,50,31,28],"class_list":["post-100822","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-adminsys","tag-linux","tag-network","tag-tip","tag-windows"],"_links":{"self":[{"href":"https:\/\/dyb.eu\/blog\/wp-json\/wp\/v2\/posts\/100822","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dyb.eu\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dyb.eu\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dyb.eu\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dyb.eu\/blog\/wp-json\/wp\/v2\/comments?post=100822"}],"version-history":[{"count":2,"href":"https:\/\/dyb.eu\/blog\/wp-json\/wp\/v2\/posts\/100822\/revisions"}],"predecessor-version":[{"id":100824,"href":"https:\/\/dyb.eu\/blog\/wp-json\/wp\/v2\/posts\/100822\/revisions\/100824"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dyb.eu\/blog\/wp-json\/wp\/v2\/media\/100825"}],"wp:attachment":[{"href":"https:\/\/dyb.eu\/blog\/wp-json\/wp\/v2\/media?parent=100822"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dyb.eu\/blog\/wp-json\/wp\/v2\/categories?post=100822"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dyb.eu\/blog\/wp-json\/wp\/v2\/tags?post=100822"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}