Sponsor:

Server and Web Integrator
Link:
Kloxo-MR logo
6.5.0 or 7.0.0
Click for "How to install"
Donation/Sponsorship:
Kloxo-MR is open-source.
Donate and or Sponsorship always welcome.
Click to:
Click Here
Please login or register. 2024-04-28, 01:31:12

Author Topic: Bug in linuxfslib.php causing disk usage not to be counted  (Read 15682 times)

0 Members and 1 Guest are viewing this topic.

Offline Spacedust

  • Super Grand Master
  • ****
  • Posts: 4,050
  • Karma: +1/-0
    • View Profile
Mustafa you made a huge mistake in this file. Leaving disk usage count to work only on linux installations using english language only.
« Last Edit: 2013-04-22, 17:37:24 by Spacedust »

Offline Spacedust

  • Super Grand Master
  • ****
  • Posts: 4,050
  • Karma: +1/-0
    • View Profile
Re: Bug in linuxfslib.php causing disk usage not to be count
« Reply #1 on: 2013-04-22, 17:34:39 »
You disabled this:

Code: [Select]
$rt = lxshell_output("du", "-sc", $path);
$os  = preg_replace("/s+/", ":", $rt);
$ret = explode(":", $os);
$t = $ret[2];

and replaced this with non-working code if Linux installation is installed in different language than English !

Code: [Select]
exec("du -sc {$path} | grep -i 'total'", $out);
$os  = preg_replace("/s+/", ":", $out[0]);
$t = str_replace(":total", "", $os);

Take a look:

Code: [Select]
[root@nowosci /]# du -sc /home/admin
100544  /home/admin
100544  razem

So there is no word total !

Code: [Select]
[root@nowosci /]# du -sc /home/admin | grep total
[root@nowosci /]#

That's why Kloxo isn't counting quota properly on so many systems, because we use polish on all of them !
« Last Edit: 1970-01-01, 01:00:00 by Guest »

Offline Spacedust

  • Super Grand Master
  • ****
  • Posts: 4,050
  • Karma: +1/-0
    • View Profile
Re: Bug in linuxfslib.php causing disk usage not to be count
« Reply #2 on: 2013-04-22, 17:40:40 »
It will be very easy to switch to quotas now - see example:

Quote
quota -u monia_mal
Disk quotas for user monia_mal (uid 2117):
 System plików   bloki mi?kki  twardy  pob?.   pliki mi?kki  twardy  pob?.
      /dev/root      28  52428800 52428800              79       0       0
       /dev/md2 33699544  52428800 52428800          312604       0       0

We should just use du -sc for mail and databases and use quota for /home.

This will give us realtime disk usage at least for /home.
« Last Edit: 1970-01-01, 01:00:00 by Guest »

Offline MRatWork

  • Administrator
  • The Elite
  • *****
  • Posts: 15,807
  • Karma: +119/-11
  • Gender: Male
    • View Profile
    • MRatWork Forum
Re: Bug in linuxfslib.php causing disk usage not to be count
« Reply #3 on: 2013-04-22, 19:12:57 »
Look like need modified as:
Code: [Select]
  exec("du -sc {$path} | grep -i '{$path}'", $out);
   $os  = preg_replace("/s+/", ":", $out[0]);
   $t = str_replace(":total", "", $os);
« Last Edit: 1970-01-01, 01:00:00 by Guest »
..:: MRatWork (Mustafa Ramadhan Projects) ::..
-- Server/Web-integrator - Web Hosting (Kloxo-MR READY!) --

Offline Spacedust

  • Super Grand Master
  • ****
  • Posts: 4,050
  • Karma: +1/-0
    • View Profile
Re: Bug in linuxfslib.php causing disk usage not to be count
« Reply #4 on: 2013-04-22, 19:23:37 »
Quote from: "MRatWork"
Look like need modified as:
Code: [Select]
  exec("du -sc {$path} | grep -i '{$path}'", $out);
   $os  = preg_replace("/s+/", ":", $out[0]);
   $t = str_replace(":total", "", $os);

