Skip to main content
Solved

Is there a way to disable/enable an alert via command line?


Forum|alt.badge.img+2

I am working on some command line automation and need to disable/enable an alert. I see that qoperation execscript is what I need but not seeing a qscript that will do what I want. Looking to disable an alert. Then the opposite to enable it.

Many thanks!

Best answer by RMcG

I think the simplest method would be to use the REST API. If you want a quick way to do this via the Command Line then you can use the QCurl command https://documentation.commvault.com/11.24/expert/134805_executing_rest_apis_using_qcurl.html.

Basic steps...

  • Login using QLogin
  • List the alerts so you can fetch the alert id
    • qcurl -op GET -url "https://{server}/webconsole/api/AlertRule"
  • Disable the alert
    • qcurl -op POST -url "https://{server}/webconsole/api/AlertRule/{alertId}/Action/Disable" -req " "
  • Enable the alert
    • qcurl -op POST -url "https://{server}/webconsole/api/AlertRule/{alertId}/Action/Enable" -req " "

Alternatively if you’re a fan of PowerShell then you can use the Invoke-WebRequest or Invoke-RestAPI method to achieve the same.

Screenshot showing examples of QCurl method in action...

 Alert Operations REST API Docs:

View original
Did this answer your question?

3 replies

Damian Andre
Vaulter
Forum|alt.badge.img+23

@RMcG - thoughts ? :)

 


Forum|alt.badge.img+6
  • Vaulter
  • 30 replies
  • Answer
  • July 14, 2021

I think the simplest method would be to use the REST API. If you want a quick way to do this via the Command Line then you can use the QCurl command https://documentation.commvault.com/11.24/expert/134805_executing_rest_apis_using_qcurl.html.

Basic steps...

  • Login using QLogin
  • List the alerts so you can fetch the alert id
    • qcurl -op GET -url "https://{server}/webconsole/api/AlertRule"
  • Disable the alert
    • qcurl -op POST -url "https://{server}/webconsole/api/AlertRule/{alertId}/Action/Disable" -req " "
  • Enable the alert
    • qcurl -op POST -url "https://{server}/webconsole/api/AlertRule/{alertId}/Action/Enable" -req " "

Alternatively if you’re a fan of PowerShell then you can use the Invoke-WebRequest or Invoke-RestAPI method to achieve the same.

Screenshot showing examples of QCurl method in action...

 Alert Operations REST API Docs:


Forum|alt.badge.img+2

Thank you so much! I’ve been using their qoperation cmds and wrapping them around Powershell. I’ve been avoiding the REST API a bit because I don’t fully understand how to implement it. Let me take a look some more. Thanks again!!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings