GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Python-Packet-Loss-Monitor/packet_loss_monitor.php at main · drobin04/Python-Packet-Loss-Monitor

Expand file tree

/

packet_loss_monitor.php

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
40 lines (34 loc) · 1.37 KB
/

packet_loss_monitor.php

Copy path

File metadata and controls

40 lines (34 loc) · 1.37 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
// Set the timezone to Cancun
date_default_timezone_set('America/Cancun');
$database = new SQLite3('results.s3db');
// Calculate time passed since last ping failure
$last_failure_query = $database->query('SELECT MAX(timestamp) FROM packet_loss');
$last_failure_timestamp = $last_failure_query->fetchArray()[0];
$time_passed = time() - strtotime($last_failure_timestamp);
// Calculate the count of failures in the past hour
$current_time = time();
$one_hour_ago = $current_time - 3600;
$past_hour_query = $database->query("SELECT COUNT(*) FROM packet_loss WHERE timestamp >= $one_hour_ago");
$num_failures = $past_hour_query->fetchArray()[0];
// Calculate hours, minutes, and seconds
$hours = floor($time_passed / 3600);
$minutes = floor(($time_passed % 3600) / 60);
$seconds = $time_passed % 60;
// Determine the background color based on the time passed
$background_color = ($time_passed > 3600) ? '#c5f3c1' : '#ffcccb';
// Display the information with the appropriate background color
echo '<html>';
echo '<head><meta http-equiv="refresh" content="4">';
echo '<style>';
echo 'body {';
echo ' background-color: ' . $background_color . ';';
echo '}';
echo '</style>';
echo '</head>';
echo '<body>';
echo "Time passed since last ping failure: $hours hours, $minutes minutes, $seconds seconds<br>";
echo "Number of failures in the past hour: $num_failures";
echo '</body>';
echo '</html>';
?>
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.