Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "email: Removed clamav monit tasks"
This reverts commit d4ddb82.
- Loading branch information
Patrick J Cherry
committed
Jul 7, 2017
1 parent
a3d992d
commit 283b60a
Showing
2 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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__ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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__ | ||
|