Exemple #1
0
    def test_current_state(self):
        configuration = SmartMonContext()
        configuration.monitor_name = "testdata"
        configuration.state_variables = monitor('testdata').getLastSample().objects[0]
#        self.assertEqual(configuration.state_variables.result, 0)
        self.assertEqual(lastSample().result, 0)
        self.assertEqual(sum(lastSamples(5).result), 0+1+2+3+4)
Exemple #2
0
 def test_current_state(self):
     configuration = SmartMonContext()
     configuration.monitor_name = "testdata"
     configuration.state_variables = monitor(
         'testdata').getLastSample().objects[0]
     #        self.assertEqual(configuration.state_variables.result, 0)
     self.assertEqual(lastSample().result, 0)
     self.assertEqual(sum(lastSamples(5).result), 0 + 1 + 2 + 3 + 4)
Exemple #3
0
 def setUp(self):
     LOG_FILENAME = "./sFTP_monitor.out__"
     logging.basicConfig(
         filename=LOG_FILENAME,
         level=logging.INFO,
     )
     configuration = SmartMonContext()
     configuration.monitor_name = "test_000"
     configuration.datastore_directory = "./testdata"
Exemple #4
0
 def evaluate(self, script, state_variables=None):
     """Evaluate script."""
     if state_variables is not None:
         for var in state_variables:
             vars()[var] = state_variables[var]
     elif SmartMonContext().state_variables is not None:
         for var in SmartMonContext().state_variables:
             vars()[var] = SmartMonContext().state_variables[var]
     return eval(script)
Exemple #5
0
    def getLastSamples(self, number_of_entries):
        """Return n last samples as a Samples object."""
        configuration = SmartMonContext()
        store = DataStore()
        store.setWorkingDirectory(SmartMonContext().datastore_directory)
        storage = store.getStorage(self.name)

        entries = Samples()
        entries.objects = storage.getLastEntries(number_of_entries)
        return entries
Exemple #6
0
    def getLastSample(self):
        """Return last sample as a Samples object."""
        store = DataStore()
        store.setWorkingDirectory(SmartMonContext().datastore_directory)
        configuration = SmartMonContext()
        storage = store.getStorage(self.name)

        entries = Samples()
        entries.single_entry = True
        entries.objects = storage.getLastEntries(1)
        return entries
Exemple #7
0
def lastSample():
    """Return last n samples for current monitor."""
    configuration = SmartMonContext()
    entries = Samples()
    entries.single_entry = True
    entries.objects = []
    entries.objects.append(configuration.state_variables)
    return entries
Exemple #8
0
    def getLastSamplesForPeriod(self, amount, units):
        """Return last samples for time interval."""
        # print "Samples.getLastTime", number_of_entries, units

        store = DataStore()
        store.setWorkingDirectory(SmartMonContext().datastore_directory)
        storage = store.getStorage(self.name)

        entries = Samples()
        entries.objects = storage.getLastEntriesForPeriod(amount, units)
        return entries
Exemple #9
0
 def test_attribute_getter_table(self):
     configuration = SmartMonContext()
     self.assertEqual(
         monitor('test_000').getLastSample().getTableVar(
             "SRP DM performance measurements", 'dmMonitor.login', 'Value'),
         391)
     self.assertEqual(
         monitor('test_000').getLastSample().
         SRP_DM_performance_measurements['dmMonitor.login']['Value'], 391)
     self.assertEqual(
         monitor('test_000').getLastSample().
         SRP_DM_performance_measurements.dmMonitor_login.Value, 391)
Exemple #10
0
def lastSamples(number_of_entries):
    """Return last n samples for current monitor."""
    configuration = SmartMonContext()

    store = DataStore()
    store.setWorkingDirectory(
        configuration.datastore_directory)  # TODO: move out
    storage = store.getStorage(configuration.monitor_name)

    entries = Samples()
    entries.objects = storage.getLastEntries(number_of_entries)
    return entries
Exemple #11
0
 def setUp(self):
     LOG_FILENAME = "./sFTP_monitor.out__"
     logging.basicConfig(filename=LOG_FILENAME, level=logging.INFO,)
     configuration = SmartMonContext()
     configuration.monitor_name = "test_000"
     configuration.datastore_directory = "./testdata"