Jump to content

New Plugin - Disk Space


chef

Recommended Posts

@@CBers I'm not sure I can change the labels on the datasets for the graph. It's calculated in total bytes because that's the information return from the OS.

 

That's why I recalculate more friendly units at the bottom.

 

I'll see what I can do. Maybe just remove the graph labels?

 

What I was able to do was create a scheduled task which monitors drive space and sends admin notifications when a threshold is met.

 

It needs a little more work before I put the changes in the catalogue.

 

Right now it's sending notifications each time the task runs. Once will be enough? Or should it send more?

  • Like 1
Link to comment
Share on other sites

CBers

@@CBers I'm not sure I can change the labels on the datasets for the graph. It's calculated in total bytes because that's the information return from the OS.

 

That's why I recalculate more friendly units at the bottom.

 

I'll see what I can do. Maybe just remove the graph labels?

See what others say ?

 

What I was able to do was create a scheduled task which monitors drive space and sends admin notifications when a threshold is met.

 

It needs a little more work before I put the changes in the catalogue.

 

Right now it's sending notifications each time the task runs. Once will be enough? Or should it send more?

Once per run, perhaps default to an hourly run ?

 

If the Admin hasn't fixed it by then, they can always disabled the ST.

  • Like 1
Link to comment
Share on other sites

@@CBers backend notifications are setup, but after an entire afternoon thinking I was missing something, the notifications are all third party plugins for the server.

 

Question: is the activity log loaded and saved inside a database? or is it read from a file? Or is it read from a db file?

 

If it is in a db I could use sqlite commands to write to the activity log... I've never done that before, but it could be done.

 

There is no other way to access the Alert list on the dashboard that I can see.

 

Looks like the ActivityLog function in the JavaScript is being really choosey about what it posts to the Alert list. It uses

 

events.on(serverNotification, "ActivityLogEntry", onUpdate)

 

 

But only specific alerts get posted there, failed tasks, plugin installs etc.

 

Do you know anything more to help with this conundrum?

Edited by chef
  • Like 1
Link to comment
Share on other sites

maegibbons

For me I use pushover for my emby alerts which will be great with your low disk space notifications.

 

Not having it on the dashboard is not a deal breaker in my eyes.

 

Krs

 

Mark

 

Sent from my SM-N976B using Tapatalk

  • Like 1
Link to comment
Share on other sites

1.0.0.2

 

1. Scheduled Task Added to monitor Disk Space (will run every hour) - this task is hidden by default

 

2. Notifications Added when a drive has surpassed 90% of it's space

Note: Windows decides 90% is the threshold to alert the user of an almost full hard drive. So I guess we can do it too

 

3. Removed chartJS drive donuts tool-tips.

 

TODO: Add custom tool-tips - https://www.chartjs.org/docs/latest/configuration/tooltip.html#external-custom-tooltips

 

I'd be great to get some feedback on the notifications.

 

@@CBers

@@maegibbons

 

 

 

 

Oh yeah, is this math right??

                var threshold = driveInfo.TotalSize - (driveInfo.TotalSize / 10); //Remove 10% of the total from the total
                if (driveInfo.AvailableFreeSpace < threshold) return; //if it's less move on
Edited by chef
  • Like 2
Link to comment
Share on other sites

CBers

1.0.0.2

 

1. Scheduled Task Added to monitor Disk Space (will run every hour) - this task is hidden by default

 

2. Notifications Added when a drive has surpassed 90% of it's space

Note: Windows decides 90% is the threshold to alert the user of an almost full hard drive. So I guess we can do it too

 

I'd be great to get some feedback on the notifications.

Many thanks Chef.

 

I had quite a few notifications overnight, telling me that certain drives were full, such as:

 

T:\ (Transcoding-Temp) disk space almost full - 1.8 TB

S:\ (Bay 5 MSA) disk space almost full - 1.8 TB

M:\ (MDRIVE) disk space almost full - 1.8 TB

 

You can see from the image, that those drives are not full at all:

 

5e2ff2e060c75_EmbyDiskSpace3.jpg

 

Is the maths the wrong way round ?

 

Why is the ST hidden ? Would be nice to have the ability to change the schedule, if nothing else.

 

Great work though Chef and a much needed addition to Emby.

 

Looking forward to future releases :)

 

.

Edited by CBers
  • Like 1
Link to comment
Share on other sites

1.0.0.3 

 

fixed 90% threshold calculation

Scheduled Task is now visible for configurations

  • Like 1
Link to comment
Share on other sites

Dibbes
                var threshold = driveInfo.TotalSize - (driveInfo.TotalSize / 10); //Remove 10% of the total from the total
                if (driveInfo.AvailableFreeSpace < threshold) return; //if it's less move on

 

not sure, but shouldn't that be:

 

var threshold = driveInfo.TotalSize - (driveInfo.TotalSize * 0.9); //Remove 10% of the total from the total

if (driveInfo.AvailableFreeSpace < threshold) return; //if it's less move on

 

or if you cannot use decimals:

 

var threshold = driveInfo.TotalSize - ((driveInfo.TotalSize / 100) * 90); //Remove 10% of the total from the total

if (driveInfo.AvailableFreeSpace < threshold) return; //if it's less move on

 

 

Edit: Looks like you beat me to it... 

Edited by Dibbes
  • Like 1
Link to comment
Share on other sites

I ended up using

 

0.9*driveInfo.totalSpace

 

This might end up with precision floating point number, and I'm not exactly sure how that will affect things. There are a lot bytes in Terabytes and then to calculate a float out of that might be really huge.

 

Might have to round the number.

Edited by chef
Link to comment
Share on other sites

CBers

90% of anything is very confusing.

 

90% of a 1Tb drive is 921Gb, but 90% of a 8Tb drive is 7372Gb.

 

Not sure how easy it would be, but perhaps the threshold should be Gb, rather than a percentage ?

 

I remember from my unix days that I always checked for %, but also included the free space remaining for a filesystem, so you could see if you needed to worry or not, or adjust the threshold.

 

Can't download the latest version of the plugin as it fails.

 

Download validation failed for Disk Space. Probably corrupted during transfer.
at Emby.Server.Implementations.Updates.InstallationManager.PerformPackageInstallation(IProgress`1 progress, String target, PackageVersionInfo package, CancellationToken cancellationToken)
at Emby.Server.Implementations.Updates.InstallationManager.InstallPackageInternal(PackageVersionInfo package, Boolean isPlugin, IProgress`1 progress, CancellationToken cancellationToken)
at Emby.Server.Implementations.Updates.InstallationManager.InstallPackage(PackageVersionInfo package, Boolean isPlugin, IProgress`1 progress, CancellationToken cancellationToken)
at Emby.Server.Implementations.ScheduledTasks.PluginUpdateTask.Execute(CancellationToken cancellationToken, IProgress`1 progress)
at Emby.Server.Implementations.ScheduledTasks.ScheduledTaskWorker.ExecuteInternal(TaskOptions options)
How can I manually run the plugin update ST as @@Luke has hidden them?
Link to comment
Share on other sites

Dibbes

I ended up using

 

0.9*driveInfo.totalSpace

 

This might end up with precision floating point number, and I'm not exactly sure how that will affect things. There are a lot bytes in Terabytes and then to calculate a float out of that might be really huge.

 

Might have to round the number.

 

Why would you want to do that? Just don't give a percentage, but do it in GB or TB...

 

EDIT: and this time it was @@CBers who beat me to it...

Edited by Dibbes
  • Like 1
Link to comment
Share on other sites

Dibbes

 

90% of anything is very confusing.

 

90% of a 1Tb drive is 921Gb, but 90% of a 8Tb drive is 7372Gb.

 

Not sure how easy it would be, but perhaps the threshold should be Gb, rather than a percentage ?

 

