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

NMS-16970: Implement framework for collecting initial system data #7556

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class UsageStatisticsReportDTO {
private Integer m_availableProcessors;
private Long m_freePhysicalMemorySize;
private Long m_totalPhysicalMemorySize;
private Long m_usedPhysicalMemorySize;
private long m_provisiondImportThreadPoolSize;
private long m_provisiondScanThreadPoolSize;
private long m_provisiondRescanThreadPoolSize;
Expand Down Expand Up @@ -92,6 +93,8 @@ public class UsageStatisticsReportDTO {
private int notifications;
private long m_onmsStartupTimeSeconds;

private String m_hostName;

private Map<String, Long> m_applianceCounts = Collections.emptyMap();

private boolean m_inContainer;
Expand Down Expand Up @@ -125,6 +128,15 @@ public String getOsName() {
return m_osName;
}

public String getHostName() { return m_hostName; }

public void setHostName(String hostName) { this.m_hostName = hostName; }

public Long getUsedPhysicalMemorySize() { return m_usedPhysicalMemorySize; }

public void setUsedPhysicalMemorySize(Long usedPhysicalMemorySize) { this.m_usedPhysicalMemorySize = usedPhysicalMemorySize;
}

public void setOsVersion(String osVersion){
m_osVersion = osVersion;
}
Expand Down Expand Up @@ -528,6 +540,7 @@ public void setApplianceCounts(Map<String, Long> applianceCounts) {
m_applianceCounts = applianceCounts;
}


public String toJson() {
return toJson(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
import org.opennms.netmgt.dao.api.ProvisiondConfigurationDao;
import org.opennms.netmgt.dao.api.SnmpInterfaceDao;
import org.opennms.netmgt.model.OnmsMonitoringSystem;
import org.opennms.netmgt.model.OnmsNode;
import org.opennms.netmgt.provision.persist.ForeignSourceRepository;
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource;
import org.slf4j.Logger;
Expand Down Expand Up @@ -255,14 +256,23 @@ public UsageStatisticsReportDTO generateReport() {
"The usage report will be submitted with a null system id.", e);
}
// Operating System

usageStatisticsReport.setOsName(System.getProperty("os.name"));
usageStatisticsReport.setOsArch(System.getProperty("os.arch"));
usageStatisticsReport.setOsVersion(System.getProperty("os.version"));


// OpenNMS version and flavor
usageStatisticsReport.setVersion(sysInfoUtils.getVersion());
usageStatisticsReport.setPackageName(sysInfoUtils.getPackageName());
// Object counts
usageStatisticsReport.setNodes(m_nodeDao.countAll());
//
if(m_nodeDao.countAll()>0) {
OnmsNode node = m_nodeDao.load(1);
usageStatisticsReport.setHostName(node.getLabel());
}

usageStatisticsReport.setIpInterfaces(m_ipInterfaceDao.countAll());
usageStatisticsReport.setSnmpInterfaces(m_snmpInterfaceDao.countAll());
usageStatisticsReport.setSnmpInterfacesWithFlows(m_snmpInterfaceDao.getNumInterfacesWithFlows());
Expand Down Expand Up @@ -328,7 +338,10 @@ private void setSystemJmxAttributes(UsageStatisticsReportDTO usageStatisticsRepo
Object totalPhysicalMemSizeObj = getJmxAttribute(JMX_OBJ_OS, JMX_ATTR_TOTAL_PHYSICAL_MEMORY_SIZE);
if (totalPhysicalMemSizeObj != null) {
usageStatisticsReport.setTotalPhysicalMemorySize((long) totalPhysicalMemSizeObj);

}
long usedPhysicalMemory = (long)totalPhysicalMemSizeObj - (long)freePhysicalMemSizeObj;
usageStatisticsReport.setUsedPhysicalMemorySize(usedPhysicalMemory);
Object availableProcessorsObj = getJmxAttribute(JMX_OBJ_OS, JMX_ATTR_AVAILABLE_PROCESSORS);
if (availableProcessorsObj != null) {
usageStatisticsReport.setAvailableProcessors((int) availableProcessorsObj);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{
"metadata": [
{
"key": "hostName",
"name": "Host name",
"description": "Host Name",
"datatype": "string"
},
{
"key": "alarms",
"name": "Current alarm count",
Expand Down Expand Up @@ -402,6 +408,12 @@
"description": "",
"datatype": "number"
},
{
"key": "usedPhysicalMemorySize",
"name": "Used Physical Memory Size",
"description": "",
"datatype": "number"
},
{
"key": "tssPlugins",
"name": "TSS plugin loaded, if any",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public void canMarshallToJson() {
usageStatisticsReport.setGroups(0);
usageStatisticsReport.setOnmsStartupTimeSeconds(1000L);
usageStatisticsReport.setInContainer(false);
usageStatisticsReport.setUsedPhysicalMemorySize(0L);
usageStatisticsReport.setHostName("localhost");
String actualJson = usageStatisticsReport.toJson();
System.err.println(actualJson);

Expand Down Expand Up @@ -121,8 +123,10 @@ public void canMarshallToJson() {
"\"totalPhysicalMemorySize\":null," +
"\"tssStrategies\":null," +
"\"users\":0," +
"\"version\":\"10.5.7\"" +
"}";
"\"version\":\"10.5.7\"," +
"\"usedPhysicalMemorySize\":0," +
"\"hostName\":\"localhost\"" +
"}";

assertEquals(expectedJson, actualJson);
}
Expand Down
Loading