Service apache tombe , raison pas encore trouvée

Bonjour, je vous demande un coup de main en raison de mon ignorance dans la rédaction d’un script.
Voila mon problème:
j’ai 2 jeedom :le principal « musclé » sur Nuc intel I8 avce 16Go de mem et 160 Go de ssd .
et un Jeedom secondaire (sur le meme réseau) sur RPi3 très light , uniquement pour monitoring et supporter le plugin Lecteur Ir qui fonctionne mal sur le Nuc, mais le problème n’est pas là.
De temps en temps (une à deux fois / an) sur le Jeedom principal le service Apache2 tombe (enfin s’arrète) donc jeedom devient inaccessible. L’accès en SSH fonctionne parfaitement et il suffit que je lance la commande en ssh:

/etc/init.d/apache2 restart

et ça repart. Sauf que si ça se passe en mon absence impossible de le faire.
Je cherche pourquoi apache s’arrète mais pas encore trouvé.
ce que je cherche à faire en attendant de trouver pourquoi, c’est de monitorer avec le Rpi3 le service apache2 du Jeedom principal. Je pense qu’avec le plugin scrip ça doit etre possibel et si le service est arrèté lancer la commande en root sur le jeedom principal /etc/init.d/apache2 restart .
problème je suis une quiche dans la rédaction du scrip sh.
Si avez le courage votre aide sera la TRES bien venue
Merci d’avance

Le NUC est capable de monitorer Apache2 avec un script bash qui peut être lancé automatiquement via la crontab.

Script à compléter pour ton cas trouvé sur la toile.

#!/bin/bash

if systemctl is-active -q apache2; then
  echo "Statistic:0"
else
  echo "Statistic:1"
fi

il faudrait regarder les logs apache, l’indice se trouve forcément dedans. qu’est ce que raconte le fichier error.log par exemple ? ( /var/log/apache2/error.log)

