mex-docs

What is mcctl?

The mcctl utility is designed to provide access to the MobiledgeX apis from the command line. This is a MobiledgeX supported utility and can be downloaded from Artifactory. Binaries for both MacOS and Linux x86_64 are available.

How to Install mcctl

Once downloaded, you will need to add execute permission to the file in order to execute it. This can be done by using the terminal to run chmod 755 ./mcctl.

Users of MacOS Catalina will need to take an additional step to authorize the application with Gatekeeper. This involves the following steps:

  1. Open finder in the directory (folder) where you have downloaded the mcctl program. This can be done by running open . in the terminal.
  2. Launch the app you’re trying to run and acknowledge the Gatekeeper warning that prevents the app from running.
  3. Head to System Preferences > Security and Privacy > General and look for a note at the bottom of the screen about an app launch being denied.
  4. Click on “Open Anyway” to bypass Gatekeeper and launch the app.

Overview of mcctl

Command Help

Running mmctl with either the -h flag or no arguments will cause it to print the usage information. Additionally, the help information will be displayed when invalid commands or arguments are specified (this behavior can be changed by supplying the --silence-usage flag to mcctl).

$ mcctl
Usage:
  mcctl [command]

Available Commands:
  login
  user            manage users
  role            manage user roles
  org             manage organizations
  controller      register country controllers
  alldata         bulk manage data
  region          manage region data
  config          admin config
  audit           show audit logs
  orgcloudlet     manage Org Cloudlets
  orgcloudletpool manage Org CloudletPools
  metrics         view metrics
  events          view events
  help            Help about any command

Flags:
      --addr string            MC address (default "http://127.0.0.1:9900")
      --data string            json formatted input data, alternative to name=val args list
      --datafile string        file containing json/yaml formatted input data, alternative to name=val args list
      --debug                  debug
  -h, --help                   help for mcctl
      --output-format string   output format: yaml, json, or json-compact (default "yaml")
      --output-stream          stream output incrementally if supported by command (default true)
      --parsable               generate parsable output
      --silence-usage          silence-usage
      --skipverify             don't verify cert for TLS connections
      --token string           JWT token

Use "mcctl [command] --help" for more information about a command.

Additionally, using the keyword help along with the command you wish to view help information on will provide addtiional data. For example, to get help on the audit command option, you can simply run:

$ mcctl  --addr https://console.mobiledgex.net  help audit
show audit logs

Usage:
  mcctl audit [command]

Available Commands:
  showself    
  showorg     

Flags:
  -h, --help   help for audit

Global Flags:
      --addr string            MC address (default "http://127.0.0.1:9900")
      --data string            json formatted input data, alternative to name=val args list
      --datafile string        file containing json/yaml formatted input data, alternative to name=val args list
      --debug                  debug
      --output-format string   output format: yaml, json, or json-compact (default "yaml")
      --output-stream          stream output incrementally if supported by command (default true)
      --parsable               generate parsable output
      --silence-usage          silence-usage
      --skipverify             don't verify cert for TLS connections
      --token string           JWT token

Use "mcctl audit [command] --help" for more information about a command.

