agent: |
Check disk space
This command checks for the consumed disk space at the root.
- 1fkgSSXIaebh6Sxi4EyygGet available disk space
1
There was a problem that the LLM was not able to address. Please rephrase your prompt and try again.Process the output of df and extract the available disk space percentage.
inputsoutputsparts = dfoutput.split() perc_parts = [x for x in parts if '%' in x] used_disk_space = float(perc_parts[1].strip('%')) available_disk = 100.0 - used_disk_space print(available_disk)copied1 - 2t8xsXDSIdIwlxojVl9ixPerform disk cleanup if needed
2
Perform disk cleanup if needed
There was a problem that the LLM was not able to address. Please rephrase your prompt and try again.Check the available disk space percentage against a threshold and if it drops below it then trigger disk cleanup.
inputsoutputsif available_disk > 25.0: context.skip_sub_tasks = Truecopied2- 2.1vbE8Q3dXkJDvAUrwWQ4BNotify about disk space before cleaning up
2.1
Notify about disk space before cleaning up
There was a problem that the LLM was not able to address. Please rephrase your prompt and try again.inputsoutputschannel = "alerts" message = "The disk has filled up! Only this much left: " + str(available_disk) message += "\n Going to clean up the disk with docker system prune -a -f" cred_label = "slack_creds"copied2.1- 2.1.1jyZjUv9D2aHq1mJJfvtyPost a message to a Slack channel
2.1.1
Post a message to a Slack channel
There was a problem that the LLM was not able to address. Please rephrase your prompt and try again.Post the formatted message to a given Slack channel. Use the cred_label to get the right credentials stored in the backed.
inputsoutputsprint("Message: ", message) print("channel: ", channel) # print("cred_label: ", cred_label) # print("num_duplicates: ", num_duplicates) from slack_sdk import WebClient from slack_sdk.errors import SlackApiError # Retrieve credentials based on a label provided creds_resp = _get_creds(cred_label) creds = creds_resp['creds'] slack_token = creds['password'] # Initialize the Slack client client = WebClient(token=slack_token) # Function to send message to Slack def send_message_to_slack(channel, message): try: response = client.chat_postMessage( channel=channel, text=message ) print("Message sent successfully:", response["ts"]) except SlackApiError as e: print(f"Error sending message: {e.response['error']}") send_message_to_slack(channel, message)copied2.1.1
- 2.2mHtPaDwqLVtVZfeFeAdVClean up disk
2.2
There was a problem that the LLM was not able to address. Please rephrase your prompt and try again.This command prunes all the unused images that bloat our storage. It does not touch the ones that are in use. Deletes stopped containers too.
inputsoutputscmd = "docker system prune -a -f --volumes" op = _exe(hostname, cmd) print(op)copied2.2 - 2.3koLpXP0IGnnApRrcfU5QNotify again after cleaning up the disk
2.3
Notify again after cleaning up the disk
There was a problem that the LLM was not able to address. Please rephrase your prompt and try again.inputsoutputschannel = "alerts" message = "After cleaning up, here's the disk space: \n" message += '```\n' message += _exe(hostname, "df /") message += '```\n' cred_label = "slack_creds"copied2.3- 2.3.1jyZjUv9D2aHq1mJJfvtyPost a message to a Slack channel
2.3.1
Post a message to a Slack channel
There was a problem that the LLM was not able to address. Please rephrase your prompt and try again.Post the formatted message to a given Slack channel. Use the cred_label to get the right credentials stored in the backed.
inputsoutputsprint("Message: ", message) print("channel: ", channel) # print("cred_label: ", cred_label) # print("num_duplicates: ", num_duplicates) from slack_sdk import WebClient from slack_sdk.errors import SlackApiError # Retrieve credentials based on a label provided creds_resp = _get_creds(cred_label) creds = creds_resp['creds'] slack_token = creds['password'] # Initialize the Slack client client = WebClient(token=slack_token) # Function to send message to Slack def send_message_to_slack(channel, message): try: response = client.chat_postMessage( channel=channel, text=message ) print("Message sent successfully:", response["ts"]) except SlackApiError as e: print(f"Error sending message: {e.response['error']}") send_message_to_slack(channel, message)copied2.3.1