hidue to ram problems at our vserver some of our tasks stopped working in the middle of the night or while we were not around. so i wrote a script checking for the tasks in top, the socket file and so on.

Feature List:

checking for the sockets of a task (it can be any file)

looking for the task (or its children) in top

getting a file from a server and compare it with a local one (checking Apache)

sending a mail to a local address and search its local mailbox folder (checking MTA)

query something from a mysql database and comparing it with a given string

logging to a file

trying to start the inactive tasks

sending a mail if something is wrong

Code:

#!/bin/bash

############## CONFIG ##############

path="/home/jonny007/scripts/" #path where the temp files and the log shall be createdlogLevel=2 #level, which messages shall be written into the log. 0=off; 1=error; 2=warn; 3=infologFile="logCheck.log" #logFilelogCutLength=15 #number of lines, which shall be cut of the log of the sevicesemail="email@gmail.de"subjectMail="check results"contentMail="<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"><html><head><style type=\"text/css\">body{font-family:verdana}.green{background:#040;color:#0A0}.red{background:#A00;color:#400}.left{text-align:center}.left b{text-decoration:underline;color:#000}th,table{border:none}th{font-size:110%;line-height:300%}td{border:1px solid #000}</style><title></title></head><body><table><tr><th colspan=\"2\">`date`</th></tr>"

#XTended Check#path to where all the vhosts are locatedvhosts="/somethings/vhosts/"#http hostshostArray=( "http://URI1" "https://URI2")#files to queryfileArray=( "/index.html" "/robots.txt")#subfolder from $vhosts where the file is locatedsourceFolderArray=( "site1" "site2")

#address to send the test mail totestMailAddress="noone@localmail"#path to the mailbox of the address abovetestMailboxPath="/some/thing/vmail/mailbox/new"

mysqlUser="someUser"mysqlPwd="aPassword"mysqlDb="database"mysqlQuery="SELECT password FROM virtual_users WHERE user='noone'"mysqlResult="secret"

Who is online

Users browsing this forum: Google [Bot] and 1 guest

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum