Is there a tool available for monitoring server status with HTML/CSS

I am interested in a way to create an HTML or CSS code that can ping an address or IP every 10 minutes to determine if it is sending back a signal. If a signal is received, I want the status on my website to display as 'online'. In case there is no signal, I would like the text on my webpage to show 'offline'. Configuring this to work with multiple servers seems daunting to me at this point. So far, I have only been able to figure out how to do this using cron jobs, but since I'm running Windows 7, scripting it in the emulators I found has proven difficult due to my lack of experience. As a beginner in HTML and CSS, this challenge feels quite overwhelming for me.

Any assistance with this matter would be highly appreciated. Thank you in advance.

Answer №1

Is it possible to create a file on an external server?

If yes, include a small stylesheet there that modifies the following HTML:

<span class="active">Active</span>
<span class="inactive">Inactive</span>

transforming this CSS (on your server):

.active { display: none; }
.inactive { display: inline; }

to this:

.active { display: inline; }
.inactive { display: none; }

Ensure you link them so that the external server's stylesheet is the final one in your HTML header.


Nevertheless, this method using just CSS cannot be repeated every ten minutes - for that, JavaScript is required.

Create a JSON-P request to the external server, set the text default to "inactive" in your HTML, and change it to "active" if the JSON-P request is successful. (JSON-P should not return any errors.) However, you must have a custom page on that external server to return the JSON data, even if it's empty.

If you do not have permission to write on the external server, then there may not be much you can do in this case.

Answer №2

To incorporate this functionality on your webpage, you'll need to include some JavaScript code.

One approach is to make an AJAX request to check if the page is online - a successful AJAX request will return a 200 status code indicating that the page has loaded. If the page is hosted on a different domain than your test page, you may need to enable Cross Origin Requests (CORS) or use JSONP response, or set up a proxy page on your server.

Keep in mind that a failed request doesn't necessarily mean the website itself is offline - it could also be due to a dropped connection on your end.

Answer №3

To set up a server base script, you'll need to use PHP or ASP along with JavaScript that includes AJAX on the client side.

