get power information

@return void
968262
private function _power()
    {
        foreach ($this->_buf as $sensor) {
            if (((isset($sensor['Sensor Type (Threshold)']) && ($sensor['Sensor Type (Threshold)'] == 'Current'))
                ||(isset($sensor['Sensor Type (Analog)']) && ($sensor['Sensor Type (Analog)'] == 'Current')))
               && isset($sensor['Unit']) && ($sensor['Unit'] == 'Watts')
               && isset($sensor['Value'])) {
                $dev = new SensorDevice();
                $dev->setName($sensor['Sensor']);
                $dev->setValue($sensor['Value']);
                if (isset($sensor['Upper Critical']) && (($max = $sensor['Upper Critical']) != "na")) {
                    $dev->setMax($max);
                }
                if (isset($sensor['Status']) && (($status = $sensor['Status']) != "ok")) {
                    $dev->setEvent($status);
                }
                $this->mbinfo->setMbPower($dev);
            }
        }
    }
496446
private function _info()
    {
        foreach ($this->_output as $ups) {

            $dev = new UPSDevice();

            // General info
            $dev->setName("EVER");
            $dev->setMode("PowerSoftPlus");
            $maxpwr = 0;
            $load = null;
            if (preg_match('/^Identifier: UPS Model\s*:\s*(.*)$/m', $ups, $data)) {
                $dev->setModel(trim($data[1]));
                if (preg_match('/\s(\d*)[^\d]*$/', trim($data[1]), $number)) {
                    $maxpwr=$number[1]*0.65;
                }
            }
            if (preg_match('/^Current UPS state\s*:\s*(.*)$/m', $ups, $data)) {
                $dev->setStatus(trim($data[1]));
            }
            if (preg_match('/^Output load\s*:\s*(.*)\s\[\%\]$/m', $ups, $data)) {
               $load = trim($data[1]);
            }
            //wrong Output load issue
            if (($load == 0) && ($maxpwr != 0) && preg_match('/^Effective power\s*:\s*(.*)\s\[W\]$/m', $ups, $data)) {
                $load = 100.0*trim($data[1])/$maxpwr;
            }
            if ($load != null) {
                $dev->setLoad($load);
            }
            // Battery
            if (preg_match('/^Battery voltage\s*:\s*(.*)\s\[Volt\]$/m', $ups, $data)) {
                $dev->setBatteryVoltage(trim($data[1]));
            }
            if (preg_match('/^Battery state\s*:\s*(.*)$/m', $ups, $data)) {
                if (preg_match('/^At full capacity$/', trim($data[1]))) {
                    $dev->setBatterCharge(100);
                } elseif (preg_match('/^(Discharged)|(Depleted)$/', trim($data[1]))) {
                    $dev->setBatterCharge(0);
                }
            }
            // Line
            if (preg_match('/^Input voltage\s*:\s*(.*)\s\[Volt\]$/m', $ups, $data)) {
                $dev->setLineVoltage(trim($data[1]));
            }
            if (preg_match('/^Input frequency\s*:\s*(.*)\s\[Hz\]$/m', $ups, $data)) {
                $dev->setLineFrequency(trim($data[1]));
            }
            $this->upsinfo->setUpsDevices($dev);
        }
    }
656653
private function _get_systeminfo()
    {
        if ($this->_systeminfo === null) CommonFunctions::executeProgram('systeminfo', '', $this->_systeminfo, false);
        return $this->_systeminfo;
    }
568305
def power_on(env, identifier):
    """"""

    vsi = SoftLayer.VSManager(env.client)
    vs_id = helpers.resolve_id(vsi.resolve_ids, identifier, 'VS')
    env.client['Virtual_Guest'].powerOn(id=vs_id)
873339
def total_power(self):
        
        power = self.average_current * self.voltage
        return round(power, self.sr)