Yes it works ok on polish linux. But this is only a temporary solution which takes almost 4 hours to count on our filesystem and causing very high I/O load. We must use quota -u as soon as possible.
« Last Edit: 1970-01-01, 01:00:00 by Guest »

Offline MRatWork

  • Administrator
  • The Elite
  • *****
  • Posts: 15,807
  • Karma: +119/-11
  • Gender: Male
    • View Profile
    • MRatWork Forum
Re: Bug in linuxfslib.php causing disk usage not to be count
« Reply #5 on: 2013-04-22, 19:36:19 »
Using 'quota -u' not work in my servers
« Last Edit: 1970-01-01, 01:00:00 by Guest »
..:: MRatWork (Mustafa Ramadhan Projects) ::..
-- Server/Web-integrator - Web Hosting (Kloxo-MR READY!) --

Offline Spacedust

  • Super Grand Master
  • ****
  • Posts: 4,050
  • Karma: +1/-0
    • View Profile
Re: Bug in linuxfslib.php causing disk usage not to be count
« Reply #6 on: 2013-04-22, 19:42:40 »
Quote from: "MRatWork"
Using 'quota -u' not work in my servers

Make sure you use add "usrjquota=aquota.user,grpjquota=aquota.group,usrquota,grpquota" to each entry you want quotas in /etc/fstab:

Code: [Select]
proc /proc proc defaults 0 0
none /dev/pts devpts gid=5,mode=620 0 0
tmpfs /dev/shm        tmpfs   defaults        0       0
/dev/md0 /boot ext3           defaults  1 1
/dev/md1        /       ext4    rw,discard,noatime,nodiratime,usrjquota=aquota.user,grpjquota=aquota.group,usrquota,grpquota,jqfmt=vfsv0        1       1
/dev/md2        /home   ext4    rw,noatime,nodiratime,usrjquota=aquota.user,grpjquota=aquota.group,usrquota,grpquota,jqfmt=vfsv0        0       0
/dev/md3 /var/lib/mysql ext4    rw,discard,noatime,nodiratime,usrjquota=aquota.user,grpjquota=aquota.group,usrquota,grpquota,jqfmt=vfsv0  1      1
/root/swapfile1 swap swap defaults 0 0

Then reboot to remount all partition.

Then run /script/fixquota and all will work ok.
« Last Edit: 1970-01-01, 01:00:00 by Guest »

Offline MRatWork

  • Administrator
  • The Elite
  • *****
  • Posts: 15,807
  • Karma: +119/-11
  • Gender: Male
    • View Profile
    • MRatWork Forum
Re: Bug in linuxfslib.php causing disk usage not to be count
« Reply #7 on: 2013-04-22, 19:48:38 »
@Spacedust,

A problems is most servers (especially vps) not using quota for partitions. Using 'quota -u' need modified partition config and it's make more difficult rather then using 'du -sc'.
« Last Edit: 1970-01-01, 01:00:00 by Guest »
..:: MRatWork (Mustafa Ramadhan Projects) ::..
-- Server/Web-integrator - Web Hosting (Kloxo-MR READY!) --

Offline Spacedust

  • Super Grand Master
  • ****
  • Posts: 4,050
  • Karma: +1/-0
    • View Profile
Re: Bug in linuxfslib.php causing disk usage not to be count
« Reply #8 on: 2013-04-22, 19:53:07 »
Quote from: "MRatWork"
@Spacedust,

A problems is most servers (especially vps) not using quota for partitions. Using 'quota -u' need modified partition config and it's make more difficult rather then using 'du -sc'.

All servers should use quotas. What's the problem to add these entries during Kloxo install ?

You can then remount partitions with:

Code: [Select]
remount -o /dev/<partitionname>
No need to reboot. cPanel and DirectAdmin are using quotas so I don't know what's the problem.

If you dislike quotas then please make a second version with du -sc and use it by default. We won't use du -sc because it's overloading our servers.

Imagine what would happens if you run it on a 16 TB array. It would take ages to complete.

If you won't use quotas then your users are able to use more disk space than they're allowed so this is a big security problem.
« Last Edit: 1970-01-01, 01:00:00 by Guest »

