Skip to content

Commit

Permalink
mssql: expose server version info
Browse files Browse the repository at this point in the history
Signed-off-by: Jan-Otto Kröpke <[email protected]>
  • Loading branch information
jkroepke committed Nov 17, 2024
1 parent 025a437 commit 78f4266
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 55 deletions.
2 changes: 1 addition & 1 deletion docs/collector.mssql.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Port of MSSQL server used for `windows_mssql_info` metric. Default is `1433`.

| Name | Description | Type | Labels |
|--------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|-------------------------------|
| `windows_mssql_info` | Returns infomation about the MSSQL server running on port 1433 | gauge | `version` |
| `windows_mssql_info` | Returns information about the MSSQL server running on port 1433 | gauge | `version` |
| `windows_mssql_collector_duration_seconds` | The time taken for each sub-collector to return | gauge | `collector`, `mssql_instance` |
| `windows_mssql_collector_success` | 1 if sub-collector succeeded, 0 otherwise | gauge | `collector`, `mssql_instance` |
| `windows_mssql_accessmethods_au_batch_cleanups` | The total number of batches that were completed successfully by the background task that cleans up deferred dropped allocation units | counter | `mssql_instance` |
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/prometheus-community/windows_exporter
go 1.23

require (
github.com/Microsoft/go-winio v0.6.2
github.com/Microsoft/hcsshim v0.12.9
github.com/alecthomas/kingpin/v2 v2.4.0
github.com/bmatcuk/doublestar/v4 v4.7.1
Expand All @@ -19,7 +20,6 @@ require (
)

require (
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
Expand Down
2 changes: 1 addition & 1 deletion internal/collector/mssql/mssql.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ func (c *Collector) getMSSQLServerVersion(port uint16) (string, string, error) {
return "", "", fmt.Errorf("failed to open the process with PID %d: %w", pid, err)
}

defer windows.CloseHandle(hProcess)
defer windows.CloseHandle(hProcess) //nolint:errcheck

processFilePath, err := process.QueryFullProcessImageName(hProcess, process.ImageNameFormatWin32Path)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions internal/headers/iphlpapi/iphlpapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ func TestGetOwnerPIDOfTCPPort(t *testing.T) {
t.Parallel()

lister, err := net.Listen("tcp", "127.0.0.1:0")
require.NoError(t, err)

t.Cleanup(func() {
require.NoError(t, lister.Close())
})
Expand Down
5 changes: 5 additions & 0 deletions internal/headers/iphlpapi/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (

// MIB_TCPROW_OWNER_PID structure for IPv4.
// https://learn.microsoft.com/en-us/windows/win32/api/tcpmib/ns-tcpmib-mib_tcprow_owner_pid
//
//nolint:unused
type MIB_TCPROW_OWNER_PID struct {
dwState MIB_TCP_STATE
dwLocalAddr BigEndianUint32
Expand All @@ -20,6 +22,8 @@ type MIB_TCPROW_OWNER_PID struct {

// MIB_TCP6ROW_OWNER_PID structure for IPv6.
// https://learn.microsoft.com/en-us/windows/win32/api/tcpmib/ns-tcpmib-mib_tcp6row_owner_pid
//
//nolint:unused
type MIB_TCP6ROW_OWNER_PID struct {
ucLocalAddr [16]byte
dwLocalScopeId uint32
Expand Down Expand Up @@ -85,5 +89,6 @@ type BigEndianUint32 uint32
func (b BigEndianUint32) uint16() uint16 {
data := make([]byte, 2)
binary.BigEndian.PutUint16(data, uint16(b))

return binary.LittleEndian.Uint16(data)
}
52 changes: 0 additions & 52 deletions test/main.go

This file was deleted.

0 comments on commit 78f4266

Please sign in to comment.