How to Use the Command 'ohdear-cli' (with Examples)
The ohdear-cli
is an unofficial command-line interface tool designed for interacting with the Oh Dear monitoring service. Built with Laravel Zero, this tool provides developers and system administrators a quick and efficient way to manage their Oh Dear accounts directly from the terminal. By utilizing this CLI, users can perform various tasks such as managing websites, checking statuses, and retrieving user information, all without needing to access the Oh Dear web interface.
Use case 1: Display Details About the Currently Authenticated User
Code:
ohdear-cli me
Motivation for using the example:
Understanding which account you are currently authenticated under is fundamental to managing your digital assets effectively. By checking the details of the currently authenticated user, you can verify that you are operating under the correct profile, especially useful when managing multiple Oh Dear accounts or when access tokens have been shared across teams.
Explanation for every argument:
ohdear-cli
: This is the main command line application allowing users to interact with the Oh Dear service.me
: This command displays details about the account currently authenticated. It effectively queries the API to fetch user-specific information like email, name, and account roles.
Example output:
Name: John Doe
Email: john.doe@example.com
Role: Administrator
Use case 2: Add a New Site to Oh Dear
Code:
ohdear-cli sites:add example.com
Motivation for using the example:
Adding a new site to be monitored is a common task when setting up surveillance on web performance and uptime. This command allows administrators or developers to quickly integrate a new domain into the Oh Dear monitoring system without the need for navigating through a web interface, thereby saving time and automating their workflow.
Explanation for every argument:
ohdear-cli
: This is the command-line tool for accessing Oh Dear services.sites:add
: This subcommand specifies the action of adding a new site.example.com
: This is the URL of the site you wish to add. This argument should be replaced with the actual domain you want to monitor.
Example output:
Site added successfully!
Site ID: 1234
Name: example.com
Status: Monitoring activated
Use case 3: Display a List of Sites and Their Current Status
Code:
ohdear-cli sites:list
Motivation for using the example:
Knowing the current status of your monitored sites is crucial for maintaining uptime and performance levels. By using this command, users can quickly retrieve a list of all the sites they are monitoring, alongside their current statuses (e.g., up or down), without manually browsing through a dashboard.
Explanation for every argument:
ohdear-cli
: The main command for accessing Oh Dear using CLI.sites:list
: This specific command retrieves and displays a list of all sites currently monitored by the authenticated user.
Example output:
1. example.com - Status: Up
2. anotherexample.com - Status: Down
3. mywebsite.com - Status: Up
Use case 4: Display Details About a Specific Site
Code:
ohdear-cli sites:show 1234
Motivation for using the example:
Occasionally, a detailed investigation into a particular site’s performance or status history is required. This command allows users to retrieve comprehensive details about a specific site, which can help in diagnosing issues or understanding its monitoring history and configuration.
Explanation for every argument:
ohdear-cli
: The CLI tool for interacting with the Oh Dear platform.sites:show
: This command indicates that the user wishes to display details about a specific site.1234
: Represents the unique site ID for which you want the details. Replace1234
with the actual site ID you are interested in.
Example output:
Site ID: 1234
Name: example.com
Uptime status: Up
Monitored from: 2019-01-01
Checks: HTTP, SSL certificate
Conclusion:
The ohdear-cli
is a versatile and powerful tool for managing your Oh Dear monitoring services directly from the command line. Whether you are verifying user details, adding a new site, listing all monitored sites, or fetching details of a specific domain, this CLI provides a smooth, quick, and efficient way to ensure that your online assets are effectively monitored and managed.