Пример #1
0
 def install_ontransit_cron_scripts(self):
     '''Install cron scripts to make sure ontransit data is up-to-date.
     '''
     
     # check if script folder exists
     if not exists(self.script_dir):
         run('mkdir {0}'.format(self.script_dir))
         
     # check if data folder exists
     if not exists(self.data_dir):
         run('mkdir {0}'.format(self.data_dir))
         
     # prepare nightly update cron script
     with open(os.path.join(CONFIG_TEMPLATE_DIR, 'gtfs_refresh_crontab')) as f:
         cron_template = f.read()
         
     cron_settings = dict(cron_email=self.aws_conf.get('cron_email'),
                          logfile=unix_path_join(self.data_dir, 'nightly_refresh.out'),
                          user=self.user,
                          ontransit_base_folder=self.ontransit_base_folder)
     cron = cron_template.format(**cron_settings)
         
     crontab_update(cron, 'gtfs_refresh_cron')
     
     # prepare block delay purge cron script
     with open(os.path.join(CONFIG_TEMPLATE_DIR, 'block_delay_purge_crontab')) as f:
         cron_template = f.read()
         
     cron_settings = dict(cron_email=self.aws_conf.get('cron_email'),
                          logfile=unix_path_join(self.data_dir, 'blockPurge.out'),
                          user=self.user,
                          ontransit_base_folder=self.ontransit_base_folder)
     cron = cron_template.format(**cron_settings)
         
     crontab_update(cron, 'block_delay_purge_cron')
Пример #2
0
    def install_custom_monitoring(self):
        '''Installs a custom monitoring script to monitor memory and disk utilization.
        '''

        # install helpers
        sudo(
            'yum -y install perl-DateTime perl-Sys-Syslog perl-LWP-Protocol-https'
        )

        # dl scripts
        run('wget http://aws-cloudwatch.s3.amazonaws.com/downloads/CloudWatchMonitoringScripts-1.2.1.zip'
            )
        sudo('unzip CloudWatchMonitoringScripts-1.2.1.zip -d /usr/local')
        run('rm CloudWatchMonitoringScripts-1.2.1.zip')

        # prepare the monitoring crontab
        with open(os.path.join(CONFIG_TEMPLATE_DIR,
                               'monitoring_crontab')) as f:
            cron = f.read()

        cron_settings = dict(
            aws_access_key_id=self.aws_conf.get('aws_access_key_id'),
            aws_secret_key=self.aws_conf.get('aws_secret_access_key'),
            cron_email=self.aws_conf.get('cron_email'))
        aws_logging_cron = cron.format(**cron_settings)

        # start crontab for aws monitoring
        crontab_update(aws_logging_cron, 'aws_monitoring')
Пример #3
0
    def install_ontransit_cron_scripts(self):
        '''Install cron scripts to make sure ontransit data is up-to-date.
        '''

        # check if script folder exists
        if not exists(self.script_dir):
            run('mkdir {0}'.format(self.script_dir))

        # check if data folder exists
        if not exists(self.data_dir):
            run('mkdir {0}'.format(self.data_dir))

        # prepare nightly update cron script
        with open(os.path.join(CONFIG_TEMPLATE_DIR,
                               'gtfs_refresh_crontab')) as f:
            cron_template = f.read()

        cron_settings = dict(cron_email=self.aws_conf.get('cron_email'),
                             logfile=unix_path_join(self.data_dir,
                                                    'nightly_refresh.out'),
                             user=self.user,
                             ontransit_base_folder=self.ontransit_base_folder)
        cron = cron_template.format(**cron_settings)

        crontab_update(cron, 'gtfs_refresh_cron')

        # prepare block delay purge cron script
        with open(
                os.path.join(CONFIG_TEMPLATE_DIR,
                             'block_delay_purge_crontab')) as f:
            cron_template = f.read()

        cron_settings = dict(cron_email=self.aws_conf.get('cron_email'),
                             logfile=unix_path_join(self.data_dir,
                                                    'blockPurge.out'),
                             user=self.user,
                             ontransit_base_folder=self.ontransit_base_folder)
        cron = cron_template.format(**cron_settings)

        crontab_update(cron, 'block_delay_purge_cron')
Пример #4
0
 def install_custom_monitoring(self):
     '''Installs a custom monitoring script to monitor memory and disk utilization.
     '''
     
     # install helpers
     sudo('yum -y install perl-DateTime perl-Sys-Syslog perl-LWP-Protocol-https')
     
     # dl scripts
     run('wget http://aws-cloudwatch.s3.amazonaws.com/downloads/CloudWatchMonitoringScripts-1.2.1.zip')
     sudo('unzip CloudWatchMonitoringScripts-1.2.1.zip -d /usr/local')
     run('rm CloudWatchMonitoringScripts-1.2.1.zip')
     
     # prepare the monitoring crontab        
     with open(os.path.join(CONFIG_TEMPLATE_DIR, 'monitoring_crontab')) as f:
         cron = f.read()
     
     cron_settings = dict(aws_access_key_id=self.aws_conf.get('aws_access_key_id'),
                          aws_secret_key=self.aws_conf.get('aws_secret_access_key'),
                          cron_email=self.aws_conf.get('cron_email'))  
     aws_logging_cron = cron.format(**cron_settings)
         
     # start crontab for aws monitoring
     crontab_update(aws_logging_cron, 'aws_monitoring')