From 305aabdbe5ed1e5df8687bda50c59c6a9678b2a7 Mon Sep 17 00:00:00 2001 From: k-joseph Date: Wed, 14 Sep 2016 10:16:48 +0300 Subject: [PATCH] RWSPU-45: Fixing some 64bitgit add . failing architectures --- .../DHISGenerateDataValueSetSchemas.java | 27 ++-- .../WindowsResourceFileNotFoundHack.java | 2 +- .../indicators/OSAndHardwareIndicators.java | 134 ++++++++++-------- .../resources/dhis-dataelementsMetadata.json | 4 +- .../api/SystemMonitorServiceTest.java | 2 +- .../systemmonitor/api/TestOSHILibrary.java | 3 +- .../web/dwr/DWRSystemMonitorService.java | 6 +- 7 files changed, 97 insertions(+), 81 deletions(-) diff --git a/api/src/main/java/org/openmrs/module/systemmonitor/export/DHISGenerateDataValueSetSchemas.java b/api/src/main/java/org/openmrs/module/systemmonitor/export/DHISGenerateDataValueSetSchemas.java index d83a71f..a2e20fe 100644 --- a/api/src/main/java/org/openmrs/module/systemmonitor/export/DHISGenerateDataValueSetSchemas.java +++ b/api/src/main/java/org/openmrs/module/systemmonitor/export/DHISGenerateDataValueSetSchemas.java @@ -34,9 +34,10 @@ public static JSONObject generateRwandaSPHEMTDHISDataValueSets() { JSONArray jsonToBePushed; JSONArray jsonDataValueSets = new JSONArray(); SystemMonitorService systemMonitorService = Context.getService(SystemMonitorService.class); + OSAndHardwareIndicators osshi = new OSAndHardwareIndicators(); - String systemId = OSAndHardwareIndicators.getHostName() + "-" + (OSAndHardwareIndicators.getMacAddress() != null - ? OSAndHardwareIndicators.getMacAddress().replace(":", "") : ""); + String systemId = osshi.getHostName() + "-" + (osshi.getMacAddress() != null + ? osshi.getMacAddress().replace(":", "") : ""); String dhisOrgUnitUid = DHISMapping .getDHISMappedObjectValue(systemMonitorService.getCurrentConfiguredDHISOrgUnit().getPropertyValue()); @@ -48,23 +49,23 @@ public static JSONObject generateRwandaSPHEMTDHISDataValueSets() { String openmrsAPPName = WebConstants.WEBAPP_NAME; - Integer uptime = OSAndHardwareIndicators.PROCESSOR_SYSTEM_UPTIME.intValue(); + Integer uptime = osshi.PROCESSOR_SYSTEM_UPTIME.intValue(); - String processor = OSAndHardwareIndicators.getLinuxProcessorName(); + String processor = osshi.getLinuxProcessorName(); Integer openmrsUptime = systemMonitorService.getOpenMRSSystemUpTime().intValue(); - Long freeMemory = OSAndHardwareIndicators.MEMORY_AVAILABLE; + Long freeMemory = osshi.MEMORY_AVAILABLE; - Long usedMemory = OSAndHardwareIndicators.MEMORY_USED; + Long usedMemory = osshi.MEMORY_USED; - Long totalMemory = OSAndHardwareIndicators.MEMORY_TOTAL; + Long totalMemory = osshi.MEMORY_TOTAL; - String operatingSystem = SystemPropertiesIndicators.OS_NAME + ", Family: " + OSAndHardwareIndicators.OS_FAMILY - + ", Manufacturer: " + OSAndHardwareIndicators.OS_MANUFACTURER + ", Version Name: " - + OSAndHardwareIndicators.OS_VERSION_NAME + ", Version Number: " - + OSAndHardwareIndicators.OS_VERSION_NUMBER + ", Build Number: " - + OSAndHardwareIndicators.OS_VERSION_BUILDNUMBER; + String operatingSystem = SystemPropertiesIndicators.OS_NAME + ", Family: " + osshi.OS_FAMILY + + ", Manufacturer: " + osshi.OS_MANUFACTURER + ", Version Name: " + + osshi.OS_VERSION_NAME + ", Version Number: " + + osshi.OS_VERSION_NUMBER + ", Build Number: " + + osshi.OS_VERSION_BUILDNUMBER; String operatingSystemArch = SystemPropertiesIndicators.OS_ARCH; @@ -101,7 +102,7 @@ public static JSONObject generateRwandaSPHEMTDHISDataValueSets() { JSONObject serverRealLocation = null; try { serverRealLocation = CurlEmulator - .get(SystemMonitorConstants.IP_INFO_URL + OSAndHardwareIndicators.getIpAddress(), null, null); + .get(SystemMonitorConstants.IP_INFO_URL + osshi.getIpAddress(), null, null); } catch (UnknownHostException e) { e.printStackTrace(); } catch (SocketException e) { diff --git a/api/src/main/java/org/openmrs/module/systemmonitor/hacks/WindowsResourceFileNotFoundHack.java b/api/src/main/java/org/openmrs/module/systemmonitor/hacks/WindowsResourceFileNotFoundHack.java index e637ddb..b29fa26 100644 --- a/api/src/main/java/org/openmrs/module/systemmonitor/hacks/WindowsResourceFileNotFoundHack.java +++ b/api/src/main/java/org/openmrs/module/systemmonitor/hacks/WindowsResourceFileNotFoundHack.java @@ -113,7 +113,7 @@ public class WindowsResourceFileNotFoundHack { * This must be updated every time * src/main/resources/dhis-dataelementsMetadata.json is updated */ - public static String dataElementsMetadata = "{ \"pager\": { \"page\": 1, \"pageCount\": 1, \"total\": 58, \"pageSize\": 100 }, \"dataElements\": [ { \"lastUpdated\": \"2016-07-13T07:05:17.318+0000\", \"created\": \"2016-07-13T06:45:38.841+0000\", \"name\": \"Date for last backup\", \"id\": \"v3Pww13i2r1\", \"href\": \"http://82.196.9.250:8080/api/dataElements/v3Pww13i2r1\" }, { \"lastUpdated\": \"2016-05-16T08:31:01.138+0000\", \"created\": \"2016-05-16T08:31:01.125+0000\", \"name\": \"File System Encoding\", \"id\": \"RlDJSS2SRXL\", \"href\": \"http://82.196.9.250:8080/api/dataElements/RlDJSS2SRXL\" }, { \"lastUpdated\": \"2016-02-22T21:25:12.085+0000\", \"created\": \"2016-02-21T11:27:03.298+0000\", \"name\": \"Free Memory (MB)\", \"id\": \"ZPrLSHvWDm8\", \"href\": \"http://82.196.9.250:8080/api/dataElements/ZPrLSHvWDm8\" }, { \"lastUpdated\": \"2016-05-16T08:48:46.331+0000\", \"created\": \"2016-05-16T08:48:46.325+0000\", \"name\": \"Installed Modules\", \"id\": \"ICTGPRAVZVZ\", \"href\": \"http://82.196.9.250:8080/api/dataElements/ICTGPRAVZVZ\" }, { \"lastUpdated\": \"2016-05-16T08:13:48.734+0000\", \"created\": \"2016-05-16T08:13:48.730+0000\", \"name\": \"Java Runtime Name\", \"id\": \"SrKrLKmigUg\", \"href\": \"http://82.196.9.250:8080/api/dataElements/SrKrLKmigUg\" }, { \"lastUpdated\": \"2016-05-16T08:14:28.986+0000\", \"created\": \"2016-05-16T08:14:28.979+0000\", \"name\": \"Java Runtime Version\", \"id\": \"ixpB1MGxTOt\", \"href\": \"http://82.196.9.250:8080/api/dataElements/ixpB1MGxTOt\" }, { \"lastUpdated\": \"2016-05-16T08:11:15.936+0000\", \"created\": \"2016-05-16T08:11:15.932+0000\", \"name\": \"Java Vendor\", \"id\": \"TuBY7HgyJ7J\", \"href\": \"http://82.196.9.250:8080/api/dataElements/TuBY7HgyJ7J\" }, { \"lastUpdated\": \"2016-05-16T08:09:56.165+0000\", \"created\": \"2016-05-16T08:09:19.753+0000\", \"name\": \"Java Version\", \"id\": \"FmjhhJQyLoy\", \"href\": \"http://82.196.9.250:8080/api/dataElements/FmjhhJQyLoy\" }, { \"lastUpdated\": \"2016-05-16T08:12:31.371+0000\", \"created\": \"2016-05-16T08:12:31.363+0000\", \"name\": \"JVM Vendor\", \"id\": \"yIMQP0rsprI\", \"href\": \"http://82.196.9.250:8080/api/dataElements/yIMQP0rsprI\" }, { \"lastUpdated\": \"2016-05-16T08:11:50.278+0000\", \"created\": \"2016-05-16T08:11:50.273+0000\", \"name\": \"JVM Version\", \"id\": \"RgJN8fbRRuW\", \"href\": \"http://82.196.9.250:8080/api/dataElements/RgJN8fbRRuW\" }, { \"lastUpdated\": \"2016-02-21T11:59:54.669+0000\", \"created\": \"2016-02-21T07:54:24.177+0000\", \"name\": \"Number Of System Starts\", \"id\": \"q8LwlSrBOSj\", \"href\": \"http://82.196.9.250:8080/api/dataElements/q8LwlSrBOSj\" }, { \"lastUpdated\": \"2016-02-22T09:58:12.284+0000\", \"created\": \"2016-02-22T09:58:12.277+0000\", \"name\": \"OpenMRS App Name\", \"id\": \"ec9fC1xmg8R\", \"href\": \"http://82.196.9.250:8080/api/dataElements/ec9fC1xmg8R\" }, { \"lastUpdated\": \"2016-02-22T21:37:52.612+0000\", \"created\": \"2016-02-21T11:53:20.730+0000\", \"name\": \"OpenMRS Uptime (%)\", \"id\": \"OBJQIpvppBt\", \"href\": \"http://82.196.9.250:8080/api/dataElements/OBJQIpvppBt\" }, { \"lastUpdated\": \"2016-07-03T21:40:53.466+0000\", \"created\": \"2016-07-01T04:52:08.802+0000\", \"name\": \"OpenMRS Uptime (minutes)\", \"id\": \"WdPwtuNKhcd\", \"href\": \"http://82.196.9.250:8080/api/dataElements/WdPwtuNKhcd\" }, { \"lastUpdated\": \"2016-05-16T08:34:04.818+0000\", \"created\": \"2016-05-16T08:34:04.808+0000\", \"name\": \"OpenMRS Version\", \"id\": \"Gnpcar514A3\", \"href\": \"http://82.196.9.250:8080/api/dataElements/Gnpcar514A3\" }, { \"lastUpdated\": \"2016-05-16T08:10:10.315+0000\", \"created\": \"2016-05-16T08:06:28.206+0000\", \"name\": \"Operating System\", \"id\": \"CRThksbOPAd\", \"href\": \"http://82.196.9.250:8080/api/dataElements/CRThksbOPAd\" }, { \"lastUpdated\": \"2016-05-16T08:10:20.972+0000\", \"created\": \"2016-05-16T08:07:30.528+0000\", \"name\": \"Operating System Arch\", \"id\": \"EFfJ4CVvac2\", \"href\": \"http://82.196.9.250:8080/api/dataElements/EFfJ4CVvac2\" }, { \"lastUpdated\": \"2016-05-16T08:10:32.087+0000\", \"created\": \"2016-05-16T08:08:37.421+0000\", \"name\": \"Operating System Version\", \"id\": \"l76OuWQxBYa\", \"href\": \"http://82.196.9.250:8080/api/dataElements/l76OuWQxBYa\" }, { \"lastUpdated\": \"2016-07-01T05:09:58.632+0000\", \"created\": \"2016-06-30T19:50:28.943+0000\", \"name\": \"Patient CD4 Count Test Results - All\", \"id\": \"UEfoD5rcZbC\", \"href\": \"http://82.196.9.250:8080/api/dataElements/UEfoD5rcZbC\" }, { \"lastUpdated\": \"2016-07-01T05:10:20.261+0000\", \"created\": \"2016-06-30T19:50:56.520+0000\", \"name\": \"Patient CD4 Count Test Results - Last 6 Months\", \"id\": \"d3XqMIFIoz6\", \"href\": \"http://82.196.9.250:8080/api/dataElements/d3XqMIFIoz6\" }, { \"lastUpdated\": \"2016-07-01T05:10:10.452+0000\", \"created\": \"2016-06-30T19:51:19.308+0000\", \"name\": \"Patient CD4 Count Test Results - Last Year\", \"id\": \"GHq0YsrAsaf\", \"href\": \"http://82.196.9.250:8080/api/dataElements/GHq0YsrAsaf\" }, { \"lastUpdated\": \"2016-07-14T08:00:52.280+0000\", \"created\": \"2016-07-11T09:06:52.731+0000\", \"name\": \"Patient CD4 Count Test Results - Yesterday\", \"id\": \"QoIyYyc7Z36\", \"href\": \"http://82.196.9.250:8080/api/dataElements/QoIyYyc7Z36\" }, { \"lastUpdated\": \"2016-05-01T17:52:05.525+0000\", \"created\": \"2016-05-01T17:52:05.436+0000\", \"name\": \"Patient Viral Load Test Results - All\", \"id\": \"AB7Nj3FNvR6\", \"href\": \"http://82.196.9.250:8080/api/dataElements/AB7Nj3FNvR6\" }, { \"lastUpdated\": \"2016-05-01T17:52:39.755+0000\", \"created\": \"2016-05-01T17:52:39.723+0000\", \"name\": \"Patient Viral Load Test Results - Last 6 Months\", \"id\": \"TIdLXyneWYd\", \"href\": \"http://82.196.9.250:8080/api/dataElements/TIdLXyneWYd\" }, { \"lastUpdated\": \"2016-05-01T17:53:15.989+0000\", \"created\": \"2016-05-01T17:53:15.982+0000\", \"name\": \"Patient Viral Load Test Results - Last Year\", \"id\": \"D30SnV0TGws\", \"href\": \"http://82.196.9.250:8080/api/dataElements/D30SnV0TGws\" }, { \"lastUpdated\": \"2016-07-14T08:01:07.195+0000\", \"created\": \"2016-07-11T09:07:21.967+0000\", \"name\": \"Patient Viral Load Test Results - Yesterday\", \"id\": \"uaUc1zJbaEC\", \"href\": \"http://82.196.9.250:8080/api/dataElements/uaUc1zJbaEC\" }, { \"lastUpdated\": \"2016-02-22T10:00:21.933+0000\", \"created\": \"2016-02-22T10:00:21.919+0000\", \"name\": \"Primary Clinic Days\", \"id\": \"rb9ef1D53Fv\", \"href\": \"http://82.196.9.250:8080/api/dataElements/rb9ef1D53Fv\" }, { \"lastUpdated\": \"2016-02-22T10:01:28.305+0000\", \"created\": \"2016-02-22T10:01:28.294+0000\", \"name\": \"Primary Clinic Hours\", \"id\": \"VDEnb2bEQH3\", \"href\": \"http://82.196.9.250:8080/api/dataElements/VDEnb2bEQH3\" }, { \"lastUpdated\": \"2016-07-03T08:22:16.698+0000\", \"created\": \"2016-07-03T08:22:16.679+0000\", \"name\": \"Processor\", \"id\": \"xr3kif2Vuzu\", \"href\": \"http://82.196.9.250:8080/api/dataElements/xr3kif2Vuzu\" }, { \"lastUpdated\": \"2016-02-22T09:57:43.364+0000\", \"created\": \"2016-02-22T09:57:43.346+0000\", \"name\": \"Server Id\", \"id\": \"yBHJmoeteNR\", \"href\": \"http://82.196.9.250:8080/api/dataElements/yBHJmoeteNR\" }, { \"lastUpdated\": \"2016-06-15T23:39:37.239+0000\", \"created\": \"2016-06-15T23:39:36.920+0000\", \"name\": \"Server's Real Location\", \"id\": \"hKJXqpumYZ6\", \"href\": \"http://82.196.9.250:8080/api/dataElements/hKJXqpumYZ6\" }, { \"lastUpdated\": \"2016-07-03T08:00:23.659+0000\", \"created\": \"2016-07-01T04:51:28.393+0000\", \"name\": \"Server Uptime (minutes)\", \"id\": \"RiyIySUEl1W\", \"href\": \"http://82.196.9.250:8080/api/dataElements/RiyIySUEl1W\" }, { \"lastUpdated\": \"2016-05-16T12:26:00.679+0000\", \"created\": \"2016-05-16T08:24:23.282+0000\", \"name\": \"System DateTime\", \"id\": \"vXlzpA8wi6K\", \"href\": \"http://82.196.9.250:8080/api/dataElements/vXlzpA8wi6K\" }, { \"lastUpdated\": \"2016-05-16T08:17:52.006+0000\", \"created\": \"2016-05-16T08:17:51.995+0000\", \"name\": \"System Language\", \"id\": \"RHNugiFzCnz\", \"href\": \"http://82.196.9.250:8080/api/dataElements/RHNugiFzCnz\" }, { \"lastUpdated\": \"2016-05-16T08:19:02.190+0000\", \"created\": \"2016-05-16T08:19:02.180+0000\", \"name\": \"System Timezone\", \"id\": \"GldPX7AtrxQ\", \"href\": \"http://82.196.9.250:8080/api/dataElements/GldPX7AtrxQ\" }, { \"lastUpdated\": \"2016-02-22T21:36:51.246+0000\", \"created\": \"2016-02-21T07:53:47.279+0000\", \"name\": \"System Uptime - LastMonth (%)\", \"id\": \"q9MRIo5DX4I\", \"href\": \"http://82.196.9.250:8080/api/dataElements/q9MRIo5DX4I\" }, { \"lastUpdated\": \"2016-02-22T21:37:01.730+0000\", \"created\": \"2016-02-21T07:53:05.307+0000\", \"name\": \"System Uptime - LastWeek (%)\", \"id\": \"h08FIw8cVUD\", \"href\": \"http://82.196.9.250:8080/api/dataElements/h08FIw8cVUD\" }, { \"lastUpdated\": \"2016-02-22T21:37:10.224+0000\", \"created\": \"2016-02-21T07:52:49.030+0000\", \"name\": \"System Uptime - ThisWeek (%)\", \"id\": \"CrZDptrDUqA\", \"href\": \"http://82.196.9.250:8080/api/dataElements/CrZDptrDUqA\" }, { \"lastUpdated\": \"2016-05-16T08:32:40.970+0000\", \"created\": \"2016-05-16T08:32:40.965+0000\", \"name\": \"Temporary Directory\", \"id\": \"FveZHUNsC1o\", \"href\": \"http://82.196.9.250:8080/api/dataElements/FveZHUNsC1o\" }, { \"lastUpdated\": \"2016-02-21T11:59:23.539+0000\", \"created\": \"2016-02-10T10:19:34.196+0000\", \"name\": \"Total Encounters\", \"id\": \"RYe2tuO9njZ\", \"href\": \"http://82.196.9.250:8080/api/dataElements/RYe2tuO9njZ\" }, { \"lastUpdated\": \"2016-02-22T21:27:59.936+0000\", \"created\": \"2016-02-21T11:26:42.724+0000\", \"name\": \"Total Memory (MB)\", \"id\": \"FRANuyR9bKI\", \"href\": \"http://82.196.9.250:8080/api/dataElements/FRANuyR9bKI\" }, { \"lastUpdated\": \"2016-02-21T12:00:32.336+0000\", \"created\": \"2016-02-10T10:19:47.725+0000\", \"name\": \"Total Observations\", \"id\": \"NorJph8rRjt\", \"href\": \"http://82.196.9.250:8080/api/dataElements/NorJph8rRjt\" }, { \"lastUpdated\": \"2016-07-14T07:47:32.359+0000\", \"created\": \"2016-02-10T10:20:23.671+0000\", \"name\": \"Total Patients - Active\", \"id\": \"hk0HYxaBPtz\", \"href\": \"http://82.196.9.250:8080/api/dataElements/hk0HYxaBPtz\" }, { \"lastUpdated\": \"2016-02-22T21:39:29.961+0000\", \"created\": \"2016-02-10T10:20:35.935+0000\", \"name\": \"Total Patients - New\", \"id\": \"aGdN2xl9nUj\", \"href\": \"http://82.196.9.250:8080/api/dataElements/aGdN2xl9nUj\" }, { \"lastUpdated\": \"2016-02-21T12:01:54.504+0000\", \"created\": \"2016-02-10T10:20:05.289+0000\", \"name\": \"Total Users\", \"id\": \"GKi8zBGuC3p\", \"href\": \"http://82.196.9.250:8080/api/dataElements/GKi8zBGuC3p\" }, { \"lastUpdated\": \"2016-02-21T12:02:10.067+0000\", \"created\": \"2016-02-10T10:21:00.277+0000\", \"name\": \"Total Visits\", \"id\": \"nqGCy0uyzm8\", \"href\": \"http://82.196.9.250:8080/api/dataElements/nqGCy0uyzm8\" }, { \"lastUpdated\": \"2016-02-22T21:27:46.253+0000\", \"created\": \"2016-02-21T15:36:08.574+0000\", \"name\": \"Used Memory (MB)\", \"id\": \"QZMqiNLOZNH\", \"href\": \"http://82.196.9.250:8080/api/dataElements/QZMqiNLOZNH\" }, { \"lastUpdated\": \"2016-05-16T08:31:53.663+0000\", \"created\": \"2016-05-16T08:31:53.659+0000\", \"name\": \"User Directory\", \"id\": \"Fy0lelr1WAB\", \"href\": \"http://82.196.9.250:8080/api/dataElements/Fy0lelr1WAB\" }, { \"lastUpdated\": \"2016-05-16T08:16:32.731+0000\", \"created\": \"2016-05-16T08:16:32.720+0000\", \"name\": \"User Name\", \"id\": \"KiOmWTYmc4F\", \"href\": \"http://82.196.9.250:8080/api/dataElements/KiOmWTYmc4F\" }, { \"lastUpdated\": \"2016-07-14T07:37:18.634+0000\", \"created\": \"2016-07-11T09:01:58.001+0000\", \"name\": \"New Total Adult Initial Encounters\", \"id\": \"HkctO4QQgte\", \"href\": \"http://82.196.9.250:8080/api/dataElements/HkctO4QQgte\" }, { \"lastUpdated\": \"2016-07-14T07:37:31.893+0000\", \"created\": \"2016-07-11T09:03:50.692+0000\", \"name\": \"New Total Adult Return Encounters\", \"id\": \"aHYdS1cNuam\", \"href\": \"http://82.196.9.250:8080/api/dataElements/aHYdS1cNuam\" }, { \"lastUpdated\": \"2016-07-14T07:37:53.031+0000\", \"created\": \"2016-07-06T16:33:19.037+0000\", \"name\": \"New Total Encounters\", \"id\": \"oUoKdxhelRG\", \"href\": \"http://82.196.9.250:8080/api/dataElements/oUoKdxhelRG\" }, { \"lastUpdated\": \"2016-07-14T07:38:03.349+0000\", \"created\": \"2016-07-11T09:00:14.506+0000\", \"name\": \"New Total Observations\", \"id\": \"BHXAiiCvX5K\", \"href\": \"http://82.196.9.250:8080/api/dataElements/BHXAiiCvX5K\" }, { \"lastUpdated\": \"2016-07-14T07:38:17.822+0000\", \"created\": \"2016-07-11T09:05:03.038+0000\", \"name\": \"New Total Paediatrics Initial Encounters\", \"id\": \"UidOuL65vMw\", \"href\": \"http://82.196.9.250:8080/api/dataElements/UidOuL65vMw\" }, { \"lastUpdated\": \"2016-07-14T07:38:30.489+0000\", \"created\": \"2016-07-11T09:05:33.184+0000\", \"name\": \"New Total Paediatrics Return Encounters\", \"id\": \"CdlLkU6tqSX\", \"href\": \"http://82.196.9.250:8080/api/dataElements/CdlLkU6tqSX\" }, { \"lastUpdated\": \"2016-07-14T07:47:53.987+0000\", \"created\": \"2016-07-14T07:47:53.944+0000\", \"name\": \"New Total Patients - Active\", \"id\": \"GCC9L1LGFBH\", \"href\": \"http://82.196.9.250:8080/api/dataElements/GCC9L1LGFBH\" }, { \"lastUpdated\": \"2016-07-14T07:48:16.890+0000\", \"created\": \"2016-07-14T07:48:16.876+0000\", \"name\": \"New Total Patients - New\", \"id\": \"JNsXijeCdIx\", \"href\": \"http://82.196.9.250:8080/api/dataElements/JNsXijeCdIx\" }, { \"lastUpdated\": \"2016-07-14T07:38:40.938+0000\", \"created\": \"2016-07-11T09:00:44.485+0000\", \"name\": \"New Total Users\", \"id\": \"luKfl7hZZek\", \"href\": \"http://82.196.9.250:8080/api/dataElements/luKfl7hZZek\" } ] }"; + public static String dataElementsMetadata = "{ \"pager\": { \"page\": 1, \"pageCount\": 1, \"total\": 58, \"pageSize\": 100 }, \"dataElements\": [ { \"lastUpdated\": \"2016-07-13T07:05:17.318+0000\", \"created\": \"2016-07-13T06:45:38.841+0000\", \"name\": \"Date for last backup\", \"id\": \"v3Pww13i2r1\", \"href\": \"http://82.196.9.250:8080/api/dataElements/v3Pww13i2r1\" }, { \"lastUpdated\": \"2016-05-16T08:31:01.138+0000\", \"created\": \"2016-05-16T08:31:01.125+0000\", \"name\": \"File System Encoding\", \"id\": \"RlDJSS2SRXL\", \"href\": \"http://82.196.9.250:8080/api/dataElements/RlDJSS2SRXL\" }, { \"lastUpdated\": \"2016-02-22T21:25:12.085+0000\", \"created\": \"2016-02-21T11:27:03.298+0000\", \"name\": \"Free Memory (MB)\", \"id\": \"ZPrLSHvWDm8\", \"href\": \"http://82.196.9.250:8080/api/dataElements/ZPrLSHvWDm8\" }, { \"lastUpdated\": \"2016-05-16T08:48:46.331+0000\", \"created\": \"2016-05-16T08:48:46.325+0000\", \"name\": \"Installed Modules\", \"id\": \"ICTGPRAVZVZ\", \"href\": \"http://82.196.9.250:8080/api/dataElements/ICTGPRAVZVZ\" }, { \"lastUpdated\": \"2016-05-16T08:13:48.734+0000\", \"created\": \"2016-05-16T08:13:48.730+0000\", \"name\": \"Java Runtime Name\", \"id\": \"SrKrLKmigUg\", \"href\": \"http://82.196.9.250:8080/api/dataElements/SrKrLKmigUg\" }, { \"lastUpdated\": \"2016-05-16T08:14:28.986+0000\", \"created\": \"2016-05-16T08:14:28.979+0000\", \"name\": \"Java Runtime Version\", \"id\": \"ixpB1MGxTOt\", \"href\": \"http://82.196.9.250:8080/api/dataElements/ixpB1MGxTOt\" }, { \"lastUpdated\": \"2016-05-16T08:11:15.936+0000\", \"created\": \"2016-05-16T08:11:15.932+0000\", \"name\": \"Java Vendor\", \"id\": \"TuBY7HgyJ7J\", \"href\": \"http://82.196.9.250:8080/api/dataElements/TuBY7HgyJ7J\" }, { \"lastUpdated\": \"2016-05-16T08:09:56.165+0000\", \"created\": \"2016-05-16T08:09:19.753+0000\", \"name\": \"Java Version\", \"id\": \"FmjhhJQyLoy\", \"href\": \"http://82.196.9.250:8080/api/dataElements/FmjhhJQyLoy\" }, { \"lastUpdated\": \"2016-05-16T08:12:31.371+0000\", \"created\": \"2016-05-16T08:12:31.363+0000\", \"name\": \"JVM Vendor\", \"id\": \"yIMQP0rsprI\", \"href\": \"http://82.196.9.250:8080/api/dataElements/yIMQP0rsprI\" }, { \"lastUpdated\": \"2016-05-16T08:11:50.278+0000\", \"created\": \"2016-05-16T08:11:50.273+0000\", \"name\": \"JVM Version\", \"id\": \"RgJN8fbRRuW\", \"href\": \"http://82.196.9.250:8080/api/dataElements/RgJN8fbRRuW\" }, { \"lastUpdated\": \"2016-02-21T11:59:54.669+0000\", \"created\": \"2016-02-21T07:54:24.177+0000\", \"name\": \"Number Of System Starts\", \"id\": \"q8LwlSrBOSj\", \"href\": \"http://82.196.9.250:8080/api/dataElements/q8LwlSrBOSj\" }, { \"lastUpdated\": \"2016-02-22T09:58:12.284+0000\", \"created\": \"2016-02-22T09:58:12.277+0000\", \"name\": \"OpenMRS App Name\", \"id\": \"ec9fC1xmg8R\", \"href\": \"http://82.196.9.250:8080/api/dataElements/ec9fC1xmg8R\" }, { \"lastUpdated\": \"2016-02-22T21:37:52.612+0000\", \"created\": \"2016-02-21T11:53:20.730+0000\", \"name\": \"OpenMRS Uptime (%)\", \"id\": \"OBJQIpvppBt\", \"href\": \"http://82.196.9.250:8080/api/dataElements/OBJQIpvppBt\" }, { \"lastUpdated\": \"2016-07-03T21:40:53.466+0000\", \"created\": \"2016-07-01T04:52:08.802+0000\", \"name\": \"OpenMRS Uptime (minutes)\", \"id\": \"WdPwtuNKhcd\", \"href\": \"http://82.196.9.250:8080/api/dataElements/WdPwtuNKhcd\" }, { \"lastUpdated\": \"2016-05-16T08:34:04.818+0000\", \"created\": \"2016-05-16T08:34:04.808+0000\", \"name\": \"OpenMRS Version\", \"id\": \"Gnpcar514A3\", \"href\": \"http://82.196.9.250:8080/api/dataElements/Gnpcar514A3\" }, { \"lastUpdated\": \"2016-05-16T08:10:10.315+0000\", \"created\": \"2016-05-16T08:06:28.206+0000\", \"name\": \"Operating System\", \"id\": \"CRThksbOPAd\", \"href\": \"http://82.196.9.250:8080/api/dataElements/CRThksbOPAd\" }, { \"lastUpdated\": \"2016-05-16T08:10:20.972+0000\", \"created\": \"2016-05-16T08:07:30.528+0000\", \"name\": \"Operating System Arch\", \"id\": \"EFfJ4CVvac2\", \"href\": \"http://82.196.9.250:8080/api/dataElements/EFfJ4CVvac2\" }, { \"lastUpdated\": \"2016-05-16T08:10:32.087+0000\", \"created\": \"2016-05-16T08:08:37.421+0000\", \"name\": \"Operating System Version\", \"id\": \"l76OuWQxBYa\", \"href\": \"http://82.196.9.250:8080/api/dataElements/l76OuWQxBYa\" }, { \"lastUpdated\": \"2016-07-01T05:09:58.632+0000\", \"created\": \"2016-06-30T19:50:28.943+0000\", \"name\": \"Patient CD4 Count Test Results - All\", \"id\": \"UEfoD5rcZbC\", \"href\": \"http://82.196.9.250:8080/api/dataElements/UEfoD5rcZbC\" }, { \"lastUpdated\": \"2016-07-01T05:10:20.261+0000\", \"created\": \"2016-06-30T19:50:56.520+0000\", \"name\": \"Patient CD4 Count Test Results - Last 6 Months\", \"id\": \"d3XqMIFIoz6\", \"href\": \"http://82.196.9.250:8080/api/dataElements/d3XqMIFIoz6\" }, { \"lastUpdated\": \"2016-07-01T05:10:10.452+0000\", \"created\": \"2016-06-30T19:51:19.308+0000\", \"name\": \"Patient CD4 Count Test Results - Last Year\", \"id\": \"GHq0YsrAsaf\", \"href\": \"http://82.196.9.250:8080/api/dataElements/GHq0YsrAsaf\" }, { \"lastUpdated\": \"2016-07-14T08:00:52.280+0000\", \"created\": \"2016-07-11T09:06:52.731+0000\", \"name\": \"Patient CD4 Count Test Results - New\", \"id\": \"QoIyYyc7Z36\", \"href\": \"http://82.196.9.250:8080/api/dataElements/QoIyYyc7Z36\" }, { \"lastUpdated\": \"2016-05-01T17:52:05.525+0000\", \"created\": \"2016-05-01T17:52:05.436+0000\", \"name\": \"Patient Viral Load Test Results - All\", \"id\": \"AB7Nj3FNvR6\", \"href\": \"http://82.196.9.250:8080/api/dataElements/AB7Nj3FNvR6\" }, { \"lastUpdated\": \"2016-05-01T17:52:39.755+0000\", \"created\": \"2016-05-01T17:52:39.723+0000\", \"name\": \"Patient Viral Load Test Results - Last 6 Months\", \"id\": \"TIdLXyneWYd\", \"href\": \"http://82.196.9.250:8080/api/dataElements/TIdLXyneWYd\" }, { \"lastUpdated\": \"2016-05-01T17:53:15.989+0000\", \"created\": \"2016-05-01T17:53:15.982+0000\", \"name\": \"Patient Viral Load Test Results - Last Year\", \"id\": \"D30SnV0TGws\", \"href\": \"http://82.196.9.250:8080/api/dataElements/D30SnV0TGws\" }, { \"lastUpdated\": \"2016-07-14T08:01:07.195+0000\", \"created\": \"2016-07-11T09:07:21.967+0000\", \"name\": \"Patient Viral Load Test Results - New\", \"id\": \"uaUc1zJbaEC\", \"href\": \"http://82.196.9.250:8080/api/dataElements/uaUc1zJbaEC\" }, { \"lastUpdated\": \"2016-02-22T10:00:21.933+0000\", \"created\": \"2016-02-22T10:00:21.919+0000\", \"name\": \"Primary Clinic Days\", \"id\": \"rb9ef1D53Fv\", \"href\": \"http://82.196.9.250:8080/api/dataElements/rb9ef1D53Fv\" }, { \"lastUpdated\": \"2016-02-22T10:01:28.305+0000\", \"created\": \"2016-02-22T10:01:28.294+0000\", \"name\": \"Primary Clinic Hours\", \"id\": \"VDEnb2bEQH3\", \"href\": \"http://82.196.9.250:8080/api/dataElements/VDEnb2bEQH3\" }, { \"lastUpdated\": \"2016-07-03T08:22:16.698+0000\", \"created\": \"2016-07-03T08:22:16.679+0000\", \"name\": \"Processor\", \"id\": \"xr3kif2Vuzu\", \"href\": \"http://82.196.9.250:8080/api/dataElements/xr3kif2Vuzu\" }, { \"lastUpdated\": \"2016-02-22T09:57:43.364+0000\", \"created\": \"2016-02-22T09:57:43.346+0000\", \"name\": \"Server Id\", \"id\": \"yBHJmoeteNR\", \"href\": \"http://82.196.9.250:8080/api/dataElements/yBHJmoeteNR\" }, { \"lastUpdated\": \"2016-06-15T23:39:37.239+0000\", \"created\": \"2016-06-15T23:39:36.920+0000\", \"name\": \"Server's Real Location\", \"id\": \"hKJXqpumYZ6\", \"href\": \"http://82.196.9.250:8080/api/dataElements/hKJXqpumYZ6\" }, { \"lastUpdated\": \"2016-07-03T08:00:23.659+0000\", \"created\": \"2016-07-01T04:51:28.393+0000\", \"name\": \"Server Uptime (minutes)\", \"id\": \"RiyIySUEl1W\", \"href\": \"http://82.196.9.250:8080/api/dataElements/RiyIySUEl1W\" }, { \"lastUpdated\": \"2016-05-16T12:26:00.679+0000\", \"created\": \"2016-05-16T08:24:23.282+0000\", \"name\": \"System DateTime\", \"id\": \"vXlzpA8wi6K\", \"href\": \"http://82.196.9.250:8080/api/dataElements/vXlzpA8wi6K\" }, { \"lastUpdated\": \"2016-05-16T08:17:52.006+0000\", \"created\": \"2016-05-16T08:17:51.995+0000\", \"name\": \"System Language\", \"id\": \"RHNugiFzCnz\", \"href\": \"http://82.196.9.250:8080/api/dataElements/RHNugiFzCnz\" }, { \"lastUpdated\": \"2016-05-16T08:19:02.190+0000\", \"created\": \"2016-05-16T08:19:02.180+0000\", \"name\": \"System Timezone\", \"id\": \"GldPX7AtrxQ\", \"href\": \"http://82.196.9.250:8080/api/dataElements/GldPX7AtrxQ\" }, { \"lastUpdated\": \"2016-02-22T21:36:51.246+0000\", \"created\": \"2016-02-21T07:53:47.279+0000\", \"name\": \"System Uptime - LastMonth (%)\", \"id\": \"q9MRIo5DX4I\", \"href\": \"http://82.196.9.250:8080/api/dataElements/q9MRIo5DX4I\" }, { \"lastUpdated\": \"2016-02-22T21:37:01.730+0000\", \"created\": \"2016-02-21T07:53:05.307+0000\", \"name\": \"System Uptime - LastWeek (%)\", \"id\": \"h08FIw8cVUD\", \"href\": \"http://82.196.9.250:8080/api/dataElements/h08FIw8cVUD\" }, { \"lastUpdated\": \"2016-02-22T21:37:10.224+0000\", \"created\": \"2016-02-21T07:52:49.030+0000\", \"name\": \"System Uptime - ThisWeek (%)\", \"id\": \"CrZDptrDUqA\", \"href\": \"http://82.196.9.250:8080/api/dataElements/CrZDptrDUqA\" }, { \"lastUpdated\": \"2016-05-16T08:32:40.970+0000\", \"created\": \"2016-05-16T08:32:40.965+0000\", \"name\": \"Temporary Directory\", \"id\": \"FveZHUNsC1o\", \"href\": \"http://82.196.9.250:8080/api/dataElements/FveZHUNsC1o\" }, { \"lastUpdated\": \"2016-02-21T11:59:23.539+0000\", \"created\": \"2016-02-10T10:19:34.196+0000\", \"name\": \"Total Encounters\", \"id\": \"RYe2tuO9njZ\", \"href\": \"http://82.196.9.250:8080/api/dataElements/RYe2tuO9njZ\" }, { \"lastUpdated\": \"2016-02-22T21:27:59.936+0000\", \"created\": \"2016-02-21T11:26:42.724+0000\", \"name\": \"Total Memory (MB)\", \"id\": \"FRANuyR9bKI\", \"href\": \"http://82.196.9.250:8080/api/dataElements/FRANuyR9bKI\" }, { \"lastUpdated\": \"2016-02-21T12:00:32.336+0000\", \"created\": \"2016-02-10T10:19:47.725+0000\", \"name\": \"Total Observations\", \"id\": \"NorJph8rRjt\", \"href\": \"http://82.196.9.250:8080/api/dataElements/NorJph8rRjt\" }, { \"lastUpdated\": \"2016-07-14T07:47:32.359+0000\", \"created\": \"2016-02-10T10:20:23.671+0000\", \"name\": \"Total Patients - Active\", \"id\": \"hk0HYxaBPtz\", \"href\": \"http://82.196.9.250:8080/api/dataElements/hk0HYxaBPtz\" }, { \"lastUpdated\": \"2016-02-22T21:39:29.961+0000\", \"created\": \"2016-02-10T10:20:35.935+0000\", \"name\": \"Total Patients - New\", \"id\": \"aGdN2xl9nUj\", \"href\": \"http://82.196.9.250:8080/api/dataElements/aGdN2xl9nUj\" }, { \"lastUpdated\": \"2016-02-21T12:01:54.504+0000\", \"created\": \"2016-02-10T10:20:05.289+0000\", \"name\": \"Total Users\", \"id\": \"GKi8zBGuC3p\", \"href\": \"http://82.196.9.250:8080/api/dataElements/GKi8zBGuC3p\" }, { \"lastUpdated\": \"2016-02-21T12:02:10.067+0000\", \"created\": \"2016-02-10T10:21:00.277+0000\", \"name\": \"Total Visits\", \"id\": \"nqGCy0uyzm8\", \"href\": \"http://82.196.9.250:8080/api/dataElements/nqGCy0uyzm8\" }, { \"lastUpdated\": \"2016-02-22T21:27:46.253+0000\", \"created\": \"2016-02-21T15:36:08.574+0000\", \"name\": \"Used Memory (MB)\", \"id\": \"QZMqiNLOZNH\", \"href\": \"http://82.196.9.250:8080/api/dataElements/QZMqiNLOZNH\" }, { \"lastUpdated\": \"2016-05-16T08:31:53.663+0000\", \"created\": \"2016-05-16T08:31:53.659+0000\", \"name\": \"User Directory\", \"id\": \"Fy0lelr1WAB\", \"href\": \"http://82.196.9.250:8080/api/dataElements/Fy0lelr1WAB\" }, { \"lastUpdated\": \"2016-05-16T08:16:32.731+0000\", \"created\": \"2016-05-16T08:16:32.720+0000\", \"name\": \"User Name\", \"id\": \"KiOmWTYmc4F\", \"href\": \"http://82.196.9.250:8080/api/dataElements/KiOmWTYmc4F\" }, { \"lastUpdated\": \"2016-07-14T07:37:18.634+0000\", \"created\": \"2016-07-11T09:01:58.001+0000\", \"name\": \"New Total Adult Initial Encounters\", \"id\": \"HkctO4QQgte\", \"href\": \"http://82.196.9.250:8080/api/dataElements/HkctO4QQgte\" }, { \"lastUpdated\": \"2016-07-14T07:37:31.893+0000\", \"created\": \"2016-07-11T09:03:50.692+0000\", \"name\": \"New Total Adult Return Encounters\", \"id\": \"aHYdS1cNuam\", \"href\": \"http://82.196.9.250:8080/api/dataElements/aHYdS1cNuam\" }, { \"lastUpdated\": \"2016-07-14T07:37:53.031+0000\", \"created\": \"2016-07-06T16:33:19.037+0000\", \"name\": \"New Total Encounters\", \"id\": \"oUoKdxhelRG\", \"href\": \"http://82.196.9.250:8080/api/dataElements/oUoKdxhelRG\" }, { \"lastUpdated\": \"2016-07-14T07:38:03.349+0000\", \"created\": \"2016-07-11T09:00:14.506+0000\", \"name\": \"New Total Observations\", \"id\": \"BHXAiiCvX5K\", \"href\": \"http://82.196.9.250:8080/api/dataElements/BHXAiiCvX5K\" }, { \"lastUpdated\": \"2016-07-14T07:38:17.822+0000\", \"created\": \"2016-07-11T09:05:03.038+0000\", \"name\": \"New Total Paediatrics Initial Encounters\", \"id\": \"UidOuL65vMw\", \"href\": \"http://82.196.9.250:8080/api/dataElements/UidOuL65vMw\" }, { \"lastUpdated\": \"2016-07-14T07:38:30.489+0000\", \"created\": \"2016-07-11T09:05:33.184+0000\", \"name\": \"New Total Paediatrics Return Encounters\", \"id\": \"CdlLkU6tqSX\", \"href\": \"http://82.196.9.250:8080/api/dataElements/CdlLkU6tqSX\" }, { \"lastUpdated\": \"2016-07-14T07:47:53.987+0000\", \"created\": \"2016-07-14T07:47:53.944+0000\", \"name\": \"New Total Patients - Active\", \"id\": \"GCC9L1LGFBH\", \"href\": \"http://82.196.9.250:8080/api/dataElements/GCC9L1LGFBH\" }, { \"lastUpdated\": \"2016-07-14T07:48:16.890+0000\", \"created\": \"2016-07-14T07:48:16.876+0000\", \"name\": \"New Total Patients - New\", \"id\": \"JNsXijeCdIx\", \"href\": \"http://82.196.9.250:8080/api/dataElements/JNsXijeCdIx\" }, { \"lastUpdated\": \"2016-07-14T07:38:40.938+0000\", \"created\": \"2016-07-11T09:00:44.485+0000\", \"name\": \"New Total Users\", \"id\": \"luKfl7hZZek\", \"href\": \"http://82.196.9.250:8080/api/dataElements/luKfl7hZZek\" } ] }"; public static void addMappingsFileToSystemMonitorDataDirectory() { try { diff --git a/api/src/main/java/org/openmrs/module/systemmonitor/indicators/OSAndHardwareIndicators.java b/api/src/main/java/org/openmrs/module/systemmonitor/indicators/OSAndHardwareIndicators.java index 528a18e..84e9b08 100644 --- a/api/src/main/java/org/openmrs/module/systemmonitor/indicators/OSAndHardwareIndicators.java +++ b/api/src/main/java/org/openmrs/module/systemmonitor/indicators/OSAndHardwareIndicators.java @@ -25,99 +25,100 @@ import oshi.software.os.OperatingSystemVersion; public class OSAndHardwareIndicators { - private static SystemInfo si = new SystemInfo(); + private SystemInfo si = new SystemInfo(); - private static CentralProcessor p = getCentralProcessor(); + private CentralProcessor p = getCentralProcessor(); - private static HardwareAbstractionLayer hal = si.getHardware(); + private HardwareAbstractionLayer hal = si.getHardware(); - private static GlobalMemory memory = getMemory(); + private GlobalMemory memory = getMemory(); - private static OperatingSystem os = getOperatingSystem(); + private OperatingSystem os = getOperatingSystem(); - private static Sensors s = si.getHardware().getSensors(); + private Sensors s = si.getHardware().getSensors(); - private static OperatingSystemVersion version = os != null ? os.getVersion() : null; + private OperatingSystemVersion version = os != null ? os.getVersion() : null; - private static PowerSource[] psArr = /*si.getHardware().getPowerSources()*/null;; + private PowerSource[] psArr = /* + * si.getHardware().getPowerSources( ) + */null;; - public static String PROCESSOR_NAME = getLinuxProcessorName(); + public String PROCESSOR_NAME = getLinuxProcessorName(); - public static String PROCESSOR_VENDOR = p != null ? p.getVendor() : null; + public String PROCESSOR_VENDOR = p != null ? p.getVendor() : null; - public static Double PROCESSOR_SYSTEM_LOAD = p != null ? p.getSystemLoadAverage() : null; + public Double PROCESSOR_SYSTEM_LOAD = p != null ? p.getSystemLoadAverage() : null; - public static String PROCESSOR_SERIAL_NUMBER = p != null ? p.getSystemSerialNumber() : null; + public String PROCESSOR_SERIAL_NUMBER = p != null ? p.getSystemSerialNumber() : null; - public static Integer PROCESSOR_LOGICAL_COUNT = p != null ? p.getLogicalProcessorCount() : null; + public Integer PROCESSOR_LOGICAL_COUNT = p != null ? p.getLogicalProcessorCount() : null; - public static Integer PROCESSOR_PHYSICAL_COUNT = p != null ? p.getPhysicalProcessorCount() : null; + public Integer PROCESSOR_PHYSICAL_COUNT = p != null ? p.getPhysicalProcessorCount() : null; - public static Integer PROCESSOR_THREAD_COUNT = p != null ? p.getThreadCount() : null; + public Integer PROCESSOR_THREAD_COUNT = p != null ? p.getThreadCount() : null; /** * Total Physical Memory (RAM) in Megabytes(MB) */ - public static Long MEMORY_TOTAL = memory != null ? memory.getTotal() / 1048576 + public Long MEMORY_TOTAL = memory != null ? memory.getTotal() / 1048576 : Runtime.getRuntime().maxMemory() / 1048576; /** * Used Physical Memory (RAM) in Megabytes(MB) */ - public static Long MEMORY_USED = memory != null ? (memory.getTotal() - memory.getAvailable()) / 1048576 + public Long MEMORY_USED = memory != null ? (memory.getTotal() - memory.getAvailable()) / 1048576 : Runtime.getRuntime().totalMemory() / 1048576; /** * Available Physical Memory (RAM) in Megabytes(MB) */ - public static Long MEMORY_AVAILABLE = memory != null ? memory.getAvailable() / 1048576 + public Long MEMORY_AVAILABLE = memory != null ? memory.getAvailable() / 1048576 : Runtime.getRuntime().freeMemory() / 1048576; /** * Total Swap memory in Megabytes(MB) */ - public static Long MEMORY_SWAP_TOTAL = memory != null ? memory.getSwapTotal() / 1048576 : null; + public Long MEMORY_SWAP_TOTAL = memory != null ? memory.getSwapTotal() / 1048576 : null; /** * Used Swap Memory in Megabytes(MB) */ - public static Long MEMORY_SWAP_USED = memory != null ? memory.getSwapUsed() / 1048576 : null; + public Long MEMORY_SWAP_USED = memory != null ? memory.getSwapUsed() / 1048576 : null; /** * Free Swap Memory in Megabytes(MB) */ - public static Long MEMORY_SWAP_FREE = memory != null ? (memory.getSwapTotal() - memory.getSwapUsed()) / 1048576 - : null; + public Long MEMORY_SWAP_FREE = memory != null ? (memory.getSwapTotal() - memory.getSwapUsed()) / 1048576 : null; /** * CPU Voltage in Volts (V) */ - public static Double CPU_VOLTAGE = /*s.getCpuVoltage()*/null; + public Double CPU_VOLTAGE = /* s.getCpuVoltage() */null; /** * CPU Temperature in Degrees celsius (°C) */ - public static Double CPU_TEMPERATURE = /*s.getCpuTemperature()*/null; + public Double CPU_TEMPERATURE = /* s.getCpuTemperature() */null; - public static int[] FAN_SPEED = /*s.getFanSpeeds()*/null; + public int[] FAN_SPEED = /* s.getFanSpeeds() */null; - public static String OS_FAMILY = os != null ? os.getFamily() : ""; + public String OS_FAMILY = os != null ? os.getFamily() : ""; - public static String OS_MANUFACTURER = os != null ? os.getManufacturer() : ""; + public String OS_MANUFACTURER = os != null ? os.getManufacturer() : ""; - public static String OS_VERSION_NAME = version != null ? version.getCodeName() : System.getProperty("os.version"); + public String OS_VERSION_NAME = version != null ? version.getCodeName() : System.getProperty("os.version"); - public static String OS_VERSION_BUILDNUMBER = version.getBuildNumber(); + public String OS_VERSION_BUILDNUMBER = version != null ? version.getBuildNumber() : ""; - public static String OS_VERSION_NUMBER = version != null ? version.getVersion() : System.getProperty("os.name"); + public String OS_VERSION_NUMBER = version != null ? version.getVersion() : System.getProperty("os.name"); /** * Time from when System started in minutes */ - public static Long PROCESSOR_SYSTEM_UPTIME = p != null ? p.getSystemUptime() / 60 + public Long PROCESSOR_SYSTEM_UPTIME = p != null ? p.getSystemUptime() / 60 : ManagementFactory.getRuntimeMXBean().getUptime() / 60; - public static String getHostName() { + public String getHostName() { try { return InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { @@ -126,7 +127,7 @@ public static String getHostName() { return null; } - private static OperatingSystem getOperatingSystem() { + private OperatingSystem getOperatingSystem() { OperatingSystem os = null; try { @@ -137,7 +138,7 @@ private static OperatingSystem getOperatingSystem() { return os; } - private static GlobalMemory getMemory() { + private GlobalMemory getMemory() { GlobalMemory memory = null; try { memory = hal.getMemory(); @@ -147,7 +148,7 @@ private static GlobalMemory getMemory() { return memory; } - public static String getIpAddress() throws SocketException, UnknownHostException { + public String getIpAddress() throws SocketException, UnknownHostException { try { @SuppressWarnings("static-access") String publicIp = new CurlEmulator().sendNormalHtmlGET("http://ipinfo.io/ip"); @@ -161,39 +162,48 @@ public static String getIpAddress() throws SocketException, UnknownHostException return InetAddress.getLocalHost().getHostAddress(); } - public static JSONArray getNetworkInformation() { - JSONArray json = new JSONArray(); - - for (NetworkIF net : si.getHardware().getNetworkIFs()) { - JSONObject js = new JSONObject(); + public JSONArray getNetworkInformation() { + JSONArray json = null; - if (net != null) { - js.put("name", net.getDisplayName()); - js.put("macAddress", net.getMacaddr()); - js.put("speed", net.getSpeed()); - js.put("packetsReceived", net.getPacketsRecv()); - js.put("packetsSent", net.getPacketsSent()); - js.put("mtu", net.getMTU()); - json.put(js); + try { + for (NetworkIF net : si.getHardware().getNetworkIFs()) { + json = new JSONArray(); + JSONObject js = new JSONObject(); + + if (net != null) { + js.put("name", net.getDisplayName()); + js.put("macAddress", net.getMacaddr()); + js.put("speed", net.getSpeed()); + js.put("packetsReceived", net.getPacketsRecv()); + js.put("packetsSent", net.getPacketsSent()); + js.put("mtu", net.getMTU()); + json.put(js); + } } + } catch (NoClassDefFoundError e) { + e.printStackTrace(); } return json; } - public static String getMacAddress() { - String macAdd = null; + public String getMacAddress() { + String macAdd = ""; + + JSONArray networkInformation = getNetworkInformation(); - for (int i = 0; i < getNetworkInformation().length(); i++) { - if (getNetworkInformation().getJSONObject(i) != null - && StringUtils.isNotBlank(getNetworkInformation().getJSONObject(i).getString("macAddress"))) { - macAdd = getNetworkInformation().getJSONObject(i).getString("macAddress"); - break; + if (networkInformation != null) { + for (int i = 0; i < networkInformation.length(); i++) { + if (networkInformation.getJSONObject(i) != null + && StringUtils.isNotBlank(networkInformation.getJSONObject(i).getString("macAddress"))) { + macAdd = networkInformation.getJSONObject(i).getString("macAddress"); + break; + } } } return macAdd; } - public static JSONArray getDisksInformation() { + public JSONArray getDisksInformation() { JSONArray json = new JSONArray(); for (HWDiskStore disk : si.getHardware().getDiskStores()) { @@ -210,7 +220,7 @@ public static JSONArray getDisksInformation() { return json; } - public static JSONArray getPowerInformation() { + public JSONArray getPowerInformation() { JSONArray json = new JSONArray(); for (PowerSource ps : psArr) { @@ -226,7 +236,7 @@ public static JSONArray getPowerInformation() { return json; } - public static String getLinuxProcessorName() { + public String getLinuxProcessorName() { if (p != null && "Linux".equals(System.getProperties().getProperty("os.name")) && StringUtils.isBlank(p.getName())) { String[] cmds = { "/bin/sh", "-c", "cat /proc/cpuinfo | grep 'name' | uniq" }; @@ -237,7 +247,7 @@ public static String getLinuxProcessorName() { } } - private static CentralProcessor getCentralProcessor() { + private CentralProcessor getCentralProcessor() { CentralProcessor p = null; try { p = si.getHardware().getProcessor(); @@ -246,13 +256,15 @@ private static CentralProcessor getCentralProcessor() { // (x86)\Apache Software Foundation\Tomcat // 6.0\temp\1472550968944.openmrs-lib-cache\systemmonitor\com\sun\jna\win32-x86\jnidispatch.dll: // Can't find dependent libraries thrown on some Windows servers - e.printStackTrace(); + // e.printStackTrace(); + p = null; + } catch (NoClassDefFoundError e) { p = null; } return p; } - private static String executeCommand(String[] commands) { + private String executeCommand(String[] commands) { StringBuffer output = new StringBuffer(); Process p; diff --git a/api/src/main/resources/dhis-dataelementsMetadata.json b/api/src/main/resources/dhis-dataelementsMetadata.json index c7c4393..442c385 100644 --- a/api/src/main/resources/dhis-dataelementsMetadata.json +++ b/api/src/main/resources/dhis-dataelementsMetadata.json @@ -156,7 +156,7 @@ { "lastUpdated": "2016-07-14T08:00:52.280+0000", "created": "2016-07-11T09:06:52.731+0000", - "name": "Patient CD4 Count Test Results - Yesterday", + "name": "Patient CD4 Count Test Results - New", "id": "QoIyYyc7Z36", "href": "http://82.196.9.250:8080/api/dataElements/QoIyYyc7Z36" }, @@ -184,7 +184,7 @@ { "lastUpdated": "2016-07-14T08:01:07.195+0000", "created": "2016-07-11T09:07:21.967+0000", - "name": "Patient Viral Load Test Results - Yesterday", + "name": "Patient Viral Load Test Results - New", "id": "uaUc1zJbaEC", "href": "http://82.196.9.250:8080/api/dataElements/uaUc1zJbaEC" }, diff --git a/api/src/test/java/org/openmrs/module/systemmonitor/api/SystemMonitorServiceTest.java b/api/src/test/java/org/openmrs/module/systemmonitor/api/SystemMonitorServiceTest.java index 11a948e..56c9320 100644 --- a/api/src/test/java/org/openmrs/module/systemmonitor/api/SystemMonitorServiceTest.java +++ b/api/src/test/java/org/openmrs/module/systemmonitor/api/SystemMonitorServiceTest.java @@ -205,7 +205,7 @@ public void test_hibernateCriteriaRestrictions() throws IOException { @Test public void testGetIp() throws SocketException, UnknownHostException { - System.out.println("IP ADDR: " + OSAndHardwareIndicators.getIpAddress()); + System.out.println("IP ADDR: " + new OSAndHardwareIndicators().getIpAddress()); } @Ignore diff --git a/api/src/test/java/org/openmrs/module/systemmonitor/api/TestOSHILibrary.java b/api/src/test/java/org/openmrs/module/systemmonitor/api/TestOSHILibrary.java index 9544cd9..a40c09d 100644 --- a/api/src/test/java/org/openmrs/module/systemmonitor/api/TestOSHILibrary.java +++ b/api/src/test/java/org/openmrs/module/systemmonitor/api/TestOSHILibrary.java @@ -36,6 +36,7 @@ * @TODO Re-write a version of this library that supports lower java version * instead of requiring 1.8 */ +@Ignore public class TestOSHILibrary { @Test @@ -87,7 +88,7 @@ public void test_systemNetwork() throws IOException, UnknownHostException { System.out.println("IP ADDRESS: " + InetAddress.getLocalHost().getHostAddress()); System.out.println("NETWORK SPEED: " + net.getSpeed()); - String ipInfoUrl = "http://ipinfo.io/" + OSAndHardwareIndicators.getIpAddress(); + String ipInfoUrl = "http://ipinfo.io/" + new OSAndHardwareIndicators().getIpAddress(); String googleIpInfoUrl = "http://ipinfo.io/8.8.8.8"; System.out.println("ipInfoUrl: " + ipInfoUrl); System.out.println("CurlEmulator.get(googleIpInfoUrl): " + CurlEmulator.get(googleIpInfoUrl, null, null)); diff --git a/omod/src/main/java/org/openmrs/module/systemmonitor/web/dwr/DWRSystemMonitorService.java b/omod/src/main/java/org/openmrs/module/systemmonitor/web/dwr/DWRSystemMonitorService.java index d31804f..c2b2b40 100644 --- a/omod/src/main/java/org/openmrs/module/systemmonitor/web/dwr/DWRSystemMonitorService.java +++ b/omod/src/main/java/org/openmrs/module/systemmonitor/web/dwr/DWRSystemMonitorService.java @@ -22,8 +22,10 @@ public String getDataForClientPushing() { ? Context.getAdministrationService().getGlobalProperty(ConfigurableGlobalProperties.DHISAPI_URL) + SystemMonitorConstants.DHIS_API_DATAVALUES_URL : ""; - String systemId = OSAndHardwareIndicators.getHostName() + "-" + (OSAndHardwareIndicators.getMacAddress() != null - ? OSAndHardwareIndicators.getMacAddress().replace(":", "") : ""); + OSAndHardwareIndicators osshi = new OSAndHardwareIndicators(); + + String systemId = osshi.getHostName() + "-" + (osshi.getMacAddress() != null + ? osshi.getMacAddress().replace(":", "") : ""); JSONObject allDataValues = prepareClientMonitoredData(); JSONObject allDHISValuesJSON = new JSONObject();