Network & Systems Management Solutions Providers

Blog

30 Oct

By Mark Roberts

Exported Alert - Delete Content of Temp Folder if Disk is Full

Automation is spouted from every blog post, whitepaper and rooftop it seems currently, with the keyword DevOps thrown in for good measure. Now some of this can be very complex, with the idea that IT departments can unburden themselves from common or garden tasks and automate them away. In this Blog Bite, I am going to show you a nice and straightforward way to perform some automation to deal with an everyday task of keeping a C: OS drive from filling up and causing immediate performance degradation.

 

I must highlight at the beginning that this is not a one size fits all approach and is a fix to allow some space to be reclaimed to deal with the immediacy of performance affecting a filled volume. You are still very likely to need to go on to the machines and review what further actions are needing to be done; cleanse more files, increase volume size etc.

 

The what, where and how…

 

  • The first thing to ensure is that you have the server populated within Orion and that the C: drive is monitored.
  • Create an alert (Settings > Manage Alerts > Create New) which has the necessary Trigger Logic, such as the following, which uses Custom Properties to be more accurate per volume. Add any further logic to restrict to certain servers etc. as required. Remember you are auto deleting files here, so be clear on what qualifies for inclusion or not.

Customise Wireless Per SSID Add Resources

  • The reset action is suggested to be another rule which looks for the volume to be back to a normal level i.e. not in warning or critical condition
  • Within the Alert definition wizard on the Trigger Action page add a ‘Execute a Program’ action
      • In the window that opens we need to provide the path to the PowerShell command line, which includes the 3 parameters our script needs to work correctly:

 

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy unrestricted -command "c:\SolarWindsScripts\deletetempfiles.ps1 -ComputerName ${N=SwisEntity;M=Node.DNS} -FilePath c:\SolarWindsScripts\FolderList.csv -AlertObjectID${N=Alerting;M=AlertObjectID}"

 

NOTE: I have used the sub folder on C: “SolarWindsScripts” to store the PowerShell script used

 

It is always nice to know what has actually been achieved with this activity and therefore I am leveraging the SolarWinds API (SWIS) to update the Alert Note field with information on how many files and how much space has been deleted.

 

Requirements:

 

  • The PowerShell script utilises WINRM in order that the file delete actions are performed by the remote server
  • The following variables need to be reviewed and adjusted to suit your environment
    • $FilePath - File Location where the CSV file is located for the filtering mechanism. The csv file contains 3 columns:
        • Folder – the folders to be included for deletion
        • OlderThan – file aging filter to exclude files older than x days
        • Exclusion – files or extensions to be excluded from deletion, and yes it does accept wildcards! (eg: *.reg). Leave empty to delete all content
  • The alert Trigger definition utilises a Custom Property on the Volume object VolCriticalThreshold and VolWarningThreshold
    • Adjust the Trigger rule to work for you
  • The API action to insert the results into the Alert Note field requires the credentials to be configured
    • Edit the PS1 file and update the information on line 91. The use of SecureString is recommended
  • One final obvious statement, ensure you enable the alert in Alert Manager to allow this to do its magic.

 

The main thing here is that the script has all the power, so you can extend this to other folders very easily and also with PowerShell perform tasks like emptying recycle bins for example.

 

I do hope you find this useful and please post back if you have an example of how this has helped you.

 

>>>DOWNLOAD EXPORTED ALERT - DELETE CONTENT OF TEMP FOLDER IF DISK IS FULL<<<

 

Training Courses for SolarWinds Customers

Prosperon Networks are the UK's leading authority on SolarWinds IT Management Solutions. We run training courses that suit a number of roles in your organisation, these courses cater for engineers, helpdesk operators and management personnel who all use monitoring platforms differently. The SolarWinds products retain their simplicity and ease of use, however product training in some form is recommended to get the most out of the tools we use every day.

 

 

 

 

15 Jan5 Day Administrator Course for SolarWinds

Training covers all core Orion products & SCP Exam…

23 April5 Day Administrator Course for SolarWinds

Training covers all core Orion products & SCP Exam…