# Plans

Plans are statements that are evaluated by the nodes to determine actions to take on resources. Currently there are very limited values available future updates will add significantly more values. Below are two common statements. Once a statement has been defined it can be added to pod unit instance spec by referencing the name as shown below.

```yaml
plan: +/plan/primary
```

The statement below checks if the last timestamp for when the host communicated with the IMDS server is less then 60 seconds ago and if the last heartbeat from the instance was more then 60 seconds ago. Then if both of these conditions are true for 15 seconds the instance is stopped.

```sql
IF instance.last_timestamp < 60 AND instance.last_heartbeat > 60 FOR 15 THEN 'stop'
```

The next statement initiates a start action if the instance is not already running. This will override the user attempting to stop an instance.

```sql
IF instance.state != 'running' THEN 'start'
```

### &#x20;Operators

Below are the available operators and functions of each operator.

| Operator | Function                                                           |
| -------- | ------------------------------------------------------------------ |
| `==`     | Values are equal                                                   |
| `!=`     | Values are not equal                                               |
| `<`      | Int value is less then                                             |
| `>`      | Int value is greater then                                          |
| `<=`     | Int value is less then or equal                                    |
| `>=`     | Int value is greater then or equal                                 |
| `AND`    | Both conditions must be true                                       |
| `OR`     | One of the conditions must be true                                 |
| `FOR`    | The statement must evaluate as true for provided number of seconds |
| `THEN`   | Action to take if statement evaluates as true                      |

### Values

Below are all the values currently available for statements.

<table><thead><tr><th width="220.66656494140625">Key</th><th width="83">Type</th><th>Value</th></tr></thead><tbody><tr><td>unit.name</td><td>string</td><td>Name of unit</td></tr><tr><td>unit.count</td><td>int</td><td>Number of active deployments</td></tr><tr><td>instance.name</td><td>string</td><td>Name of instance</td></tr><tr><td>instance.state</td><td>string</td><td>State of instance. Includes starting, running, stopped, failed, updating and provisioning</td></tr><tr><td>instance.action</td><td>string</td><td>Current action being taken on instance. Includes start, stop and destroy</td></tr><tr><td>instance.processors</td><td>int</td><td>Number of processors on instance</td></tr><tr><td>instance.memory</td><td>int</td><td>Size of instance memory in megabytes</td></tr><tr><td>instance.last_timestamp</td><td>int</td><td>Number of seconds since the last IMDS sync. This indicates if the host is communicating with the IMDS server. It does not indicate the instance is communicating with the IMDS server. This can be used with the last heartbeat to ignore expired heartbeats if the host has not been communicating with the IMDS server.</td></tr><tr><td>instance.last_heartbeat</td><td>int</td><td>Number of seconds since the last instance heartbeat. This indicates if the host and instance are communicating with the IMDS server.</td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.pritunl.com/kb/cloud/components/plans.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
