Class: OkComputer::Clamav::ClamdCheck
- Inherits:
-
OkComputer::Check
- Object
- OkComputer::Check
- OkComputer::Clamav::ClamdCheck
- Defined in:
- lib/ok_computer/clamav/clamd_check.rb
Overview
This class performs a health check on a clamd instance using the PING command.
Instance Attribute Summary collapse
-
#socket_path ⇒ Object
readonly
Returns the value of attribute socket_path.
Instance Method Summary collapse
- #check ⇒ Object
-
#initialize(socket_path: '/var/run/clamav/clamd.ctl') ⇒ ClamdCheck
constructor
‘socket_path`: the Unix socket path clamd is using.
Constructor Details
#initialize(socket_path: '/var/run/clamav/clamd.ctl') ⇒ ClamdCheck
‘socket_path`: the Unix socket path clamd is using.
default: /var/run/clamav/clamd.ctl (Debian/Ubuntu) homebrew on macOS uses /tmp/clamd.socket
13 14 15 |
# File 'lib/ok_computer/clamav/clamd_check.rb', line 13 def initialize(socket_path:'/var/run/clamav/clamd.ctl') @socket_path = socket_path end |
Instance Attribute Details
#socket_path ⇒ Object (readonly)
Returns the value of attribute socket_path.
7 8 9 |
# File 'lib/ok_computer/clamav/clamd_check.rb', line 7 def socket_path @socket_path end |
Instance Method Details
#check ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ok_computer/clamav/clamd_check.rb', line 17 def check socket = UNIXSocket.new(socket_path) socket.write "nPING\n" clamd_status = socket.readline socket.close if clamd_status != "PONG\n" mark_failure "clamd responded to PING with #{clamd_status}" else 'clamd is running and responds to PING' end end |