64145
protected function _cpuinfo()
    {
        if (CommonFunctions::rfts('/proc/cpuinfo', $bufr, 0, 4096, false)) {
            $processors = preg_split('/\s?\n\s?\n/', trim($bufr));
            foreach ($processors as $processor) {
                $_n = ""; $_f = ""; $_m = ""; $_s = "";
                $dev = new CpuDevice();
                $details = preg_split("/\n/", $processor, -1, PREG_SPLIT_NO_EMPTY);
                foreach ($details as $detail) {
                    $arrBuff = preg_split('/\s+:\s+/', trim($detail));
                    if (count($arrBuff) == 2) {
                        switch (strtolower($arrBuff[0])) {
                        case 'model name':
                            $_n = $arrBuff[1];
                            break;
                        case 'cpu mhz':
                            $dev->setCpuSpeed($arrBuff[1]);
                            break;
                        case 'cpu family':
                            $_f = $arrBuff[1];
                            break;
                        case 'model':
                            $_m = $arrBuff[1];
                            break;
                        case 'stepping':
                            $_s = $arrBuff[1];
                            break;
                        case 'flags':
                            if (preg_match("/ vmx/", $arrBuff[1])) {
                                $dev->setVirt("vmx");
                            } elseif (preg_match("/ svm/", $arrBuff[1])) {
                                $dev->setVirt("svm");
                            }
                        break;
                        }
                    }
                }
                if ($_n == "") $_n="CPU";
                if ($_f != "") $_n.=" Family ".$_f;
                if ($_m != "") $_n.=" Model ".$_m;
                if ($_s != "") $_n.=" Stepping ".$_s;
                $dev->SetModel($_n);
                $this->sys->setCpus($dev);
            }
        } else
        foreach ($this->readdmesg() as $line) {
            if (preg_match('/kernel: (CPU .*) freq (.*) MHz/', $line, $ar_buf)) {
                $dev = new CpuDevice();
                $dev->setModel($ar_buf[1]);
                $dev->setCpuSpeed($ar_buf[2]);
                $this->sys->setCpus($dev);
            }
        }
    }
239270
private function _info()
    {
        if (! empty($this->_output)) {
            foreach ($this->_output as $name => $value) {
                $temp = preg_split("/\n/", $value, -1, PREG_SPLIT_NO_EMPTY);
                $ups_data = array();
                foreach ($temp as $valueTemp) {
                    $line = preg_split('/: /', $valueTemp, 2);
                    $ups_data[$line[0]] = isset($line[1]) ? trim($line[1]) : '';
                }
                $dev = new UPSDevice();
                //General
                $dev->setName($name);
                if (isset($ups_data['ups.model'])) {
                    $dev->setModel($ups_data['ups.model']);
                }
                if (isset($ups_data['driver.name'])) {
                    $dev->setMode($ups_data['driver.name']);
                }
                if (isset($ups_data['ups.status'])) {
                    $dev->setStatus($ups_data['ups.status']);
                }

                //Line
                if (isset($ups_data['input.voltage'])) {
                    $dev->setLineVoltage($ups_data['input.voltage']);
                }
                if (isset($ups_data['input.frequency'])) {
                    $dev->setLineFrequency($ups_data['input.frequency']);
                }
                if (isset($ups_data['ups.load'])) {
                    $dev->setLoad($ups_data['ups.load']);
                }

                //Battery
                if (isset($ups_data['battery.voltage'])) {
                    $dev->setBatteryVoltage($ups_data['battery.voltage']);
                }
                if (isset($ups_data['battery.charge'])) {
                    $dev->setBatterCharge($ups_data['battery.charge']);
                }
                if (isset($ups_data['battery.runtime'])) {
                    $dev->setTimeLeft(round($ups_data['battery.runtime']/60, 2));
                }

                //Temperature
                if (isset($ups_data['ups.temperature'])) {
                    $dev->setTemperatur($ups_data['ups.temperature']);
                }

                $this->upsinfo->setUpsDevices($dev);
            }
        }
    }
