Operating System - HP-UX
1753767 Members
5501 Online
108799 Solutions
New Discussion юеВ

New to UNIX, need help with script

 
SOLVED
Go to solution
Jarheadatheart
Regular Advisor

New to UNIX, need help with script

Guru's, I am new to UNIX and attempting to learn a bit of scripting. Please see attached. The problem is that I do not know how to properly modify this script. It is to check filesystem usage, and e-mail when over 95% usage. However, the cron job has it running every 20 minutes, and it writes a new "emailfile" to /tmp everytime. How do I get it to run and ONLY create the file if something IS over 95% or possibly create the file everytime, but remove it afterwards??? Any help is appreciated.....
19 REPLIES 19
Stephan._1
Trusted Contributor

Re: New to UNIX, need help with script

Hi,
this will require more than a small change in the script. The whole concept in the script is at the moment to create the email file and check after it.


Line 33-35:
# Create the "emailfile"
echo "SEE THE FOLLOWING FILE: /tmp/"`date "+bdf%m%d%y%H"` > $emailfile
echo "" >> $emailfile

After a quick check there should be a file for every hour - or is it for every run?
Share what you know, learn what you don't.
James R. Ferguson
Acclaimed Contributor

Re: New to UNIX, need help with script

Hi:

First, please post your attachment as a TEXT file and not a Microsoft Word document.

...JRF...
Jarheadatheart
Regular Advisor

Re: New to UNIX, need help with script

SVO, it is every run..... not just every hour

My apologies, here it is again in Text.
James R. Ferguson
Acclaimed Contributor

Re: New to UNIX, need help with script

Hi:

The script will need some work. You might be better served by using and studying one that meets your objectives. Bill Hassell has one as an attachment in this thread :

http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1100009

Regards!

...JRF...
Jarheadatheart
Regular Advisor

Re: New to UNIX, need help with script

Thanks James, that is incredibly helpful.... Gonna take be a bit to get through it all, but juding by the description, this will work wonderfully.
Jarheadatheart
Regular Advisor

Re: New to UNIX, need help with script

James,
I have been trying this all day. I get error: /usr/local/bin/diskspace.sh[391]: /home: Syntax error

IF I DON'T clear out all temp files used located on /var/tmp/diskspace

If I do clear them out, I don't get the syntax error but either way I DON'T get the e-mail notification.

Thoughts?
Jarheadatheart
Regular Advisor

Re: New to UNIX, need help with script

Upon further review, it is supposed to error out IF that filesystem has already been marked.

However, the sendmail syntax still won't send the mail...... and the debug doesn't show anything.
Jarheadatheart
Regular Advisor

Re: New to UNIX, need help with script

attached is the debug
James R. Ferguson
Acclaimed Contributor
Solution

Re: New to UNIX, need help with script

Hi (again):

If you don't have any HFS filesystems then delete the 'hfs' token from the '/etc/diskspace.conf' file that you should have created (see the internal instructions).

Then run the script like:

# ./diskspace.sh -e"jarheadatheart@us.org"

This gives me alerts, BUT upon rerunning, I see the behavior you noted:

...[390]:LASTVALUE + INCR: The specified number is not valid for this command.

The key appears to be to make sure that you have a 'diskspace.conf' file that has mountpoints with maximum and minimums defined, like:

/usr 90 2

...but not:

/usr 90

...despite what the documentation might suggest.

For example, this works only the first time and fails thereafter:

vxfs
25 1
/patches 26

...but this fixes the problem:

vxfs
25 1
/patches 26 1

Regards!

...JRF...