Skip to content

Commit

Permalink
Revert "email: Removed clamav monit tasks"
Browse files Browse the repository at this point in the history
This reverts commit d4ddb82.
  • Loading branch information
Patrick J Cherry committed Jul 7, 2017
1 parent a3d992d commit 283b60a
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
51 changes: 51 additions & 0 deletions email/symbiosis/monit.d/clamav-daemon
@@ -0,0 +1,51 @@
#!/usr/bin/ruby

require 'symbiosis/monitor/check'

class ClamdCheck < Symbiosis::Monitor::Check

def initialize
super
@process.pidfile = "/var/run/clamav/clamd.pid"
@process.initscript = "/etc/init.d/clamav-daemon"
@name = "clamd"
end

def do_check
#
# Check the initscript. If it is missing, make sure that the process is
# actually suppose to be running, before raising an error.
#
unless initscript_ok?
if should_be_running
return SystemExit::EX_CONFIG
else
puts "Daemon state probably OK -- initscript is missing and #{@name} supposed to be running."
return 0
end
end

r = do_process_check
if SystemExit::EX_TEMPFAIL == r
should_be_running ? self.start : self.stop
end
return r
end

def should_be_running
(0 < Dir.glob('/srv/*/config/antivirus').length)
end

#
# Ignore the test if
# * dpkg if running
# * the initscript is missing and clamav should not be running.
#
def should_ignore?
self.class.dpkg_running? or
(not File.exist?(@process.initscript) and not should_be_running)
end
end

exit ClamdCheck.new.do_check if $0 == __FILE__

41 changes: 41 additions & 0 deletions email/symbiosis/monit.d/clamav-freshclam
@@ -0,0 +1,41 @@
#!/usr/bin/ruby

require 'symbiosis/monitor/check'

class FreshclamCheck < Symbiosis::Monitor::Check

def initialize
super
@process.pidfile = "/var/run/clamav/freshclam.pid"
@process.initscript = "/etc/init.d/clamav-freshclam"
@name = "freshclam"
end

def do_check
#
# Check the initscript. If it is missing, make sure that the process is
# actually suppose to be running, before raising an error.
#
unless initscript_ok?
if should_be_running
return SystemExit::EX_CONFIG
else
puts "Daemon state probably OK -- initscript is missing and #{@name} supposed to be running."
return 0
end
end

r = do_process_check
if SystemExit::EX_TEMPFAIL == r
should_be_running ? self.start : self.stop
end
return r
end

def should_be_running
(0 < Dir.glob('/srv/*/config/antivirus').length)
end
end

exit FreshclamCheck.new.do_check if $0 == __FILE__

0 comments on commit 283b60a

Please sign in to comment.