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

Move to uint64 for procnet, deal with MaxConn #75

Merged

Conversation

fearful-symmetry
Copy link
Contributor

So, in order to deal with the fact that TCP.MaxConn can be a -1, we originally stored ProcNet values in map[string]int64.

However, after talking with @urso and looking it over, chances are there's some uint64 sized values floating around in here. Looking at the kernel source, it appears that MaxConn is the only signed value in here, and it's stored in a unsigned long before being cast to an int in order to print.

I'm not entirely happy with this, but we're in a situation where we have one oddball value that we want to handle differently. This PR just requires the user that there's a value they need to print as an int or hex value in order to make it usable.

There's a few other solutions here:

Make a struct like this:

type SNMP struct {
	IP      map[string]uint64 `json:"ip" netstat:"Ip"`
	ICMP    map[string]uint64 `json:"icmp" netstat:"Icmp"`
	ICMPMsg map[string]uint64 `json:"icmp_msg" netstat:"IcmpMsg"`
	TCP     map[string]uint64 `json:"tcp" netstat:"Tcp"`
	UDP     map[string]uint64 `json:"udp" netstat:"Udp"`
	UDPLite map[string]uint64 `json:"udp_lite" netstat:"UdpLite"`
        TCPMaxConn int32 `json:"max_conn"`
}

Or like this:

type SNMP struct {
	IP      map[string]uint64 `json:"ip" netstat:"Ip"`
	ICMP    map[string]uint64 `json:"icmp" netstat:"Icmp"`
	ICMPMsg map[string]uint64 `json:"icmp_msg" netstat:"IcmpMsg"`
	TCP     SNMPTCP `json:"tcp" netstat:"Tcp"`
	UDP     map[string]uint64 `json:"udp" netstat:"Udp"`
	UDPLite map[string]uint64 `json:"udp_lite" netstat:"UdpLite"`
}

type SNMPTCP{
    MaxConn int32 
    Values map[string]uint64

}

Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

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

LGTM, but needs a CHANGELOG entry.

@fearful-symmetry fearful-symmetry merged commit 07a209a into elastic:master Jan 11, 2020
@urso
Copy link

urso commented Jan 13, 2020

I see it's also merged. Maybe worth to mention that this change fixes the parser returning error of the complete namespace if some octet counter has reached values > 2^63

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants