Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #20: Create Windows.yaml #21

Merged
merged 5 commits into from
Feb 5, 2024
Merged
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
264 changes: 264 additions & 0 deletions src/main/connector/system/Windows/Windows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,264 @@
extends:
- ../System/System
metrics:
system.service.state:
description: Service Status
type:
stateSet:
- Running
- Stopped
- Paused
- Start Pending
- Stop Pending
- Pause Pending
- Continue Pending
- Unknown
connector:
displayName: WindowsOS
platform: Any platform with Windows
reliesOn: WMI
information: Gives OS specific information and metrics
detection:
connectionTypes:
alexdgilbert marked this conversation as resolved.
Show resolved Hide resolved
- remote
- local
appliesTo:
- nt
criteria:
- type: wmi
namespace: root\CIMv2
query: SELECT * FROM Win32_OperatingSystem
monitors:
cpu:
simple:
sources:
processorInformation:
# cpuId;user;system;idle;
type: wmi
namespace: root\CIMv2
query: SELECT Name,PercentUserTime,PercentPrivilegedTime,PercentIdleTime FROM Win32_PerfRawData_Counters_ProcessorInformation
computes:
- type: excludeMatchingLines
column: 1
regExp: _Total
- type: extract
column: 1
subSeparators: ","
subColumn: 2
# Convert 100ns to s
- type: divide
column: 2
value: 100000000
- type: divide
column: 3
value: 100000000
- type: divide
column: 4
value: 100000000
mapping:
source: ${source::processorInformation}
attributes:
id: $1
name: cpu $1
system.cpu.logical_number: $1
metrics:
system.cpu.utilization{system.cpu.state="user"}: rate($2)
system.cpu.utilization{system.cpu.state="system"}: rate($3)
system.cpu.utilization{system.cpu.state="idle"}: rate($4)
system.cpu.time{system.cpu.state="user"}: $2
system.cpu.time{system.cpu.state="system"}: $3
system.cpu.time{system.cpu.state="idle"}: $4
memory:
simple:
sources:
# Free;Free;Cached;Cached
memoryInformation:
type: wmi
namespace: root\CIMv2
query: SELECT FreeAndZeroPageListBytes,FreeAndZeroPageListBytes,CacheBytes,CacheBytes FROM Win32_PerfRawData_PerfOS_Memory
calculatedMemoryInformation:
# Free;Free%;Cached;Cached%;Used;Used%;Total
type: wmi
namespace: root\CIMv2
query: SELECT TotalVisibleMemorySize FROM Win32_OperatingSystem
computes:
# Combining both sources for calculations
- type: leftConcat
Copy link
Member

Choose a reason for hiding this comment

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

That's a terrible way of joining 2 tables 😅

The problem with this hack is that the leftConcat operation is not specified with a table as the value to concatenate:

  • Do we concatenate the entire table into each line of the source?
  • Do we concatenate line-by-line?

If we could find a better way to "merge" source(1) and source(2), that would be preferrable and clearer.

column: 1
value: ${source::memoryInformation}
# Converting total to bytes and making a copy for used memory
- type: multiply
column: 5
value: 1024
- type: duplicateColumn
column: 5
# Finding used memory and making a copy for utilization
- type: subtract
column: 5
value: $1
- type: duplicateColumn
column: 5
# Calculate utilization by dividing usage by total memory
- type: divide
column: 2
value: $7
- type: divide
column: 4
value: $7
- type: divide
column: 6
value: $7
mapping:
source: ${source::calculatedMemoryInformation}
attributes:
id: memory_usage
system.memory.limit: $7
metrics:
system.memory.usage{system.memory.usage="free"}: $1
Copy link
Member

Choose a reason for hiding this comment

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

Do your calculations match with what you see in Task Manager?

