Esempio n. 1
0
def system_load():
    """check load average for last 15 minutes"""

    with open('/proc/loadavg') as f:
        loadavg_line = f.read()

    avg = float(loadavg_line.split()[2])
    if avg > LOAD_THRESHOLD:
        raise CheckFailed('Heavy load for last 15 minutes: %s' % avg)
Esempio n. 2
0
def check_space_for_path(path):
    if not os.path.exists(path):
        logger.warn('%s does not exist for disk space check' % path)
    else:
        disk_stats = os.statvfs(path)
        bytes_available = disk_stats.f_bsize * disk_stats.f_bavail
        if bytes_available < LOWSPACE_THRESHOLD:
            msg = '%s is low on disk space'  % path
            raise CheckFailed(msg)
Esempio n. 3
0
def _check_layer_capabilities(layer):
    try:
        layer.metadata()
        return
    except:
        pass
    url = settings.INTERNAL_GEOSERVER_BASE_URL + "%s/%s/" % tuple(
        layer.typename.split(':'))
    url = url + "wms?request=getcapabilities&version=1.1.0"
    try:
        xml = urlopen(url).read()
    except Exception, ex:
        raise CheckFailed('error reading from url: %s, %s', url, ex)
Esempio n. 4
0
def _check_layer_latlon_bbox(layer):
    if layer.resource.latlon_bbox is None:
        raise CheckFailed('missing bbox')
Esempio n. 5
0
def _check_layer():
    pass


def _check_layer_latlon_bbox(layer):
    if layer.resource.latlon_bbox is None:
        raise CheckFailed('missing bbox')


def _check_layer_capabilities(layer):
    try:
        layer.metadata()
        return
    except:
        pass
    url = settings.INTERNAL_GEOSERVER_BASE_URL + "%s/%s/" % tuple(
        layer.typename.split(':'))
    url = url + "wms?request=getcapabilities&version=1.1.0"
    try:
        xml = urlopen(url).read()
    except Exception, ex:
        raise CheckFailed('error reading from url: %s, %s', url, ex)
    try:
        tree = fromstring(xml)
    except:
        raise CheckFailed('invalid xml:\n%s' % xml)
    else:
        if tree.find('ServiceException') is not None:
            raise CheckFailed('Service Exception:\n%s' % xml)
Esempio n. 6
0
def check_for_missing_latlng():
    for f in scan_geoserver_data_dir(lambda x: x.endswith('featuretype.xml')):
        with open(f) as f:
            if 'latLonBoundingBox' not in f.read():
                raise CheckFailed('Missing latLonBoundingBox in %s' % f.name)
Esempio n. 7
0
def check_for_empty_slds():
    for f in files_matching_extension('.sld'):
        if os.stat(f).st_size == 0:
            raise CheckFailed('Empty sld: %s' % f)
Esempio n. 8
0
def ok_response_from(url, timeout=30):
    result = urllib2.urlopen(url, timeout=timeout)
    if result.getcode() != 200:
        raise CheckFailed('Invalid response from %s' % url)