-
-
Notifications
You must be signed in to change notification settings - Fork 558
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1045 from jookies/0.10
0.10
- Loading branch information
Showing
43 changed files
with
1,067 additions
and
480 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
version: "3" | ||
|
||
services: | ||
redis: | ||
image: redis:alpine | ||
|
||
rabbit-mq: | ||
image: rabbitmq:alpine | ||
|
||
prometheus: | ||
image: prom/prometheus:latest | ||
restart: unless-stopped | ||
ports: | ||
- '9090:9090' | ||
volumes: | ||
- ./misc/config/prometheus.yml:/etc/prometheus/prometheus.yml | ||
- monitoring_data:/prometheus | ||
command: | ||
- '--config.file=/etc/prometheus/prometheus.yml' | ||
- '--storage.tsdb.path=/prometheus' | ||
- '--web.console.libraries=/etc/prometheus/console_libraries' | ||
- '--web.console.templates=/etc/prometheus/consoles' | ||
- '--web.enable-lifecycle' | ||
depends_on: | ||
- jasmin | ||
|
||
grafana: | ||
image: grafana/grafana | ||
restart: unless-stopped | ||
ports: | ||
- 3000:3000 | ||
environment: | ||
GF_INSTALL_PLUGINS: "grafana-clock-panel,grafana-simple-json-datasource" | ||
volumes: | ||
- monitoring_data:/var/lib/grafana | ||
depends_on: | ||
- prometheus | ||
|
||
jasmin: | ||
build: | ||
context: ./ | ||
dockerfile: ./docker/Dockerfile.dev | ||
container_name: jasmin | ||
volumes: | ||
- ./jasmin:/usr/jasmin/jasmin | ||
ports: | ||
- 2775:2775 | ||
- 8990:8990 | ||
- 1401:1401 | ||
depends_on: | ||
- redis | ||
- rabbit-mq | ||
environment: | ||
REDIS_CLIENT_HOST: redis | ||
AMQP_BROKER_HOST: rabbit-mq | ||
|
||
volumes: | ||
monitoring_data: { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
|
||
MAJOR = 0 | ||
MINOR = 10 | ||
PATCH = 11 | ||
PATCH = 12 | ||
META = '' | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
from twisted.web.resource import Resource | ||
|
||
from jasmin.protocols.http.stats import HttpAPIStatsCollector | ||
from jasmin.protocols.smpp.stats import SMPPClientStatsCollector, SMPPServerStatsCollector | ||
|
||
PROM_METRICS_HTTPAPI = { | ||
'request_count': {'type': b'counter', 'help': b'Http request count.'}, | ||
'interceptor_count': {'type': b'counter', 'help': b'Successful http request count.'}, | ||
'auth_error_count': {'type': b'counter', 'help': b'Authentication error count.'}, | ||
'route_error_count': {'type': b'counter', 'help': b'Routing error count.'}, | ||
'interceptor_error_count': {'type': b'counter', 'help': b'Interceptor error count.'}, | ||
'throughput_error_count': {'type': b'counter', 'help': b'Throughput exceeded error count.'}, | ||
'charging_error_count': {'type': b'counter', 'help': b'Charging error count.'}, | ||
'server_error_count': {'type': b'counter', 'help': b'Server error count.'}, | ||
'success_count': {'type': b'counter', 'help': b'Successful http request count.'}, | ||
} | ||
PROM_METRICS_SMPPC = { | ||
'connected_count': {'type': b'counter', 'help': b'Cumulated number of successful connections.'}, | ||
'disconnected_count': {'type': b'counter', 'help': b'Cumulated number of disconnections.'}, | ||
'bound_count': {'type': b'counter', 'help': b'Number of bound sessions.'}, | ||
'submit_sm_request_count': {'type': b'counter', 'help': b'SubmitSm pdu requests count.'}, | ||
'submit_sm_count': {'type': b'counter', 'help': b'Complete SubmitSm transactions count.'}, | ||
'deliver_sm_count': {'type': b'counter', 'help': b'DeliverSm pdu requests count.'}, | ||
'data_sm_count': {'type': b'counter', 'help': b'Complete DataSm transactions count.'}, | ||
'interceptor_count': {'type': b'counter', 'help': b'Interceptor calls count.'}, | ||
'elink_count': {'type': b'counter', 'help': b'EnquireLinks count.'}, | ||
'throttling_error_count': {'type': b'counter', 'help': b'Throttling errors count.'}, | ||
'interceptor_error_count': {'type': b'counter', 'help': b'Interception errors count.'}, | ||
'other_submit_error_count': {'type': b'counter', 'help': b'Other errors count.'}, | ||
} | ||
PROM_METRICS_SMPPS_API = { | ||
'connected_count': {'type': b'counter', 'help': b'Number of connected sessions.'}, | ||
'connect_count': {'type': b'counter', 'help': b'Cumulated number of connect requests.'}, | ||
'disconnect_count': {'type': b'counter', 'help': b'Cumulated number of disconnect requests.'}, | ||
'interceptor_count': {'type': b'counter', 'help': b'Interceptor calls count.'}, | ||
'bound_trx_count': {'type': b'counter', 'help': b'Number of bound sessions in transceiver mode.'}, | ||
'bound_rx_count': {'type': b'counter', 'help': b'Number of bound sessions in receiver mode.'}, | ||
'bound_tx_count': {'type': b'counter', 'help': b'Number of bound sessions in transmitter mode.'}, | ||
'bind_trx_count': {'type': b'counter', 'help': b'Number of bind requests in transceiver mode.'}, | ||
'bind_rx_count': {'type': b'counter', 'help': b'Number of bind requests in receiver mode.'}, | ||
'bind_tx_count': {'type': b'counter', 'help': b'Number of bind requests in transmitter mode.'}, | ||
'unbind_count': {'type': b'counter', 'help': b'Cumulated number of unbind requests.'}, | ||
'submit_sm_request_count': {'type': b'counter', 'help': b'SubmitSm pdu requests count.'}, | ||
'submit_sm_count': {'type': b'counter', 'help': b'Complete SubmitSm transactions count.'}, | ||
'deliver_sm_count': {'type': b'counter', 'help': b'DeliverSm pdu requests count.'}, | ||
'data_sm_count': {'type': b'counter', 'help': b'Complete DataSm transactions count.'}, | ||
'elink_count': {'type': b'counter', 'help': b'EnquireLinks count.'}, | ||
'throttling_error_count': {'type': b'counter', 'help': b'Throttling errors count.'}, | ||
'interceptor_error_count': {'type': b'counter', 'help': b'Interception errors count.'}, | ||
'other_submit_error_count': {'type': b'counter', 'help': b'Other errors count.'}, | ||
} | ||
|
||
|
||
class Metrics(Resource): | ||
isleaf = True | ||
|
||
def __init__(self, SMPPClientManagerPB, log): | ||
Resource.__init__(self) | ||
|
||
self.SMPPClientManagerPB = SMPPClientManagerPB | ||
self.log = log | ||
|
||
def render_GET(self, request): | ||
""" | ||
/metrics request processing, used for exporting prometheus metrics | ||
""" | ||
|
||
self.log.debug("Rendering /metrics response with args: %s from %s", | ||
request.args, request.getClientIP()) | ||
|
||
request.responseHeaders.addRawHeader(b"content-type", b"text/plain") | ||
request.setResponseCode(200) | ||
|
||
# Init response payload | ||
response = [] | ||
|
||
# Fill httpapi stats | ||
_s = HttpAPIStatsCollector().get() | ||
for metric, descriptor in PROM_METRICS_HTTPAPI.items(): | ||
response.extend([ | ||
b'# TYPE httpapi_%s %s' % (metric.encode(), descriptor['type']), | ||
b'# HELP httpapi_%s %s' % (metric.encode(), descriptor['help']), | ||
('httpapi_%s %s' % (metric, _s.get(metric))).encode(), | ||
]) | ||
|
||
# Fill smppcs stats | ||
_connectors = self.SMPPClientManagerPB.perspective_connector_list() | ||
_stats = {} | ||
for metric, descriptor in PROM_METRICS_SMPPC.items(): | ||
if len(_connectors) > 0: | ||
response.extend([ | ||
b'# TYPE smppc_%s %s' % (metric.encode(), descriptor['type']), | ||
b'# HELP smppc_%s %s' % (metric.encode(), descriptor['help']), | ||
]) | ||
|
||
for _connector in _connectors: | ||
_cid = _connector['id'] | ||
_s = _stats.get(_cid, SMPPClientStatsCollector().get(_cid)) | ||
|
||
response.extend([ | ||
('smppc_%s{cid="%s"} %s' % (metric, _cid, _s.get(metric))).encode(), | ||
]) | ||
|
||
# Fill smpps stats | ||
_s = SMPPServerStatsCollector().get('smpps_01').getStats() | ||
for metric, descriptor in PROM_METRICS_SMPPS_API.items(): | ||
response.extend([ | ||
b'# TYPE smppsapi_%s %s' % (metric.encode(), descriptor['type']), | ||
b'# HELP smppsapi_%s %s' % (metric.encode(), descriptor['help']), | ||
('smppsapi_%s %s' % (metric, _s.get(metric))).encode(), | ||
]) | ||
|
||
# Add padding | ||
response.extend([b'', b'']) | ||
|
||
return b'\n'.join(response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Kubernetes clustering for Jasmin | ||
################################ | ||
|
||
Go to Jasmin docs to get `detailed Kubernetes how-to <https://docs.jasminsms.com/en/latest/installation/index.html#install-k8s>`_. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: jasmin | ||
labels: | ||
app: jasmin | ||
spec: | ||
hostname: jasmin | ||
subdomain: app | ||
containers: | ||
- name: jasmin | ||
image: jookies/jasmin:latest | ||
ports: | ||
- containerPort: 2775 | ||
name: smpp-port | ||
protocol: TCP | ||
- containerPort: 1401 | ||
name: http-port | ||
protocol: TCP | ||
- containerPort: 8990 | ||
name: cli-port | ||
protocol: TCP | ||
lifecycle: | ||
postStart: | ||
exec: | ||
command: [ "sh", "-c", "cp /tmp/jasminconfig/* /etc/jasmin/" ] | ||
volumeMounts: | ||
- name: jasminconfig | ||
mountPath: /tmp/jasminconfig | ||
volumes: | ||
- name: jasminconfig | ||
configMap: | ||
name: etcjasmin | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: app | ||
spec: | ||
selector: | ||
name: jasmin | ||
clusterIP: None | ||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: etcjasmin | ||
data: | ||
jasmin.cfg: | | ||
# This is a simplified config version taken from the /etc/jasmin/jasmin.cfg file | ||
# Some parameters are slightly fine tuned for better performance, amqp and redis | ||
# parameters are updated accordingly to kubernetes requirements. | ||
[sm-listener] | ||
publish_submit_sm_resp = False | ||
submit_max_age_smppc_not_ready = 300 | ||
[dlr] | ||
dlr_lookup_retry_delay = 180 | ||
[amqp-broker] | ||
host = rabbit.mq.farirat.svc.cluster.local | ||
[deliversm-thrower] | ||
http_timeout = 10 | ||
retry_delay = 90 | ||
max_retries = 2 | ||
[dlr-thrower] | ||
http_timeout = 10 | ||
retry_delay = 90 | ||
max_retries = 2 | ||
[redis-client] | ||
host = redis.store.farirat.svc.cluster.local | ||
poolsize = 30 |
Oops, something went wrong.