check_eventlog

Checks the Windows eventlog entries.

Basically, this check wraps this WMI query:

SELECT
    ComputerName,
    LogFile,
    Category,
    EventCode,
    EventIdentifier,
    EventType,
    Message,
    SourceName,
    Type,
    TimeWritten,
    TimeGenerated
FROM
    Win32_NTLogEvent

See here for a description of the provided fields.

Filter conditions on id, level and source (or provider) are added to the WHERE clause of the WMI query when possible, the filter is still applied to the returned events.

Implementation

WindowsLinuxFreeBSDmacOS
✅

Argument Defaults

ArgumentDefault Value
filterlevel in (‘warning’, ’error’, ‘critical’)
warninglevel = ‘warning’ or problem_count > 0
criticallevel in (’error’, ‘critical’)
empty-state0 (OK)
empty-syntax%(status) - No entries found
top-syntax%(status) - %(count) message(s) %(problem_list)
ok-syntax%(status) - Event log seems fine
detail-syntax%(file) %(source) (%(message))

Check Specific Arguments

ArgumentDescription
event-codesEvent codes to query for, comma separated values are combined with OR. Valid range is 0-65535. Can be specified multiple times.
fileFile to read (can be specified multiple times to check multiple files)
logAlias for file
scan-rangeSets time range to scan for message (default is 24h)
timezoneSets the timezone for time metrics (default is local time)
truncate-messageMaximum length of message for each event log message text
uniqueAlias for unique-index
unique-indexCombination of fields that identifies unique events, set to 0 to disable. Default is “%(log)-%(source)-%(id)”

Attributes

Filter Keywords

these can be used in filters and thresholds (along with the default attributes):

AttributeDescription
computerWhich computer generated the message (ComputerName)
fileThe logfile name
logAlias for file
idEventlog id (EventCode)
eventidentifierEvent identifier (EventIdentifier)
levelSeverity level (lowercase Type)
messageThe message as a string
sourceThe source system (SourceName)
providerAlias for source
writtenTime of the message being written (TimeWritten)

Examples

Default Check

check_eventlog
OK - Event log seems fine

Return all events, by default only unique events will be returned:

check_eventlog "detail-syntax=%(id) %(uniqueindex)" "unique-index=0"
WARNING - 4 message(s) warning(10010 Application-Microsoft-Windows-RestartManager-10010, 10016 System-Microsoft-Windows-DistributedCOM-10016, 6155 System-LsaSrv-6155, 6147 System-LsaSrv-6147)

Example using check_snclient and Naemon

Naemon Config

define command{
    command_name         check_snclient
    command_line         $USER1$/check_snclient -k -p 'your-password' -u 'https://$HOSTADDRESS$:8443' $ARG1$ $ARG2$
}

define service {
    host_name            testhost
    service_description  check_eventlog
    use                  generic-service
    check_command        check_snclient!check_eventlog!filter=provider = 'Microsoft-Windows-Security-SPP' and id = 903 and message like 'foo'
}