UNIX Process Monitoring

g-Solutions

UNIX Process Monitoring

 

Implementation

 

A generic script (monitoring.sh) has been developed to monitor UNIX process running longer than a given number of days.

 

Figure 1 monitoring.sh Usage

monitor

 Usage ./monitoring.sh [processName] [maxDays] [emails]

Input Arguments

Name

Position

Notes

processName

1

The process name that the script will monitor. The scripts uses the grep command based on the output of the UNIX command `ps –ef` to determine process to monitor.

maxDays

2

The maximum number of days the process is allowed to run before an alert is generated.

 

Note maxDays is compared with the process start execution time using an AWK script named "monitoring.awk".

emails

3

Comma separated list of emails addresses were alerts will be sent.

 

The emails are sent using the sendmail UNIX command.

 

 

Below is the sample output of the following command;

 

 

The following is the report of the long running UNIX processes.

UID

PID

Start Time

Max Duration (Days)

Command

 

 

 

 

 

testuser

928

Jul 12

2

oracleTP (LOCAL=NO)

testuser

934

Jul 12

2

oracleTP (LOCAL=NO)

testuser

907

Jul 12

2

oracleTP (LOCAL=NO)

testuser

924

Jul 12

2

oracleTP (LOCAL=NO)

 

 Schedule Installation

The monitoring script can be scheduled to execute using UNIX's CRON.

 

Prerequisite

* All files must copied to the ~/monitoring directory of the install user

[Installations files]

monitoring.awk

monitoring.sh

monitoring_daily_9.crontab

 

(Note add email address to monitoring_daily_9.crontab)

 

Installations step

1.       cd ~/monitoring

2.       crontab monitoring_daily_9.crontab

 

Verification

crontab -l

0 9 * * *  ~/monitoring/monitoring.sh oracleTP 2 "emails"

 

Runs at 9 AM every morning.

 

Download UNIX scripts