Subversion Repositories ALCASAR

Rev

Rev 2976 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2976 Rev 3037
Line 36... Line 36...
36
     * get all information from all configured ups in phpsysinfo.ini and store output in internal array
36
     * get all information from all configured ups in phpsysinfo.ini and store output in internal array
37
     */
37
     */
38
    public function __construct()
38
    public function __construct()
39
    {
39
    {
40
        parent::__construct();
40
        parent::__construct();
-
 
41
        if (defined('PSI_UPS_POWERSOFTPLUS_ACCESS') && (strtolower(trim(PSI_UPS_POWERSOFTPLUS_ACCESS))==='data')) {
-
 
42
            CommonFunctions::rftsdata('upspowersoftplus.tmp', $temp);
-
 
43
            if (! empty($temp)) {
-
 
44
                $this->_output[] = $temp;
-
 
45
            }
41
        if (PSI_OS == 'Linux') {
46
        } elseif (PSI_OS == 'Linux') {
42
            CommonFunctions::executeProgram('powersoftplus', '-p', $temp);
47
            CommonFunctions::executeProgram('powersoftplus', '-p', $temp);
43
            if (! empty($temp)) {
48
            if (! empty($temp)) {
44
                $this->_output[] = $temp;
49
                $this->_output[] = $temp;
45
            }
50
            }
46
        }
51
        }
47
    }
52
    }
48
 
53
 
49
    /**
54
    /**
50
     * parse the input and store data in resultset for xml generation
55
     * parse the input and store data in resultset for xml generation
51
     *
56
     *
52
     * @return Void
57
     * @return void
53
     */
58
     */
54
    private function _info()
59
    private function _info()
55
    {
60
    {
56
        foreach ($this->_output as $ups) {
61
        foreach ($this->_output as $ups) {
57
 
62
 
Line 69... Line 74...
69
                }
74
                }
70
            }
75
            }
71
            if (preg_match('/^Current UPS state\s*:\s*(.*)$/m', $ups, $data)) {
76
            if (preg_match('/^Current UPS state\s*:\s*(.*)$/m', $ups, $data)) {
72
                $dev->setStatus(trim($data[1]));
77
                $dev->setStatus(trim($data[1]));
73
            }
78
            }
74
            if (preg_match('/^Output load\s*:\s*(.*)\s\[\%\]$/m', $ups, $data)) {
79
            if (preg_match('/^Output load\s*:\s*(.*)\s\[\%\]\r?$/m', $ups, $data)) {
75
               $load = trim($data[1]);
80
               $load = trim($data[1]);
76
            }
81
            }
77
            //wrong Output load issue
82
            //wrong Output load issue
78
            if (($load == 0) && ($maxpwr != 0) && preg_match('/^Effective power\s*:\s*(.*)\s\[W\]$/m', $ups, $data)) {
83
            if (($load == 0) && ($maxpwr != 0) && preg_match('/^Effective power\s*:\s*(.*)\s\[W\]\r?$/m', $ups, $data)) {
79
                $load = 100.0*trim($data[1])/$maxpwr;
84
                $load = 100.0*trim($data[1])/$maxpwr;
80
            }
85
            }
81
            if ($load != null) {
86
            if ($load != null) {
82
                $dev->setLoad($load);
87
                $dev->setLoad($load);
83
            }
88
            }
84
            // Battery
89
            // Battery
85
            if (preg_match('/^Battery voltage\s*:\s*(.*)\s\[Volt\]$/m', $ups, $data)) {
90
            if (preg_match('/^Battery voltage\s*:\s*(.*)\s\[Volt\]\r?$/m', $ups, $data)) {
86
                $dev->setBatteryVoltage(trim($data[1]));
91
                $dev->setBatteryVoltage(trim($data[1]));
87
            }
92
            }
88
            if (preg_match('/^Battery state\s*:\s*(.*)$/m', $ups, $data)) {
93
            if (preg_match('/^Battery state\s*:\s*(.*)$/m', $ups, $data)) {
89
                if (preg_match('/^At full capacity$/', trim($data[1]))) {
94
                if (preg_match('/^At full capacity$/', trim($data[1]))) {
90
                    $dev->setBatterCharge(100);
95
                    $dev->setBatterCharge(100);
91
                } elseif (preg_match('/^(Discharged)|(Depleted)$/', trim($data[1]))) {
96
                } elseif (preg_match('/^(Discharged)|(Depleted)$/', trim($data[1]))) {
92
                    $dev->setBatterCharge(0);
97
                    $dev->setBatterCharge(0);
93
                }
98
                }
94
            }
99
            }
95
            // Line
100
            // Line
96
            if (preg_match('/^Input voltage\s*:\s*(.*)\s\[Volt\]$/m', $ups, $data)) {
101
            if (preg_match('/^Input voltage\s*:\s*(.*)\s\[Volt\]\r?$/m', $ups, $data)) {
97
                $dev->setLineVoltage(trim($data[1]));
102
                $dev->setLineVoltage(trim($data[1]));
98
            }
103
            }
99
            if (preg_match('/^Input frequency\s*:\s*(.*)\s\[Hz\]$/m', $ups, $data)) {
104
            if (preg_match('/^Input frequency\s*:\s*(.*)\s\[Hz\]\r?$/m', $ups, $data)) {
100
                $dev->setLineFrequency(trim($data[1]));
105
                $dev->setLineFrequency(trim($data[1]));
101
            }
106
            }
102
            $this->upsinfo->setUpsDevices($dev);
107
            $this->upsinfo->setUpsDevices($dev);
103
        }
108
        }
104
    }
109
    }
Line 106... Line 111...
106
    /**
111
    /**
107
     * get the information
112
     * get the information
108
     *
113
     *
109
     * @see PSI_Interface_UPS::build()
114
     * @see PSI_Interface_UPS::build()
110
     *
115
     *
111
     * @return Void
116
     * @return void
112
     */
117
     */
113
    public function build()
118
    public function build()
114
    {
119
    {
115
        $this->_info();
120
        $this->_info();
116
    }
121
    }