Documentation > Examples >> edit on GitHub

Examples

This repository contains example code for programming against the Crossbar.io Fabric Center (CFC) API to remotely manage and monitor your Crossbar.io Fabric (CF) nodes connected to CFC.

Examples (for user management realms):

The examples can be run via make directives, in which case some necessary parameters are pre-set, e.g.

make ex_status realm=demos

where you need to just replace demos with the name of a management realm that you've created.

Here is how to run the examples with providing a full set of parameters yourself:

$ python3 -u examples/ex_status.py \
    --url wss://fabric.crossbario.com/ws \
    --realm demos \
    --keyfile ${HOME}/.cbf/default.priv
2017-09-08T12:54:28 CFC status:
{'name': 'demos',
 'now': '2017-09-08T10:54:28.220Z',
 'started': '2017-09-06T17:04:59.124Z',
 'tick': 30115,
 'type': 'management',
 'uptime': 'a day',
 'version': '17.9.1'}

The necessary connection parameters include:

  • --url wss://fabric.crossbario.com/ws => the URL of our live CFC (use your own URL here if running CFC OEM)
  • --realm demos => the name of the user management realm to connect (use your own management realm here!)
  • --keyfile => a valid cbsh user key

Examples (for global users realm):

IMPORTANT: While all of above examples need to connect to a user created management realm on CFC, the following examples need to connect to the global users realm on CFC.

Top

Get Status

This example demonstrates how to connect to CFC and retrieve status. That's it. It is the "most basic example".

APIs covered:

Top

Listing nodes

This example demonstrates how to iterate over the CF nodes in a management realm and retrieve detailed node status from nodes which are online.

APIs covered:

Top

Listing workers

This example demonstrates how to iterate over the (currently connected) CF nodes, and on each node, iterate over the currently running workers to retrieve worker information.

APIs covered:

Top

Starting Routers

This example demonstrates how to dynamically start a new router worker on a node, start a realm and a role on the router and finally start a listening transport so the router will accept incoming WAMP connections.

APIs covered:

Top

Starting Proxies

This example demonstrates how to dynamically start and stop proxy workers on a node.

APIs covered:

Top

Starting Guests

This example demonstrates how to dynamically start and stop guest workers on a node.

APIs covered:

Top

Listing Sessions

The example demonstrates listing of WAMP sessions currently joined on router realms running on CF nodes connected to CFC.

This is using the Remote Realm WAMP meta API

The APIs covered:

Top

Listing Registrations and Subscriptions

The example demonstrates listing of WAMP subscriptions and registrations currently active for WAMP sessions on router realms running on CF nodes connected to CFC.

This is using the Remote Realm WAMP meta API

The APIs covered:

Top

Worker CPU Affinity

Demonstrates getting/setting the CPU affinity set of CF workers.

APIs covered:

Top

Process Statistics

This example demonstrates how to retrieve OS process statistics for Crossbar.io Fabric node controller and worker processes.

APIs covered:

Top

Worker Logs

This example demonstrates how to remotely retrieve the log output from a worker running on a node, and how to receive a live feed for such a worker log.

APIs covered:

Top

Message Tracing

Crossbar.io Fabric has an message tracing extensions built into the routing core of Crossbar.io.

This allows to tap into the feeds of WAMP messages flowing through the routing core - in real-time.

The example will iterate over all router workers on all CF nodes, stop all traces (if any), and start a new trace on each router worker. It will run the trace for 10s, stop the traces and retrieve tracing data collected during the trace.

The APIs covered:

Top

Manage Docker

This is under development and not yet working.

Crossbar.io Fabric allows to remotely manage a Docker daemon running on the host the Crossbar.io Fabric node is deployed on.

This allows to dynamically provision, deploy and manage application components wrapped in Docker containers on CF nodes.

The APIs covered:

Top
Community Chat