Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 27 additions & 38 deletions docs/checks/commands/check_eventlog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,14 @@ comment: auto-generated by make docs, do not edit

Checks Windows event log entries.

This check wraps the following WMI query:

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

See the [field descriptions](https://learn.microsoft.com/en-us/previous-versions/windows/desktop/eventlogprov/win32-ntlogevent).

When possible, SNClient adds filter conditions on id, level and source (or provider) to the WMI query's WHERE clause.
SNClient still applies the filter to the returned events.
This check reads all installed event log channels with the Windows Event Log API
(wevtapi.dll). Use channel to read selected channels only.

The check reads events newer than scan-range and applies the filter afterwards.
Channel errors are skipped while all channels are read. If no single channel can
be read, the check returns an error.

The file, log, and source names are legacy aliases for channel and provider.

- [Argument Defaults](#argument-defaults)
- [Attributes](#attributes)
Expand All @@ -48,39 +35,41 @@ SNClient still applies the filter to the returned events.
| 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)) |
| detail-syntax | %(channel) %(provider) (%(message)) |

## Check Specific Arguments

| Argument | Description |
| ---------------- | -------------------------------------------------------------------------------------------------- |
| event-codes | Event codes to query. SNClient combines comma-separated values with OR. Valid range: 0-65535. You can repeat this option. |
| file | File to read. Repeat this option to check multiple files. |
| log | Alias for file |
| channel | Event log channel to read. Repeat this option to check multiple channels. |

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like i said in the comment, the additions of new args/attributes are done in a single comment and can be reverted

| event-codes | Only show events with these event codes. SNClient combines comma-separated values with OR. Valid range: 0-65535. You can repeat this option. |
| file | Legacy alias for channel. |
| log | Legacy alias for channel. |
| scan-range | Time range to search for messages (default is 24h) |
| timezone | Set the timezone for time metrics (default is local time) |
| truncate-message | Maximum length of each event log message |
| unique | Alias for unique-index |
| unique-index | Fields that identify unique events. Set to 0 to disable. Default is "%(log)-%(source)-%(id)" |
| unique-index | Fields that identify unique events. Set to 0 to disable. Default is "%(channel)-%(provider)-%(id)" |

## Attributes

### Filter Keywords

Use these attributes in filters and thresholds, along with the default attributes:

| Attribute | Description |
| --------------- | --------------------------------------------------- |
| computer | Which computer generated the message (ComputerName) |
| file | The logfile name |
| log | Alias for file |
| id | Eventlog ID (EventCode) |
| eventidentifier | Event identifier (EventIdentifier) |
| level | Severity level (lowercase Type) |
| message | The message as a string |
| source | The source system (SourceName) |
| provider | Alias for source |
| written | Time of the message being written (TimeWritten) |
| Attribute | Description |
| --------------- | ----------------------------------------------------- |
| channel | The event log channel name |
| provider | The event provider name |
| file | Legacy alias for channel |
| log | Legacy alias for channel |
| source | Legacy alias for provider |
| computer | Which computer generated the message (Computer) |
| id | Event ID |
| eventidentifier | Event identifier (EventID) |
| level | Severity level (error, warning, information, verbose) |
| message | The message as a string |
| written | Time of the message being written (TimeCreated) |

## Examples

Expand Down
1 change: 0 additions & 1 deletion pkg/eventlog/eventlog.go

This file was deleted.

91 changes: 0 additions & 91 deletions pkg/eventlog/eventlog_windows.go

This file was deleted.

55 changes: 22 additions & 33 deletions pkg/snclient/check_eventlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ func init() {
AvailableChecks["check_eventlog"] = CheckEntry{"check_eventlog", NewCheckEventlog}
}

const DefaultUniqueIndex = "%(log)-%(source)-%(id)"
const DefaultUniqueIndex = "%(channel)-%(provider)-%(id)"

type CheckEventlog struct {
files []string
Expand All @@ -26,62 +26,51 @@ func (l *CheckEventlog) Build() *CheckData {
name: "check_eventlog",
description: `Checks Windows event log entries.

This check wraps the following WMI query:
This check reads all installed event log channels with the Windows Event Log API
(wevtapi.dll). Use channel to read selected channels only.

SELECT
ComputerName,
LogFile,
Category,
EventCode,
EventIdentifier,
EventType,
Message,
SourceName,
Type,
TimeWritten,
TimeGenerated
FROM
Win32_NTLogEvent
The check reads events newer than scan-range and applies the filter afterwards.
Channel errors are skipped while all channels are read. If no single channel can
be read, the check returns an error.

See the [field descriptions](https://learn.microsoft.com/en-us/previous-versions/windows/desktop/eventlogprov/win32-ntlogevent).

When possible, SNClient adds filter conditions on id, level and source (or provider) to the WMI query's WHERE clause.
SNClient still applies the filter to the returned events.`,
The file, log, and source names are legacy aliases for channel and provider.`,
implemented: Windows,
result: &CheckResult{
State: CheckExitOK,
},
hasInventory: NoCallInventory,
args: map[string]CheckArgument{
"file": {value: &l.files, description: "File to read. Repeat this option to check multiple files."},
"log": {value: &l.files, description: "Alias for file"},
"channel": {value: &l.files, description: "Event log channel to read. Repeat this option to check multiple channels."},
"file": {value: &l.files, description: "Legacy alias for channel."},
"log": {value: &l.files, description: "Legacy alias for channel."},
"timezone": {description: "Set the timezone for time metrics (default is local time)"},
"scan-range": {value: &l.scanRange, description: "Time range to search for messages (default is 24h)"},
"truncate-message": {value: &l.truncateMessage, description: "Maximum length of each event log message"},
"unique-index": {value: &l.uniqueIndex, description: "Fields that identify unique events. Set to 0 to disable. Default is \"" + DefaultUniqueIndex + "\""},
"unique": {value: &l.uniqueIndex, description: "Alias for unique-index"},
"event-codes": {value: &l.eventCodesFilters, isFilter: true, description: "Event codes to query. SNClient combines comma-separated values with OR. " +
"event-codes": {value: &l.eventCodesFilters, isFilter: true, description: "Only show events with these event codes. SNClient combines comma-separated values with OR. " +
"Valid range: 0-65535. You can repeat this option."},
},
defaultFilter: "level in ('warning', 'error', 'critical')",
defaultWarning: "level = 'warning' or problem_count > 0",
defaultCritical: "level in ('error', 'critical')",
detailSyntax: "%(file) %(source) (%(message))",
detailSyntax: "%(channel) %(provider) (%(message))",
okSyntax: "%(status) - Event log seems fine",
topSyntax: "%(status) - %(count) message(s) %(problem_list)",
emptySyntax: "%(status) - No entries found",
emptyState: 0,
attributes: []CheckAttribute{
{name: "computer", description: "Which computer generated the message (ComputerName)"},
{name: "file", description: "The logfile name"},
{name: "log", description: "Alias for file"},
{name: "id", description: "Eventlog ID (EventCode)"},
{name: "eventidentifier", description: "Event identifier (EventIdentifier)"},
{name: "level", description: "Severity level (lowercase Type)"},
{name: "channel", description: "The event log channel name"},
{name: "provider", description: "The event provider name"},
{name: "file", description: "Legacy alias for channel"},
{name: "log", description: "Legacy alias for channel"},
{name: "source", description: "Legacy alias for provider"},
{name: "computer", description: "Which computer generated the message (Computer)"},
{name: "id", description: "Event ID"},
{name: "eventidentifier", description: "Event identifier (EventID)"},
{name: "level", description: "Severity level (error, warning, information, verbose)"},
{name: "message", description: "The message as a string"},
{name: "source", description: "The source system (SourceName)"},
{name: "provider", description: "Alias for source"},
{name: "written", description: "Time of the message being written (TimeWritten)", unit: UDate},
{name: "written", description: "Time of the message being written (TimeCreated)", unit: UDate},
},
exampleDefault: `
check_eventlog
Expand Down
Loading
Loading