Skip to content

Commit

Permalink
Fix smartd not running alert
Browse files Browse the repository at this point in the history
  • Loading branch information
themylogin committed Mar 25, 2019
1 parent a5e0c3b commit 7b80ca6
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/middlewared/middlewared/alert/source/smartd.py
Expand Up @@ -5,26 +5,25 @@

class smartdAlertSource(ThreadedAlertSource):
level = AlertLevel.WARNING
title = "smartd not running"
title = "smartd is not running"

def check_sync(self):
if self.middleware.call_sync("datastore.query", "services.services", [("srv_service", "=", "smartd"),
("srv_enable", "=", True)]):
# sysctl kern.vm_guest will return a hypervisor name, or the string "none"
# if FreeNAS is running on bare iron.
p0 = subprocess.Popen(["/sbin/sysctl", "-n", "kern.vm_guest"], stdin=subprocess.PIPE,
p0 = subprocess.Popen(["/sbin/sysctl", "-n", "kern.vm_guest"], stdin=subprocess.PIPE,
stdout=subprocess.PIPE, encoding="utf8")
status = p0.communicate()[0].strip()
# This really isn"t confused with python None
if status != "none":
# We got something other than "none", maybe "vmware", "xen", "vbox". Regardless, smartd not running
# in these environments isn"t a huge deal. So we"ll skip alerting.
return

if not self.middleware.call_sync("system.is_freenas"):
if self.middleware.call_sync("notifier.failover_status") != "MASTER":
return
p1 = subprocess.Popen(["/usr/sbin/service", "smartd-daemon", "status"], stdin=subprocess.PIPE,
stdout=subprocess.PIPE, encoding="utf8")
status = p1.communicate()[0]
if p1.returncode == 1:
return Alert(status)

if not self.middleware.call_sync("service.started", "smartd"):
return Alert("smartd is not running")

0 comments on commit 7b80ca6

Please sign in to comment.