Example #1
0
def list_monitors(aws_namespaces=None):
    '''List the monitors tagged with the matching namesspaces
    
        namespaces - list of AWS namespaces to match, i.e. ['AWS/EC2']
    
    If no aws_namespaces are provided, all tags starting with 'AWS/' will be
    matched.
        
    '''
    # TODO handle cases where we want to get them all and filter, as well
    # as multiple tagged queries to Monitis API, with flag or heuristic
    # For now, just grab them all and filter

    if aws_namespaces is not None:
        return [
            mon for mon in get_monitors()
            if mon.get_monitor_info()['tag'] in aws_namespaces
        ]
    else:
        # if no namespace given, match every tag starting with 'AWS/'
        return [
            mon for mon in get_monitors()
            if re.match('AWS/',
                        mon.get_monitor_info()['tag'])
        ]
Example #2
0
 def test_get_monitors(self):
     mon = CustomMonitor.add_monitor(
         self.result_params,name='gmtest',tag='gmtesttag')
     mon_list = get_monitors(tag='gmtesttag',m_type='custom')
     mon.delete_monitor()
     assert_equal(len(mon_list), 1)
     assert_equal(mon_list[0].tag, 'gmtesttag')
Example #3
0
def list_monitors(aws_namespaces=None):
    '''List the monitors tagged with the matching namesspaces
    
        namespaces - list of AWS namespaces to match, i.e. ['AWS/EC2']
    
    If no aws_namespaces are provided, all tags starting with 'AWS/' will be
    matched.
        
    '''
    # TODO handle cases where we want to get them all and filter, as well
    # as multiple tagged queries to Monitis API, with flag or heuristic
    # For now, just grab them all and filter

    if aws_namespaces is not None:
        return [mon for mon in get_monitors() 
            if mon.get_monitor_info()['tag'] in aws_namespaces]
    else:
        # if no namespace given, match every tag starting with 'AWS/'
        return [mon for mon in get_monitors()
            if re.match('AWS/', mon.get_monitor_info()['tag']) ]
Example #4
0
def delete_monitor(id=None, name=None):
    '''Delete the specified monitor
    
    If both name and id are given, prefer id'''
    if id is None:
        # get the ID based on the name
        monitor_list = [mon for mon in get_monitors()
            if mon.get_monitor_info()['name'] == name]
        monitor = monitor_list[0] # TODO handle case where len != 1
    else:
        monitor = CustomMonitor.fetch(monitor_id=id)
    monitor.delete_monitor()
Example #5
0
def delete_monitor(id=None, name=None):
    '''Delete the specified monitor
    
    If both name and id are given, prefer id'''
    if id is None:
        # get the ID based on the name
        monitor_list = [
            mon for mon in get_monitors()
            if mon.get_monitor_info()['name'] == name
        ]
        monitor = monitor_list[0]  # TODO handle case where len != 1
    else:
        monitor = CustomMonitor.fetch(monitor_id=id)
    monitor.delete_monitor()
Example #6
0
def list_monitors():
    try:
        cm_list = get_monitors(tag='netstat')
    except MonitisError, err:
        raise Usage(err)