This is a Powershell tool for monitoring a set of http hosts that logs into MSSQL database. You can download the lastest version here
This tool need as a swiss knife for monitoring websites without using external service or installing complex softwares. It may be needed to monitor some site, also for testing\debugging purpouses and you don't want to spend too much time adopting huge tools. Or you may need a monitor tool that can be customized to collect complex statistics or add business login into monitor.
Because this project is build trying to keep it as much simple as possible, it is just a simple power shell script. This means you'll just have to download a single file and run. No worry about install process, download frameworks or prerequisites. Just download and run. Easy right? This will install you powershell as a windows service. All settings can be tuned directly into the script or using an external config file. Once service is running, he periodically reload the website list and try to call each entry, saving result into database.
Simply, Powershell Http Monitor tool has tre possible usage.
- As a standalone application, to be manually run
- As a scheduled task, to be scheduled periodically
- As a service, to run continuosly in background
Running this command the script read all websites, try to call them and finally download results into MSSQL database or log files. This usage mode desn't require any installation. It may be also scheduled using windows scheduled tasks.
Http-Monitor -Run
It is very easy to configure. Key settings:
- run it every 5 minute (or other interval)
- set the script path
- tell to scheduler to do not start multiple instances
See screeshot for all steps:
The trick is to define a task starting once (now) but repeaded indefinitely every x minutes.
This is easy. You have only to following text into editbox (just replace with you absolute filepath).
Powershell -file "<pathtofile>\Http-Monitor.ps1"
Last step of wizard is needed to avoid multiple instance at the same time. Just choose "do not allow new instance" in drop down.
This install the powershell script as service.
PS > Http-Monitor -Setup
#once it is installed you can control using script or service.mmc
PS > Http-Monitor -Start
PS > Http-Monitor -Stop
As Powershell Http Monitor is a dry application, with no UI, configuration is the most tricky part, but at the end there are few things to learn.
- Application settings: this can be edited inside the main application script or using external script.
- Input: there is a text file with one host for each row.
The file path must match application settings path. The file must contain the list of websites, with http or https prefix. This is usually a list of homepages but, by design Power Shell Monitoring Tool can accept any other url.
This may be useful to monitor all sites into one iis server. To do this it is needed to use appcmd command to dump binding into a text file. It is easy to process using regexp to translate into a list of site url.
You can configure application settings in two ways:
- editing script inline (see section "Application settings")
- manage settings in a separate files (recommended). Application looks for "settings.ps1" file into app directory and overwrite default settings with that one.
You can copy settings remaning it correctly download file
Settings are very easy to undestand and with some attention you will be able to get the right tuning.
######################################
#
# Application Settings
#
######################################
# DB SETTINGS
# -----------------------------------
$writeToDB= $true # enable or disable db logging
$DBServer = "(localdb)\Projects" # MSSQL host, usully .\SQLEXPRESS, .\SQLSERVER
$DBName = "httpstatus" # name of db.(HAVE TO BE CREATED)
$ConnectionString = "Server=$DBServer;Database=$DBName;Integrated Security=True;" # full connection string. Write here password if not in integrated security
# EMAIL SETTINGS
# -----------------------------------
$sendEmail=$true #enable email send
$emailErrorCodes=500,200 # list of status codes that produces error
$emailFrom="Http Monitor Tool <[email protected]>"
$emailTo="Me <destination [email protected]>"
$smtpServer="127.0.01" #smtp server. To use autenticated smtp server you have to change Do-Monitor function.
$errorSubject="Http-Monitor: Get Error on site" # subject of email notification
$errorBody="Monitoring script get an errror. See details." #subject of error body
# MONITOR SETTINGS
# ----------------------------------
$dbpath=$workingPath+"\db.txt" # db of web sites to monitor. One per line. Must have protocol predix. i.e. http://www.google.it
$monitoring= @() # list of ips to monitor. This is used to focus ips on some destination only "8.8.8.8","4.4.4.4"
$userAgent = [Microsoft.PowerShell.Commands.PSUserAgent]::Chrome #agent used to download files
$delay=5 # number of seconds to wait between checking website inside a full run (used to avoid server overload)
$delayIteration=100 # number of seconds between checks ( once I checked all sites, I wait this time before a full control)
# LOGGING FILES
# ----------------------------------
$traceFile=$workingPath+"\tomonitor.txt" # log of monitored sites
$errorFile=$workingPath+"\error.txt" # error only file
$outFile=$workingPath+"\out.txt" # full log file
The download badge is part of "GitHub Analytics" one small application that give statistic about your github profile.
Please try this also and let me know what you think about!
#############################################################################################
#
# Copyright (C) 2017 Daniele Fontani
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
#############################################################################################