Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
settingsd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
settingsd
Commits
d1d97e64
Commit
d1d97e64
authored
Nov 15, 2010
by
Devaev Maxim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add simple SMART support checking
parent
7b6ec750
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
11 deletions
+20
-11
fmod_disks_smart.py
plugins/functions/fmod_disks_smart.py
+20
-11
No files found.
plugins/functions/fmod_disks_smart.py
View file @
d1d97e64
...
...
@@ -26,17 +26,17 @@ SMART_METHODS_NAMESPACE = "disks.smart"
##### Private classes #####
class
Disk
(
service
.
FunctionObject
)
:
def
__init__
(
self
,
device_path
,
object_path
,
service_object
=
None
)
:
def
__init__
(
self
,
device_
file_
path
,
object_path
,
service_object
=
None
)
:
service
.
FunctionObject
.
__init__
(
self
,
object_path
,
service_object
)
self
.
__device_
path
=
devic
e_path
self
.
__device_
file_path
=
device_fil
e_path
### DBus methods ###
@service.functionMethod
(
SMART_METHODS_NAMESPACE
,
out_signature
=
"a(isiiiissss)"
)
def
attributes
(
self
)
:
proc_args
=
"
%
s -A
%
s"
%
(
config
.
value
(
SERVICE_NAME
,
"smartctl_prog_path"
),
self
.
__device_path
)
proc_args
=
"
%
s -A
%
s"
%
(
config
.
value
(
SERVICE_NAME
,
"smartctl_prog_path"
),
self
.
__device_
file_
path
)
(
proc_stdout
,
proc_stderr
,
proc_returncode
)
=
tools
.
execProcess
(
proc_args
)
if
proc_returncode
!=
0
:
...
...
@@ -68,7 +68,7 @@ class Disk(service.FunctionObject) :
@service.functionMethod
(
SMART_METHODS_NAMESPACE
,
out_signature
=
"b"
)
def
health
(
self
)
:
proc_args
=
"
%
s -H
%
s"
%
(
config
.
value
(
SERVICE_NAME
,
"smartctl_prog_path"
),
self
.
__device_path
)
proc_args
=
"
%
s -H
%
s"
%
(
config
.
value
(
SERVICE_NAME
,
"smartctl_prog_path"
),
self
.
__device_
file_
path
)
(
proc_stdout
,
proc_stderr
,
proc_returncode
)
=
tools
.
execProcess
(
proc_args
)
if
proc_returncode
!=
0
:
...
...
@@ -119,8 +119,9 @@ class Service(service.Service) :
devices_count
=
0
for
device
in
self
.
__udev_client
.
query_by_subsystem
(
"block"
)
:
device_name
=
device
.
get_name
()
if
disks_filter_regexp
.
match
(
device_name
)
:
disks_smart_shared
.
addSharedObject
(
device_name
,
Disk
(
device
.
get_device_file
(),
device_file_path
=
device
.
get_device_file
()
if
disks_filter_regexp
.
match
(
device_name
)
and
self
.
smartAvailable
(
device_file_path
)
:
disks_smart_shared
.
addSharedObject
(
device_name
,
Disk
(
device_file_path
,
dbus_tools
.
joinPath
(
DISKS_SMART_SHARED_NAME
,
device_name
),
self
))
devices_count
+=
1
logger
.
verbose
(
"{mod}: Added
%
d devices"
%
(
devices_count
))
...
...
@@ -148,23 +149,31 @@ class Service(service.Service) :
### Private ###
def
smartAvailable
(
self
,
device_file_path
)
:
# FIXME: Add normal checking for SMART support
proc_args
=
"
%
s
%
s"
%
(
config
.
value
(
SERVICE_NAME
,
"smartctl_prog_path"
),
device_file_path
)
(
proc_stdout
,
proc_stderr
,
proc_returncode
)
=
tools
.
execProcess
(
proc_args
)
return
not
bool
(
proc_returncode
)
###
def
udevEvent
(
self
,
udev_client
,
action
,
device
)
:
disks_smart_shared
=
shared
.
Functions
.
shared
(
DISKS_SMART_SHARED_NAME
)
registered_devices_list
=
disks_smart_shared
.
sharedObjects
()
.
keys
()
if
re
.
match
(
config
.
value
(
SERVICE_NAME
,
"disks_filter"
),
device
.
get_name
())
:
device_name
=
device
.
get_name
()
device_path
=
device
.
get_device_file
()
device_
file_
path
=
device
.
get_device_file
()
if
action
==
"add"
and
not
device
in
registered_devices_list
:
disks_smart_shared
.
addSharedObject
(
device_name
,
Disk
(
device_path
,
if
action
==
"add"
and
not
device
in
registered_devices_list
and
self
.
smartAvailable
(
device_file_path
)
:
disks_smart_shared
.
addSharedObject
(
device_name
,
Disk
(
device_
file_
path
,
dbus_tools
.
joinPath
(
DISKS_SMART_SHARED_NAME
,
device_name
),
self
))
self
.
__disks_smart
.
devicesChanged
()
logger
.
debug
(
"{mod}: Added SMART disk
\"
%
s
\"
"
%
(
device_path
))
logger
.
debug
(
"{mod}: Added SMART disk
\"
%
s
\"
"
%
(
device_
file_
path
))
elif
device
.
get_action
()
==
"remove"
and
device_name
in
registered_devices_list
:
disks_smart_shared
.
sharedObject
(
device_name
)
.
removeFromConnection
()
disks_smart_shared
.
removeSharedObject
(
device_name
)
self
.
__disks_smart
.
devicesChanged
()
logger
.
debug
(
"{mod}: Removed SMART disk
\"
%
s
\"
"
%
(
device_path
))
logger
.
debug
(
"{mod}: Removed SMART disk
\"
%
s
\"
"
%
(
device_
file_
path
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment