Jump to content

notification when file size exceeds limit


turgel

Recommended Posts

Hello,

I was wondering if it is possible to get a notification if a file exceeds a certain file size.

In my case I want to get an alert when a file or a folder exceeds 5 GB. Is that possible?

I only found an option to either monitor the whole harddisk or get an alert when a file changes in size

Link to comment
Share on other sites

  • Staff

Hi,

You can get the file/folder size of a file with powershell (check this link: https://technet.microsoft.com/en-us/library/ff730945.aspx), if the condition matches then you can send a notification with this plugin: http://forum.pulseway.com/topic/962-notification-bridge and then create a scheduled task that will run the script every minute or so.

Chris

Link to comment
Share on other sites

Hi everyone,

After playing around with the powershell i wrote a small script which does the following:

1. get the size of a certain folder 

2. take this result and compare it with a set limit (in this case 7500 Megabytes)

3. if this limit is exceeded it starts the pulseway notifcation bridge and sends out the notification.

 

This is very useful to me, i use it to monitor the sql database size of vmware vcenter.

I will post it here, hopefully it will help someone else:

###########################################################

 

$h = 7500
$colItems = (Get-ChildItem "C:\THISFOLDER" | Measure-Object -property length -sum)
"{0:N2}" -f ($colItems.sum / 1MB) + " MB"


If ($colItems.sum / 1MB -gt $h )

invoke-item "C:\YOURPULSEWAYFOLDER\NOT.lnk"

}

 

##################################################################

 

note: I made a link to the notifcationbridge.exe (NOT.lnk) to give to correct commands, writing it out directly in the powershell didn't work for some reason.

Link to comment
Share on other sites

  • Staff

Hi,

Thank you for posting your script. Here is how you can start a process with arguments from powershell:

$plugin = "C:\Users\paul\Documents\notification-bridge-plugin\Release\NotificationBridge.exe"
&$plugin -p 1 -t "test"

Note: The "NotificationBridge.exe" doesn't need to be in the same directory as Pulseway, neither the .dll file.

Chris

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...