package Cpanel::ResourceUsage::Custom::backupmgrstats; use strict; use warnings; use JSON; use Cpanel (); use Cpanel::AdminBin (); use Cpanel::Logger (); sub get_usages { my ($user) = @_; # Make the function unusable if the cPanel account is in demo mode. if ( $Cpanel::CPDATA{'DEMO'} ) { return; } my $stats = decode_json Cpanel::AdminBin::Call::call( 'Backups', # namespace: bin/admin/Backups 'Backups', # module: bin/admin/Backups/Backups 'BACKUPS', # function '{"action": "stats", "args": ""}' ); if ($$stats{'status'} != 0) { Cpanel::Logger->new()->warn($$stats{'error'}); return; } if ($$stats{'data'}{'quota'} > 0){ if (exists $$stats{'data'}{'svr_usage'}) { return ( { id => 'backup_mgr_user', # unique ID for this stat, not displayed description => "Backup Usage for $user", # display name in the stats bar usage => $$stats{'data'}{'usage'} * 1048576, maximum => $$stats{'data'}{'quota'} * 1048576, formatter => 'format_bytes', app => 'backup_mgr', }, { id => 'backup_mgr_server', # unique ID for this stat, not displayed description => "Total Server Backup Usage", # display name in the stats bar usage => $$stats{'data'}{'svr_usage'} * 1048576, maximum => $$stats{'data'}{'svr_quota'} * 1048576, formatter => 'format_bytes' } ); } else { return ( { id => 'backup_mgr_user', # unique ID for this stat, not displayed description => 'Backup Usage', # display name in the stats bar usage => $$stats{'data'}{'usage'} * 1048576, maximum => $$stats{'data'}{'quota'} * 1048576, formatter => 'format_bytes', app => 'backup_mgr', } ); } } else { return; } } 1;