Offline Spacedust

  • Super Grand Master
  • ****
  • Posts: 4,050
  • Karma: +1/-0
    • View Profile
Re: Bug in linuxfslib.php causing disk usage not to be count
« Reply #9 on: 2013-04-22, 20:01:10 »
Sorry, a typo:

Code: [Select]
mount -o remount /dev/<partitionname>
Then you should see something like this inside dmesg:

Code: [Select]
EXT4-fs (md1): re-mounted. Opts: discard,usrjquota=aquota.user,grpjquota=aquota.group,usrquota,grpquota,jqfmt=vfsv0
« Last Edit: 1970-01-01, 01:00:00 by Guest »

Offline MRatWork

  • Administrator
  • The Elite
  • *****
  • Posts: 15,807
  • Karma: +119/-11
  • Gender: Male
    • View Profile
    • MRatWork Forum
Re: Bug in linuxfslib.php causing disk usage not to be count
« Reply #10 on: 2013-04-22, 20:14:32 »
Try with:
Code: [Select]
// exec("du -sc {$path} | grep -i '{$path}'", $out);
exec("du -s {$path}", $out);
$os  = preg_replace("/s+/", ":", $out[0]);
$t = str_replace(":{$path}", "", $os);
« Last Edit: 1970-01-01, 01:00:00 by Guest »
..:: MRatWork (Mustafa Ramadhan Projects) ::..
-- Server/Web-integrator - Web Hosting (Kloxo-MR READY!) --

Offline Spacedust

  • Super Grand Master
  • ****
  • Posts: 4,050
  • Karma: +1/-0
    • View Profile
Re: Bug in linuxfslib.php causing disk usage not to be count
« Reply #11 on: 2013-04-22, 20:30:30 »
Quote from: "MRatWork"
Try with:
Code: [Select]
// exec("du -sc {$path} | grep -i '{$path}'", $out);
exec("du -s {$path}", $out);
$os  = preg_replace("/s+/", ":", $out[0]);
$t = str_replace(":{$path}", "", $os);

Work ok for me, but maybe we should use ionice -c2 before this command to reduce I/O load ?

How these lines should look if I want to use quota ?
« Last Edit: 1970-01-01, 01:00:00 by Guest »

Offline MRatWork

  • Administrator
  • The Elite
  • *****
  • Posts: 15,807
  • Karma: +119/-11
  • Gender: Male
    • View Profile
    • MRatWork Forum
Re: Bug in linuxfslib.php causing disk usage not to be count
« Reply #12 on: 2013-04-22, 20:48:15 »
Yes. this function 'lxfile_dirsize($path, $byteflag = false)' need 'path'.

If using 'quota -u', need new function like 'lxfile_quotasize($user, $byteflag = false)'.
« Last Edit: 1970-01-01, 01:00:00 by Guest »
..:: MRatWork (Mustafa Ramadhan Projects) ::..
-- Server/Web-integrator - Web Hosting (Kloxo-MR READY!) --

Offline Spacedust

  • Super Grand Master
  • ****
  • Posts: 4,050
  • Karma: +1/-0
    • View Profile
Re: Bug in linuxfslib.php causing disk usage not to be count
« Reply #13 on: 2013-04-22, 22:54:42 »
Quote from: "MRatWork"
Yes. this function 'lxfile_dirsize($path, $byteflag = false)' need 'path'.

If using 'quota -u', need new function like 'lxfile_quotasize($user, $byteflag = false)'.

Can you write one for testing purposes ?
« Last Edit: 1970-01-01, 01:00:00 by Guest »

Offline Spacedust

  • Super Grand Master
  • ****
  • Posts: 4,050
  • Karma: +1/-0
    • View Profile
Re: Bug in linuxfslib.php causing disk usage not to be count
« Reply #14 on: 2013-04-23, 16:03:52 »
Mustafa do something about this. It's overloading our servers !!!

Here's load average from last night:

« Last Edit: 1970-01-01, 01:00:00 by Guest »

 


Top 4 Global Search Engines:    Google    Bing    Baidu    Yahoo

Page created in 0.082 seconds with 18 queries.

web stats analysis