Operations 6 min read

How to Run Remote Scripts and Track Website Traffic with Zabbix

This guide shows how to configure Zabbix to execute remote shutdown or service commands on hosts via the web UI, enable remote command execution, and create scripts that collect total and incremental website PV/UV metrics, then display them in Zabbix dashboards.

Open Source Linux
Open Source Linux
Open Source Linux
How to Run Remote Scripts and Track Website Traffic with Zabbix

1. Executing Remote Scripts via Zabbix

Scenario: Use the Zabbix web interface to run shutdown commands or start/stop services on hosts that have the Zabbix agent installed, without logging in manually.

Configuration Steps

Create a script in the Zabbix web UI: Management → Scripts → Create Script.

Set the script name, type (script for Windows/Linux), execution location (Zabbix agent, proxy, or server), command, and host permissions.

Enable remote commands on the Zabbix agent by editing the agent configuration file, changing EnableRemoteCommands=0 to EnableRemoteCommands=1, and restarting the agent.

After creation, the script appears under the host’s context menu in the Zabbix monitoring view; selecting it runs the command on the target host.

2. Monitoring Website PV/UV with Zabbix

Goal: Collect total page views (PV) and unique visitors (UV) and their 5‑minute increments.

Definitions

UV – unique visitors, each distinct IP counted once per day.

PV – page view count, each request recorded.

Script Example (pvuv_number.sh)

/bin/bash
# desc: used nginx pv and uv
uv_number(){
  cat /usr/local/nginx/logs/access.log | awk '{print $1}' | sort | uniq | wc -l
}

pv_number(){
  cat /usr/local/nginx/logs/access.log | awk '{print $7}' | wc -l
}

case $1 in
  uv|UV) uv_number ;;
  pv|PV) pv_number ;;
esac
exit 0

Make the script executable and owned by the zabbix user, then configure a Zabbix agent item (e.g., nginx.conf) to call the script.

Template Creation

Add an item for total PV.

Add an item for PV increment over 5 minutes.

Add analogous items for UV.

Result

The Zabbix dashboard now displays the current PV, UV, and their recent increments for the monitored website.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

ZabbixPVuvremote script executionwebsite monitoring
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.