314523
protected function _cpuinfo()
    {

        if (CommonFunctions::executeProgram('sysinfo', '-cpu', $bufr, PSI_DEBUG)) {
            $cpus = preg_split("/\nCPU #\d+/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
            $cpuspeed = "";
            foreach ($cpus as $cpu) {
                if (preg_match("/^.*running at (\d+)MHz/", $cpu, $ar_buf)) {
                    $cpuspeed = $ar_buf[1];
                } elseif (preg_match("/^: \"(.*)\"/", $cpu, $ar_buf)) {
                    $dev = new CpuDevice();
                    $dev->setModel($ar_buf[1]);
                    $arrLines = preg_split("/\n/", $cpu, -1, PREG_SPLIT_NO_EMPTY);
                    foreach ($arrLines as $Line) {
                        if (preg_match("/^\s+Data TLB:\s+(.*)K-byte/", $Line, $Line_buf)) {
                            $dev->setCache(max($Line_buf[1]*1024, $dev->getCache()));
                        } elseif (preg_match("/^\s+Data TLB:\s+(.*)M-byte/", $Line, $Line_buf)) {
                            $dev->setCache(max($Line_buf[1]*1024*1024, $dev->getCache()));
                        } elseif (preg_match("/^\s+Data TLB:\s+(.*)G-byte/", $Line, $Line_buf)) {
                            $dev->setCache(max($Line_buf[1]*1024*1024*1024, $dev->getCache()));
                        } elseif (preg_match("/\s+VMX/", $Line, $Line_buf)) {
                            $dev->setVirt("vmx");
                        } elseif (preg_match("/\s+SVM/", $Line, $Line_buf)) {
                            $dev->setVirt("svm");
                        }
                    }
                    if ($cpuspeed != "") {
                        $dev->setCpuSpeed($cpuspeed);
                    }
                    $this->sys->setCpus($dev);
                }
            }
        }
    }
608688
def get_power(self):
        
        response = self.raw_command(netfn=0, command=1)
        if 'error' in response:
            raise exc.IpmiException(response['error'])
        assert (response['command'] == 1 and response['netfn'] == 1)
        powerstate = 'on' if (response['data'][0] & 1) else 'off'
        return {'powerstate': powerstate}
554204
def power(attrs, inputs, proto_obj):
    """"""
    new_attrs = translation_utils._fix_attribute_names(attrs, {'exponent':'exp'})
    if 'broadcast' in attrs:
        new_attrs = translation_utils._remove_attributes(new_attrs, ['broadcast'])
        if attrs['broadcast'] == 1:
            return 'broadcast_power', new_attrs, inputs
        else:
            mxnet_op = symbol.pow(inputs[0], inputs[1])
            return mxnet_op, new_attrs, inputs
    mxnet_op = symbol.broadcast_power(inputs[0], inputs[1])
    return mxnet_op, new_attrs, inputs
574917
public function getBattery()
    {

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

        // Return values
        $return = [];

        // Here they should be
        $bats = (array) @glob('/sys/class/power_supply/BAT*', GLOB_NOSORT);

        // Get vals for each battery
        foreach ($bats as $b) {
            foreach (array($b.'/manufacturer', $b.'/status') as $f) {
                if (!is_file($f)) {
                    continue 2;
                }
            }

            // Get these from the simple text files
            if (is_file($b.'/energy_full')) {
                $charge_full = Common::getIntFromFile($b.'/energy_full');
                $charge_now = Common::getIntFromFile($b.'/energy_now');
            }
            else if (is_file($b.'/charge_full')) {
                $charge_full = Common::getIntFromFile($b.'/charge_full');
                $charge_now = Common::getIntFromFile($b.'/charge_now');
            }
            else {
                continue;
            }

            // Alleged percentage
            $percentage = $charge_now != 0 && $charge_full != 0 ? (round($charge_now / $charge_full, 4) * 100) : '?';

            // Save result set
            $return[] = array(
                'charge_full' => $charge_full,
                'charge_now' => $charge_now,
                'percentage' => (is_numeric($percentage) && $percentage > 100 ? 100 : $percentage),
                'device' => Common::getContents($b.'/manufacturer').' '.Common::getContents($b.'/model_name', 'Unknown'),
                'state' => Common::getContents($b.'/status', 'Unknown'),
            );
        }

        // Give it
        return $return;
    }
512468
public function throttle()
    {
        if ((time() - $this->lastCpuCheck) >= $this->cpuCheckFrequency) {
            $load = sys_getloadavg();
            
            if ($load[0]/$this->cpuCount >= $this->cpuTarget) {
                $this->pause += $this->throttleSensitivity;
                $this->controller->notify('Daemon throttling down');
            } else {
                $this->pause -= $this->throttleSensitivity;
                $this->controller->notify('Daemon throttling up');
            }

            $this->lastCpuCheck = time();
        }

        // Never allow pause to dip below 1 microsecond
        if ($this->pause < 1) {
            $this->pause = 1;
        }

        return $this->pause;
    }
620130
public function getPerformance()
    {
        try {
            return [
                'memory' => $this->performanceAnalyzer->getMemory(),
                'storage' => $this->performanceAnalyzer->getStorage(),
                'cpu' => $this->performanceAnalyzer->getCpu(),
            ];
        } catch (Exception $e) {
            $this->issueService->exception($e);
        }
    }
690113
def getChargingCurrent(self):
    """"""
    command = '$GG'
    currentAndVoltage = self.sendCommand(command)
    amps = float(currentAndVoltage[1])/1000
    return amps
1126288
public function result()
    {

        // Don't bother if it didn't go well
        if ($this->_res === false) {
            return false;
        }

        // Store rows here
        $rows = [];

        // Start showing connections
        $rows[] = array(
            'type' => 'header',
            'columns' => array(
                'UPS Name',
                'Model',
                'Battery Volts',
                'Battery Charge',
                'Time Left',
                'Current Load',
                $this->_res['watts_used'] ? 'Current Usage' : false,
                'Status',
            ),
        );

        // And all the values
        $rows[] = array(
            'type' => 'values',
            'columns' => array(
                $this->_res['name'],
                $this->_res['model'],
                $this->_res['volts'],
                $this->_res['charge'],
                $this->_res['time_left'],
                $this->_res['load'],
                $this->_res['watts_used'] ? $this->_res['watts_used'].'W' : false,
                $this->_res['status'],
            ),
        );

        // Give it off
        return array(
            'root_title' => 'APC UPS Status',
            'rows' => $rows,
        );
    }
864200
public function info()
    {
        $info = [
            'id' => $this->id,
            'project' => $this->project,
            'uniquifier' => $this->uniquifier,
            'description' => $this->description,
            'isInactive' => $this->isInactive,
            'agentVersion' => $this->agentVersion,
            'sourceContexts' => array_map(function ($esc) {
                if (empty($esc)) {
                    return [];
                }
                return is_array($esc) ? $esc['context'] : $esc->context()->info();
            }, $this->extSourceContexts),
            'extSourceContexts' => array_map(function ($esc) {
                return is_array($esc) ? $esc : $esc->info();
            }, $this->extSourceContexts)
        ];
        if ($this->status) {
            $info['status'] = $this->status->info();
        }
        if (!empty($this->labels)) {
            $info['labels'] = $this->labels;
        }
        return $info;
    }
391010
public function getCPU()
    {

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

        $cpus = array();
        $alt = false;
        $object = $this->wmi->ExecQuery('SELECT Name, Manufacturer, CurrentClockSpeed, NumberOfLogicalProcessors,LoadPercentage FROM Win32_Processor');

        if (!is_object($object)) {
            $object = $this->wmi->ExecQuery('SELECT Name, Manufacturer, CurrentClockSpeed,LoadPercentage FROM Win32_Processor');
            $alt = true;
        }

        foreach ($object as $cpu) {
            $curr = array(
                'Model' => $cpu->Name,
                'Vendor' => $cpu->Manufacturer,
                'MHz' => $cpu->CurrentClockSpeed,
            );

            if ($cpu->LoadPercentage != '') {
                $curr['usage_percentage'] = $cpu->LoadPercentage;
            }

            if (!$alt) {
                for ($i = 0; $i < $cpu->NumberOfLogicalProcessors; ++$i) {
                    $cpus[] = $curr;
                }
            } else {
                $cpus[] = $curr;
            }
        }

        return $cpus;
    }