1748347 Members
4927 Online
108762 Solutions
New Discussion

Require inputs

 
Vishal_1980
Regular Advisor

Require inputs

Hello Experts,

 

I had a script which was writen by Bill Hassell sir.

 

I have to test this on 2 of my servers .The host names are : eccdbciqv ,eccidbcibv.

 

I need to monitor the /,/usr/tmp,/var & /stand file system

 

Request you to please guide me in this regard.

 

attach is the script ....

 

Thanks & regards,
Vishal

6 REPLIES 6
Bill Hassell
Honored Contributor

Re: Require inputs

diskspace was an old script that would look at mountpoints and then send notices when occupied space is too high. In order to keep email storms from occurring, it would not send additional alerts uness the space grew another % value. However, if the space never changed, no more alerts would be sent.

 

So I abandoned that script and wrote a new one that monitors several system resources at the same time, and send one notice per hour per event. (the hour is configurable). That way, a missed email will be repeated every hour until the problem is resolved while the script runs every few minutes.

 

The script is called adminalert.sh and selectively monors the following items:

 

- CPU load

- Disk space

- NFS problems

- ping testing

- Check if processes are running

- User login disable checks

 

When you run it, it will automatically create a sample config file with all of the checks turned off but with sample values. Edit the /etc/adminalert.config file to set the limits and tests you want to make. Edit the email address for the notifications and then add adminlert.sh to cron, running about once several times each hour.

 

Here's the usage:

 

 # adminalert -?

   Usage: adminalert [-c] [-t]
   where -c = Just show the config file without comments
         -t = send test message to EMAIL from the config file

Requires /etc/adminalert.config to run.
The config file will have the name of the functions
  to invoke plus any variables for the functions.

This means that the conditions to check can be enabled
  or disabled in realtime by editing the config file.

To start, just run adminalert -c to see the default
  settings and to create the initial config file.
  Then edit the config file based on the comments.

and here's what one of my systems has in the config file.

Notice that you can read the file with just the command adminalert -c:

 

# adminalert -c

/etc/adminalert.config contents:

    EMAILFREQ=60
    EMAIL=bhassell@sourcedirect.com
    EMAILFROM=billh@bilhassell.com
    LogFile=true
    LoadAlert=0
       LOADLIMIT=2.
    DiskFull=1
      MOUNTS=/:95,/opt:85,/tmp:95,/var:95
    NFSalert=1
      NFSWAITSECS=3
      NFSMOUNTS=/mnt2
    PingTest=1
      PINGHOSTS=ftp:8:3:20:true,atl3:5,atl6:8:3:20,atl10:8:3:20,atl5par
    ProcMon=1
      PROCS=swapper,nfsd:16,httpd:1:4
    UserLockCheck=1
      LOCKED=root,blh,sduser

The config file is consulted every time the script runs, so just edit the file to change monitoring.



Bill Hassell, sysadmin
Vishal_1980
Regular Advisor

Re: Require inputs

Dear Sir,

Thanks a lot for the inputs provided by you.
However i am going through the script & unable to understand where to edit it. I have to monitor my 2 production servers namely :eccdvcib & eccidvcibd.

Request you to please suggest....

Thanks & regards,
Vishal
Bill Hassell
Honored Contributor

Re: Require inputs

There is nothing to change in the script. Just run it one time. It will create the configuration file.

 

You then edit the configuration file: /etc/adminalert.config

 

 

 

You did not give any details about monitoring these filesystems so I will have to guess what you need.

 

In the new config file, change these lines:

 

EMAIL=somebody1@mycompany.com
EMAILFROM=somebody2@mycompany.com

 

EMAIL shoud be an email address to send notices when there is a problem. To specify multiple addresses, add additional addresses using commas:

 

EMAIL=somebody1@mycompany.com,somebody2@mycompany.com

 

EMAILFROM should be your email address, or any valid email address.

 

Then to monitor the filesystems you listed:

 

DiskFull=1    
  MOUNTS="/:90,/opt:85,/tmp:90,/var:90,/stand:90"

And that's it. Now test the program by running it like this:

 

adminalert -t

 

It will send you a message that has the config file as the message.

 

You can then copy the script and the working config file to the other system and add it to cron.



Bill Hassell, sysadmin
Vishal_1980
Regular Advisor

Re: Require inputs

Thanks a lot Bill sir...& how many time i have to say that ....you are just fabolus ......Sir i need to learn scripting ( please suggest some basic book ) & i have 1 wish that when shall i meet you face to face.........

Waiting for your reply ....

Many thanks & regards,
Vishal
Bill Hassell
Honored Contributor

Re: Require inputs

Here are some free tutorials from the net:

 

http://www.ibm.com/developerworks/aix/library/au-kornshellscripting/
http://www.bolthole.com/solaris/ksh.html
http://www.qnx.com/developers/docs/6.4.1/neutrino/user_guide/scripts.htmltraining

 

And a couple of books. The books are references rather than how-to guides. They are similar to dictionaries where you can find specific words but they are not training books.

http://www.amazon.com/Learning-Korn-Shell-Arnold-Robbins/dp/0596001959/
http://www.amazon.com/New-KornShell-Command-Programming-Language/dp/0131827006/

 

The last reference above (New Korn Shell) is by David Korn (yes, he wrote ksh) and is my primary reference guide.

 

NOTE: There will be references to the Bourne shell which is called sh on Unix systems. However, on HP-UX, there are two sh programs, one is found in /usr/bin/sh (symlink = /bin/sh) and the other is located in /usr/old/bin/sh -- which is the old (and not recommended) Bourne shell.The /usr/bin/sh shell is called the POSIX shell by HP and is the one I use. However,

more than 95% of my scripts will run using ksh as they are very similar.

 

HP-UX is the only OS that confuses these two, but you can safely use either ksh or sh in HP-UX. If you are learning multiple OS platforms such as Solaris, AIX or Linux, ksh is the most portable. You will find bash (the born-again shell) on virtually all Linux systems but not on HP-UX unless you add it.

 

The two best ways to learn shell programming is to write simple scripts and embellish them as you learn new techniques and the other is to read scripts written by others.



Bill Hassell, sysadmin
Vishal_1980
Regular Advisor

Re: Require inputs

Good morning sir,

And thanks a lot for the information.I am going through the links provided by you.

With Regards,
Vishal