Sponsored Content
Full Discussion: Bash Monitoring Alert Script
Top Forums Shell Programming and Scripting Bash Monitoring Alert Script Post 302327814 by cbo0485 on Monday 22nd of June 2009 04:01:59 PM
Old 06-22-2009
Bash Monitoring Alert Script

Done some google search on this, and I can find a ton that just search for a domain, like yahoo.com, google.com, etc...

But I need to take one I found, and modify it to include port number. I have a bunch of apache instances that I manage and it's a pretty consolidated environment, so lots of apache servers using lots of different ports. One domain, like abc.com will point towards 2-4 apache instances on different servers/port number combinations.

Here is the code I found that worked well, but I need to be able to check them by servernameSmilieort rather than domain.com.

Code:
#!/bin/bash
# Simple SHELL script for Linux and UNIX system monitoring with
# ping command
# -------------------------------------------------------------------------
# Copyright (c) 2006 nixCraft project <http://www.cyberciti.biz/fb/>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# -------------------------------------------------------------------------
# Setup email ID below
# See URL for more info:
# http://www.cyberciti.biz/tips/simple-linux-and-unix-system-monitoring-with-ping-command-and-scripts.html
# -------------------------------------------------------------------------

# add ip / hostname separated by while space
HOSTS='cat server_list.txt'

# no ping request
COUNT=1

# email report when
SUBJECT="Ping failed"
EMAILID="test@domain.com"
for myHost in $HOSTS
do
  count=$(ping -c $COUNT $myHost | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')
  if [ $count -eq 0 ]; then
    # 100% failed
    echo "Host : $myHost is down (ping failed) at $(date)" | mail -s "$SUBJECT" $EMAILID
  fi
done

Edit: I know you can't use ping to specify a port number, but is there another way to send a packet to a serverSmilieort for the monitoring script?

Last edited by cbo0485; 06-22-2009 at 05:07 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Monitoring a file - Basic Bash Question

*This is not homework I am new to UNIX and want to try this Monitoring a file demo* *If this is the wrong forum please move it - im new to the forums* $1 = the file to be monitored $2 = the time for the file to sleep If the file gets changed (using -nt) it will send my username mail saying... (2 Replies)
Discussion started by: Nolan-
2 Replies

2. Infrastructure Monitoring

Monitoring and Alert System

hi, i serarch monitoring and alert system. when HDD and services are down. Send email and sms alert to me and help desk. but i don't find any program. Can you help me ? Thanks. (1 Reply)
Discussion started by: oulutas
1 Replies

3. Shell Programming and Scripting

Help with Monitoring script

Hi Gurus, Currently I am learning UNIX through online forums and unix blogs. I have the below requirement. I need to write a script to monitor server processes. For example, there are 3 processes currently running on the server.(java, pmrepagent, pmserver). If any of the process goes down,... (2 Replies)
Discussion started by: svajhala
2 Replies

4. Shell Programming and Scripting

need script bash alert email

Hello I have a server it is running more than 5 people Scripts I want to send a warning to the administrator for the main server All is written in the ssh strain For example, when typing the following command "ls" " rm " and other email sends the administrator for the main server About it... (2 Replies)
Discussion started by: x-zer0
2 Replies

5. Linux

Memory monitoring and sending alert mail to users in network using shell script

i m workiing on a shell script which may monitors network memory and send alert to user if it increase a threshold (1 Reply)
Discussion started by: navdeep5673
1 Replies

6. Infrastructure Monitoring

Alert / Monitoring / Historial Data Open Source

hi guys my boss asked me for a tool to monitor and alert my Linux boxes... and some Win boxes... but not only monitor for high CPU Usage, hign memory usage and so on....he also wants a tool for historical data I mean something like I want to know the CPU Usage and memory usage for the last... (1 Reply)
Discussion started by: karlochacon
1 Replies

7. UNIX for Advanced & Expert Users

ldapsearch in monitoring script without bind password written in script

Hi I do a very simple monitoring of our OpenLDAP (runs in cronjob and generate alerts if unsuccessfull) $ ldapsearch -h hostname.domain -D "cn=monitor_user,ou=People,dc=organisation" -w "password" -b "dc=organisation" -x "(&(cn=monitor_user)(ou=People))" dn | grep -v version dn:... (4 Replies)
Discussion started by: slashdotweenie
4 Replies

8. Shell Programming and Scripting

Alert for monitoring

Dear All, I am new to unix scripting, i need to develop a alert system which get trigger when my scripts don't find any *.log file to copy from one directory to other directory. In detail my scripts run every day and it create a dummy file and check all those *.log file 1 day old and copy them... (3 Replies)
Discussion started by: guddu_12
3 Replies

9. What is on Your Mind?

Script to alert with email after a job got successful in monitoring tool

Hi guyz, Please send me a script which is to be sending an automatic email to particular mail id's when a job get complete with status successful. Please send me your script to my mail id : rehan.csjmu@gmail.com Thanks in Advance. ---------- Post updated at 11:33 AM ----------... (1 Reply)
Discussion started by: Rehan Ahmad
1 Replies

10. Shell Programming and Scripting

How to block first bash script until second bash script script launches web server/site?

I'm new to utilities like socat and netcat and I'm not clear if they will do what I need. I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes. I'm using Cygwin bash on Windows 10. My... (3 Replies)
Discussion started by: siegfried
3 Replies
GOOGLE-SITEMAPGEN(1)					      General Commands Manual					      GOOGLE-SITEMAPGEN(1)

NAME
google-sitemapgen -- simple script to automate production of sitemaps for a webserver SYNOPSIS
google-sitemapgen [--testing] [--help] [--config=config.xml] DESCRIPTION
This manual page documents briefly the google-sitemapgen command. This manual page was written for the Debian distribution because the original program does not have a manual page. google-sitemapgen is a program that automatically produces sitemaps for a webserver, in the Google Sitemap Protocol (GSP). Sitemap files are XML listings of content you make available on your web server. The files can be directly submitted to search engines as hints for the search engine web crawlers as they index your web site. This can result in better coverage of your web content in search engine indices, and less of your bandwidth spent doing it. OPTIONS
--config=config.xml Specify the location of the configuration config.xml --testing Used to test the sitemap generator configuration. --help Display a summary of options and exit. SEE ALSO
/usr/share/doc/google-sitemapgen/examples/example_config.xml.gz AUTHOR
Google Sitemap was originally written by Google Code <opensource@google.com>. This manual page was written by Kumar Appaiah <akumar@ee.iitm.ac.in> for the Debian system (but may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 any later version pub- lished by the Free Software Foundation. On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. GOOGLE-SITEMAPGEN(1)
All times are GMT -4. The time now is 03:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy