write a Python script that will test the HTTP Service to see if it is "up and operational".

computer science

Description

 write a Python script that will test the HTTP Service to see if it is "up and operational". Note that the HTTP service may be "down" for a period of time, so you should check the other components to see why the HTTP service is down. Devise a test plan and execute it!

turn in

test plan and code

WebCheck.py

#!/usr/bin/python

 

import hashlib

from sys import argv

from socket import *

 

def connScan(tgtHost):

  try:

    connSkt = socket(AF_INET, SOCK_STREAM)

    connSkt.connect((tgtHost, 80))

    connSkt.send('GET /\r\n')

    results = connSkt.recv(4096)

    myHash = hashlib.md5()

    myHash.update(results)

    print "URL: " + tgtHost + ", Hash: " + myHash.hexdigest()

  except:

    print 'No connection...'

  finally:

    connSkt.close()

 

def main():

#  script, ip = argv

  connScan('10.0.95.82')

 

if __name__ == "__main__":

  main()

 

 

mysqlCheck.py

#!/usr/bin/python

 

import MySQLdb

 

dbconn = MySQLdb.connect(   '10.0.95.82',     'admin' ,      'changeme',       'test')

dbcur = dbconn.cursor()

 

dbcur.execute('select * from test')

 

data = dbcur.fetchone()

print data

 

 

WebCheck2.py

#!/usr/bin/python3

 

import requests

import urllib.request

 

url = "http://10.0.95.82"

 

response = requests.get(url)

 

print(response.text)

 

 

 

 

ping -c 5 10.0.95.82

 

echo "------------------------ "

 

./mysqlCheck.py

 

echo "----------------------- "

 

./WebCheck.py


Related Questions in computer science category