Help Server Script

Automate Actions using Server Scripts

Automate an action by uploading a script in one of the supported scripting languages and reduce performance degradation issues.

Use Case: Continuous Delivery

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 and reboot the application to ensure continued performance. 

Problem Statement:

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

Solution:

Execute a script file that will automatically move the audit logs from /home to /backup and reboot the application.

How it Works

Considering the above use case, the Site24x7 Server Monitoring agent will send the disk data to the Site24x7 data center (DC). When there is a threshold violation of 80%, Site24x7 DC will trigger execution of the script by sending the script execution configuration details to the agent to perform the movement of logs from /home to /backup. If the script is a local file, the agent will execute the script and result will be sent to Site24x7 DC, that will be displayed in the Site24x7 web client. If the script is a remote file (uploaded to Site24x7), the agent will download it from Site24x7 DC via an API call, execute the script, and delete the local file. The result will then be displayed in the Site24x7 web client.

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 Script.
  3. Provide a Display Name for identification purposes.
  4. Choose the type of OS Platform: Windows | Linux.
  5. Under Script Format, choose the Scripting Language of the server script.
    • Windows - Batch, PowerShell or VB 
    • Linux - Shell, Python, Python 3, Ruby
  6. Once you select the script type, Enter the File Path of the script file. You can either
    • Enter the absolute path of your script file manually
    • Upload a new script, or 
      • You can upload a maximum of 25 new files
      • Ensure a unique name for every file uploaded
    • Select an existing one from the drop-down
    You can use the Delete option to remove existing script files. The file will be removed from the agent permanently. But, a script file already associated with an automation cannot be deleted. 
  7. If required, enter Arguments to your uploaded script file. In the black window, you will be able to see a preview of your selected file path with the selected language and arguments, if any.
    By default, the script file will be placed in the folder "action_script" under the Windows/Linux agent installation folder($$DEFAULT_PATH$$). To modify the path, edit the Enter the File Path field.
  8. Send Incident Parameters associated to your monitor outage, to be passed along with the body of your script. Learn more.  
    Incident parameters will be passed along with the script only when there is an actual status change or attribute change associated with the monitor. No incident parameters will be sent while executing a test automation.
  9. After uploading the file, Select Hosts for executing the server script.
    You can choose $LOCALHOST to execute the automation on any host where there is a threshold violation or monitor status change. This is applicable only for server monitors (agent-based).
  10. Enter a Time-out period (in seconds) representing the maximum time period the agent has to wait for the script 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.
  11. You can choose to Send an Email of the Automation Result to the user group configured in the notification profile. By default, it is set as 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.
  12. 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 (ServerIT Automation Templates) and use the  icon for a test run. Read more.

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

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 the desired event. 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 Script