File System Usage Calculation

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

File System Usage Calculation

Ryan Hoshor
Hello everyone,
        I posted this on the public forums, but was directed to post it here, so I am just copying from my post here: http://forum.owncloud.org/viewtopic.php?f=26&t=20857&p=58502

I am attempting to write a script that will calculate the usage of every person's account for internal billing purposes. I have a bash script that calculates the actual disk space used on the storage backend, but that is sort of clunky for what I need. I used the following SQL to try and calculate, but am getting incorrect results:


      SELECT
         oc_storages.id,
         oc_filecache.storage,
         SUM(oc_filecache.size/8589934592) AS size
      FROM
         oc_filecache
      JOIN
         oc_storages
      ON
         oc_filecache.storage = oc_storages.numeric_id
      GROUP BY
         storage


Any ideas where the 'settings/templates/personal.php' file gets it's information from, or how to access that info for each and every user of the system?


<?php
    // From settings/templates/personal.php
    print_unescaped($l->t('You have used <strong>%s</strong> of the available <strong>%s</strong>', array($_['usage'], $_['total_space'])));
?>


Thanks in advance!


Thanks,
--
Ryan Hoshor ~ Systems Administrator
computerconnections
wiconnectwireless
(608) 524-2610 ~ www.ccwis.com


_______________________________________________
Devel mailing list
[hidden email]
http://mailman.owncloud.org/mailman/listinfo/devel
Reply | Threaded
Open this post in threaded view
|

Re: File System Usage Calculation

Robin Appelman-3
On Wednesday 23 April 2014 15:16:36 Ryan Hoshor wrote:

> Hello everyone,
> I posted this on the public forums, but was directed to post it here, so I
> am just copying from my post here:
> http://forum.owncloud.org/viewtopic.php?f=26&t=20857&p=58502
>
> I am attempting to write a script that will calculate the usage of every
> person's account for internal billing purposes. I have a bash script that
> calculates the actual disk space used on the storage backend, but that is
> sort of clunky for what I need. I used the following SQL to try and
> calculate, but am getting incorrect results:
>
>
>       SELECT
>          oc_storages.id,
>          oc_filecache.storage,
>          SUM(oc_filecache.size/8589934592) AS size
>       FROM
>          oc_filecache
>       JOIN
>          oc_storages
>       ON
>          oc_filecache.storage = oc_storages.numeric_id
>       GROUP BY
>          storage
>
>
> Any ideas where the 'settings/templates/personal.php' file gets it's
> information from, or how to access that info for each and every user of the
> system?

The size for folders in the database is already the sum of each file within the
folder, you don't need to sum yourself. You only have to get the size of the
`files` folder

       SELECT
          oc_storages.id,
          oc_filecache.storage,
          oc_filecache.size/8589934592 AS size
       FROM
          oc_filecache
       JOIN
          oc_storages
       ON
          oc_filecache.storage = oc_storages.numeric_id
       WHERE
         name = 'files'
       GROUP BY
          storage

 - Robin Appelman
_______________________________________________
Devel mailing list
[hidden email]
http://mailman.owncloud.org/mailman/listinfo/devel