npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sematext-agent-nginx

v2.0.4

Published

SPM Agent for monitoring Nginx

Downloads

26

Readme

Build Status

This is the NGINX monitoring Agent for Sematext Cloud

Preparation

  1. Get a free Sematext account

  2. Create a Monitoring App of type "Nginx" and copy the SPM App Token - or execute the commands displayed in the Sematext UI (which are described here as well)

  3. Install Node.js on your Nginx server

  4. Activate Nginx stub_status module in the server section e.g. in /etc/nginx/sites-enabled/default:

location /nginx_status {
  # Turn on nginx stats
  stub_status on;
  # I do not need logs for stats
  access_log   off;
  # Security: Please use you local IP address instead ...
  allow all;
}

Optional preparation for PHP FastCGI Process Manager (FPM): To add monitoring for PHP-FPM follow these instructions.

Setup

# Install sematext-agent-nginx 
npm i sematext-agent-nginx -g
# If you use Sematext Cloud EU, set region for API endpoints
# sematext-nginx-setup -r EU
# Install systemd or upstart service file for sematext-agent-nginx 
sematext-nginx-setup -t YOUR_SPM_TOKEN_HERE -n http://localhost/nginx_status

Configuration

The setup script stores the configuration in /etc/sematext/sematext-agent-nginx.config

In case you want to change settings later edit /etc/sematext/sematext-agent-nginx.config. A typical case is to add receiver URL for On-Premises installation of SPM in the config file:

# default value for SaaS / Sematext Cloud: https://spm-receiver.sematext.com:443/receiver/v1/_bulk
spmSenderBulkInsertUrl: http://your-spm-server:8084/_bulk
# default value for SaaS / Sematext Cloud: https://event-receiver.sematext.com
eventsReceiverUrl:  http://your-spm-server:8083

Restart the Sematext Nginx Agent after config changes, depending on the init system:

  • Upstart (Ubuntu):
    sudo service sematext-agent-nginx restart 
  • Systemd (Linux others):
    sudo systemctl stop sematext-agent-nginx
    sudo systemctl start sematext-agent-nginx
  • Launchd (Mac OS X):
    sudo launchctl stop com.sematext.sematext-agent-nginx
    sudo launchctl stop com.sematext.sematext-agent-nginx

For tests you can just run the agent from command line:

sematext-agent-nginx --config /etc/sematext/sematext-agent-nginx.config

Results

NGINX Metrics in Sematext:

Docker

Sematext Agent for Nginx includes a docker file and startup script to build a Docker image.

git clone https://github.com/sematext/sematext-agent-nginx.git
cd sematext-agent-nginx
docker build -t sematext/sematext-agent-nginx .

The Sematext Nginx Agent supports following parameters on Docker:

| Environment Variable | Description | |----------------------|-------------| | Required parameters | | | SPM_TOKEN | your SPM Token for the Nginx SPM App | | NGINX_STATUS_URL | the URL to Nginx server, delivering the stats (see Nginx configuration above). Please note the servername/ip must be reachable from the agent container. You might need to use --link nginx-container-name to create the network link. NGINX_STATUS_URL is not required with DOCKER_AUTO_DISCOVERY.| |Docker auto discovery | Detect new nginx containers for monitoring! | | DOCKER_AUTO_DISCOVERY | Enable auto discovery of containers e.g. DOCKER_AUTO_DISCOVERY=true | | SPM_DOCKER_NETWORK | Name of the network to be used for HTTP queries to nginx. If this is set to "host" and docker run parameter --net=host the connection is made to the exposed ports. If this is not set or any other network name (e.g. bridge) the connection is done via nginx container IP address and 'internal' port 80 (used inside the nginx container). This feature works only when the Docker socket is mounted with -v /var/run/docker.sock:/var/run/docker.sock| | NGINX_STATUS_PATH | Location of the nginx status page e.g. "/nginx_status" | | PHP_FPM_STATUS_PATH | Location of the PHP FPM status page e.g. "/status" | | IMAGE_NAME_PATTERN | Regular expression to match nginx image name. Default value 'nginx'| | General parameters | | | HTTPS_PROXY | Url to HTTPS proxy if the agent runs behind a firewall | | SPM_RECEIVER_URL | Optional for SPM On-Premises, default value: https://spm-receiver.sematext.com:443/receiver/v1/_bulk for On-Premises receiver use http://your-spm-server:8084|_bulk.
| EVENTS_RECEIVER_URL | Optional for SPM On-Premises, default value: https://event-receiver.sematext.com. For On-Premises use http://your-spm-server:8083|

Example:

docker run --name sematext-agent-nginx -e SPM_TOKEN=YOUR_SPM_NGINX_TOKEN_HERE  \ 
-e NGINX_STATUS_URL=http://nginx-server/nginx_status \ 
-d  sematext/sematext-agent-nginx

Example with auto discovery of nginx containers via Docker API:

docker run --name sematext-agent-nginx \
-e SPM_TOKEN=YOUR_SPM_NGINX_TOKEN_HERE \
-e NGINX_STATUS_PATH=/nginx_Status \
-e DOCKER_AUTO_DISCOVERY=true \
--net=host -e SPM_DOCKER_NETWORK=host \
-v /var/run/docker.sock:/var/run/docker.sock -d \
sematext/sematext-agent-nginx

Support