### Output Formats
The `mcctl` utility will produce output in three different formats:
* [YAML](https://en.wikipedia.org/wiki/YAML)
* [JSON](https://en.wikipedia.org/wiki/JSON) Data with added whitespace for readability.
* [JSON-compact](https://en.wikipedia.org/wiki/JSON) Data without extra whitespace.

Using mcctl

Logging In

In order to use mcctl, you must first log into the api to retrieve an authorization token.

mcctl login --addr  https://console-stage.mobiledgex.net  name=jschmidt                   
password:
login successful
token saved to /home/jschmidt/.mctoken

Permission Errors

Commands for which you do not have permission to run will be rejected with a 403 return code from the API.

$ mcctl config  --addr  https://console-stage.mobiledgex.net   show   
Error: Forbidden (403), Forbidden
Usage: mcctl config show [flags] [args]

Required Args:


Optional Args:


Flags:
  -h, --help   help for show

Global Flags:
      --addr string            MC address (default "http://127.0.0.1:9900")
      --data string            json formatted input data, alternative to name=val args list
      --datafile string        file containing json/yaml formatted input data, alternative to name=val args list
      --debug                  debug
      --output-format string   output format: yaml, json, or json-compact (default "yaml")
      --output-stream          stream output incrementally if supported by command (default true)
      --parsable               generate parsable output
      --silence-usage          silence-usage
      --skipverify             don't verify cert for TLS connections
      --token string           JWT token

Account Management

The mcctl utility can be used to create, update, and delete account level information with the MeX envrionment for users with appropriate permissions.

User Management

$ mcctl --addr https://console.mobiledgex.net  user

The following user operations are available with the mcctl user command:

Role Management

$ mcctl --addr https://console.mobiledgex.net  role

The following user operations are available with the mcctl role command:

Organization Management

$ mcctl --addr https://console.mobiledgex.net org

The following user operations are available with the mcctl org command:

Metric Commands

The same metrics that are presented in the MeX Web GUI can be viewed from the CLI by using the metrics command to the mcctl utility.

The examples below request the output in JSON format, but it is possible to retrieve the data in YAML or condensed JSON (JSON without extra whitespace formatting).

Note: The mcctl utility provides a stable interface to the MeX APIs. The API can be accessed directly, but the API interface is subject to change.

$ mcctl --addr https://console.mobiledgex.net  metrics

The metrics command will show metrics for:

All metrics commands can be qualified with a time or duration parameter.

Internal Notes: Details on the available metrics are available in the MeX Wiki at this link. This should be added to this doc for the developer portal.

Application Metrics

Required Args:
  region        Region name
  app-org       Organization or Company name of the App
  selector      Comma separated list of metrics to view

Optional Args:
  appname       App name
  appvers       App version
  cluster       Cluster name
  cluster-org   Organization or Company Name that a Cluster is used by
  cloudlet      Name of the cloudlet
  cloudlet-org  Company or Organization name of the cloudlet
  last          Display the last X metrics
  starttime     Time to start displaying stats from
  endtime       Time up to which to display stats

Data Keys

Example

$ mcctl  --addr https://console.mobiledgex.net  --output-format json metrics app region=EU app-org=demoorg selector=cpu,mem,disk,network last=1 appname=mexfastapi10

{
  "data": [
    {
      "Series": [
        {
          "columns": [
            "time",
            "app",
            "ver",
            "cluster",
            "clusterorg",
            "cloudlet",
            "cloudletorg",
            "apporg",
            "pod",
            "cpu",
            "mem",
            "disk",
            "sendBytes",
            "recvBytes"
          ],
          "name": "appinst-network",
          "values": [
            [
              "2020-06-08T22:16:46.88950592Z",
              "mexfastapi10",
              null,
              "fastapiCluster",
              "demoorg",
              "hamburg-main",
              "TDG",
              "demoorg",
              "mexfastapi10",
              null,
              null,
              null,
              603979776,
              138412032
            ]
          ]
        },
        {
          "columns": [
            "time",
            "app",
            "ver",
            "cluster",
            "clusterorg",
            "cloudlet",
            "cloudletorg",
            "apporg",
            "pod",
            "cpu",
            "mem",
            "disk",
            "sendBytes",
            "recvBytes"
          ],
          "name": "appinst-mem",
          "values": [
            [
              "2020-06-08T22:16:46.88950592Z",
              "mexfastapi10",
              null,
              "fastapiCluster",
              "demoorg",
              "hamburg-main",
              "TDG",
              "demoorg",
              "mexfastapi10",
              null,
              269588889,
              null,
              null,
              null
            ]
          ]
        },
        {
          "columns": [
            "time",
            "app",
            "ver",
            "cluster",
            "clusterorg",
            "cloudlet",
            "cloudletorg",
            "apporg",
            "pod",
            "cpu",
            "mem",
            "disk",
            "sendBytes",
            "recvBytes"
          ],
          "name": "appinst-disk",
          "values": [
            [
              "2020-06-08T22:16:46.88950592Z",
              "mexfastapi10",
              null,
              "fastapiCluster",
              "demoorg",
              "hamburg-main",
              "TDG",
              "demoorg",
              "mexfastapi10",
              null,
              null,
              0,
              null,
              null
            ]
          ]
        },
        {
          "columns": [
            "time",
            "app",
            "ver",
            "cluster",
            "clusterorg",
            "cloudlet",
            "cloudletorg",
            "apporg",
            "pod",
            "cpu",
            "mem",
            "disk",
            "sendBytes",
            "recvBytes"
          ],
          "name": "appinst-cpu",
          "values": [
            [
              "2020-06-08T22:16:46.88950592Z",
              "mexfastapi10",
              null,
              "fastapiCluster",
              "demoorg",
              "hamburg-main",
              "TDG",
              "demoorg",
              "mexfastapi10",
              0.24,
              null,
              null,
              null,
              null
            ]
          ]
        }
      ]
    }
  ]
}

Cluster Metrics

Required Args:
  region        Region name
  cluster-org   Organization or Company Name that a Cluster is used by
  selector      Comma separated list of metrics to view

Optional Args:
  cluster       Cluster name
  cloudlet-org  Company or Organization name of the cloudlet
  cloudlet      Name of the cloudlet
  last          Display the last X metrics
  starttime     Time to start displaying stats from
  endtime       Time up to which to display stats

Data Keys

Example

$ mcctl  --addr https://console.mobiledgex.net  --output-format json metrics cluster  region=EU cluster-org=demoorg selector=cpu,mem,disk,network last=1
{
  "data": [
    {
      "Series": [
        {
          "columns": [
            "time",
            "cluster",
            "clusterorg",
            "cloudlet",
            "cloudletorg",
            "cpu",
            "mem",
            "disk",
            "sendBytes",
            "recvBytes"
          ],
          "name": "cluster-network",
          "values": [
            [
              "2020-06-08T22:22:38.972597948Z",
              "action-test-cluster",
              "demoorg",
              "munich-main",
              "TDG",
              null,
              null,
              null,
              675353748,
              30297980534
            ]
          ]
        },
        {
          "columns": [
            "time",
            "cluster",
            "clusterorg",
            "cloudlet",
            "cloudletorg",
            "cpu",
            "mem",
            "disk",
            "sendBytes",
            "recvBytes"
          ],
          "name": "cluster-mem",
          "values": [
            [
              "2020-06-08T22:22:38.972597948Z",
              "action-test-cluster",
              "demoorg",
              "munich-main",
              "TDG",
              null,
              6.191279821549256,
              null,
              null,
              null
            ]
          ]
        },
        {
          "columns": [
            "time",
            "cluster",
            "clusterorg",
            "cloudlet",
            "cloudletorg",
            "cpu",
            "mem",
            "disk",
            "sendBytes",
            "recvBytes"
          ],
          "name": "cluster-disk",
          "values": [
            [
              "2020-06-08T22:22:38.972597948Z",
              "action-test-cluster",
              "demoorg",
              "munich-main",
              "TDG",
              null,
              null,
              15.501801142916749,
              null,
              null
            ]
          ]
        },
        {
          "columns": [
            "time",
            "cluster",
            "clusterorg",
            "cloudlet",
            "cloudletorg",
            "cpu",
            "mem",
            "disk",
            "sendBytes",
            "recvBytes"
          ],
          "name": "cluster-cpu",
          "values": [
            [
              "2020-06-08T22:22:38.972597948Z",
              "action-test-cluster",
              "demoorg",
              "munich-main",
              "TDG",
              0,
              null,
              null,
              null,
              null
            ]
          ]
        }
      ]
    }
  ]
}

Cloudlet Metrics

Required Args:
  region        Region name
  cloudlet-org  Company or Organization name of the cloudlet
  selector      Comma separated list of metrics to view

Optional Args:
  cloudlet      Name of the cloudlet
  last          Display the last X metrics
  starttime     Time to start displaying stats from
  endtime       Time up to which to display stats

Data Keys

Example

mcctl  --addr https://console.mobiledgex.net  --output-format json metrics cloudlet region=EU cloudlet-org=TDG selector=utilization,network,ipusage last=1
{
  "data": [
    {
      "Series": [
        {
          "columns": [
            "time",
            "cloudlet",
            "cloudletorg",
            "vCpuUsed",
            "vCpuMax",
            "memUsed",
            "memMax",
            "diskUsed",
            "diskMax",
            "netSend",
            "netRecv",
            "floatingIpsUsed",
            "floatingIpsMax",
            "ipv4Used",
            "ipv4Max"
          ],
          "name": "cloudlet-utilization",
          "values": [
            [
              "2020-06-08T22:38:00.458128973Z",
              "munich-main",
              "TDG",
              188,
              200,
              350208,
              512000,
              920,
              5000,
              null,
              null,
              null,
              null,
              null,
              null
            ]
          ]
        },
        {
          "columns": [
            "time",
            "cloudlet",
            "cloudletorg",
            "vCpuUsed",
            "vCpuMax",
            "memUsed",
            "memMax",
            "diskUsed",
            "diskMax",
            "netSend",
            "netRecv",
            "floatingIpsUsed",
            "floatingIpsMax",
            "ipv4Used",
            "ipv4Max"
          ],
          "name": "cloudlet-network",
          "values": [
            [
              "2020-06-08T01:52:29.244553765Z",
              "berlin-main",
              "TDG",
              null,
              null,
              null,
              null,
              null,
              null,
              null,
              0,
              null,
              null,
              null,
              null
            ]
          ]
        },
        {
          "columns": [
            "time",
            "cloudlet",
            "cloudletorg",
            "vCpuUsed",
            "vCpuMax",
            "memUsed",
            "memMax",
            "diskUsed",
            "diskMax",
            "netSend",
            "netRecv",
            "floatingIpsUsed",
            "floatingIpsMax",
            "ipv4Used",
            "ipv4Max"
          ],
          "name": "cloudlet-ipusage",
          "values": [
            [
              "2020-06-08T22:38:08.425162762Z",
              "munich-main",
              "TDG",
              null,
              null,
              null,
              null,
              null,
              null,
              null,
              null,
              0,
              10,
              33,
              1004
            ]
          ]
        }
      ]
    }
  ]
}

Event Commands

The same events that are presented in the MeX Web GUI can be viewed from the CLI by using the events command to the mcctl utility. The examples below request the output in JSON format, but it is possible to retrieve the data in YAML or condensed JSON (JSON without extra whitespace formatting).

Note: The mcctl utility provides a stable interface to the MeX APIs. The API can be accessed directly, but the API interface is subject to change.

$ mcctl --addr https://console.mobiledgex.net  events

The events command will show events for:

All events commands can be qualified with a time or duration parameter.

Application Events

Required Args:
  region       Region name
  apporg       Organization or Company Name that a Developer is part of

Optional Args:
  appname      App name
  appvers      App version
  cluster      Cluster name
  cloudlet     Name of the cloudlet
  cloudletorg  Organization name owning of the cloudlet
  last         Display the last X Events
  starttime    Time to start displaying stats from
  endtime      Time up to which to display stats

Data Keys

Example

$ mcctl  --addr https://console.mobiledgex.net  --output-format json events app region=EU apporg=demoorg
{
  "data": [
    {
      "Series": [
        {
          "columns": [
            "time",
            "app",
            "ver",
            "cluster",
            "clusterorg",
            "cloudlet",
            "cloudletorg",
            "apporg",
            "event",
            "status"
          ],
          "name": "appinst",
          "values": [
            [
              "2020-06-11T21:45:37.030622125Z",
              "leotest",
              "1.1",
              "autoclusterleotest",
              "demoorg",
              "dusseldorf-main",
              "TDG",
              "demoorg",
              "DELETED",
              "DOWN"
            ],
            [
              "2020-06-11T16:17:18.954135649Z",
              "leotest",
              "1.1",
              "autoclusterleotest",
              "demoorg",
              "dusseldorf-main",
              "TDG",
              "demoorg",
              "CREATED",
              "UP"
            ],
            [
              "2020-06-11T16:09:28.014006366Z",
              "leotest",
              "1.0",
              "autoclusterleotest",
              "demoorg",
              "hamburg-main",
              "TDG",
              "demoorg",
              "DELETED",
              "DOWN"
            ],
            [
              "2020-05-22T16:50:59.47204115Z",
              "helm3-test",
              "1.0",
              "autoclusterhelm3-test",
              "demoorg",
              "dusseldorf-main",
              "TDG",
              "demoorg",
              "DELETED",
              "DOWN"
            ]
          ]
        }
      ]
    }
  ]
}

Cluster Events

Required Args:
  region       Region name
  clusterorg   

Optional Args:
  cluster      Cluster name
  cloudletorg  Organization name owning of the cloudlet
  cloudlet     Name of the cloudlet
  last         Display the last X Events
  starttime    Time to start displaying stats from
  endtime      Time up to which to display stats

Data Keys

Example

mcctl  --addr https://console.mobiledgex.net  --output-format json events cluster region=EU clusterorg=demoorg
{
  "data": [
    {
      "Series": [
        {
          "columns": [
            "time",
            "cluster",
            "clusterorg",
            "cloudlet",
            "cloudletorg",
            "flavor",
            "vcpu",
            "ram",
            "disk",
            "other",
            "event",
            "status"
          ],
          "name": "clusterinst",
          "values": [
            [
              "2020-06-11T21:45:37.030373227Z",
              "autoclusterleotest",
              "demoorg",
              "dusseldorf-main",
              "TDG",
              "m4.small",
              2,
              2048,
              20,
              "map[]",
              "DELETED",
              "DOWN"
            ],
            [
              "2020-06-11T16:16:56.117330464Z",
              "autoclusterleotest",
              "demoorg",
              "dusseldorf-main",
              "TDG",
              "m4.small",
              2,
              2048,
              20,
              "map[]",
              "CREATED",
              "UP"
            ],
            [
              "2020-06-11T16:09:28.013967166Z",
              "autoclusterleotest",
              "demoorg",
              "hamburg-main",
              "TDG",
              "m4.small",
              2,
              2048,
              20,
              "map[]",
              "DELETED",
              "DOWN"
            ]
          ]
        }
      ]
    }
  ]
}

Cloudlet Events

Required Args:
  region       Region name
  cloudletorg  Organization name owning of the cloudlet

Optional Args:
  cloudlet     Name of the cloudlet
  last         Display the last X Events
  starttime    Time to start displaying stats from
  endtime      Time up to which to display stats

Data Keys

Example

mcctl  --addr https://console.mobiledgex.net  --output-format json events cloudlet region=EU cloudletorg=TDG   
{
  "data": [
    {
      "Series": [
        {
          "columns": [
            "time",
            "cloudlet",
            "cloudletorg",
            "event",
            "status"
          ],
          "name": "cloudlet",
          "values": [
            [
              "2020-06-08T18:29:37.15500575Z",
              "berlin-test",
              "TDG",
              "DELETED",
              "DOWN"
            ],
            [
              "2020-06-08T12:43:46.058384029Z",
              "berlin-test",
              "TDG",
              "CREATED",
              "UP"
            ],
            [
              "2020-06-04T19:11:49.067685911Z",
              "Berlin-Main-Test",
              "TDG",
              "DELETED",
              "DOWN"
            ],
            [
              "2020-06-04T19:09:28.727345388Z",
              "Berlin-Main-Test",
              "TDG",
              "CREATED",
              "UP"
            ],
            [
              "2020-05-15T17:22:31.181937143Z",
              "frankfurt-5glab",
              "TDG",
              "CREATED",
              "UP"
            ]
          ]
        }
      ]
    }
  ]
}

Audit Commands

The mcctl utility can be used to pull audit information for the current user or the current organization.

Self Audit Example

mcctl  --addr https://console.mobiledgex.net  --output-format json audit showself

[
  {
    "operationname": "/api/v1/auth/metrics/app",
    "username": "jay.schmidt",
    "clientip": "172.17.0.1",
    "status": 400,
    "starttime": 1591654143039652,
    "duration": 274,
    "request": "{\"appinst\":{\"app_key\":{\"organization\":\"demoorg\"}},\"region\":\"EU\",\"selector\":\"cpu,mem,disk,network,tcp,udp\"}",
    "response": "{\"message\":\"Invalid appinst selector: tcp\"}",
    "error": "",
    "traceid": "442ca89d3418b6af"
  },
  {
    "operationname": "/api/v1/auth/metrics/cloudlet",
    "username": "jay.schmidt",
    "clientip": "172.17.0.1",
    "status": 400,
    "starttime": 1591654011509158,
    "duration": 193,
    "request": "{\"cloudlet\":{\"organization\":\"TDG\"},\"region\":\"EU\",\"selector\":\"cpu\"}",
    "response": "{\"message\":\"Invalid cloudlet selector: cpu\"}",
    "error": "",
    "traceid": "04a229ee7dfde458"
  },
  {
    "operationname": "/api/v1/login",
    "username": "jay.schmidt",
    "clientip": "172.17.0.1",
    "status": 400,
    "starttime": 1591641868552332,
    "duration": 1082826,
    "request": "{\"username\":\"jay.schmidt\",\"password\":\"\"}",
    "response": "{\"message\":\"Invalid username or password\"}",
    "error": "",
    "traceid": "5d425c8cb9dbc53c"
  }
]

Organization Audit Example

mcctl  --addr https://console.mobiledgex.net  --output-format json audit showorg

[
  {
    "operationname": "/api/v1/login",
    "username": "mcviewer",
    "clientip": "172.17.0.1",
    "status": 200,
    "starttime": 1591656362716240,
    "duration": 94992,
    "request": "",
    "response": "{\"token\":\"\"}",
    "error": "",
    "traceid": "1ab4474ed71c4a40"
  },
  {
    "operationname": "/api/v1/login",
    "username": "cloudops-monitor",
    "clientip": "172.17.0.1",
    "status": 200,
    "starttime": 1591656304644725,
    "duration": 100843,
    "request": "{\"username\":\"cloudops-monitor\",\"password\":\"\"}",
    "response": "{\"token\":\"\"}",
    "error": "",
    "traceid": "7de5361a1c17af69"
  },
  {
    "operationname": "/api/v1/login",
    "username": "mcviewer",
    "clientip": "172.17.0.1",
    "status": 200,
    "starttime": 1591656242564764,
    "duration": 87877,
    "request": "",
    "response": "{\"token\":\"\"}",
    "error": "",
    "traceid": "7b3a4699aef3dcad"
  }
]

Regional commands

The region subcommand provides access to the most commonly used commands for managing a deployment.

Flavor Management

Operator Codes

Cloudlet Management

Cloudlet Pools (Private Edge)

Cluster Management

Application Management

Application Instance Management

Policy Management

Regional Settings

Resource Tagging

Debugging

Device Management

Misc Commands