2021-05-07 10:39:55 +00:00
|
|
|
import org.sysmon.plugins.sysmon_aix.AixProcessorExtension
|
|
|
|
import org.sysmon.plugins.sysmon_aix.AixProcessorStat
|
|
|
|
import spock.lang.Specification
|
|
|
|
|
|
|
|
class AixProcessorTest extends Specification {
|
|
|
|
|
2021-05-11 13:37:23 +00:00
|
|
|
void "test AIX lparstat output processing"() {
|
2021-05-07 10:39:55 +00:00
|
|
|
|
|
|
|
setup:
|
2021-05-11 13:37:23 +00:00
|
|
|
def testFile = new File(getClass().getResource('/lparstat-aix.txt').toURI())
|
2021-05-07 10:39:55 +00:00
|
|
|
List<String> lines = testFile.readLines("UTF-8")
|
|
|
|
|
|
|
|
when:
|
|
|
|
AixProcessorExtension extension = new AixProcessorExtension()
|
2021-05-10 14:56:56 +00:00
|
|
|
AixProcessorStat stats = extension.processCommandOutput(lines)
|
2021-05-07 10:39:55 +00:00
|
|
|
|
|
|
|
then:
|
2021-05-10 14:56:56 +00:00
|
|
|
stats.getUser() == 83.7f
|
|
|
|
stats.getSys() == 3.3f
|
|
|
|
stats.getWait() == 0.0f
|
|
|
|
stats.getIdle() == 13.0f
|
|
|
|
stats.getFields().get("ent") == 0.50f
|
2021-05-07 10:39:55 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-05-10 14:56:56 +00:00
|
|
|
|
2021-05-11 13:37:23 +00:00
|
|
|
void "test Linux lparstat output processing"() {
|
|
|
|
|
|
|
|
setup:
|
|
|
|
def testFile = new File(getClass().getResource('/lparstat-linux.txt').toURI())
|
|
|
|
List<String> lines = testFile.readLines("UTF-8")
|
|
|
|
|
|
|
|
when:
|
|
|
|
AixProcessorExtension extension = new AixProcessorExtension()
|
|
|
|
AixProcessorStat stats = extension.processCommandOutput(lines)
|
|
|
|
|
|
|
|
then:
|
|
|
|
stats.getUser() == 0.03f
|
|
|
|
stats.getSys() == 0.0f
|
|
|
|
stats.getWait() == 0.0f
|
|
|
|
stats.getIdle() == 99.97f
|
|
|
|
stats.getFields().get("ent") == 4.00f
|
|
|
|
stats.getTags().get("mode") == "Uncapped"
|
|
|
|
stats.getTags().get("type") == "Shared"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-05-07 10:39:55 +00:00
|
|
|
}
|