Esempio n. 1
0
File: app.py Progetto: manasg/amon
    def get(self):
        date_from = self.get_argument('date_from', False)
        date_to = self.get_argument('date_to', False)
        charts = self.get_arguments('charts', None)

        if date_from:
            date_from = datestring_to_utc_datetime(date_from)
        # Default - 24 hours period
        else:
            day = timedelta(hours=24)
            date_from = self.now - day

        if date_to:
            date_to = datestring_to_utc_datetime(date_to)
        else:
            date_to = self.now

        date_from = datetime_to_unixtime(date_from)
        date_to = datetime_to_unixtime(date_to)

        if len(charts) > 0:
            active_checks = charts
        else:
            active_checks = settings.SYSTEM_CHECKS

        checks = system_model.get_system_data(active_checks, date_from, date_to)
        first_check_date = system_model.get_first_check_date()

        # Convert the dates to local time for display
        first_check_date = utc_unixtime_to_localtime(first_check_date)
        date_from = utc_unixtime_to_localtime(date_from)
        date_to = utc_unixtime_to_localtime(date_to)

        # Get the difference between UTC and localtime - used to display 
        # the ticks in the charts
        zone_difference = localtime_utc_timedelta()

        # Get the max date - utc, converted to localtime
        max_date = utc_now_to_localtime()

        if checks != False:
            network = []
            network_interfaces = []

            disk = []
            volumes = []

            # Add network adapters 
            if 'network' in active_checks:
                for check in checks['network']:
                    network.append(check)   

                _interfaces = get_network_interfaces()
                for interface in _interfaces:
                    if interface not in network_interfaces:
                        network_interfaces.append(interface)

            # Add disk volumes
            if 'disk' in active_checks:
                for check in checks['disk']:
                    disk.append(check)

                _volumes = get_disk_volumes()
                for volume in _volumes:
                    if volume not in volumes:
                        volumes.append(volume)

            self.render('system.html',
                    current_page='system',
                    active_checks=active_checks,
                    charts=charts,
                    checks=checks,
                    network=network,
                    network_interfaces=network_interfaces,
                    volumes=volumes,
                    disk=disk,
                    date_from=date_from,
                    date_to=date_to,
                    first_check_date=first_check_date,
                    zone_difference=zone_difference,
                    max_date=max_date
                    )
Esempio n. 2
0
    def get(self):

        date_from = self.get_argument('date_from', False)
        date_to = self.get_argument('date_to', False)
        charts = self.get_arguments('charts', None)

        if date_from:
            date_from = datestring_to_unixtime(date_from)

        # Default - 24 hours period
        else:
            day = timedelta(hours=24)
            yesterday = self.now - day

            date_from = datetime_to_unixtime(yesterday)

        if date_to:
            date_to = datestring_to_unixtime(date_to)
        else:
            date_to = datetime_to_unixtime(self.now)

        if len(charts) > 0:
            active_checks = charts
        else:
            active_checks = settings.SYSTEM_CHECKS

        checks = system_model.get_system_data(active_checks, date_from,
                                              date_to)
        first_check_date = system_model.get_first_check_date()

        if checks != False:
            network = []
            network_interfaces = []

            disk = []
            volumes = []

            # Add network adapters
            if 'network' in active_checks:
                for check in checks['network']:
                    network.append(check)

                _interfaces = get_network_interfaces()
                for interface in _interfaces:
                    if interface not in network_interfaces:
                        network_interfaces.append(interface)

            # Add disk volumes
            if 'disk' in active_checks:
                for check in checks['disk']:
                    disk.append(check)

                _volumes = get_disk_volumes()
                for volume in _volumes:
                    if volume not in volumes:
                        volumes.append(volume)

            self.render(
                'system.html',
                current_page='system',
                active_checks=active_checks,
                charts=charts,
                checks=checks,
                network=network,
                network_interfaces=network_interfaces,
                volumes=volumes,
                disk=disk,
                date_from=date_from,
                date_to=date_to,
                first_check_date=first_check_date,
            )
