Skip to content

Instantly share code, notes, and snippets.

@themightychris
Last active May 29, 2021 09:31
Show Gist options
  • Save themightychris/881c3eae8a9235c4f4a922f95cdd0102 to your computer and use it in GitHub Desktop.
Save themightychris/881c3eae8a9235c4f4a922f95cdd0102 to your computer and use it in GitHub Desktop.
emergence monitoring
#!/bin/bash
if [ ! -f /etc/goaccess.conf ]; then
cat > /etc/goaccess.conf <<- END_OF_CONFIG
time-format %T
date-format %d/%b/%Y
log_format %v %h - %^ [%d:%t %^] "%r" %s %b "%R" "%u" "%^"
END_OF_CONFIG
fi
tail -n "${TAIL_LINES:-0}" -f /emergence/sites/*/logs/access.log | awk '$8=$1$8' | goaccess --config-file=/etc/goaccess.conf

Monitor emergence services with goaccess and netdata

  • Configure for php section in /emergence/config.json

        "php": {
            // ...
            "statusPath": "/.well-known/php-fpm-status",
            // ...
        }
    
  • Stop php in kernel panel, then stop/start emergence-kernel

  • Live patch nginx config: /emergence/services/etc/nginx.conf

        server {
            listen 127.0.0.1:80;
            server_name localhost;
            location /.well-known/nginx-status {
                stub_status on;
            }
            location /.well-known/php-fpm-status {
                include /etc/nginx/fastcgi_params;
                fastcgi_pass unix:/emergence/services/run/php-fpm/php-fpm.sock;
                fastcgi_param PATH_INFO $fastcgi_script_name;
            }
        }
    
  • reload nginx config without emergence re-rendering config

    killall -HUP nginx
  • Edit /hab/svc/netdata/config/python.d/phpfpm.conf

    localhost:
      name : 'local'
      url  : "http://localhost/.well-known/php-fpm-status?full&json"
    
  • Edit /hab/svc/netdata/config/python.d/nginx.conf

    localhost:
      name : 'local'
      url  : 'http://localhost/.well-known/nginx-status'
    
  • Create mysql user for netdata

    create user 'netdata'@'localhost';
    grant replication client on *.* to 'netdata'@'localhost';
    flush privileges;
  • Edit /hab/svc/netdata/config/python.d/mysql.conf

    local:
      user: 'netdata'
      socket: '/emergence/services/run/mysqld/mysqld.sock'
    
  • Reload netdata service:

    hab svc unload core/netdata
    hab svc load core/netdata
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment