Welcome to Geeklog, Anonymous Saturday, November 15 2025 @ 09:55 am EST
Geeklog Forums
Geeklog Site Health Monitor
Status: offline
::Ben
Forum User
Full Member
Registered: 01/14/05
Posts: 1582
🧩 Site Health Monitor Block for Geeklog
The Site Health Monitor is a lightweight PHP block that helps administrators keep an eye on the real-time load of their Geeklog website.
It measures the total number of page requests per second across all visitors and displays a simple, color-coded status indicator:
🟢 Normal — site operating smoothly
🟠 Moderate Load — higher than usual traffic
🔴 High Load — slowdown protection active
Designed for shared hosting environments, it doesn’t require any external dependencies or database writes.
The script uses a small temporary file to track traffic activity, making it safe, portable, and fast to install.
Admins can optionally enable a slight delay during overload periods or log warnings to the PHP error log for monitoring.
Perfect for small to medium Geeklog sites that want a quick visual indicator of their site’s performance without needing a full server monitoring solution.
// Geeklog Site Health Monitor (global traffic indicator)
// Works on shared hosting – uses a small temp file as counter
// ======================================================================
function throttle_check() {
// --- Configuration ---
$limit_normal = 10; // normal load = <10 req/s
$limit_warning = 25; // warning zone = 10–25 req/s
$window = 1; // 1 second time window
$data_file = sys_get_temp_dir() . '/geeklog_traffic.dat';
$now = microtime(true);
$window_start = floor($now);
// --- Load previous request data ---
$data = @json_decode(@file_get_contents($data_file), true);
if (!is_array($data)) {
$data = ['count' => 0, 'ts' => $window_start];
}
// --- Reset or increment counter ---
if ($data['ts'] == $window_start) {
$data['count']++;
} else {
$data['ts'] = $window_start;
$data['count'] = 1;
}
// --- Save updated data ---
@file_put_contents($data_file, json_encode($data));
// --- Determine global site health ---
$req = $data['count'];
if ($req <= $limit_normal) {
$status = '🟢 Site running normally';
$color = 'green';
} elseif ($req <= $limit_warning) {
$status = '🟠 Site under moderate load';
$color = 'orange';
} else {
$status = '🔴 High load – slowdown active';
$color = 'red';
// Optional: add small server-side delay to ease pressure
usleep(300000); // 0.3s
}
// --- Optional logging when overloaded ---
if ($req > $limit_warning) {
error_log("Geeklog Site Health: {$req} req/s (load warning)");
}
// --- Display site health status ---
$output = "<div style='font-size:13px; text-align:center; padding:5px;'>";
$output .= "<strong style='color:$color;'>$status</strong><br/>";
$output .= "<small>Requests this second: $req</small>";
$output .= "</div>";
return $output;
}
The Site Health Monitor is a lightweight PHP block that helps administrators keep an eye on the real-time load of their Geeklog website.
It measures the total number of page requests per second across all visitors and displays a simple, color-coded status indicator:
🟢 Normal — site operating smoothly
🟠 Moderate Load — higher than usual traffic
🔴 High Load — slowdown protection active
Designed for shared hosting environments, it doesn’t require any external dependencies or database writes.
The script uses a small temporary file to track traffic activity, making it safe, portable, and fast to install.
Admins can optionally enable a slight delay during overload periods or log warnings to the PHP error log for monitoring.
Perfect for small to medium Geeklog sites that want a quick visual indicator of their site’s performance without needing a full server monitoring solution.
Text Formatted Code
// ======================================================================// Geeklog Site Health Monitor (global traffic indicator)
// Works on shared hosting – uses a small temp file as counter
// ======================================================================
function throttle_check() {
// --- Configuration ---
$limit_normal = 10; // normal load = <10 req/s
$limit_warning = 25; // warning zone = 10–25 req/s
$window = 1; // 1 second time window
$data_file = sys_get_temp_dir() . '/geeklog_traffic.dat';
$now = microtime(true);
$window_start = floor($now);
// --- Load previous request data ---
$data = @json_decode(@file_get_contents($data_file), true);
if (!is_array($data)) {
$data = ['count' => 0, 'ts' => $window_start];
}
// --- Reset or increment counter ---
if ($data['ts'] == $window_start) {
$data['count']++;
} else {
$data['ts'] = $window_start;
$data['count'] = 1;
}
// --- Save updated data ---
@file_put_contents($data_file, json_encode($data));
// --- Determine global site health ---
$req = $data['count'];
if ($req <= $limit_normal) {
$status = '🟢 Site running normally';
$color = 'green';
} elseif ($req <= $limit_warning) {
$status = '🟠 Site under moderate load';
$color = 'orange';
} else {
$status = '🔴 High load – slowdown active';
$color = 'red';
// Optional: add small server-side delay to ease pressure
usleep(300000); // 0.3s
}
// --- Optional logging when overloaded ---
if ($req > $limit_warning) {
error_log("Geeklog Site Health: {$req} req/s (load warning)");
}
// --- Display site health status ---
$output = "<div style='font-size:13px; text-align:center; padding:5px;'>";
$output .= "<strong style='color:$color;'>$status</strong><br/>";
$output .= "<small>Requests this second: $req</small>";
$output .= "</div>";
return $output;
}
3
4
Quote
All times are EST. The time is now 09:55 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content