Solaris: email to user

Hi,

I would like to run cron job daily at 8:00 P.M in order to check the filesysem sizes , if if finds any filesystem space reaches to 90% it should me an email address to my outlook ( xxxxxx@abcd.com ) .

need your suggestion or direction how to achieve this.

Regards

Assuming you have are monitoring the /var filesystem on a Solaris system then you could use:

$ df -k /var
Filesystem            kbytes    used   avail capacity  Mounted on
/dev/dsk/c0t0d0s3     138703    65426  59407    53%    /var
$ 

So to extract the value you could use:

$ df -k /var | grep /var$ | awk '{ print $5 }'

Which will extract the percentage full (the fifth item in the list) avoiding picking up the fifth item in the header line.

So in a script you would so:

PERCENTFULL=`df -k /var | grep /var$ | awk '{ print $5 }'`

You can then test for a value greater than 90% you can do:

if [ ${PERCENTFULL} -gt 90 ]; then
  send_an_email
fi

Sending an email depends on what you have on your system, on Solaris I would use mailx thus:

mailx -s "Subject heading" person@domain.com < inputfile

Where you have put what you want to send in the message in inputfile.

You would then call the resulting script from cron at 8pm every night:

0 20 * * * /usr/local/bin/yourscript.sh

HTH

Hi,
Thanks for your update,
could you help me to comeout of this mailx problem , I dont why it couldnot able to send message to one of my Microsoft Outlook email .

Regards

Use the -v flag:

mailx -v -s test youraddress@domain.com
hello world
.

It will come out with a bunch of messages. If all goes well, check /var/log/mail.log

The part of the log that shows what mail server it is talking to would be helpful.

The MS Exchange server has to have SMTP enabled - you'll need to ask and Exchange expert about how to do that.

For Solaris 8 and below to make your Solaris machine use a particular machine as its mail server you can put an entry into its /etc/hosts file giving the IP address, name and then an alias of mailhost, this can be done in DNS using a MX (mail exchanger) record..

Hi ,

I found this error messages when i use below switch with mailx

$mailx -v -s  test maooah@mail.com
hello world
.
EOT
DRIAD@root $mrai.com: Name server timeout
maooah@mail.com... Transient parse error -- message queued for future delivery
maooah@mail.com... queued

Regards

Looks like DNS is broken, presumably at the mrai.com end, but it is worth checking DNS is working at your end.

Hi Tony,

how can is verify DNS is working fine ?

Regards

---------- Post updated at 01:15 AM ---------- Previous update was at 12:53 AM ----------

Hi Tony,

How can I verify DNS is working fine ?

Regards

Do you have entries in /etc/resolv.conf(4) and is dns listed in the hosts line in /etc/nsswitch.conf(4)?

Can you look up any DNS address, e.g.:

$ nslookup news.bbc.co.uk
$ nslookup <ip address from above>

and then if sendmail is using DNS to find the mail exchanger then:

$ nslookup
> servertype=MX

and then

> mailhost

and then to exit from nslookup:

> exit

On my system the above looks like:

$ nslookup news.bbc.co.uk
Server:        10.0.0.2
Address:    10.0.0.2#53

Non-authoritative answer:
news.bbc.co.uk    canonical name = newswww.bbc.net.uk.
Name:    newswww.bbc.net.uk
Address: 212.58.226.73

$ nslookup 212.58.226.73
Server:        10.0.0.2
Address:    10.0.0.2#53

Non-authoritative answer:
73.226.58.212.in-addr.arpa    name = newslb305.telhc.bbc.co.uk.

Authoritative answers can be found from:

$ nslookup
> servertype=MX
Server:        10.0.0.2
Address:    10.0.0.2#53

Non-authoritative answer:
Name:    servertype=MX.FullerDomain
Address: 67.215.65.132
> mailhost
Server:        10.0.0.2
Address:    10.0.0.2#53

Non-authoritative answer:
Name:    mailhost.FullerDomain
Address: 67.215.65.132
> exit
$

Hi Tony,

the ouput of nslookup command and contents of resolv.conf and nsswitch.conf files.

root $nslookup SAM.MRAI.COM 
*** Can't find server name for address 127.0.0.1: No response from server
*** Default servers are not available


root $cat resolv.conf
domain          mrai.com
#nameserver     182.40.3.16
root $cat nsswitch.conf#
# /etc/nsswitch.files:
#
# An example file that could be copied over to /etc/nsswitch.conf; it
# does not use any naming service.
#
# "hosts:" and "services:" in this file are used only if the
# /etc/netconfig file has a "-" for nametoaddr_libs of "inet" transports.

passwd:     files
group:      files
hosts:      files dns
ipnodes:    files
networks:   files
protocols:  files
rpc:        files
ethers:     files
netmasks:   files
bootparams: files
publickey:  files
# At present there isn't a 'files' backend for netgroup;  the system will
#   figure it out pretty quickly, and won't use netgroups at all.
netgroup:   files
automount:  files
aliases:    files
services:   files
sendmailvars:   files
printers:       user files

auth_attr:  files
prof_attr:  files
project:    files

thanks for your cooperation.

Regards

Looks like your /etc/inet/hosts file needs a localhost entry put back into it or else the linking of /etc/hosts and /etc/inet/hosts has been lost.

Put:

127.0.0.1 localhost

into /etc/inet/hosts if not already present and ensure that /etc/hosts is a link to /etc/hosts (hard or symbolic).

Then try nslookup again.

Update:
Should have looked a bit more closely, the resolv.conf file does not list an active nameserver, the only one listed is commented out, I suggest you either try uncommenting out the one already listed in your resolv.conf and/or find out what the IP address of the DNS server on your network is and out it into your resolv.conf. This is why nslookup is trying to use localhost as the DNS server.

Dear Tony,

This is just give some overview of our setup we have two solaris fujitsu servers running with solaris 9 version and both are in active - active mode with veritas clustering, and on this servers we have Database on single server and on second server Application Tier.
1) I verified the link between /etc/hosts and /etc/inet/hosts it is there.
root $ls -ltr hosts
lrwxrwxrwx 1 root root 12 Oct 17 2005 hosts -> ./inet/hosts

2)I checked the below entry in /etc/hosts file its not there , if I made entry in this file do we face any impact due to this modification .

127.0.0.1 localhost

It would help for your nameserver setting not to be commented out by that leading "#" ...

Dear Tony and patrick

any update .

Regards

Did you read/understood my previous answer ?

We are both trying to tell you the same thing:

Hi Tony and Jlliagre,

Jlliagre: i panic for removing this parameter becuase this server is in veritas clustering with another server in Active Active mode, this settings may cause any problem to our EBiz Suite 11i, but from Oracle Application workflow we are receiving emails to our MS Exchange users with out any issue.
Appreciate your time and efforts for resolving this issue
sorry for the late response