API to get usage information

2 posts / 0 new
Last post
#1 Sat, 06/11/2011 - 04:08
pran

API to get usage information

Hi all. Is there an existing API I can remotely call to get usage information like total disk space, DB usage space, bandwidth, etc. per virtual host using either the virtual host ID or domain name?

Tue, 11/20/2012 - 02:00
Elsys

list-domains, will get you your disk usage, list-users with --mailbox-size flag will get mailboxes call list-users for each domain individually. DB usage list-databases will do the trick again with the --domain flag set to your domain. Also you want to have multiline or simple-multiline enabled. Depending on how many domains your going to be doing this with at one time you may end up having a ton of cpu cycles being used. So I suggest having each domain have a separate page for usage or using a javascript toggle on some divs and populating the usage information via Ajax when it's requested otherwise your page will be really heavy if you want all your domains on the same page.

On another point you could also write a cron script to export the return of these functions into a mysql database formatted how you would like it then query that from your page. If you don't want to use ajax/separate pages. However this cron will mean that whatever usage data you do get depending on how often your job is run will be in the past by that many minutes/hours/days.

Topic locked