system.memory.usage{system.memory.usage="used"}: $5
system.memory.usage{system.memory.usage="cached"}: $3
system.memory.utilization{system.memory.usage="free"}: $2
system.memory.utilization{system.memory.usage="used"}: $6
system.memory.utilization{system.memory.usage="cached"}: $4
file_system:
simple:
sources:
# DeviceID;FreeSpace;UsedSpace;VolumeName
fileSystemInformation:
type: wmi
namespace: root\CIMv2
query: SELECT DeviceID,FreeSpace,Size,VolumeName FROM Win32_LogicalDisk
computes:
- type: subtract
column: 3
value: $2
mapping:
source: ${source::fileSystemInformation}
attributes:
id: $1
system.filesystem.device: $1
system.filesystem.volumeName: $4
metrics:
system.filesystem.usage{system.filesystem.state=free}: $2
system.filesystem.usage{system.filesystem.state=used}: $3
service:
simple:
sources:
# Name;ProcessId;StartMode;State
serviceInformation:
type: wmi
namespace: root\CIMv2
query: SELECT Name,ProcessId,State FROM Win32_Service WHERE StartMode != 'Disabled'
mapping:
source: ${source::serviceInformation}
attributes:
id: $1
processId: $2
metrics:
system.service.state: $3
paging:
simple:
sources:
# BytesUsed;BytesFree;UtilizationUsed;UtilizationFree;TotalBytes
pagingUsageInformation:
type: wmi
namespace: root\CIMv2
query: SELECT PercentUsage,PercentUsage_Base,PercentUsage,PercentUsage_Base FROM Win32_PerfRawData_PerfOS_PagingFile WHERE Name = '_Total'
computes:
alexdgilbert marked this conversation as resolved.
Show resolved Hide resolved
- type: subtract
column: 2
value: $1
- type: divide
column: 3
value: $4
- type: rightConcat
column: 3
value: ;1
- type: subtract
column: 4
value: $3
# BytesUsed;BytesFree;UtilizationUsed;UtilizationFree;TotalBytes;PageOutputPersec;PageInputPersec;PageFaultsPersec;WriteCopiesPersec
pagingCombinedInformation:
type: wmi
namespace: root\CIMv2
query: SELECT PageWritesPersec,PageReadsPersec,PageFaultsPersec,WriteCopiesPersec FROM Win32_PerfRawData_PerfOS_Memory
computes:
- type: subtract
column: 3
value: $4
- type: leftConcat
column: 1
value: ${source::pagingUsageInformation}
mapping:
source: ${source::pagingCombinedInformation}
attributes:
id: paging
metrics:
system.paging.usage{system.paging.state="used"}: $1
system.paging.usage{system.paging.state="free"}: $2
system.paging.utilization{system.paging.state="used"}: $3
system.paging.utilization{system.paging.state="free"}: $4
system.paging.operations{system.paging.direction="out"}: $6
system.paging.operations{system.paging.direction="in"}: $7
system.paging.faults{system.paging.type="soft"}: $8
system.paging.faults{system.paging.type="hard"}: $9
network:
simple:
sources:
# Name;PacketsOutboundDiscarded;PacketsReceivedDiscarded;PacketsSentPersec;PacketsReceivedPersec;PacketsOutboundErrors;PacketsReceivedErrors
networkInformation:
type: wmi
namespace: root\CIMv2
query: >
SELECT Name,
PacketsOutboundDiscarded,
PacketsReceivedDiscarded,
PacketsSentPersec,
PacketsReceivedPersec,
PacketsOutboundErrors,
PacketsReceivedErrors,
BytesSentPerSec,
BytesReceivedPerSec
FROM Win32_PerfRawData_Tcpip_NetworkInterface
mapping:
source: ${source::networkInformation}
attributes:
id: $1
metrics:
system.network.dropped{network.io.direction="transmit"}: $2
alexdgilbert marked this conversation as resolved.
Show resolved Hide resolved
system.network.dropped{network.io.direction="receive"}: $3
system.network.packets{network.io.direction="transmit"}: $4
system.network.packets{network.io.direction="receive"}: $5
system.network.errors{network.io.direction="transmit"}: $6
system.network.errors{network.io.direction="receive"}: $7
system.network.io{network.io.direction="transmit"}: $8
system.network.io{network.io.direction="receive"}: $9
physical_disk:
simple:
sources:
# Name;DiskReadBytesPersec;DiskWriteBytesPersec;DiskReadsPersec;DiskWritesPersec;PercentDiskTime;PercentDiskReadTime;PercentDiskWriteTime
physicalDiskInformation:
type: wmi
namespace: root\CIMv2
query: >
SELECT Name,
DiskReadBytesPersec,
DiskWriteBytesPersec,
DiskReadsPersec,
DiskWritesPersec,
PercentDiskTime,
PercentDiskReadTime,
PercentDiskWriteTime
FROM Win32_PerfRawData_PerfDisk_PhysicalDisk WHERE NAME != '_Total'
mapping:
source: ${source::physicalDiskInformation}
attributes:
id: $1
metrics:
system.disk.io{disk.io.direction="read"}: $2
system.disk.io{disk.io.direction="write"}: $3
system.disk.operations{disk.io.direction="read"}: $4
system.disk.operations{disk.io.direction="write"}: $5
system.disk.io_time: $6
system.disk.operation_time{disk.io.direction="read"}: $7
system.disk.operation_time{disk.io.direction="write"}: $8