in

How to Monitor Port and Website with Open Source: A Comprehensive Guide

Keeping your applications and services up and running is critical in today‘s world. As an infrastructure engineer, having robust monitoring in place allows you to be proactive and address issues before they cause major outages. While large enterprises often invest in premium monitoring platforms, open source tools provide a free yet powerful alternative for lean teams.

In this comprehensive guide, I‘ll walk you through how to monitor ports and websites using PHP Server Monitor – a feature-packed PHP-based monitoring solution. By the end, you‘ll have a solid understanding of how to:

  • Install and configure PHP Server Monitor
  • Monitor URLs and ports
  • Customize alerts and notifications
  • Visualize uptime and latency
  • Expand monitoring as your needs grow

So let‘s get started! This guide assumes you have Linux administration basics down – if not, I highly recommend Linux Training and Certification Courses to skill up first.

Why is Monitoring Important?

Before we dive in, it‘s worth covering why monitoring is so critical for any online service:

  • It allows you to detect outages and degraded performance before customers complain. This reduces downtime and improves user experience.

  • With historical monitoring data, you gain visibility into usage patterns and can plan capacity expansion.

  • Alerts notify you of issues that require intervention, allowing for fast troubleshooting and resolution.

  • Monitoring provides metrics to assess infrastructure and application health. You can optimize configurations for better efficiency.

  • It builds confidence in your stack‘s reliability so you can focus on shipping new features versus firefighting.

Simply put, monitoring gives you the insights needed to confidently operate and improve complex computing systems.

Overview of PHP Server Monitor

PHP Server Monitor is a great open source solution that delivers on core monitoring necessities without breaking the bank. Let‘s look at some of its capabilities:

  • Monitor URLs – HTTP/HTTPS, with custom timeout thresholds. Alert on HTTP status codes or missing content.

  • Monitor TCP and UDP Ports -Alert on open, closed or timeout.

  • MySQL and Load Monitoring – Track MySQL connectivity and server load.

  • Email/SMS/Telegram Alerts – Get notified immediately when something needs attention.

  • Uptime Graphs – Visualize availability and response times over time.

  • API and Plugins – Expand monitoring by developing custom checks.

It runs on a LAMP (Linux, Apache, MySQL, PHP) stack and stores metric data in MySQL for generating historical reports. The setup is straightforward, but does require basic sysadmin skills.

Now let‘s go through the installation and configuration!

Pre-requisites and Installation

PHP Server Monitor requires:

  • Linux or Unix server
  • Apache 2.2.x or higher
  • PHP 5.5.9+
  • MySQL 5.0.3+ or MariaDB
  • CURL

Use your package manager (e.g APT, Yum) to install the above on your chosen server. For example on CentOS:

yum install httpd mysql-server php php-mysql curl

Additional LAMP installation instructions can be found here.

Once LAMP is ready, create a database and user for PHP Server Monitor:

CREATE DATABASE psm; 

CREATE USER ‘psmuser‘@‘localhost‘ IDENTIFIED BY ‘monitor123‘;

GRANT ALL ON psm.* TO ‘psmuser‘@‘localhost‘;

With the prerequisites in place, we can now install PHP Server Monitor:

  1. Download the latest release

  2. Extract and copy the phpservermon folder to your Apache doc root (usually /var/www/html)

  3. Browse to http://your_ip/phpservermon/install.php

  4. Enter your database credentials and admin user details

  5. Click install.

That‘s it! The setup takes less than 5 minutes in most cases.

Adding Monitoring Checks

To start monitoring, we need to add servers and checks via the PHP Server Monitor UI:

  1. Login at http://your_ip/phpservermon

  2. Go to Servers > Add New

  3. Enter a name and monitoring details:

    • For URL checking, enter the full URL

    • For ports, enter the IP, port number and protocol (TCP/UDP)

  4. Click "Save" to add the check.

The new check will now show on the main status page. Green means OK, red indicates a failure.

Some examples of checks you can add:

  • Website uptime monitoring – HTTP response code 200
  • TCP port 22 – confirm SSH is listening
  • UDP port 161 – check SNMP is open
  • Website content check – alert if text is missing

The flexibility makes it easy to monitor exactly what matters for your infrastructure.

Customizing Alerts and Notifications

Getting notified of issues is critical to minimize downtime. PHP Server Monitor supports:

  • Email
  • SMS
  • Telegram
  • Pushover

To enable notifications:

  1. Go to Settings > Notification Settings

  2. Check the services you want to enable

  3. Add API keys and recipient details

Now you‘ll get an alert when any monitored service fails. You can configure each check to have custom alert thresholds before triggering a notice.

For example, allowing 2 failures within 5 minutes prevents noise from transient blips. Alerts can also be sent to multiple recipients and escalated if not acknowledged.

Visualizing Status and Uptime

The default PHP Server Monitor view shows real-time status across all checks. For historical reporting, go to Status and click the Uptime or Latency tabs.

This gives you availability and response time graphs over the last hour, day or week. Hover over data points to view exact figures.

Long term uptime trends are useful capacity planning indicators. And latency percentiles help benchmark application performance.

Expanding Monitoring Scope

While PHP Server Monitor has all core monitoring areas covered, you can further extend it:

  • Custom Checks – Write scripts that run on a schedule and report status. This allows integrating specialized monitoring needs.

  • External Data – Pull metrics from APIs, log files, databases etc. to visualize in the dashboards.

  • Plugin Integration – There are plugins for mining server stats, performance counters and more.

  • REST API – The API enables building custom dashboards and integration with other systems.

So in summary – PHP Server Monitor is a solid open source monitoring platform. It delivers the essential capabilities for up-time monitoring, alerting and reporting. And it can be adapted to monitor pretty much any aspect of your infrastructure.

Let me know in the comments if you have any other questions! I‘m happy to help you get the most value out of this tool.

AlexisKestler

Written by Alexis Kestler

A female web designer and programmer - Now is a 36-year IT professional with over 15 years of experience living in NorCal. I enjoy keeping my feet wet in the world of technology through reading, working, and researching topics that pique my interest.