- fix #271741 - smartd-conf.py should allow customization of parameters
- fix #253753 - service starting by default, perhaps shouldn't - update initscript (related #247058 - initscript review)
This commit is contained in:
parent
7d9c446d5c
commit
b021c51f2e
@ -7,9 +7,9 @@ import dbus
|
|||||||
|
|
||||||
class Drive:
|
class Drive:
|
||||||
def __init__(self, bus, device, sysfspath):
|
def __init__(self, bus, device, sysfspath):
|
||||||
self.bus = bus
|
self.bus = bus
|
||||||
self.device = device
|
self.device = device
|
||||||
self.sysfspath = sysfspath
|
self.sysfspath = sysfspath
|
||||||
|
|
||||||
def listDrivesbyHAL():
|
def listDrivesbyHAL():
|
||||||
drives = []
|
drives = []
|
||||||
@ -19,15 +19,15 @@ def listDrivesbyHAL():
|
|||||||
|
|
||||||
storage_udi_list = halm.FindDeviceByCapability('storage')
|
storage_udi_list = halm.FindDeviceByCapability('storage')
|
||||||
for udi in storage_udi_list:
|
for udi in storage_udi_list:
|
||||||
drive_obj = bus.get_object('org.freedesktop.Hal', udi)
|
drive_obj = bus.get_object('org.freedesktop.Hal', udi)
|
||||||
drive = dbus.Interface(drive_obj, 'org.freedesktop.Hal.Device')
|
drive = dbus.Interface(drive_obj, 'org.freedesktop.Hal.Device')
|
||||||
storage_bus = drive.GetProperty('storage.bus')
|
storage_bus = drive.GetProperty('storage.bus')
|
||||||
drive_type = drive.GetProperty('storage.drive_type')
|
drive_type = drive.GetProperty('storage.drive_type')
|
||||||
if (storage_bus == 'ide' or storage_bus == 'scsi') and drive_type == 'disk':
|
if (storage_bus == 'ide' or storage_bus == 'scsi') and drive_type == 'disk':
|
||||||
device_file = drive.GetProperty('block.device')
|
device_file = drive.GetProperty('block.device')
|
||||||
sysfs_path = drive.GetProperty('linux.sysfs_path')
|
sysfs_path = drive.GetProperty('linux.sysfs_path')
|
||||||
drv = Drive(storage_bus, device_file, sysfs_path)
|
drv = Drive(storage_bus, device_file, sysfs_path)
|
||||||
drives += [drv]
|
drives += [drv]
|
||||||
return drives
|
return drives
|
||||||
|
|
||||||
drives = listDrivesbyHAL()
|
drives = listDrivesbyHAL()
|
||||||
@ -66,27 +66,35 @@ print """# *SMARTD*AUTOGENERATED* /etc/smartd.conf
|
|||||||
|
|
||||||
def getfile(fname):
|
def getfile(fname):
|
||||||
try:
|
try:
|
||||||
fh = open(fname)
|
fh = open(fname)
|
||||||
line = fh.read().rstrip()
|
line = fh.read().rstrip()
|
||||||
fh.close()
|
fh.close()
|
||||||
except IOError:
|
except IOError:
|
||||||
line = ''
|
line = ''
|
||||||
return line
|
return line
|
||||||
|
|
||||||
|
try:
|
||||||
|
execfile('/etc/sysconfig/smartmontools')
|
||||||
|
except IOError:
|
||||||
|
pass
|
||||||
|
|
||||||
for drive in drives:
|
for drive in drives:
|
||||||
if getfile("%s/removable" % drive.sysfspath) == '0':
|
if getfile("%s/removable" % drive.sysfspath) == '0':
|
||||||
driver = ''
|
driver = ''
|
||||||
comment = ''
|
comment = ''
|
||||||
if getfile("%s/device/vendor" % drive.sysfspath) == 'ATA':
|
if getfile("%s/device/vendor" % drive.sysfspath) == 'ATA':
|
||||||
driver = '-d ata '
|
driver = '-d ata'
|
||||||
if float(getfile("/sys/module/libata/version")) < 1.20:
|
if float(getfile("/sys/module/libata/version")) < 1.20:
|
||||||
comment = "# not yet supported in this kernel version\n# "
|
comment = "# not yet supported in this kernel version\n# "
|
||||||
if not comment:
|
if not comment:
|
||||||
status = os.system("/usr/sbin/smartctl -s on -i %s%s 2>&1 >/dev/null" %
|
status = os.system("/usr/sbin/smartctl -s on -i %s%s 2>&1 >/dev/null" %
|
||||||
(driver, drive.device))
|
(driver, drive.device))
|
||||||
if not os.WIFEXITED(status) or os.WEXITSTATUS(status) != 0:
|
if not os.WIFEXITED(status) or os.WEXITSTATUS(status) != 0:
|
||||||
comment = "# smartctl -i returns error for this drive\n# "
|
comment = "# smartctl -i returns error for this drive\n# "
|
||||||
print "%s%s %s-H -m root" % (comment, drive.device, driver)
|
try:
|
||||||
|
print "%s%s %s %s" % (comment, drive.device, driver, smartd_conf_opts)
|
||||||
|
except NameError:
|
||||||
|
print "%s%s %s -H -m root" % (comment, drive.device, driver)
|
||||||
|
|
||||||
print """
|
print """
|
||||||
# First two SCSI disks. This will monitor everything that smartd can
|
# First two SCSI disks. This will monitor everything that smartd can
|
||||||
|
145
smartd.initd
145
smartd.initd
@ -2,13 +2,23 @@
|
|||||||
|
|
||||||
# smartmontools init file for smartd
|
# smartmontools init file for smartd
|
||||||
# Copyright (C) 2002-4 Bruce Allen <smartmontools-support@lists.sourceforge.net>
|
# Copyright (C) 2002-4 Bruce Allen <smartmontools-support@lists.sourceforge.net>
|
||||||
# $Id: smartd.initd,v 1.5 2007/06/21 13:26:38 tsmetana Exp $
|
# $Id: smartd.initd,v 1.6 2007/09/04 11:59:22 tsmetana Exp $
|
||||||
|
|
||||||
# For RedHat and cousins:
|
# For RedHat and cousins:
|
||||||
# chkconfig: 2345 99 01
|
# chkconfig: - 99 01
|
||||||
# description: Self Monitoring and Reporting Technology (SMART) Daemon
|
# description: Self Monitoring and Reporting Technology (SMART) Daemon
|
||||||
# processname: smartd
|
# processname: smartd
|
||||||
|
|
||||||
|
### BEGIN INIT INFO
|
||||||
|
# Provides: smartd
|
||||||
|
# Required-Start: $local_fs $network
|
||||||
|
# Required-Stop: $local_fs $network
|
||||||
|
# Should-Start:
|
||||||
|
# Short-Description: Self Monitoring and Reporting Technology (SMART) Daemon
|
||||||
|
# Description: The smartd daemon monitors SMART status of the local hard drives and
|
||||||
|
# provides advanced warnings of of disk degradation or failures.
|
||||||
|
### END INIT INFO
|
||||||
|
|
||||||
# This program is free software; you can redistribute it and/or modify it
|
# This program is free software; you can redistribute it and/or modify it
|
||||||
# under the terms of the GNU General Public License as published by the Free
|
# under the terms of the GNU General Public License as published by the Free
|
||||||
# Software Foundation; either version 2, or (at your option) any later
|
# Software Foundation; either version 2, or (at your option) any later
|
||||||
@ -33,59 +43,98 @@ SMARTD_BIN=/usr/sbin/smartd
|
|||||||
|
|
||||||
[ -r /etc/sysconfig/smartmontools ] && . /etc/sysconfig/smartmontools
|
[ -r /etc/sysconfig/smartmontools ] && . /etc/sysconfig/smartmontools
|
||||||
|
|
||||||
|
RETVAL=0
|
||||||
|
prog=smartd
|
||||||
|
pidfile=/var/lock/subsys/smartd
|
||||||
|
|
||||||
|
genconfig()
|
||||||
|
{
|
||||||
|
if [ -x /usr/sbin/smartd-conf.py ]; then
|
||||||
|
GEN_CONF="*SMARTD*AUTOGENERATED*"
|
||||||
|
[ ! -f /etc/smartd.conf ] || read DUMMY GEN_CONF DUMMY </etc/smartd.conf \
|
||||||
|
&& [ "$GEN_CONF" == "*SMARTD*AUTOGENERATED*" ] \
|
||||||
|
&& smartd-conf.py 2>/dev/null >/etc/smartd.conf.new-autogenerated \
|
||||||
|
&& mv -f /etc/smartd.conf.new-autogenerated /etc/smartd.conf
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
start()
|
||||||
|
{
|
||||||
|
echo -n $"Starting $prog: "
|
||||||
|
daemon $SMARTD_BIN $smartd_opts
|
||||||
|
RETVAL=$?
|
||||||
|
echo
|
||||||
|
[ $RETVAL = 0 ] && touch $pidfile
|
||||||
|
return $RETVAL
|
||||||
|
}
|
||||||
|
|
||||||
|
stop()
|
||||||
|
{
|
||||||
|
echo -n $"Shutting down $prog: "
|
||||||
|
killproc $SMARTD_BIN
|
||||||
|
RETVAL=$?
|
||||||
|
echo
|
||||||
|
rm -f $pidfile
|
||||||
|
return $RETVAL
|
||||||
|
}
|
||||||
|
|
||||||
|
reload()
|
||||||
|
{
|
||||||
|
echo -n $"Reloading $prog daemon configuration: "
|
||||||
|
killproc $SMARTD_BIN -HUP
|
||||||
|
RETVAL=$?
|
||||||
|
echo
|
||||||
|
return $RETVAL
|
||||||
|
}
|
||||||
|
|
||||||
|
report()
|
||||||
|
{
|
||||||
|
echo -n $"Checking SMART devices now: "
|
||||||
|
killproc $SMARTD_BIN -USR1
|
||||||
|
RETVAL=$?
|
||||||
|
echo
|
||||||
|
return $RETVAL
|
||||||
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start | reload | restart)
|
|
||||||
if [ -x /usr/sbin/smartd-conf.py ]; then
|
|
||||||
GEN_CONF="*SMARTD*AUTOGENERATED*"
|
|
||||||
[ ! -f /etc/smartd.conf ] || read DUMMY GEN_CONF DUMMY </etc/smartd.conf \
|
|
||||||
&& [ "$GEN_CONF" == "*SMARTD*AUTOGENERATED*" ] \
|
|
||||||
&& smartd-conf.py 2>/dev/null >/etc/smartd.conf.new-autogenerated \
|
|
||||||
&& mv -f /etc/smartd.conf.new-autogenerated /etc/smartd.conf
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
RETVAL=0
|
|
||||||
|
|
||||||
prog=smartd
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
start)
|
start)
|
||||||
echo -n $"Starting $prog: "
|
genconfig
|
||||||
daemon $SMARTD_BIN $smartd_opts
|
start
|
||||||
touch /var/lock/subsys/smartd
|
;;
|
||||||
echo
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
stop)
|
stop)
|
||||||
echo -n $"Shutting down $prog: "
|
stop
|
||||||
killproc $SMARTD_BIN
|
;;
|
||||||
rm -f /var/lock/subsys/smartd
|
|
||||||
echo
|
|
||||||
;;
|
|
||||||
reload)
|
reload)
|
||||||
echo -n $"Reloading $prog daemon configuration: "
|
genconfig
|
||||||
killproc $SMARTD_BIN -HUP
|
reload
|
||||||
RETVAL=$?
|
;;
|
||||||
echo
|
|
||||||
;;
|
|
||||||
report)
|
report)
|
||||||
echo -n $"Checking SMART devices now: "
|
report
|
||||||
killproc $SMARTD_BIN -USR1
|
;;
|
||||||
RETVAL=$?
|
|
||||||
echo
|
|
||||||
;;
|
|
||||||
restart)
|
restart)
|
||||||
$0 stop
|
stop
|
||||||
$0 start
|
genconfig
|
||||||
;;
|
start
|
||||||
|
;;
|
||||||
|
try-restart)
|
||||||
|
if [ -f $pidfile ]; then
|
||||||
|
stop
|
||||||
|
genconfig
|
||||||
|
start
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
force-reload)
|
||||||
|
genconfig
|
||||||
|
reload || (stop; start)
|
||||||
|
;;
|
||||||
status)
|
status)
|
||||||
status $prog
|
status $prog
|
||||||
;;
|
RETVAL=$?
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo $"Usage: $0 {start|stop|reload|report|restart|status}"
|
echo $"Usage: $0 {start|stop|reload|force-reload|report|restart|try-restart|status}"
|
||||||
RETVAL=1
|
RETVAL=3
|
||||||
esac
|
esac
|
||||||
|
|
||||||
exit $RETVAL
|
exit $RETVAL
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
Summary: Tools for monitoring SMART capable hard disks
|
Summary: Tools for monitoring SMART capable hard disks
|
||||||
Name: smartmontools
|
Name: smartmontools
|
||||||
Version: 5.37
|
Version: 5.37
|
||||||
Release: 5%{?dist}
|
Release: 6%{?dist}
|
||||||
Epoch: 1
|
Epoch: 1
|
||||||
Group: System Environment/Base
|
Group: System Environment/Base
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
@ -91,6 +91,11 @@ exit 0
|
|||||||
%exclude %{_sbindir}/smartd-conf.py[co]
|
%exclude %{_sbindir}/smartd-conf.py[co]
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Sep 04 2007 Tomas Smetana <tsmetana@redhat.com> - 1:5.37-6
|
||||||
|
- fix #271741 - smartd-conf.py should allow customization of parameters
|
||||||
|
- fix #253753 - service starting by default, perhaps shouldn't
|
||||||
|
- update initscript (related #247058 - initscript review)
|
||||||
|
|
||||||
* Mon Aug 20 2007 Tomas Smetana <tsmetana@redhat.com> - 1:5.37-5
|
* Mon Aug 20 2007 Tomas Smetana <tsmetana@redhat.com> - 1:5.37-5
|
||||||
- add support for 24 disks on 3ware RAID controllers (related #252055)
|
- add support for 24 disks on 3ware RAID controllers (related #252055)
|
||||||
- fix #245442 - add %%{arm} to smartmontools's set of build archs
|
- fix #245442 - add %%{arm} to smartmontools's set of build archs
|
||||||
|
@ -1,2 +1,4 @@
|
|||||||
# command line options for smartd
|
# command line options for smartd
|
||||||
smartd_opts="-q never"
|
smartd_opts="-q never"
|
||||||
|
# autogenerated config file options
|
||||||
|
# smartd_conf_opts="-H -m root"
|
||||||
|
Loading…
Reference in New Issue
Block a user