Esempio n. 3
0
    def get(self):

        date_from = self.get_argument('date_from', False)
        date_to = self.get_argument('date_to', False)
        charts = self.get_arguments('charts', None)

        if date_from:
            date_from = datestring_to_unixtime(date_from)

        # Default - 24 hours period
        else:
            day = timedelta(hours=24)
            yesterday = self.now - day

            date_from = datetime_to_unixtime(yesterday)

        if date_to:
            date_to = datestring_to_unixtime(date_to)
        else:
            date_to = datetime_to_unixtime(self.now)

        if len(charts) > 0:
            active_checks = charts
        else:
            active_checks = settings.SYSTEM_CHECKS

        checks = system_model.get_system_data(active_checks, date_from, date_to)
        first_check_date = system_model.get_first_check_date()

        if checks != False:
            network = []
            network_interfaces = []

            disk = []
            volumes = []

            # Add network adapters 
            if 'network' in active_checks:
                for check in checks['network']:
                    network.append(check)	

                _interfaces = get_network_interfaces()
                for interface in _interfaces:
                    if interface not in network_interfaces:
                        network_interfaces.append(interface)

            # Add disk volumes
            if 'disk' in active_checks:
                for check in checks['disk']:
                    disk.append(check)

                _volumes = get_disk_volumes()
                for volume in _volumes:
                    if volume not in volumes:
                        volumes.append(volume)

            self.render('system.html',
                    current_page='system',
                    active_checks=active_checks,
                    charts=charts,
                    checks=checks,
                    network=network,
                    network_interfaces=network_interfaces,
                    volumes=volumes,
                    disk=disk,
                    date_from=date_from,
                    date_to=date_to,
                    first_check_date=first_check_date,
                    )
Esempio n. 4
0
    def get(self):
        date_from = self.get_argument('date_from', False)
        date_to = self.get_argument('date_to', False)
        charts = self.get_arguments('charts', None)

        if date_from:
            date_from = datestring_to_utc_datetime(date_from)
        # Default - 24 hours period
        else:
            day = timedelta(hours=24)
            date_from = self.now - day

        if date_to:
            date_to = datestring_to_utc_datetime(date_to)
        else:
            date_to = self.now

        date_from = datetime_to_unixtime(date_from)
        date_to = datetime_to_unixtime(date_to)

        if len(charts) > 0:
            active_checks = charts
        else:
            active_checks = settings.SYSTEM_CHECKS

        checks = system_model.get_system_data(active_checks, date_from,
                                              date_to)
        first_check_date = system_model.get_first_check_date()

        # Convert the dates to local time for display
        first_check_date = utc_unixtime_to_localtime(first_check_date)
        date_from = utc_unixtime_to_localtime(date_from)
        date_to = utc_unixtime_to_localtime(date_to)

        # Get the difference between UTC and localtime - used to display
        # the ticks in the charts
        zone_difference = localtime_utc_timedelta()

        # Get the max date - utc, converted to localtime
        max_date = utc_now_to_localtime()

        if checks != False:
            network = []
            network_interfaces = []

            disk = []
            volumes = []

            # Add network adapters
            if 'network' in active_checks:
                for check in checks['network']:
                    network.append(check)

                _interfaces = get_network_interfaces()
                for interface in _interfaces:
                    if interface not in network_interfaces:
                        network_interfaces.append(interface)

            # Add disk volumes
            if 'disk' in active_checks:
                for check in checks['disk']:
                    disk.append(check)

                _volumes = get_disk_volumes()
                for volume in _volumes:
                    if volume not in volumes:
                        volumes.append(volume)

            self.render('system.html',
                        current_page='system',
                        active_checks=active_checks,
                        charts=charts,
                        checks=checks,
                        network=network,
                        network_interfaces=network_interfaces,
                        volumes=volumes,
                        disk=disk,
                        date_from=date_from,
                        date_to=date_to,
                        first_check_date=first_check_date,
                        zone_difference=zone_difference,
                        max_date=max_date)