måndag, juni 11, 2007

Monitor harddrives using smartmontools in FreeBSD

"Control and monitor storage systems using the Self-Monitoring, Analysis and Reporting Technology System (SMART) built into most modern ATA and SCSI hard disks. In many cases, these utilities will provide advanced warning of disk degradation and failure."


Pre req:
Update ports with portsnap


#cd /usr/ports/sysutils/smartmontools
#make install clean

#cd /usr/local/etc/
#ls smart*
smartd.conf.sample

#cp smartd.conf.sample smartd.conf

#dmesg grep ata
...
ad0: 76319MB at ata0-master SATA150
ad1: 76319MB at ata0-slave SATA150
...

Check if SMART is enabled before we add config
#rehash
#smartctl -a /dev/ad(01)
..
SMART support is: Available - device has SMART capability.SMART support is: Enabled
..

# vi smartd.conf

Disable scan
#DEVICESCAN

/dev/ad0 -a -I 194 -W 4,30,40 -R 5 -m operator@domain.com
/dev/ad1 -a -I 194 -W 4,30,40-R 5 -m operator@domain.com

# echo 'smartd_enable="YES"' >> /etc/rc.conf

Done!

SSMTP, forward mail to smarthost in FreeBSD

SSMTP works (great) only for outgoing mail.
" Mail is simply forwarded to the configured mailhost.
It does not receive mail, expand aliases or manage a queue. "

Let's say you have some loghost, who should not be able to recieve mail- SSMTP works great.
Sendmail only binds to 127.0.0.1:25 default, but disable it still reduces listening ports- I like that..

Pre req:
Update FreeBSD Ports with portsnap..

Now the Action,

freebsd62# cd /usr/ports/mail/ssmtp
freebsd62# make install clean
freebsd62# cd /usr/local/etc/ssmtp
freebsd62# ls
revaliases.sample ssmtp.conf.samplemonitor
freebsd62# cp revaliases.sample revaliasesmonitor
freebsd62# cp ssmtp.conf.sample ssmtp.confmonitor
freebsd62# ls
revaliases revaliases.sample ssmtp.conf ssmtp.conf.sample
freebsd62#vi /usr/local/etc/ssmtp/ssmtp.conf

mail=mail.domain.com
rewriteDomain=domain.com
hostname=freebsd62.domain.com

# vi /etc/rc.conf
sendmail_enable="NO"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"

Test
mail -s "Testing" your.address@domain.com