def test_stats_inc(self): stats = SMPPClientStatsCollector().get(cid = 'test_stats_inc') self.assertEqual(stats.get('bound_count'), 0) stats.inc('bound_count') self.assertEqual(stats.get('bound_count'), 1) stats.inc('bound_count', 5) self.assertEqual(stats.get('bound_count'), 6)
def test_is_singleton(self): i1 = SMPPClientStatsCollector() i2 = SMPPClientStatsCollector() self.assertEqual(i1, i2) i1.get(cid = 'testing').set('last_seqNum', 100) self.assertEqual(i1.get(cid = 'testing').get('last_seqNum'), i2.get(cid = 'testing').get('last_seqNum'), )
def smppcs(self, arg, opts): sc = SMPPClientStatsCollector() headers = [ "#Connector id", "Connected at", "Bound at", "Disconnected at", "Submits", "Delivers", "QoS errs", "Other errs" ] table = [] connectors = self.pb['smppcm'].perspective_connector_list() for connector in connectors: row = [] row.append('#%s' % connector['id']) row.append( formatDateTime(sc.get(connector['id']).get('connected_at'))) row.append(formatDateTime(sc.get(connector['id']).get('bound_at'))) row.append( formatDateTime(sc.get(connector['id']).get('disconnected_at'))) row.append('%s/%s' % (sc.get(connector['id']).get('submit_sm_request_count'), sc.get(connector['id']).get('submit_sm_count'))) row.append('%s/%s' % (sc.get(connector['id']).get('deliver_sm_count'), sc.get(connector['id']).get('data_sm_count'))) row.append(sc.get(connector['id']).get('throttling_error_count')) row.append(sc.get(connector['id']).get('other_submit_error_count')) table.append(row) self.protocol.sendData(tabulate(table, headers, tablefmt="plain", numalign="left").encode('ascii'), prompt=False) self.protocol.sendData('Total connectors: %s' % (len(table)))
def smppcs(self, arg, opts): sc = SMPPClientStatsCollector() headers = ["#Connector id", "Connected at", "Bound at", "Disconnected at", "Submits", "Delivers", "QoS errs", "Other errs"] table = [] connectors = self.pb['smppcm'].perspective_connector_list() for connector in connectors: row = [] row.append('#%s' % connector['id']) row.append(formatDateTime(sc.get(connector['id']).get('connected_at'))) row.append(formatDateTime(sc.get(connector['id']).get('bound_at'))) row.append(formatDateTime(sc.get(connector['id']).get('disconnected_at'))) row.append('%s/%s' % ( sc.get(connector['id']).get('submit_sm_request_count'), sc.get(connector['id']).get('submit_sm_count'))) row.append('%s/%s' % ( sc.get(connector['id']).get('deliver_sm_count'), sc.get(connector['id']).get('data_sm_count'))) row.append(sc.get(connector['id']).get('throttling_error_count')) row.append(sc.get(connector['id']).get('other_submit_error_count')) table.append(row) self.protocol.sendData( tabulate(table, headers, tablefmt="plain", numalign="left").encode('ascii'), prompt=False) self.protocol.sendData('Total connectors: %s' % (len(table)))
def test_get_will_reuse_existent_connector(self): c = SMPPClientStatsCollector() self.assertTrue('test_get_will_reuse_existent_connector' not in c.connectors) i1 = c.get(cid = 'test_get_will_reuse_existent_connector') i2 = c.get(cid = 'test_get_will_reuse_existent_connector') self.assertEqual(i1, i2)
def smppcs(self, arg, opts): sc = SMPPClientStatsCollector() headers = [ "#Connector id", "Bound count", "Connected at", "Bound at", "Disconnected at", "Sent elink at", "Received elink at" ] table = [] connectors = self.pb['smppcm'].perspective_connector_list() for connector in connectors: row = [] row.append('#%s' % connector['id']) row.append(sc.get(connector['id']).get('bound_count')) row.append( formatDateTime(sc.get(connector['id']).get('connected_at'))) row.append(formatDateTime(sc.get(connector['id']).get('bound_at'))) row.append( formatDateTime(sc.get(connector['id']).get('disconnected_at'))) row.append( formatDateTime( sc.get(connector['id']).get('last_sent_elink_at'))) row.append( formatDateTime( sc.get(connector['id']).get('last_received_elink_at'))) table.append(row) self.protocol.sendData(tabulate(table, headers, tablefmt="plain", numalign="left").encode('ascii'), prompt=False) self.protocol.sendData('Total connectors: %s' % (len(table)))
def smppc(self, arg, opts): sc = SMPPClientStatsCollector() headers = ["#Item", "Value"] table = [] for k, v in sc.get(opts.smppc)._stats.iteritems(): row = [] row.append('#%s' % k) if k[-3:] == '_at': row.append(formatDateTime(v)) else: row.append(v) table.append(row) self.protocol.sendData(tabulate(table, headers, tablefmt = "plain", numalign = "left").encode('ascii'))
def smppc(self, arg, opts): sc = SMPPClientStatsCollector() headers = ["#Item", "Value"] table = [] for k, v in sc.get(opts.smppc).getStats().iteritems(): row = [] row.append('#%s' % k) if k[-3:] == '_at': row.append(formatDateTime(v)) else: row.append(v) table.append(row) self.protocol.sendData( tabulate(table, headers, tablefmt="plain", numalign="left").encode('ascii'))
def smppcs(self, arg, opts): sc = SMPPClientStatsCollector() headers = ["#Connector id", "Bound count", "Connected at", "Bound at", "Disconnected at", "Sent elink at", "Received elink at"] table = [] connectors = self.pb['smppcm'].perspective_connector_list() for connector in connectors: row = [] row.append('#%s' % connector['id']) row.append(sc.get(connector['id']).get('bound_count')) row.append(formatDateTime(sc.get(connector['id']).get('connected_at'))) row.append(formatDateTime(sc.get(connector['id']).get('bound_at'))) row.append(formatDateTime(sc.get(connector['id']).get('disconnected_at'))) row.append(formatDateTime(sc.get(connector['id']).get('last_sent_elink_at'))) row.append(formatDateTime(sc.get(connector['id']).get('last_received_elink_at'))) table.append(row) self.protocol.sendData(tabulate(table, headers, tablefmt = "plain", numalign = "left").encode('ascii'), prompt = False) self.protocol.sendData('Total connectors: %s' % (len(table)))
def test_stats_set(self): stats = SMPPClientStatsCollector().get(cid = 'test_stats_set') self.assertEqual(stats.get('last_seqNum'), None) stats.set('last_seqNum', 2) self.assertEqual(stats.get('last_seqNum'), 2)
def test_get_will_create_connector(self): c = SMPPClientStatsCollector() self.assertTrue('test_get_will_create_connector' not in c.connectors) c.get(cid = 'test_get_will_create_connector') self.assertTrue('test_get_will_create_connector' in c.connectors)