fb
Uncategorized 1 min

Basic health check script for Web Servers and Services

Vinay Babu Yella
Vinay Babu Yella
Solution Architect
health check for web servers and services
Scroll

health check for web servers and servicesThere are tools available to monitor the status of web servers and services, for e.g.: Nagios and SolarWinds. These tools need to be installed and configured to start monitoring/reporting and they provide many advanced features to monitor things in your IT. But if you are looking for simple solution for basic health check of your web resources without having to install special software or its agents, then this script helps you to get the job done.

What type of script is this?

This is a generic shell script with wget, curl and awk commands to monitor and notify the health of web servers and services. It monitors to check whether resources are UP, DOWN or SLOW. Keeps track of status changes and notifies whenever there is a change in state.

Sites and services of WSO2 servers are used in its configurations to demonstrate use with WSO2 servers. 

Banner-WSO2-Community-1-1

What are its features?

  • Customizable Sites and Services to monitor:
    • Monitors any HTTP or HTTPS URL, checking for “200” status return codes.
    • Monitors Web-services based on codes in response (for checking Admin service of WSO2 server, it is checking for RUNNING code in xml response)
    • Can be applied to monitor multiple sites/services (not just WSO2 middleware but for other web/application servers)
  • Checks request fulfilment time for slow responses, not just UP/DOWN
  • Sends email notification on state change (UP, SLOW, or DOWN)
  • Customizable To/From mail notification settings
  • Customizable SLOW latency threshold
  • Tracks previous state change and current state to avoid multiple notifications
  • Uses single text file for data storage, no DB necessary (configurable to have separate status files for Services and Sites)
  • No agents or special software to install

How to use this script?

Download or clone this source code. Make config changes in this script to customize list of servers and services you want to monitor. Once ready, it can be run from terminal for ad-hoc health check or as a cron job to run periodically at fixed time intervals.

Here is sample Email content/Script Output for state changes of Servers/Services:

Time: 2018-06-28 00:07:56
Site: https://localhost:9543/console/
Status: DOWN

Latency: 0 sec
Previous status: UP
Previous change: 2018-06-28 00:06:01
Time: 2018-06-28 00:07:56
Service: https://localhost:9443/services/ServerAdmin
Status: SLOW

Latency: 15 sec
Previous status: UP
Previous change: 2018-06-28 00:06:02 

I hope this is of help. Please don’t hesitate to ask your questions. I’m more than happy to help.

Full API lifecycle Management Selection Guide

WHITEPAPER

smartmockups l0qqucke