Example #1
0
def api_check():
    """
    Entry point of /api/checks
    @return: flask.Response
    """
    try:
        interval = int(Config.get_config_value('Checks', 'interval'))
    except NameError:
        interval = int(Config.CR_CONFIG_DEFAULT_CHECKS_INTERVAL)

    vars = {
        'date': datetime_to_timestamp(data.last_check.date),
        'interval': interval,
        'system': {
            'timestamp': datetime_to_timestamp(datetime.datetime.now())
        },
        'uptime': {
            'seconds': data.last_check.load.uptime,
            'boot_date': datetime_to_timestamp(data.last_check.date) - int(data.last_check.load.uptime)
        },
        'cpu': _get_cpu_info(),
        'memory': _get_memory_info(),
        'swap': _get_swap_info(),
        'load': _get_load_info(),
        'disks': _get_disks_info()
    }

    return flask.Response(response=json.dumps(vars),
                          status=200,
                          mimetype="application/json")
Example #2
0
 def test_wrong_timestamp(self):
     date_to_convert = datetime.datetime(2012, 10, 10, 10, 10, 10)
     self.assertNotEquals(cr_date.datetime_to_timestamp(date_to_convert), 1349856611L)
Example #3
0
 def test_datetime_to_timestamp(self):
     date_to_convert = datetime.datetime(2010, 1, 1, 1, 1, 1)
     self.assertEqual(cr_date.datetime_to_timestamp(date_to_convert), 1262307661L)