Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Monitor PHP-FPM and Nginx - Script for low memory environments / Alix

    Scheduled Pinned Locked Moved Development
    1 Posts 1 Posters 1.3k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • F
      freebee
      last edited by

      Hi.

      In Alix 2d3, which some days on, the pfsense get "bad gateway" message in browser. In console i get "swap out, kill pid" message.
      So, i suggest a script to solve this. Works for me.

      Install Cron package from webgui pfsense.

      • First line is the file and above the content.

      /usr/local/etc/php-fpm-test.sh

      #!/bin/sh
      SERVICE=php-fpm
      if P=$(pgrep $SERVICE)
      then
          #echo "$SERVICE is running, PID is $P"
      exit
      else
          /etc/rc.php-fpm_restart 
      fi

      /usr/local/etc/nginx-test.sh

      #!/bin/sh
      SERVICE=nginx
      if P=$(pgrep $SERVICE)
      then
          #echo "$SERVICE is running, PID is $P"
      exit
      else
          /etc/rc.restart_webgui
      fi

      OBS: If you want see if process is ok, just remove the # from echo line.
      commands:
      chmod 655 /usr/local/etc/php-fpm-test.sh
      chmod 655 /usr/local/etc/nginx-test.sh
      chmod +x /usr/local/etc/php-fpm-test.sh
      chmod +x /usr/local/etc/nginx-test.sh

      In Webgui -> Services -> Cron, insert:

      */1    *      *      *      *      root  /usr/local/etc/php-fpm-test.sh
      */1    *      *      *      *      root  /usr/local/etc/nginx-test.sh

      Each minute, the cron will execute the script.
      You can verify killing the php-fpm, nginx or both.

      Service_watch not display this services and in very low memory environments, create many child process, what is not very interested (usually idle is in 0% in busy environment) and depends on php (witch depends of more and more memory).

      1 Reply Last reply Reply Quote 0
      • First post
        Last post
      Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.