f410f09da0ad1e991e83453a69e8d434aa64f2e4
[certmaster.git] / certmaster / minion / modules / smart.py
1 ##
2 ## Grabs status from SMART to see if your hard drives are ok
3 ## Returns in the format of (return code, [line1, line2, line3,...])
4 ##
5 ## Copyright 2007, Red Hat, Inc
6 ## Michael DeHaan <mdehaan@redhat.com>
7 ##
8 ## This software may be freely redistributed under the terms of the GNU
9 ## general public license.
10 ##
11 ## You should have received a copy of the GNU General Public License
12 ## along with this program; if not, write to the Free Software
13 ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
14 ##
15
16 # other modules
17 import sub_process
18
19 # our modules
20 import func_module
21
22 # =================================
23
24 class SmartModule(func_module.FuncModule):
25
26 version = "0.0.1"
27 api_version = "0.0.1"
28 description = "Grabs status from SMART to see if your hard drives are ok."
29
30 def info(self,flags="-q onecheck"):
31 """
32 Returns a struct of hardware information. By default, this pulls down
33 all of the devices. If you don't care about them, set with_devices to
34 False.
35 """
36
37 flags.replace(";","") # prevent stupidity
38
39 cmd = sub_process.Popen("/usr/sbin/smartd %s" % flags,stdout=sub_process.PIPE,shell=True)
40 data = cmd.communicate()[0]
41
42 results = []
43
44 for x in data.split("\n"):
45 results.append(x)
46
47 return (cmd.returncode, results)