Embedding Cockpit

Using Frames
Cockpit URLs
Pinging Cockpit

Cockpit can be embedded in other projects.

Warning

None of the embedding APIs are completely stable at this time.

In addition, any APIs or behavior not explicitly documented here is an internal API and can be changed at any time.

Using Frames

Cockpit can be embedded into a larger web page as a frame. You can control some aspects of Cockpit via the URL. Here's an example:

<html>
  <head>
    <title>Embedded Cockpit</title>
  </head>
  <body>
    This is Cockpit.
    <br/>
    <iframe width="800px" height="600px"
            src="https://sunflower:9090/#server"/>
  </body>
</html>

Cockpit URLs

To confine Cockpit to a single machine, you can omit the "Hosts" element in the breadcrumb trail. The user then has no obvious way to navigate to a different machine.

To achieve this, use a URL like this:

https://server.example.com:9090/#server

Pinging Cockpit

When embedding Cockpit, it may be necessary to check whether Cockpit is available on a server before displaying the embedded Cockpit frame.

To do this perform a /ping requset to Cockpit. This is a simple HTTP GET request. It returns the following:

GET: https://server.example.com:9090/ping
200 OK: { "service": "cockpit" }

The /ping request allows Cross Origin Resource Sharing headers and as such can be performed from Javascript code with any origin. The reqeust can also be made via plain HTTP without SSL.

It is by design that no further information is present in the response.