?
Solved

Reading a flat unix file and emailing when the PCTUSED is greater than 50%

Posted on 2003-03-12
4
Medium Priority
?
322 Views
Last Modified: 2010-04-01
Hello,

I am trying to write a shell script that reads the unix flat file and email me those lines only when PCT_USED is greater than 50% and I got stuck. Can anyone please help me ASAP. Thanks in advance!

The flat file format looks like this:

HOSTNAME
FILESYSTEM ALLOCATED USED FREE PCTUSED MOUNTON

and the following is the script that I started out before I got stuck:

#!/bin/ksh                                                                      
                                                               
cat unix flat file |while read record              
do                                                                              
 num_col=`echo $record|wc -w`                                                  
 if [ $num_col -eq 1 ];                                                        
 then                                                                          
    HOSTNAME=${record}                                                          
echo $HOSTNAME                                                                  
 else                                                                          
    if  [ -n $record ];                                                        
    then                                                                        
      echo $record|read FILESYSTEM ALLOCATED USED FREE PCTUSED MOUNTON    
fi
fi
done      
The script works fine upto here and reads the values but then where I go from here, how do you give the condition: [if $PCTUSED -gt 50] then mailx $hostname, $filesystem,$allocated,$used,$free,$pctused,$mounton

Any help is appreciated!  
0
Comment
Question by:issa7860
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 14

Expert Comment

by:kennethxu
ID: 8125050
this is jsp forum, you should have posted your question on unix forum. in the mean time, you might want to try:

mail xxx@yyy.com <<EOF
subject

$hostname, $filesystem,$allocated,$used,$free,$pctused,$mounton
.
EOF
0
 
LVL 14

Accepted Solution

by:
kennethxu earned 0 total points
ID: 8125058
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 8171109
I'll get your points refunded.
0
 
LVL 5

Expert Comment

by:Netminder
ID: 8171762
Points refunded and grade changed.

Netminder
EE Admin
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Check out the latest tech news, community articles, and expert highlights in August's newsletter.
The top devops trends for 2017 are focused on improved deployment frequency, decreased lead time for change and decreased MTTR.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question