CPU History data gets deleted when you change Core Count?!? Who thought that was a good idea?
Summary: Kel L discussed an issue with the default NetSNMPCPUwithCores module, which deletes historical CPU data whenever the core count on a Linux server changes. This design flaw prevents users from analyzing performance changes due to core adjustments. Kel L suggested two solutions: modifying the script to avoid data point name changes or rewriting the module to update core count during every check. The latter solution involves a Groovy module provided by Kel L that retrieves core data in real-time, allowing for accurate performance tracking.
When the default NetSNMPCPUwithCores module that is used to get CPU Overview from Linux servers, it was created in such a way as to wipe out all your historical data any time you change the Cores on a server. This is horrible since then you can't compare to see if adding or removing cores mad a big different in overall server performance or not. I don't know why it was designed this way, but for anyone else who noticed this, but hasn't fix it yet, here are two quick fixes.
1) If you want to stay with the default module, and just fix it, find this section at the very end of the Groovy script:
Once again, I can't paste images, so you'll have to go here: https://i.imgur.com/rw55lDt.jpeg
To fix the problem, just change that last line of text and remove + coreCount at the end. Having the + coreCount will cause the name of the data point item to change when the cores change which makes it act as a new entry and the old entry disappears.
I would actually change it to something like: println coreCount + "##CPU Overview";
If it's not in there, I would also add a complex Datapoint like this so you can store the core count and graph it.
https://i.imgur.com/zCpnMfB.jpeg
However, this has a problem because the Core Count is only updated in the Discovery script. This means that if you don't run an Active Discovery after changing the cores, you will show the wrong count for up to 24 hours
2) Instead of that, I rewrote the whole module into a Groovy module that pulls the core count on every check. I'm not sure how to share that, or if LM will incorporate it into the main module, but here is the basic info.
Collection - Embedded Groovy Script:
import com.santaba.agent.groovyapi.expect.Expect;
import com.santaba.agent.groovyapi.snmp.Snmp;
def host = hostProps.get("system.hostname") ?: hostProps.get("system.ip")
def clean = { val ->
if (val == null) return ""
def s = val.toString().trim()
s = s.replaceAll(/^"+|"+$/, "")
return s
}
def snmpGet = { oid ->
clean(Snmp.get(host, oid))
}
def snmpWalk = { oid ->
Snmp.walk(host, oid)
}
// Existing OIDs
def cpuRawIdle = snmpGet(".1.3.6.1.4.1.2021.11.53.0")
def cpuRawNice = snmpGet(".1.3.6.1.4.1.2021.11.51.0")
def cpuRawSystem = snmpGet(".1.3.6.1.4.1.2021.11.52.0")
def cpuRawUser = snmpGet(".1.3.6.1.4.1.2021.11.50.0")
def cpuRawWait = snmpGet(".1.3.6.1.4.1.2021.11.54.0")
def loadAverage1min = snmpGet(".1.3.6.1.4.1.2021.10.1.3.1")
def loadAverage5min = snmpGet(".1.3.6.1.4.1.2021.10.1.3.2")
def loadAverage15min= snmpGet(".1.3.6.1.4.1.2021.10.1.3.3")
// Count logical CPUs by walking hrProcessorLoad
def walkOutput = snmpWalk(".1.3.6.1.2.1.25.3.3.1.2")
int coreCount = 0
walkOutput?.eachLine { line ->
if (line?.contains(" = ")) {
coreCount++
}
}
// Emit metrics as key=value pairs
println "CpuRawIdle=${cpuRawIdle}"
println "CpuRawNice=${cpuRawNice}"
println "CpuRawSystem=${cpuRawSystem}"
println "CpuRawUser=${cpuRawUser}"
println "CpuRawWait=${cpuRawWait}"
println "LoadAverage1min=${loadAverage1min}"
println "LoadAverage5min=${loadAverage5min}"
println "LoadAverage15min=${loadAverage15min}"
println "CoreCount=${coreCount}"
return 0Datapoints to match: https://i.imgur.com/spsLitb.jpeg
Thanks,