示例#1
0
    def process_request(self, request):

        #  Defaults
        request.now = datetime.utcnow()
        request.debug = settings.DEBUG
        request.version = VERSION

        request.timezone = 'UTC'

        if request.user.is_authenticated():
            user_preferences = user_preferences_model.get_preferences(user_id=request.user.id)

            user_timezone = user_preferences.get('timezone', 'UTC')
            request.timezone = str(user_timezone)  # Pytz timezone object
            request.timezone_offset = localtime_utc_timedelta(tz=request.timezone)

            request.account_id = settings.ACCOUNT_ID

            request.dashboards = dashboard_model.get_all(account_id=request.account_id)

            request.bookmarks = bookmarks_model.get_all()

            # Enable disable minified js and css files
            try:
                request.devmode = settings.DEVMODE
            except:
                request.devmode = False
示例#2
0
文件: app.py 项目: manasg/amon
    def get(self):

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

        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)


        all_processes_checks = settings.PROCESS_CHECKS

        if len(processes) > 0:
            processes_checks = processes
        else:
            processes_checks = settings.PROCESS_CHECKS

        process_data = process_model.get_process_data(processes_checks, date_from, date_to)

        # Convert the dates to local time for display
        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()

        self.render('processes.html',
                current_page=self.current_page,
                all_processes_checks=all_processes_checks,
                processes_checks=processes_checks,
                processes=processes,
                process_data=process_data,
                date_from=date_from,
                date_to=date_to,
                zone_difference=zone_difference,
                max_date=max_date
                )
示例#3
0
文件: app.py 项目: marshall007/amon
    def get(self):

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

        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)

        all_processes_checks = settings.PROCESS_CHECKS

        if len(processes) > 0:
            processes_checks = processes
        else:
            processes_checks = settings.PROCESS_CHECKS

        process_data = process_model.get_process_data(processes_checks,
                                                      date_from, date_to)

        # Convert the dates to local time for display
        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()

        self.render('processes.html',
                    current_page=self.current_page,
                    all_processes_checks=all_processes_checks,
                    processes_checks=processes_checks,
                    processes=processes,
                    process_data=process_data,
                    date_from=date_from,
                    date_to=date_to,
                    zone_difference=zone_difference,
                    max_date=max_date)
示例#4
0
文件: app.py 项目: 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
                    )
示例#5
0
文件: app.py 项目: marshall007/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)