riemann.xymon

Forwards events to Xymon

event->disable

(event->disable {:keys [host service ttl description], :or {host "", service "*", description ""}})

Converts an event to a Xymon disable message:

disable HOSTNAME.TESTNAME DURATION

Fields mapping is the same as event->status’. Also, the event ttl is used as duration, same as LIFETIME in event->status.

event->enable

(event->enable {:keys [host service], :or {host "", service "*"}})

Converts an event to an Xymon enable message:

enable HOSTNAME.TESTNAME

if no service is provided, the complete host is enabled.

event->status

(event->status {:keys [ttl host service state description], :or {host "", service "", description "", state "unknown"}})

Formats an event as a Xymon status message:

status[+LIFETIME][/group:GROUP] HOSTNAME.TESTNAME COLOR

Note about fields mapping: - HOSTNAME results from the string conversion (“.” -> “,”) of :host - TESTNAME results from the string conversion (#“(.| )” -> "_“) of :service - COLOR is taken as is from :state - is taken ”as is" from :description - GROUP is not handled - LIFETIME results from the rounding up to the nearest whole number of the division by 60 of :ttl. - No :ttl (i.e. :ttl nil) ends up with no LIFETIME set (defaults to Xymon server’s default lifetime) - :ttl 0 becomes +0 LIFETIME and will end up as immediate purple

events->combo

(events->combo formatter events)(events->combo formatter events messages len)

Returns a lazy sequence of combo messages. Each message is at most message-max-length long.

host->xymon

(host->xymon host)

Formats an hostname for Xymon. Basically, replaces all dot chars by commas.

message-max-length

send-message

(send-message opts message)

Sends given message to Xymon host(s).

If (:hosts opts) is a sequence and (:host opts) is false, sends the message to all hosts described in (:hosts opts). When provided (:host opts) should be a list of map and send-single-message will invoked with (merge opts <item in :hosts>).

If (:host opts) is not false, sends the message to opts.

send-message-error

(send-message-error opts exception)

Logs given exception as an error message.

send-message-error is the default error handler invoked by send-single-message if none is provided.

send-single-message

(send-single-message opts message)

Connects to a Xymon server, sends message, then closes the connection. This is a blocking operation and should happen on a dedicated thread.

If any exception is raised during the connect/send process, the result of (:error-handler opts send-message-error) is invoked as a function with opts and the exception as its parameter.

service->xymon

(service->xymon service)

Formats a service name to be understood by Xymon.

xymon

(xymon opts)

Returns a function which accepts an event or a vector of events and which sends them to Xymon, as ‘combo’ messages if specified. Filters events with nil :state or :service. Use:

(xymon {:host “127.0.0.1” :port 1984 :timeout 5000 :formatter event->status})

The :timeout value is expressed in milliseconds, as specified in java.net.Socket documentation.