Beispiel #1
0
    def test_unused_heap_java8(self):
        """Test unused heap calculations for Java 8.

        Ensure for Java 8;
        - free java heap equals (committed - used)
        """
        stats = {}
        java_version = 8
        mock_smaps_output = {
            0: 19460,
            1: 71640,
            2: 193744,
            3: 3216,
            4: 0,
            5: 92176,
            6: 0,
        }

        smaps.get_smaps_rss_by_category = Mock(return_value=mock_smaps_output)

        # Check for following Java 8 scenarios:
        # - with and without memorypools
        # - with parallelGC
        for mem_stats in [
            MENDIX_6_JAVA_8_MEMORY_STATS,
            MENDIX_6_5_0_JAVA_8_MEMORY_STATS,
            MENDIX_6_JAVA_8_STATS_PARALLELGC,
        ]:
            stats["memory"] = mem_stats
            mock_threadpool_stats = {
                "threads_priority": 0,
                "max_threads": 0,
                "min_threads": 0,
                "max_idle_time_s": 0,
                "max_queued": -0,
                "threads": 0,
                "idle_threads": 0,
                "max_stop_time_s": 0,
            }
            new_stats = _populate_stats_by_java_version(
                copy.deepcopy(stats), java_version
            )
            new_stats["threadpool"] = mock_threadpool_stats
            fixed_stats = augment_and_fix_stats(new_stats, 0, java_version)
            javaheap = fixed_stats["memory"]["javaheap"]
            self.assertEqual(
                javaheap,
                (
                    stats["memory"]["committed_heap"]
                    - stats["memory"]["used_heap"]
                ),
            )
Beispiel #2
0
 def _inject_m2ee_stats(self, stats):
     try:
         m2ee_stats, java_version = munin.get_stats_from_runtime(
             self.m2ee.client, self.m2ee.config)
         if "sessions" in m2ee_stats:
             m2ee_stats["sessions"]["user_sessions"] = {}
         m2ee_stats = munin.augment_and_fix_stats(
             m2ee_stats, self.m2ee.runner.get_pid(), java_version)
         self._sanity_check_m2ee_stats(m2ee_stats)
         stats["mendix_runtime"] = m2ee_stats
     except Exception:
         logging.debug("Unable to get metrics from runtime")
     finally:
         return stats
Beispiel #3
0
    def _inject_m2ee_stats(self, stats):
        try:
            m2ee_stats, java_version = munin.get_stats_from_runtime(
                self.m2ee.client, self.m2ee.config)
            if "sessions" in m2ee_stats:
                m2ee_stats["sessions"]["user_sessions"] = {}
            m2ee_stats = munin.augment_and_fix_stats(
                m2ee_stats, self.m2ee.runner.get_pid(), java_version)

            critical_logs_count = len(
                self.m2ee.client.get_critical_log_messages())
            m2ee_stats["critical_logs_count"] = critical_logs_count
            stats["mendix_runtime"] = m2ee_stats
        except Exception:
            logging.debug("Unable to get metrics from runtime")
        finally:
            return stats