CMD_API_SHOW_USER_USAGE (Bug?)

jsefton

Verified User
Joined
Mar 30, 2004
Messages
36
Hi Folks,

Im back again with what will probably turn out to be a RTFM issue.

I am using CMD_API_SHOW_USER_USAGE call to try and retrieve bandwidth and diskspace used. The response example below was made on a newly created user so the 0.0 values are expected.

bandwidth=0.0&domainptr=0&ftp=1&mysql=1&nemailf=0&nemailml=0&nemailr=0&nemails=1&nsubdomains=0"a=0.0&vdomains=1

The bandwidth i get fine but looking at the API spec, i expected the second key/value set to be 'quota' which is the amount of disk space used by the user.

As you can see in my response above, this value is missed out.
After playing around with other requests on sites that have plenty of activity and comparing what i get with the information in the control panel, i did manage to kindof figure it out but i think there is a serious problem with the response.

after 'exploding' the response based on &, one of the elements reads:

nsubdomains=0"a=0.0

now the a=0.0 part seems to match the quota. Im guessing that the 'quot' is missing from the start.
since nsubdomains is supposed to be a key, i also assume that " should be &

If this is a bug then can i beg and plead that you fix it as soon as possible as i need to finish my billing system in the next couple of weeks.

If this is just me in serious need to RTFM then i do apologise profusely and i will go and hide under the nearest rock!.

Thanks to u guys for implementing my feature request. (Domain Pointers.) I just noticed it when i updated to the latest version.

That was much faster than i expected.

- James
 
Hello,

It would be a bug.. but I'm not seeing that on our end.
1) let me know what OS you're using.
2) check /usr/local/directadmin/data/users/username/user.usage
maybe paste it's contents and I'll try it from there with it's values in case there is some strange condition that isn't met.

John
 
Hi John,

OS = Redhat 8.0
DA = 1.22.1


user.usage for the user that generated the previous example:

bandwidth=0.0
domainptr=0
ftp=1
mysql=0
nemailf=0
nemailml=0
nemailr=0
nemails=1
nsubdomains=0
quota=0.0
vdomains=1

user.usage for the admin user

bandwidth=777.5
db_quota=761933
domainptr=10
email_quota=0
ftp=0
mysql=6
nemailf=3
nemailml=0
nemailr=0
nemails=4
nsubdomains=3
quota=511.6
vdomains=4

I get the same problem with the admin user. (I have not tried any others)
I dont know if it makes any difference but the domain name allocated to the user (not admin) does not exist.
Also, the first user above was created using the API. (admin was obviously created when DA was installed.)

Is there anything else i can give you to help you find it?

- James
 
Hello,

I'm thinking it's just a dirty build, as the function just reads in the file, and spits out out to screen in url format.. unless the url format is choking on the data (not on other systems)... it's probably just a weird build. Wait for the next release in a few days.

John
 
Hi John,

Ok, i will wait for the next release.

However,

I got this problem on a previous build. I updated earlier today to this build to try and resolve the problem before i contacted you.

- James
 
Hello,

Alright, I'll have a look at our redhat 8.0 system to see if I can find anything.

John
 
Hi John,

I just updated to version 1222 and the response is still the same.

Also, there is another problem that appears to have come up since the upgrade to 1221.

When i create a new user(site) using either the API or doing it with the control panel, the FTP user account does not work.
I can login to the control panel, etc with the account details but when i try to connect via ftp it refuses the username/password.
In the /var/log/messages file, the following lines appear.

Jun 23 14:15:37 ns1a proftpd[6059]: www.wasteofinc.com (82.68.165.30[82.68.165.30]) - FTP session opened.

Jun 23 14:15:38 ns1a proftpd[6059]: www.wasteofinc.com (82.68.165.30[82.68.165.30]) - no such user 'waste'

Jun 23 14:15:38 ns1a proftpd[6059]: www.wasteofinc.com (82.68.165.30[82.68.165.30]) - FTP session closed.

Any ideas?

(I just rebooted the server to see if that helped.. still the same on both issues.)

Cheers,

- James
 
Interesting...

The FTP problem has 'gone away'???

Not changed anything, just tried again a few hours later and all works!

Now i am really baffled?

Maybe its time i gave up for today..lol
 
Did you manage to find anything about this yet John?

I can provide you a shell account on the server if it would help you find the problem.

- James
 
Hi John,

I think i may have found something..

the method i have been using to get the information is as follows:

$request='http://admin:password@serverip:2222/CMD_API_SHOW_USER_USAGE?user='.$account[4];
$response=file_get_contents($request);

The contents of $response are what i pasted into this thread above. I still get the same problems if i run that code now.

However,

If i manually go to the url, miss out the login details and login using the login box when prompted, the output is correct.

I guess it may be something to do with php's file_get_contents() function.

Im going to give it a try with l0rdPhil's class and see if it works any better.

Thanks for your help so far. I will shout up if i still dont get any joy so that someone can tell me the correct way of doing things.

- James
 
Hahaha,

I told you i would end up crawling under a rock!!

I have figured out what was wrong and of course it was stupidly simple. (There was not actually anything wrong.)

I was dumping the output to a webpage to view it while i was making the function.. All it took was for me to notice exactly what was missing from the output: & q u o t - and what it gets replaced with "

It was the browser that was manipulating what i saw, if only i had used 'htmlentities' or something

How stupid can one be!! I will go and hide now.

Thanks for your time John and sorry for wasting it.

Regards,

- James
 
Last edited:
Back
Top