-
Notifications
You must be signed in to change notification settings - Fork 13
/
clamav-daemon
executable file
·51 lines (42 loc) · 1.17 KB
/
clamav-daemon
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/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__