Bonjour,
j’ai un paquet de log apache, il faudrait que je retrouve la dernière date de relance.
autrement c’est du genre (peut etre à la date mais pas certain

[Wed May 08 00:00:05.733553 2024] [ssl:warn] [pid 662] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
[Wed May 08 00:00:05.733746 2024] [mpm_prefork:notice] [pid 662] AH00163: Apache/2.4.59 (Debian) OpenSSL/1.1.1w configured -- resuming normal operations
[Wed May 08 00:00:05.738166 2024] [core:notice] [pid 662] AH00094: Command line: '/usr/sbin/apache2'
[Wed May 08 19:45:58.245000 2024] [mpm_prefork:error] [pid 662] AH00161: server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting
[Wed May 08 22:14:31.819077 2024] [mpm_prefork:notice] [pid 662] AH00170: caught SIGWINCH, shutting down gracefully
[Wed May 08 22:16:29.215925 2024] [ssl:warn] [pid 656] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
[Wed May 08 22:16:29.222311 2024] [mpm_prefork:notice] [pid 656] AH00163: Apache/2.4.59 (Debian) OpenSSL/1.1.1w configured -- resuming normal operations
[Wed May 08 22:16:29.222345 2024] [core:notice] [pid 656] AH00094: Command line: '/usr/sbin/apache2'
Python 2.7.18
[Wed May 08 23:19:50.593698 2024] [mpm_prefork:notice] [pid 656] AH00170: caught SIGWINCH, shutting down gracefully
[Wed May 08 23:20:01.976450 2024] [ssl:warn] [pid 123472] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
[Wed May 08 23:20:01.984442 2024] [mpm_prefork:notice] [pid 123472] AH00163: Apache/2.4.59 (Debian) OpenSSL/1.1.1w configured -- resuming normal operations
[Wed May 08 23:20:01.984482 2024] [core:notice] [pid 123472] AH00094: Command line: '/usr/sbin/apache2'
Python 2.7.18
[Thu May 09 00:00:05.575312 2024] [mpm_prefork:notice] [pid 123472] AH00171: Graceful restart requested, doing restart

autrement le log d’hier ou apache est resté on

[Sun May 19 00:00:02.380523 2024] [ssl:warn] [pid 123472] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
[Sun May 19 00:00:02.380720 2024] [mpm_prefork:notice] [pid 123472] AH00163: Apache/2.4.59 (Debian) OpenSSL/1.1.1w configured -- resuming normal operations
[Sun May 19 00:00:02.380734 2024] [core:notice] [pid 123472] AH00094: Command line: '/usr/sbin/apache2'
[Sun May 19 20:44:40.653116 2024] [mpm_prefork:notice] [pid 123472] AH00170: caught SIGWINCH, shutting down gracefully
[Sun May 19 20:44:41.147345 2024] [ssl:warn] [pid 1071418] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
[Sun May 19 20:44:41.152102 2024] [mpm_prefork:notice] [pid 1071418] AH00163: Apache/2.4.59 (Debian) OpenSSL/1.1.1w configured -- resuming normal operations
[Sun May 19 20:44:41.152131 2024] [core:notice] [pid 1071418] AH00094: Command line: '/usr/sbin/apache2'
Python 2.7.18
[Mon May 20 00:00:01.697501 2024] [mpm_prefork:notice] [pid 1071418] AH00171: Graceful restart requested, doing restart

pour moi c’est un peu obscur … la force n’est pas avec moi :grinning:
et tout cas merci de te pencher sur le pb

On voit un restart ce qui voudrait dire que quand tu le relance il n’est pas arrêté. As tu regardé les process apache avant la relance ?

Merc @Loic

Oui j’ai un peu bidouillé en ssh pour essayer de comprendre ce que pouvait me retourner apache comme info , le vais regarder les autres log (il y en a 14 !!)
le seul log qui est un peu différent c’est celui ci:

[Wed May 08 00:00:05.733553 2024] [ssl:warn] [pid 662] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
[Wed May 08 00:00:05.733746 2024] [mpm_prefork:notice] [pid 662] AH00163: Apache/2.4.59 (Debian) OpenSSL/1.1.1w configured -- resuming normal operations
[Wed May 08 00:00:05.738166 2024] [core:notice] [pid 662] AH00094: Command line: '/usr/sbin/apache2'
[Wed May 08 19:45:58.245000 2024] [mpm_prefork:error] [pid 662] AH00161: server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting
[Wed May 08 22:14:31.819077 2024] [mpm_prefork:notice] [pid 662] AH00170: caught SIGWINCH, shutting down gracefully
[Wed May 08 22:16:29.215925 2024] [ssl:warn] [pid 656] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
[Wed May 08 22:16:29.222311 2024] [mpm_prefork:notice] [pid 656] AH00163: Apache/2.4.59 (Debian) OpenSSL/1.1.1w configured -- resuming normal operations
[Wed May 08 22:16:29.222345 2024] [core:notice] [pid 656] AH00094: Command line: '/usr/sbin/apache2'
Python 2.7.18
[Wed May 08 23:19:50.593698 2024] [mpm_prefork:notice] [pid 656] AH00170: caught SIGWINCH, shutting down gracefully
[Wed May 08 23:20:01.976450 2024] [ssl:warn] [pid 123472] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
[Wed May 08 23:20:01.984442 2024] [mpm_prefork:notice] [pid 123472] AH00163: Apache/2.4.59 (Debian) OpenSSL/1.1.1w configured -- resuming normal operations
[Wed May 08 23:20:01.984482 2024] [core:notice] [pid 123472] AH00094: Command line: '/usr/sbin/apache2'
Python 2.7.18
[Thu May 09 00:00:05.575312 2024] [mpm_prefork:notice] [pid 123472] AH00171: Graceful restart requested, doing restart

et le log suivant:

[Thu May 09 00:00:05.644567 2024] [ssl:warn] [pid 123472] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
[Thu May 09 00:00:05.644716 2024] [mpm_prefork:notice] [pid 123472] AH00163: Apache/2.4.59 (Debian) OpenSSL/1.1.1w configured -- resuming normal operations
[Thu May 09 00:00:05.644725 2024] [core:notice] [pid 123472] AH00094: Command line: '/usr/sbin/apache2'
Thu May  9 23:56:01 2024 (2950499): Error Cannot kill process 1394795: Success!
Thu May  9 23:56:01 2024 (2937681): Error Cannot kill process 1718449: Success!
Thu May  9 23:56:02 2024 (2950529): Error Cannot kill process 1249290: Success!
Thu May  9 23:56:02 2024 (211048): Error Cannot kill process 2705748: Success!
Thu May  9 23:56:03 2024 (2950528): Error Cannot kill process 2705747: Success!
Thu May  9 23:56:03 2024 (2929683): Error Cannot kill process 1718448: Success!
Thu May  9 23:56:03 2024 (2950529): Error Cannot kill process 2790570: Success!
Thu May  9 23:56:04 2024 (2950498): Error Cannot kill process 2835717: Success!
Thu May  9 23:56:04 2024 (2950528): Error Cannot kill process 1747043: Success!
Thu May  9 23:56:04 2024 (2950529): Error Cannot kill process 2929652: Success!
Thu May  9 23:56:05 2024 (210839): Error Cannot kill process 2844653: Success!
[Fri May 10 00:00:01.584179 2024] [mpm_prefork:notice] [pid 123472] AH00171: Graceful restart requested, doing restart

dans le /etc/apache2/apache2.conf, la ligne de seting du
MaxRequestWorkers
n’existe pas

Merci pour ta réponse .
mais étant incompétant en code si la réponse est « Statistic:1 » comment enclencher dans la suite du code une commande genre

sudo systemctl restart apache2

?

Si le script est lancé sous root.

#!/bin/bash

if systemctl is-active -q apache2; then
  echo "Statistic:0"
else
  echo "Statistic:1"
  systemctl start apache2  # si apache2 est arrêté, start est peu être plus approprié.
fi
3 « J'aime »

merci, c’est tout simple j’en prends bonne note.
Pour tester, j’ai arrêté apache2 avec la commande
sudo systemctl stop apache2
testé l’accès en http: le site ne répond pas et 5 minutes après (le cron du script était */5 * * * *) j’ai à nouveau eu accès à Jeedom en http . Absolument super merci beaucoup.

1 « J'aime »

Pour regarder les logs au bon moment, tu peux avoir le retour dans une commande info virtuelle binaire avec.

curl 'http://127.0.0.1/core/api/jeeApi.php?plugin=virtual&type=event&apikey=xxxxxxxxxx&id=1234&value=0'

ou

curl 'http://127.0.0.1/core/api/jeeApi.php?plugin=virtual&type=event&apikey=xxxxxxxxxx&id=1234&value=1'

1234 étant l’id de ta commande virtuelle.

Merci, je vais ça tt de suite

Ce sujet a été automatiquement fermé après 24 heures suivant le dernier commentaire. Aucune réponse n’est permise dorénavant.