API get disk usage

Discussion in 'Tips/Tricks/Mods' started by Peter Arany, May 2, 2019.

  1. Peter Arany

    Peter Arany New Member

    Hi all!
    Is there a way to get the disk usage info with the SOAP API?
    The information is stored in the monitor_data table -> type ='disk_usage'

    | 1 | disk_usage | 1556788801 | a:3:{i:1;a:7:{s:2:"fs";s:4:"udev";s:4:"type";s:8:"devtmpfs";s:4:"size";s:3:"16G";s:4:"used";s:1:"0";s:9:"available";s:3:"16G";s:7:"percent";s:2:"0%";s:7:"mounted";s:4:"/dev";}i:2;a:7:{s:2:"fs";s:5:"tmpfs";s:4:"type";s:5:"tmpfs";s:4:"size";s:4:"3.1G";s:4:"used";s:4:"113M";s:9:"available";s:4:"3.0G";s:7:"percent";s:2:"4%";s:7:"mounted";s:4:"/run";}i:3;a:7:{s:2:"fs";s:9:"/dev/sda1";s:4:"type";s:4:"ext4";s:4:"size";s:4:"226G";s:4:"used";s:3:"17G";s:9:"available";s:4:"200G";s:7:"percent";s:2:"8%";s:7:"mounted";s:1:"/";}} | ok |
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    No. You might have to add a custom remote function for that. Create a new file in remote.d folder which contains your function to query that data. similar to the other files that are in that folder.
  3. Peter Arany

    Peter Arany New Member

    Dear Till Brehm!

    Thank to your help, I could do it:


    class remoting_arape extends remoting {

    <------>public function disk_usage($session_id)
    <------><------>global $app;
    <------><------>if(!$this->checkPerm($session_id, 'server_get')) {
    <------><------><------>throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
    <------><------><------>return false;
    <------><------>if (!empty($session_id)) {
    <------><------><------>$sql = "select * from dbispconfig.monitor_data where type ='disk_usage';";
    <------><------><------>$servers = $app->db->queryAllRecords($sql);
    <------><------><------>return $servers;
    <------><------>} else {
    <------><------>return false;
    Thanks again, have a nice day!
    till likes this.

Share This Page