I remember from my unix days that I always checked for %, but also included the free space remaining for a filesystem, so you could see if you needed to worry or not, or adjust the threshold.

 

Can't download the latest version of the plugin as it fails.

 

Download validation failed for Disk Space. Probably corrupted during transfer.
at Emby.Server.Implementations.Updates.InstallationManager.PerformPackageInstallation(IProgress`1 progress, String target, PackageVersionInfo package, CancellationToken cancellationToken)
at Emby.Server.Implementations.Updates.InstallationManager.InstallPackageInternal(PackageVersionInfo package, Boolean isPlugin, IProgress`1 progress, CancellationToken cancellationToken)
at Emby.Server.Implementations.Updates.InstallationManager.InstallPackage(PackageVersionInfo package, Boolean isPlugin, IProgress`1 progress, CancellationToken cancellationToken)
at Emby.Server.Implementations.ScheduledTasks.PluginUpdateTask.Execute(CancellationToken cancellationToken, IProgress`1 progress)
at Emby.Server.Implementations.ScheduledTasks.ScheduledTaskWorker.ExecuteInternal(TaskOptions options)
How can I manually run the plugin update ST as @@Luke has hidden them?

 

 

Go to the plugin catalog and reinstall directly from there... When you click on the catalog item, it should display 1.0.0.3, at least it did for me and then click the install button...

  • Like 1
Link to comment
Share on other sites

1.0.0.4

 

Okay so you are right. Currently I have hard coded  the threshold to 5GB's left on the drive.

 

That number should be configurable, however if it is configurable then it should be for each drive because some TV recordings could fill that up pretty quickly. That's going to take some coding.

 

Plus, someone should check my math: (8589934592 bytes * 5) = 5GB

 

 

