def check_storage_errors(management, storageact_name, storage_type, subtype, key, warning, critical, verbosity): """Check storage errors for the metric given by key management -- service management object storageact_name -- storage account name storage_type -- blob/queue/table subtype - tx/cap (transactions or capacity) key - needed only for transaction metric warning - Nagios warning level warning - Nagios critical level """ primary_key, _ = retrieve_keys(management, storageact_name.lower()) if not primary_key: return 3, 'Error retrieving storage keys' storage_account = CloudStorageAccount(storageact_name.lower(), primary_key) if not storage_account: return 3, 'Error retrieving storage account' try: table_service = storage_account.create_table_service() except: return 3, 'System error in creating table service' if subtype == 'cap': if storage_type == 'blob': return check_storagecap_errors(table_service) else: return 3, 'Capacity metrics not supported for tables/queues' else: if (not key): return 3, 'Key missing' return check_storagetx_errors(table_service, storage_type, key.lower(), warning, critical, verbosity)
def check_storage_errors(management, storageact_name, storage_type, subtype, key, warning, critical, verbosity): """Check storage errors for the metric given by key management -- service management object storageact_name -- storage account name storage_type -- blob/queue/table subtype - tx/cap (transactions or capacity) key - needed only for transaction metric warning - Nagios warning level warning - Nagios critical level """ primary_key, _ = retrieve_keys(management, storageact_name.lower()) if not primary_key: return 3, 'Error retrieving storage keys' storage_account = CloudStorageAccount(storageact_name.lower(), primary_key) if not storage_account: return 3, 'Error retrieving storage account' try: table_service = storage_account.create_table_service() except: return 3, 'System error in creating table service' if subtype == 'cap': if storage_type == 'blob': return check_storagecap_errors(table_service) else: return 3, 'Capacity metrics not supported for tables/queues' else: if (not key): return 3, 'Key missing' return check_storagetx_errors(table_service, storage_type, key.lower(), warning, critical, verbosity)
errors = [] if not service.deployments: return 1, 'No deployments found' # find the production deployment among deployments production_depl = None for depl in service.deployments: if depl.deployment_slot == 'Production': production_depl = depl break error_code_all = 0 if production_depl: try: storage_account = CloudStorageAccount(storageacct_name, primary_key) table_service = storage_account.create_table_service() table_name = 'WAD'+ str(production_depl.private_id) + \ 'PT'+ '1H' +'R'+'Table' error_code_all = 0 for role in production_depl.role_list: role_clause = 'Role eq \'' + role.role_name + '\'' # we use 2 hours earlier since some times no counters # show up with 1 hour rngtime = (datetime.utcnow() - datetime.min) - \ timedelta(minutes = 120) partition_str = '0' + \ str(((rngtime.days * 24 * 60 * 60 + rngtime.seconds) * 1000 * 1000 + rngtime.microseconds)*10) partition_clause = 'PartitionKey ge \'' + partition_str + '\'' counter_clause = 'CounterName eq \'' + counter[ 'perf_counter'] + '\''
errors = [] if not service.deployments: return 1, 'No deployments found' # find the production deployment among deployments production_depl = None for depl in service.deployments: if depl.deployment_slot == 'Production': production_depl = depl break error_code_all = 0 if production_depl: try: storage_account = CloudStorageAccount(storageacct_name, primary_key) table_service = storage_account.create_table_service() table_name = 'WAD'+ str(production_depl.private_id) + \ 'PT'+ '1H' +'R'+'Table' error_code_all = 0 for role in production_depl.role_list: role_clause = 'Role eq \''+ role.role_name + '\'' # we use 2 hours earlier since some times no counters # show up with 1 hour rngtime = (datetime.utcnow() - datetime.min) - \ timedelta(minutes = 120) partition_str = '0' + \ str(((rngtime.days * 24 * 60 * 60 + rngtime.seconds) * 1000 * 1000 + rngtime.microseconds)*10) partition_clause = 'PartitionKey ge \''+ partition_str +'\'' counter_clause = 'CounterName eq \''+counter['perf_counter']+'\'' filter_str = role_clause + ' and ' + \