Help Server Commands

Execute Server Commands to Automate Actions

Automate server command execution to minimize manual intervention and improve application/server performance.

Use Case: Automate Disk Cleanup

Consider an e-commerce application that stores audit logs like user transactions in the /home disk partition. One major issue here is when the usage of the /home partition exceeds 80%. This ultimately slows down and affects performance of the application. Although, Site24x7 sends out an alert notifying excess disk usage, the IT operator has to manually move the audit logs to another disk partition /backup to ensure continued performance. 

Problem Statement:

The operator has to manually move the audit logs from /home to /backup for a disk cleanup, which is time consuming and tedious. This might also have an effect on the overall productivity.

Solution:

Automate logs cleanup by executing a mv command. Move the logs from /home to /backup, when the disk usage exceeds 80%. 

mv /home/local/e-commerce/logs /backup/logs/

Add Automation

Supported versions: 18.4.0 & above for Windows | 16.6.0 & above for Linux 

  1. Log in to Site24x7 and go to Admin > IT Automation Templates (+). You can also navigate via Server > IT Automation Templates (+). 
  2. Select the Type of Automation as Server Command.
  3. Provide a Display Name for identification purposes.
    For eg., for the above use case, the display name could be "Disk Cleanup".
  4. Choose the type of OS Platform: Windows | Linux.
  5. Enter the Server Command to be executed. For eg., to move logs from /home to /backup when there is excess disk usage in Linux,
    mv /home/local/e-commerce/logs /backup/logs/
    For Windows, enter command like
    powershell get-executionpolicy
  6. Select Hosts, Tags, or Monitor Groups for executing the server command. You can select multiple hosts for a server command for parallel execution.
    You can choose $LOCALHOST to execute the automation on any host where there is a threshold or status change violation. This is applicable only for server monitors (agent-based).
  7. Enter a Time-out period (in seconds) representing the maximum time period the agent has to wait for the command execution to complete. Post that, there will be a time-out error. This will be captured in the email report, if configured as Yes.
    The time-out is set at 15 seconds, by default. You can define a time-out between 1-90 seconds.
  8. You can choose to Send an Email of the Automation Result to the user group(s) configured in the notification profile. By default, it is set to No. This email will contain parameters including the automation name, type of automation, incident reason, destination hosts, and more.
    If you've multiple automations executed in one data collection, a consolidated email will be sent.
  9. Save the changes.
Once an automation is added, schedule these automations to be executed one after the other.

Notification Profile Settings:

Configure the following settings in the notification profile:

  • Notify Down/Trouble status after executing IT automations associated to the monitor: When set to Yes, if your monitor still faces an outage even after executing the specified action, you'll be immediately alerted about the Down/Trouble status. 
  • Suppress IT Automation of dependent monitors: When the status of the dependent resource is Down, execution of the IT automation is not performed. 

Test Automation

Once you add an automation, go to the IT Automation Summary page (Server IT Automation Templates) and use the  icon for a test run. Read more.

The test run would be applied to all the hosts selected for command execution. An exception to this would be selection of $LOCALHOST as the only host.

Click on the IT Automation Logs to view the list of automations executed by date.

Map Automation

For an automation to be executed, map it with a monitor(s) or an attribute(s). This can be done in two ways:

Related Articles

Was this document helpful?
Thanks for taking the time to share your feedback. We’ll use your feedback to improve our online help resources.

Help Server Commands