On average, how big are TV recording (considering commercials haven't been removed). We should have a default that is the size of three or four TV recordings... right?

 

Not sure what happened to the version 1.0.0.3, but 4 should work install properly.

Edited by chef
  • Like 2
Link to comment
Share on other sites

Dibbes

Plus, someone should check my math: (8589934592 bytes * 5) = 5GB

not sure how you got to that number, but 5GB is 5,368,709,120 bytes or 5e+9 bytes, depending how you want to write it out...

  • Like 1
Link to comment
Share on other sites

CBers

On average, how big are TV recording (considering commercials haven't been removed). We should have a default that is the size of three or four TV recordings... right?

 

@@Spaceboy, @@PenkethBoy and @@maegibbons should have a good idea on recording sizes.

Link to comment
Share on other sites

CBers

@@chef I'm still getting the original messages, even though v1.0.0.4 is in use.

 

T:\ (Transcoding-Temp) disk space almost full - 1.8 TB

S:\ (Bay 5 MSA) disk space almost full - 1.8 TB
M:\ (MDRIVE) disk space almost full - 1.8 TB

 

5e305b9c895b9_EmbyDiskSpace4.jpg

 

GetDriveData is returning this.

 

{"DriveName":"C:\\","VolumeLabel":"CDRIVE","TotalSize":499066789888,"UsedSpace":160648175616,"FreeSpace":338418614272,"Format":"NTFS","FriendlyName":"C","FriendlyUsed":"149.6 GB","FriendlyTotal":"464.8GB","FriendlyAvailable":"315.2 GB"},
{"DriveName":"E:\\","VolumeLabel":"Paul's Old CDRIVE","TotalSize":319964573696,"UsedSpace":163385593856,"FreeSpace":156578979840,"Format":"NTFS","FriendlyName":"E","FriendlyUsed":"152.2 GB","FriendlyTotal":"298.0GB","FriendlyAvailable":"145.8 GB"},
{"DriveName":"F:\\","VolumeLabel":"FDRIVE","TotalSize":1000202039296,"UsedSpace":159947808768,"FreeSpace":840254230528,"Format":"NTFS","FriendlyName":"F","FriendlyUsed":"149.0 GB","FriendlyTotal":"931.5GB","FriendlyAvailable":"782.5 GB"},
{"DriveName":"M:\\","VolumeLabel":"MDRIVE","TotalSize":2000396742656,"UsedSpace":712544256,"FreeSpace":1999684198400,"Format":"NTFS","FriendlyName":"M","FriendlyUsed":"679.5 MB","FriendlyTotal":"1.8 TB","FriendlyAvailable":"1.8TB"},
{"DriveName":"R:\\","VolumeLabel":"Bay 9 MSA","TotalSize":3000574668800,"UsedSpace":857840021504,"FreeSpace":2142734647296,"Format":"NTFS","FriendlyName":"R","FriendlyUsed":"798.9 GB","FriendlyTotal":"2.7TB","FriendlyAvailable":"1.9 TB"},
{"DriveName":"S:\\","VolumeLabel":"Bay 5 MSA","TotalSize":2000396742656,"UsedSpace":196579328,"FreeSpace":2000200163328,"Format":"NTFS","FriendlyName":"S","FriendlyUsed":"187.5 MB","FriendlyTotal":"1.8 TB","FriendlyAvailable":"1.8TB"},
{"DriveName":"T:\\","VolumeLabel":"Transcoding-Temp","TotalSize":2000396742656,"UsedSpace":169906176,"FreeSpace":2000226836480,"Format":"NTFS","FriendlyName":"T","FriendlyUsed":"162.0 MB","FriendlyTotal":"1.8TB","FriendlyAvailable":"1.8 TB"},
{"DriveName":"U:\\","VolumeLabel":"Bay 8 MSA","TotalSize":2000396742656,"UsedSpace":47957217280,"FreeSpace":1952439525376,"Format":"NTFS","FriendlyName":"U","FriendlyUsed":"44.7 GB","FriendlyTotal":"1.8TB","FriendlyAvailable":"1.8 TB"},
{"DriveName":"X:\\","VolumeLabel":"XDRIVE","TotalSize":30255503876096,"UsedSpace":14325955985408,"FreeSpace":15929547890688,"Format":"NTFS","FriendlyName":"X","FriendlyUsed":"13.0 TB","FriendlyTotal":"27.5TB","FriendlyAvailable":"14.5 TB"}
  • Like 1
Link to comment
Share on other sites

5e305c77ceed0_diskspacePercentage.png

 

@@CBers,

 

after working with the tool-tip in chart JS (it gets pretty complicated fast), I was able to add the percentage in a more friendly way.

 

I can't seem to charge the over all scale of the tool-tip label, it will still read the disk space in bytes, but at least you can see the calculated percentage under it.

 

Best I can currently do with chartJS at the moment.

 

1.0.0.5

 

Also changes to 10 GB left threshold, and also check TotalFreeSpace on the drive which is apparently different the Available Free space.

Edited by chef
  • Like 1
Link to comment
Share on other sites

CBers

Thanks Chef.

 

Maths: If you are checking on free space, then if you multiply the drives FREESPACE by 100 then divide by the TOTALSIZE< you will get a percentage.

 

If you then ask if that's less than the threshold (this needs enabling in the settings), then you can alert.

 

So, taking my M:\ drive figures from GetDriveData above for example, gives:

 

(1999684198400 * 100) / 2000396742656 = 99.96437985321582%.
 

Round it up to 99.96% free, or 0.04% used.

  • Like 1
Link to comment
Share on other sites

not sure how you got to that number, but 5GB is 5,368,709,120 bytes or 5e+9 bytes, depending how you want to write it out...

 

 

@@Dibbes,

 

this is correct? 10e+9 = 10GB

Edited by chef
Link to comment
Share on other sites

I found another reason why it was failing. It looks like the threshold need to be casted to a long like this:

 var threshold = (long)(driveInfo.TotalSize - (10e+9));

so that should return a long value which is 10GB less then the total space on the hard drive. 

 

That is if @@Dibbes 's math-brain says it is  :D

Edited by chef
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...