Appearance
Storage Item Editor
The Storage Editor allows you to create and save Storage Items. Storage Items are any kind of combination of text or numbers or formats like JSON. To get more details on Storage Items take a look at What are Storage Items?
Initial Screen
Below shows the initial state of the screen when no storage item is opened.
| Item | Description |
|---|---|
| Open | This will show a storage item selection dialog for opening a storage item |
| New | Clicking new will create a new storage item and will show the editor |
| Manage | Clicking on this will show the storage item manager screen. See more about the Manage Button at Manage Button |
| Mission Editor | This is a quick navigation button that will take you to the Mission Editor screen |
Opened Storage Item Editor
After pressing the Open button and selecting an existing storage item or pressing the New button, the storage item editor will appear. You can put any type of text or numbers or any format that you want into the editor. There are two main editor modes of Text or JSON. When text mode is on, you can write any format of text or numbers that you want. When JSON mode is on the editor will require you to enter proper JSON.
| Item | Description |
|---|---|
| Save | Clicking this button will save your storage item content |
| Save As | Clicking this button will save the existing content by a different name |
| Access | Clicking on this button will load the storage item access keys screen |
| text/json | These two buttons switch between text viewing mode or json viewing mode. When in json viewing mode the editor will require properly formatted json |
Access Dialog
When you press on the Access button you will be shown the Storage Item Access Keys interface. This is an important interface that allows you to give external access to your storage items. Allowing external access to your storage items enables you to integrate outside systems into your missions.
When you first load the access screen and you don't have any existing keys created you will see the following interface. You can either close the Access interface or you can press on the "Add New Key" button on the top right corner.
Creating a New Access Key
When you are in the Access Key Dialog screen it means that you are editing the access keys for the current storage item that you have loaded. To create a new access key press on the "Add New Key" button on the top right corner and you will see the following interface.
| Item | Description |
|---|---|
| Expire in | This dropdown selection will give you several options for when the key will expire. |
| Permissions | This dropdown selection give you the option for how the external access is permitted to use the storage item. The options are READ, WRITE, or READ/WRITE. READ access only allows external systems to read the specified storage item. WRITE access only allows external systems to write values to the storage item. READ/WRITE access allow the external systems to both read and write to the storage item. |
| Cancel | Press on this button to exit out of the creating mode and go back the the Access dialog |
| Submit | Press on this button and the key will be created based on your selections. |
Once you have decided on the expiration and access level for the access key press the Submit button.
Using the Access Key
When an access key has been created you have several options in the use and management of the access key. In the top right corner you can delete the key. When you press this the key will be deleleted and all access from that key will be denied.
You can on also press on the COPY button next to the key-id text. When you press this the key-id will be put into your clipboard and can be pasted in your external systems.
Another feature is the ability to get a quick cURL command for the permission type(s) that you have enabled. If you click on the READ under the permissions a complete cURL command will be placed into your clipboard which can then paste into a terminal and run the command. Here is an ecample of what the READ button will produce.
curl --location 'https://api.robotagentz.com/v1/storage-get' --header 'Content-Type: application/json' --data '{"storagekey":"042848ed283177474a108d876735c96c15d56f635391503f"}'Running this in the terminal will result in something like this:
Here is an example when you press on the WRITE button permissions. You will notice that this curl command has a content section. This is where you put in your content to write to the storage item. Keep in mind that this is a destructive write so any value that the storage had before the write will be erased.
curl --location 'https://api.robotagentz.com/v1/storage-save' --header 'Content-Type: application/json' --data '{"storagekey":"5925d65786710d6371608fffca87ef754489de7fa8e707b4","content":"{\n\t\"first\":\"Darth1\",\n\t\"second\":\"Vader1\"\n}"}'Running this in the terminal will result in something like this:
Possible Applications of the Access Keys
The storage access keys open up RobotAgentz to external access meaning that you can run cURL commands on your local machine or server to make things happen in your Agent missions.
Trigger an Agent Launch Example
You might have a scenario where you want to launch an agent to run one of your missions when your server is in a specific state. As an example we could monitor a log file on the server and when we see a specific type of log entry we could cURL write to a RobotAgentz storage item to trigger a agent to execute a mission. Maybe the mission goes through a process where it has a specific chain of command that it needs to alert via email. It emails the person at the bottom of the list, and if they don't respond that they are taking the task then the mission will go to the next person in the list.
The server side could be a Python or bash script...anything really that can monitor items locally and use a cURL command.
Here is a simple Python example that monitors the harddrive percent full and if it is above 75% then it will run a cURL command of the WRITE example above. The cURL command will write a "1" to the storage item which will then trigger an agent to be launched with a mission.
import psutil
import subprocess
import time
import logging
# Configure logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(message)s',
filename='drive_monitor.log'
)
def get_drive_usage(mount_point='/'):
"""Get the disk usage percentage for the specified mount point."""
try:
disk = psutil.disk_usage(mount_point)
return disk.percent
except Exception as e:
logging.error(f"Error getting disk usage: {e}")
return None
def run_curl_command():
"""Execute the curl command when disk usage exceeds threshold."""
curl_cmd = "curl --location 'https://api.robotagentz.com/v1/storage-save' --header 'Content-Type: application/json' --data '{\"storagekey\":\"5925d65786710d6371608fffca87ef754489de7fa8e707b4\",\"content\":\"1\"}'"
try:
result = subprocess.run(curl_cmd, shell=True, capture_output=True, text=True)
logging.info(f"curl command executed: {result.stdout}")
if result.stderr:
logging.error(f"curl command error: {result.stderr}")
except subprocess.SubprocessError as e:
logging.error(f"Error executing curl command: {e}")
def main():
# Configuration
THRESHOLD = 75.0 # Disk usage threshold in percentage
CHECK_INTERVAL = 300 # Check every 5 minutes (300 seconds)
MOUNT_POINT = '/' # Monitor root filesystem, change if needed
logging.info("Starting disk usage monitor")
while True:
usage = get_drive_usage(MOUNT_POINT)
if usage is None:
time.sleep(CHECK_INTERVAL)
continue
logging.info(f"Current disk usage: {usage}%")
if usage > THRESHOLD:
logging.warning(f"Disk usage ({usage}%) exceeds threshold ({THRESHOLD}%)")
run_curl_command()
else:
logging.info(f"Disk usage ({usage}%) is below threshold ({THRESHOLD}%)")
time.sleep(CHECK_INTERVAL)
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
logging.info("Disk usage monitor stopped by user")
except Exception as e:
logging.error(f"Unexpected error: {e}")If you prefer using BASH over Python then here is the same feature but made using a BASH script.
#!/bin/bash
# Configuration
THRESHOLD=75 # Disk usage threshold in percentage
CHECK_INTERVAL=300 # Check every 5 minutes (300 seconds)
MOUNT_POINT="/" # Monitor root filesystem
LOG_FILE="drive_monitor.log"
CURL_CMD="curl --location 'https://api.robotagentz.com/v1/storage-save' --header 'Content-Type: application/json' --data '{\"storagekey\":\"5925d65786710d6371608fffca87ef754489de7fa8e707b4\",\"content\":\"1\"}'"
# Logging function
log_message() {
local level="$1"
local message="$2"
echo "$(date '+%Y-%m-%d %H:%M:%S') - $level - $message" >> "$LOG_FILE"
}
# Get disk usage percentage
get_drive_usage() {
df -h "$MOUNT_POINT" | tail -n 1 | awk '{print $5}' | tr -d '%'
}
# Main loop
log_message "INFO" "Starting disk usage monitor"
while true; do
usage=$(get_drive_usage)
if [ $? -ne 0 ]; then
log_message "ERROR" "Failed to get disk usage"
sleep "$CHECK_INTERVAL"
continue
fi
log_message "INFO" "Current disk usage: ${usage}%"
if [ "$usage" -gt "$THRESHOLD" ]; then
log_message "WARNING" "Disk usage (${usage}%) exceeds threshold (${THRESHOLD}%)"
if eval "$CURL_CMD" >> "$LOG_FILE" 2>&1; then
log_message "INFO" "curl command executed successfully"
else
log_message "ERROR" "Failed to execute curl command"
fi
else
log_message "INFO" "Disk usage (${usage}%) is below threshold (${THRESHOLD}%)"
fi
sleep "$CHECK_INTERVAL"
doneIf you want this in a different programming language you can always paste one of the code sets above into an AI and ask for it to make it into another language.
On the RobotAgentz side we will need to first create a mission that will monitor the storage item and will launch a child agent it the value of the storage item is 1.
The following is a simple example of how a mission could be designed to monitor the storage item "mytrigger" and if it is equal to "1" it will launch and agent with the mission "email multi".