How to use the command `ohdear-cli` (with examples)

How to use the command `ohdear-cli` (with examples)

The ohdear-cli is an unofficial command-line interface for Oh Dear, written with Laravel Zero. It allows users to perform various actions related to Oh Dear’s monitoring and maintenance services directly from the command line.

Use case 1: Display details about the currently authenticated user

Code:

ohdear-cli me

Motivation: This use case is helpful when you want to quickly check the details of the user who is currently authenticated with Oh Dear. It provides information about the user’s name, email, and UUID.

Explanation:

  • ohdear-cli: The command to execute the Oh Dear CLI.
  • me: The command option to display details about the currently authenticated user.

Example output:

Name: John Doe
Email: john.doe@example.com
UUID: 12345678-1234-1234-1234-1234567890ab

Use case 2: Add a new site to Oh Dear

Code:

ohdear-cli sites:add url

Motivation: This use case allows you to add a new site to your Oh Dear account directly from the command line. It is convenient when you are managing multiple sites and want to automate the site creation process.

Explanation:

  • ohdear-cli: The command to execute the Oh Dear CLI.
  • sites:add: The command option to add a new site.
  • url: The URL of the site you want to add to Oh Dear.

Example output:

Site added successfully:
- ID: 123
- URL: https://example.com
- Team ID: 456

Use case 3: Display a list of sites and their current status

Code:

ohdear-cli sites:list

Motivation: This use case allows you to get an overview of all your sites and their current status in Oh Dear. It is useful when you want to quickly check the health and performance of your sites from the command line.

Explanation:

  • ohdear-cli: The command to execute the Oh Dear CLI.
  • sites:list: The command option to display a list of sites.

Example output:

Site List:
- ID: 123, URL: https://example1.com, Status: Up
- ID: 456, URL: https://example2.com, Status: Down 
- ID: 789, URL: https://example3.com, Status: Degraded Performance 

Use case 4: Display details about a specific site

Code:

ohdear-cli sites:show site_id

Motivation: This use case allows you to retrieve detailed information about a specific site in Oh Dear. It includes details such as the site’s URL, health status, uptime ratio, and response time. This information can be useful for monitoring and troubleshooting purposes.

Explanation:

  • ohdear-cli: The command to execute the Oh Dear CLI.
  • sites:show: The command option to display details about a specific site.
  • site_id: The ID of the site you want to retrieve details for.

Example output:

Site Details:
- ID: 123
- URL: https://example.com
- Status: Up
- Uptime ratio: 99.9%
- Avg Response Time: 200ms

Conclusion:

The ohdear-cli command is a powerful tool for managing and monitoring your sites in Oh Dear directly from the command line. The provided use cases demonstrate how to retrieve information about the currently authenticated user, add a new site, list all sites, and display details about a specific site. With this CLI, you can automate the management of your Oh Dear account and conveniently monitor the health and performance of your sites.

Related Posts

How to use the command 'kdialog' (with examples)

How to use the command 'kdialog' (with examples)

Kdialog is a command-line utility that allows users to display various types of dialog boxes within shell scripts.

Read More
How to use the command 'zopflipng' (with examples)

How to use the command 'zopflipng' (with examples)

ZopfliPNG is a PNG compression utility developed by Google. It offers an effective way to reduce the file size of PNG images while maintaining their quality.

Read More
How to use the command goreload (with examples)

How to use the command goreload (with examples)

The goreload command is a live reload utility for Go programs.

Read More