Exemple #1
0
    def _test_k8s_event_object_filter_from_environment(self,
                                                       environment_value):
        elems = ["CronJob", "DaemonSet", "Deployment"]
        os.environ["SCALYR_K8S_EVENT_OBJECT_FILTER"] = environment_value
        self._write_file_with_separator_conversion(""" {
            api_key: "hi there",
            logs: [ { path:"/var/log/tomcat6/access.log" }],
            monitors: [
                {
                    module: "scalyr_agent.builtin_monitors.kubernetes_events_monitor",
                }
            ]
          }
        """)
        config = self._create_test_configuration_instance()
        config.parse()

        test_manager = MonitorsManager(config, FakePlatform([]))
        k8s_event_monitor = test_manager.monitors[0]
        event_object_filter = k8s_event_monitor._config.get(
            "event_object_filter")
        self.assertNotEquals(elems,
                             event_object_filter)  # list != ArrayOfStrings
        self.assertEquals(type(event_object_filter), ArrayOfStrings)
        self.assertEquals(elems, list(event_object_filter))
 def test_log_write_rate(self):
     self._write_file_with_separator_conversion(""" {
         api_key: "hi there",
         logs: [ { path:"/var/log/tomcat6/access.log" }],
         monitors: [
             {
                 module: "scalyr_agent.builtin_monitors.linux_system_metrics",
                 "monitor_log_write_rate": -1,
                 "monitor_log_max_write_burst": -1
             }
         ]
       }
     """)
     config = self._create_test_configuration_instance()
     config.parse()
     test_manager = MonitorsManager(config, FakePlatform([]))
     system_metrics_monitor = test_manager.monitors[0]
     self.assertEquals(system_metrics_monitor._log_write_rate, -1)
     self.assertEquals(system_metrics_monitor._log_max_write_burst, -1)
Exemple #3
0
        def _assert_environment_variable(env_var_name, env_var_value,
                                         expected_value):
            os.environ[env_var_name] = env_var_value
            self._write_file_with_separator_conversion(""" { 
                api_key: "hi there",
                logs: [ { path:"/var/log/tomcat6/access.log" }],
                monitors: [
                    {
                        module: "scalyr_agent.builtin_monitors.kubernetes_events_monitor",
                    }
                ]
              }
            """)
            config = self._create_test_configuration_instance()
            config.parse()

            test_manager = MonitorsManager(config, FakePlatform([]))
            k8s_event_monitor = test_manager.monitors[0]
            self.assertEquals(
                expected_value,
                k8s_event_monitor._KubernetesEventsMonitor__disable_monitor)
Exemple #4
0
    def test_k8s_event_object_filter_from_config(self):
        self._write_file_with_separator_conversion(""" {
            api_key: "hi there",
            logs: [ { path:"/var/log/tomcat6/access.log" }],
            monitors: [
                {
                    module: "scalyr_agent.builtin_monitors.kubernetes_events_monitor",
                    event_object_filter: ["CronJob", "DaemonSet", "Deployment"]
                }
            ]
          }
        """)
        config = self._create_test_configuration_instance()
        config.parse()

        test_manager = MonitorsManager(config, FakePlatform([]))
        k8s_event_monitor = test_manager.monitors[0]
        event_object_filter = k8s_event_monitor._config.get(
            "event_object_filter")
        elems = ["CronJob", "DaemonSet", "Deployment"]
        self.assertNotEquals(elems, event_object_filter)  # list != JsonArray
        self.assertEquals(elems, [x for x in event_object_filter])
 def create_manager():
     scalyr_monitor.log = mock_logger
     return MonitorsManager(config, FakePlatform([]))