Consider using the jQuery library for JavaScript, which can help you save time (http://jquery.com/).

Here's an example of how your HTML structure could look:

<div class='serverstatus'></div>

For PHP, you would need to create a script like this:

$host = 'Your IP';
$port = your.port;
// Specify the Server Info [IP/PORT]
$timeout = 1;
// Establish a connection to the specified IP and port to check if it's responsive
$handler = fsockopen($host,$port,$errcd,$errstr,$timeout);
if($handler){   
   echo "1";
} else {
   echo "0"; 
} 
fclose($handler);

Next, for JavaScript:

Here is a simple Ajax function:

setTimeout(function() {$.ajax({
    url:'phpfile.php',
    type: 'GET',
    success: function(data){
        if (data == "1") {
            $(".serverstatus").html("Online");
        }
        else if (data == "0") {
            $(".serverstatus").html("Offline");
        }
        else {
            $(".serverstatus").html("Undefined");
        }

    }
});},600000);

Note: jQuery Library is required for this functionality.

CSS stands for Cascading Style Sheets and is used solely for designing purposes. It cannot be used for scripting. HTML, on the other hand, is used for creating content and not for scripting.

If you want to set up connections with external sources and implement live updates, you'll need to learn PHP or ASP for the connection part and JavaScript for real-time updates.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Looking for assistance with accessing elements using the "document.getElementById" method in Javascript

Below is the code snippet I am working with: <html> <head> <script> function adjustSelection(option) { var selectList = document.getElementById("catProdAttributeItem"); if (option == 0) { ...

Chrome introduces surprise spacing to text input fields styled uniquely

This particular code snippet is functioning correctly on Firefox, but unfortunately not on Chrome. The height of the input should match the styling of the select, but there seems to be a discrepancy in Chrome. Any ideas on how to rectify this? Upon closer ...

What is the best way to explain the concept of HTML5?

While reading a question on Stack Overflow, I came across a comment that stated: HTML5 is equal to HTML(5) + CSS3 + JavaScript. This statement truly caught me by surprise. Can it really be argued that HTML5 can be broken down into HTML(5), CSS3, and Ja ...

Switching between div elements in ReactJS

I am currently working on a web application built with ReactJS. One feature that I would like to include is similar to the following: https://i.sstatic.net/At1Gw.gif My query is as follows: What is this specific effect called? How can I go about imple ...

The width specified for the table is not being applied

I've been struggling to adjust the width of my table in order to display data from a database. I've tried using inline width, !important tag, id, and class but none have worked. Interestingly, when I apply a fixed width without dynamic data, it w ...

Automatically customizable CSS border thickness

Consider the following example of a div element: <div style="height: 10%; width: 20%; border: 1px solid black"> Div Content </div> The div above has its height and width specified in percentages. I would like the border width to adjust a ...

Tips for customizing the selected and hover color of ListItem in Material UI

Having trouble getting the 'selected' or 'hover' colors to work for the ListItem component. I've tried setting its classes like this: <ListItem selected button key="home" classes={{ selected: classes.listItemSelected } ...

Warning displayed on form input still allows submission

How can I prevent users from inserting certain words in a form on my website? Even though my code detects these words and displays a popup message, the form still submits the data once the user acknowledges the message. The strange behavior has me puzzled. ...

Sharing Iframes across various Components within a Single Page Application (like Youtube)

Did you know that Youtube now lets you minimize the player while browsing the site? It's similar to the functionality on LolEsports.com with Twitch and embedded Youtube players. I'm interested in adding this feature to my own website. Here' ...

Interactive bar chart that updates in real-time using a combination of javascript, html, and

Current Situation: I am currently in the process of iterating through a machine learning model and dynamically updating my "divs" as text labels. My goal is to transform these values into individual bars that visually represent the values instead of just d ...

Implementing a feature that ensures html elements are transparent in a PDF conversion

I am in the process of converting a webpage into a format that is easily printable as a PDF, while ensuring that it maintains the same appearance. Many tools for printing to PDF do not support background images or colors, so I am attempting to overcome thi ...

In my current project, I am developing a memory game using Ionic and Angular. The game involves displaying an ever-expanding list of numbers for the user to memorize, followed by the user typing

I am trying to make each number in an array appear and then disappear one by one. However, I have encountered an issue where only the last number shows up when there are multiple numbers in the array. I believe the problem lies within the for loop, but I h ...

Enhance form validation by utilizing jquery.validate to display appropriate icons indicating correct and incorrect input, with the option to

Trying to replicate the functionality of the jQuery validate plugin demo seen here, I am facing an issue on my own website. Upon clicking submit after the page loads, the plugin displays validation messages with a cross symbol. However, upon entering text, ...

Unable to interact with web element

When using selenium, I have a web element that I want to select. The WebElement.IsDisplayed() method returns true, but I am unable to perform the webelement.click() operation. port_dimension = canvas.find( By.xpath( "//*[local-name() = 'rect'][ ...

What could be causing my jQuery dialogs to lose their draggable functionality?

I've been struggling with making a dialog in jQuery draggable even though I've included 'draggable: true'. Can anyone help me figure out what's causing the issue? Here is the HTML code snippet: <div class="lessonDetails"> ...

What is the best way to determine the maximum `width` in a `translateX` animation?

I'm looking to design something similar to a desktop-only carousel. Here's the code snippet I have: <div class="wrapper"> <div class="image-container"> <img alt="Siac" src="https://diey.now.sh/Icons/Clients/SIAC_LOGO.svg"> ...

Discover the character "’" as well as other fascinating symbols

When transferring content into an HTML file from sources like Word documents or PDFs, I want to ensure that the special quotes and apostrophes are converted to their standard counterparts. In simpler terms, I desire to switch characters like ’ with &apo ...

Trouble with PHP and HTML Code not functioning properly after loop execution

I created a form with a dropdown menu that pulls options from a MYSQL Database. However, after fetching the options, the button and other components of the code seem to disappear. Everything else works fine when I comment out the PHP Query. <form acti ...

Translucent" outline for an "opaque" object

Consider the following HTML snippet: <div id="my_div"> </div> Now, let's take a look at the CSS code: #my_div { width: 100px; height: 100px; background-color: #0f0; op ...

Is there a way to successfully implement this CSS animation utilizing background images in a Markdown document?

I am attempting to create a dynamic animation on a <canvas> element by changing the background image using the @keyframes rule in CSS. Unfortunately, I am facing difficulty getting the animation to work. The <canvas> tag does not even display a ...