Ejemplo n.º 1
0
    def test_basic_verbose_stat(self):
        hold_count1 = 10
        interval1 = 0.1
        name1 = str(uuid.uuid4())

        systemstats.start_new_system_stat(
            name1,
            "system-stats",
            hold_count1,
            interval1)

        time.sleep((hold_count1 + 2) * interval1)
        stats_d = systemstats.get_stats(name1)
        self.assertEqual(len(stats_d['status']), hold_count1)

        ent_1 = stats_d['status'][0]
        self.assertIn('cpu-load', ent_1)
        self.assertIn('net-bytes-in', ent_1)
        self.assertIn('net-bytes-out', ent_1)
        self.assertIn('disk-read-bytes', ent_1)
        self.assertIn('disk-write-bytes', ent_1)
        self.assertIn('disk-read-ops', ent_1)
        self.assertIn('disk-write-ops', ent_1)
        self.assertIn('timestamp', ent_1)
        systemstats.stop_stats(name1)
Ejemplo n.º 2
0
 def run(self):
     systemstats.start_new_system_stat(
         self.args.statName,
         self.args.statType,
         self.args.holdCount,
         self.args.checkInterval)
     return plugin_base.PluginReply(0, reply_type="void")
Ejemplo n.º 3
0
    def test_system_stat_two_cpu_idle(self):
        hold_count1 = 10
        interval1 = 0.1
        name1 = str(uuid.uuid4())
        hold_count2 = int(hold_count1 / 2)
        interval2 = interval1 * 2
        name2 = str(uuid.uuid4())

        systemstats.start_new_system_stat(
            name1,
            "cpu-idle",
            hold_count1,
            interval1)
        systemstats.start_new_system_stat(
            name2,
            "cpu-idle",
            hold_count2,
            interval2)

        time.sleep((hold_count1 + 2) * interval1)
        stats_d = systemstats.get_stats(name1)
        self.assertEqual(len(stats_d['status']), hold_count1)

        time.sleep((hold_count2 + 2) * interval2)
        stats_d = systemstats.get_stats(name2)
        self.assertEqual(len(stats_d['status']), hold_count2)

        systemstats.stop_stats(name1)
        systemstats.stop_stats(name2)
Ejemplo n.º 4
0
 def run(self):
     kwargs = self.args.kwargs
     if kwargs is None:
         kwargs = {}
     systemstats.start_new_system_stat(
         self.args.statName,
         self.args.statType,
         self.args.holdCount,
         self.args.checkInterval,
         **kwargs)
     return plugin_base.PluginReply(0, reply_type="void")
Ejemplo n.º 5
0
 def test_system_stat_happy_path_cpu_idle(self):
     hold_count = 10
     interval = 0.1
     name = str(uuid.uuid4())
     systemstats.start_new_system_stat(
         name,
         "cpu-idle",
         hold_count,
         interval)
     time.sleep((hold_count + 2) * interval)
     stats_d = systemstats.get_stats(name)
     self.assertEqual(len(stats_d['status']), hold_count)
     systemstats.stop_stats(name)
Ejemplo n.º 6
0
 def test_system_stat_stop_twice(self):
     hold_count = 10
     interval = 0.1
     name = str(uuid.uuid4())
     systemstats.start_new_system_stat(
         name,
         "cpu-idle",
         hold_count,
         interval)
     systemstats.stop_stats(name)
     self.assertRaises(
         exceptions.AgentOptionValueNotSetException,
         systemstats.stop_stats,
         name)
Ejemplo n.º 7
0
    def test_basic_net_out(self):
        hold_count1 = 10
        interval1 = 0.1
        name1 = str(uuid.uuid4())

        systemstats.start_new_system_stat(
            name1,
            "net-bytes-out",
            hold_count1,
            interval1)

        time.sleep((hold_count1 + 3) * interval1)
        stats_d = systemstats.get_stats(name1)
        self.assertEqual(len(stats_d['status']), hold_count1)

        ent_1 = stats_d['status'][0]
        self.assertIn('net-bytes-out', ent_1)
        self.assertIn('timestamp', ent_1)
        systemstats.stop_stats(name1)
Ejemplo n.º 8
0
    def test_basic_write_ops(self):
        hold_count1 = 10
        interval1 = 0.1
        name1 = str(uuid.uuid4())

        systemstats.start_new_system_stat(
            name1,
            "disk-write-ops",
            hold_count1,
            interval1)

        time.sleep((hold_count1 + 3) * interval1)
        stats_d = systemstats.get_stats(name1)
        self.assertEqual(len(stats_d['status']), hold_count1)

        ent_1 = stats_d['status'][0]
        self.assertIn('disk-write-ops', ent_1)
        self.assertIn('timestamp', ent_1)
        systemstats.stop_stats(name1)
Ejemplo n.º 9
0
 def run(self):
     systemstats.start_new_system_stat(self.args.statName,
                                       self.args.statType,
                                       self.args.holdCount,
                                       self.args.checkInterval)
     return plugin_base.PluginReply(0, reply_type="void")