I usually deal with at least two dozen servers on a weekly basis. I thought it would be nice to create a script that asks each of them and determines whether they are up or not.
- Servers run either Apache2 or IIS7.
- Hosting Providers Are Changing
- Usually on each server there are several sites.
- The settings are incompatible, there is always an apache default “hello world” page when you access ip directly.
- All Virtualhosts Sites
I thought there would be a better way to determine if they should just take one site from each server and make a http HEAD request to make sure the response from server 200? Obviously, this would be prone to “false positive” if:
- Site configuration / setup incorrectly returns 200 OK when it should return a 4xx error code.
- If the configuration of an individual site (
<VirtualHost> ) is disabled or the site has moved to another server.
But for the most part, the HEAD request and 200 OK usage should be reliable, right? . Also, make sure that the record in domain A matches what it indicated, as this leads to the site moving.
Pseudocode:
import http list = { '72.0.0.0' : 'domain.com', '71.0.0.0' : 'blah.com', } serverNames = { 'jetty' : '72.0.0.0', 'bob' : '71.0.0.0' } for each ( list as server => domain ) { headRequest = http.head( domain ) if ( headRequest.response == 200 && http.arecord(domain) == server ) { print serverNames[server] + ' is up '; } else { print 'Server is either down or the site attached to the server lookup has moved.'; } }
I will probably write a script in Python or PHP, but this question should only discuss logic.
source share