public function getHD()
    {

        // Time?
        if (!empty($this->settings['timer'])) {
            $t = new Timer('CPU');
        }

        $drives = [];
        $curr_hd = false;

        // Parse dmesg
        foreach (explode("\n", $this->dmesg) as $dmesg_line) {
            if (preg_match('/^(\w+) at .+<([^>]+)>/', $dmesg_line, $hd_start_match)) {
                $curr_hd = $hd_start_match;
            } elseif ($curr_hd !== false && preg_match('/^'.preg_quote($curr_hd[1]).':.*\b(\d+)MB/', $dmesg_line, $hd_spec_match)) {
                $drives[] = array(
                    'name' => trim($curr_hd[2], ', '),
                    'vendor' => false,
                    'device' => '/dev/'.$curr_hd[1],
                    'size' => $hd_spec_match[1] * 1048576,

                    // Not sure how to get the following:
                    'reads' => false,
                    'writes' => false,

                );
                $curr_hd = false;
            } else {
                $curr_hd = false;
            }
        }

        // give it
        return $drives;
    }
public function getHD()
    {

        // Time?
        if (!empty($this->settings['timer'])) {
            $t = new Timer('CPU');
        }

        $drives = [];
        $curr_hd = false;

        // Parse dmesg
        foreach (explode("\n", $this->dmesg) as $dmesg_line) {
            if (preg_match('/^(\w+) at .+<([^>]+)>/', $dmesg_line, $hd_start_match)) {
                $curr_hd = $hd_start_match;
            } elseif ($curr_hd !== false && preg_match('/^'.preg_quote($curr_hd[1]).':.*\b(\d+)MB/', $dmesg_line, $hd_spec_match)) {
                $drives[] = array(
                    'name' => trim($curr_hd[2], ', '),
                    'vendor' => false,
                    'device' => '/dev/'.$curr_hd[1],
                    'size' => $hd_spec_match[1] * 1048576,

                    // Not sure how to get the following:
                    'reads' => false,
                    'writes' => false,

                );
                $curr_hd = false;
            } else {
                $curr_hd = false;
            }
        }

        // give it
        return $drives;
    }
public function getHD ( ) { // Time? if ( ! empty ( $ this -> settings [ 'timer' ] ) ) { $ t = new Timer ( 'CPU' ) ; } $ drives = [ ] ; $ curr_hd = false ; // Parse dmesg foreach ( explode ( "\n" , $ this -> dmesg ) as $ dmesg_line ) { if ( preg_match ( '/^(\w+) at .+<([^>]+)>/' , $ dmesg_line , $ hd_start_match ) ) { $ curr_hd = $ hd_start_match ; } elseif ( $ curr_hd !== false && preg_match ( '/^' . preg_quote ( $ curr_hd [ 1 ] ) . ':.*\b(\d+)MB/' , $ dmesg_line , $ hd_spec_match ) ) { $ drives [ ] = array ( 'name' => trim ( $ curr_hd [ 2 ] , ', ' ) , 'vendor' => false , 'device' => '/dev/' . $ curr_hd [ 1 ] , 'size' => $ hd_spec_match [ 1 ] * 1048576 , // Not sure how to get the following: 'reads' => false , 'writes' => false , ) ; $ curr_hd = false ; } else { $ curr_hd = false ; } } // give it return $ drives ; }
Get hard disk drives and the like
Get hard disk drives and the like