325 |
richard |
1 |
<?php
|
|
|
2 |
/***************************************************************************
|
|
|
3 |
* Copyright (C) 2006 by phpSysInfo - A PHP System Information Script *
|
|
|
4 |
* http://phpsysinfo.sourceforge.net/ *
|
|
|
5 |
* *
|
|
|
6 |
* This program is free software; you can redistribute it and/or modify *
|
|
|
7 |
* it under the terms of the GNU General Public License as published by *
|
|
|
8 |
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
9 |
* (at your option) any later version. *
|
|
|
10 |
* *
|
|
|
11 |
* This program is distributed in the hope that it will be useful, *
|
|
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
14 |
* GNU General Public License for more details. *
|
|
|
15 |
* *
|
|
|
16 |
* You should have received a copy of the GNU General Public License *
|
|
|
17 |
* along with this program; if not, write to the *
|
|
|
18 |
* Free Software Foundation, Inc., *
|
|
|
19 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
20 |
***************************************************************************/
|
|
|
21 |
|
|
|
22 |
// $Id: vitals.php,v 1.32 2007/02/18 18:59:54 bigmichi1 Exp $
|
|
|
23 |
|
|
|
24 |
// xml_vitals()
|
|
|
25 |
|
|
|
26 |
function xml_vitals () {
|
|
|
27 |
global $sysinfo;
|
|
|
28 |
global $loadbar;
|
|
|
29 |
global $show_vhostname;
|
|
|
30 |
|
|
|
31 |
$strLoadavg = "";
|
|
|
32 |
$arrBuf = ( $loadbar ? $sysinfo->loadavg( $loadbar ) : $sysinfo->loadavg() );
|
|
|
33 |
|
|
|
34 |
foreach( $arrBuf['avg'] as $strValue) {
|
|
|
35 |
$strLoadavg .= $strValue . ' ';
|
|
|
36 |
}
|
|
|
37 |
|
|
|
38 |
$_text = " <Vitals>\n"
|
|
|
39 |
. " <Hostname>" . htmlspecialchars( $show_vhostname ? $sysinfo->vhostname() : $sysinfo->chostname(), ENT_QUOTES ) . "</Hostname>\n"
|
|
|
40 |
. " <IPAddr>" . htmlspecialchars( $show_vhostname ? $sysinfo->vip_addr() : $sysinfo->ip_addr(), ENT_QUOTES ) . "</IPAddr>\n"
|
|
|
41 |
. " <Kernel>" . htmlspecialchars( $sysinfo->kernel(), ENT_QUOTES ) . "</Kernel>\n"
|
|
|
42 |
. " <Distro>" . htmlspecialchars( $sysinfo->distro(), ENT_QUOTES ) . "</Distro>\n"
|
|
|
43 |
. " <Distroicon>" . htmlspecialchars( $sysinfo->distroicon(), ENT_QUOTES ) . "</Distroicon>\n"
|
|
|
44 |
. " <Uptime>" . htmlspecialchars( $sysinfo->uptime(), ENT_QUOTES ) . "</Uptime>\n"
|
1478 |
richard |
45 |
// . " <Users>" . htmlspecialchars( $sysinfo->users(), ENT_QUOTES ) . "</Users>\n"
|
325 |
richard |
46 |
. " <LoadAvg>" . htmlspecialchars( trim( $strLoadavg ), ENT_QUOTES ) . "</LoadAvg>\n";
|
|
|
47 |
if( isset( $arrBuf['cpupercent'] ) ) {
|
|
|
48 |
$_text .= " <CPULoad>" . htmlspecialchars( round( $arrBuf['cpupercent'], 2 ), ENT_QUOTES ) . "</CPULoad>";
|
|
|
49 |
}
|
|
|
50 |
$_text .= " </Vitals>\n";
|
|
|
51 |
|
|
|
52 |
return $_text;
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
// html_vitals()
|
|
|
56 |
function html_vitals () {
|
|
|
57 |
global $webpath;
|
|
|
58 |
global $XPath;
|
|
|
59 |
global $text;
|
|
|
60 |
|
|
|
61 |
$textdir = direction();
|
|
|
62 |
$scale_factor = 2;
|
|
|
63 |
$strLoadbar = "";
|
|
|
64 |
$uptime = "";
|
2297 |
tom.houday |
65 |
$date = date('d-m-Y H:i:s');
|
|
|
66 |
$certificateInfos = openssl_x509_parse(file_get_contents('/etc/pki/tls/certs/alcasar.crt'));
|
|
|
67 |
$certExpirationDate = date('d-m-Y H:i:s', $certificateInfos['validTo_time_t']);
|
325 |
richard |
68 |
if( $XPath->match( "/phpsysinfo/Vitals/CPULoad" ) )
|
|
|
69 |
$strLoadbar = "<br>" . create_bargraph( $XPath->getData( "/phpsysinfo/Vitals/CPULoad" ), 100, $scale_factor ) . " " . $XPath->getData( "/phpsysinfo/Vitals/CPULoad" ) . "%";
|
|
|
70 |
|
|
|
71 |
$_text = "<table border=\"0\" width=\"100%\" align=\"center\">\n"
|
|
|
72 |
. " <tr>\n"
|
|
|
73 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['hostname'] . "</font></td>\n"
|
|
|
74 |
. " <td><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/Vitals/Hostname" ) . "</font></td>\n"
|
|
|
75 |
. " </tr>\n"
|
648 |
richard |
76 |
. " <tr>\n"
|
|
|
77 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['cert_expiration_date'] . "</font></td>\n"
|
2297 |
tom.houday |
78 |
. " <td><font size=\"-1\">" . $certExpirationDate . "</font></td>\n"
|
648 |
richard |
79 |
. " </tr>\n"
|
325 |
richard |
80 |
// . " <tr>\n"
|
|
|
81 |
// . " <td valign=\"top\"><font size=\"-1\">" . $text['ip'] . "</font></td>\n"
|
|
|
82 |
// . " <td><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/Vitals/IPAddr" ) . "</font></td>\n"
|
|
|
83 |
// . " </tr>\n"
|
|
|
84 |
. " <tr>\n"
|
|
|
85 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['kversion'] . "</font></td>\n"
|
|
|
86 |
. " <td><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/Vitals/Kernel" ) . "</font></td>\n"
|
|
|
87 |
. " </tr>\n"
|
|
|
88 |
. " <tr>\n"
|
|
|
89 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['dversion'] . "</font></td>\n"
|
|
|
90 |
. " <td><img width=\"16\" height=\"16\" alt=\"\" src=\"" . $webpath . "images/" . $XPath->getData( "/phpsysinfo/Vitals/Distroicon" ) . "\"> <font size=\"-1\">" . $XPath->getData("/phpsysinfo/Vitals/Distro") . "</font></td>\n"
|
|
|
91 |
. " </tr>\n"
|
|
|
92 |
. " <tr>\n"
|
1287 |
richard |
93 |
. " <td valign=\"top\"><font size=\"-1\">" . "Date" . "</font></td>\n"
|
|
|
94 |
. " <td><font size=\"-1\">" . $date . "</font></td>\n"
|
|
|
95 |
. " </tr>\n"
|
|
|
96 |
. " <tr>\n"
|
325 |
richard |
97 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['uptime'] . "</font></td>\n"
|
|
|
98 |
. " <td><font size=\"-1\">" . uptime( $XPath->getData( "/phpsysinfo/Vitals/Uptime" ) ) . "</font></td>\n"
|
|
|
99 |
. " </tr>\n"
|
1478 |
richard |
100 |
// . " <tr>\n"
|
|
|
101 |
// . " <td valign=\"top\"><font size=\"-1\">" . $text['users'] . "</font></td>\n"
|
|
|
102 |
// . " <td><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/Vitals/Users" ) . "</font></td>\n"
|
|
|
103 |
// . " </tr>\n"
|
325 |
richard |
104 |
. " <tr>\n"
|
|
|
105 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['loadavg'] . "</font></td>\n"
|
|
|
106 |
. " <td><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/Vitals/LoadAvg" ) . $strLoadbar . "</font></td>\n"
|
|
|
107 |
. " </tr>\n"
|
|
|
108 |
. "</table>\n";
|
|
|
109 |
|
|
|
110 |
return $_text;
|
|
|
111 |
}
|
|
|
112 |
|
|
|
113 |
function wml_vitals () {
|
|
|
114 |
global $XPath;
|
|
|
115 |
global $text;
|
|
|
116 |
|
|
|
117 |
$_text = "<card id=\"vitals\" title=\"" . $text['vitals'] . "\">\n"
|
|
|
118 |
. "<p>" . $text['hostname'] . ":<br/>\n"
|
|
|
119 |
. "- " . $XPath->getData( "/phpsysinfo/Vitals/Hostname" ) . "</p>\n"
|
|
|
120 |
. "<p>" . $text['ip'] . ":<br/>\n"
|
|
|
121 |
. "- " . $XPath->getData( "/phpsysinfo/Vitals/IPAddr" ) . "</p>\n"
|
|
|
122 |
. "<p>" . $text['kversion'] . ":<br/>\n"
|
|
|
123 |
. "- " . $XPath->getData( "/phpsysinfo/Vitals/Kernel" ) . "</p>\n"
|
|
|
124 |
. "<p>" . $text['uptime'] . ":<br/>\n"
|
|
|
125 |
. "- " . uptime( $XPath->getData( "/phpsysinfo/Vitals/Uptime" ) ) . "</p>\n"
|
|
|
126 |
. "<p>" . $text['users'] . ":<br/>"
|
|
|
127 |
. "- " . $XPath->getData( "/phpsysinfo/Vitals/Users" ) . "</p>\n"
|
|
|
128 |
. "<p>" . $text['loadavg'] . ":<br/>"
|
|
|
129 |
. "- " . $XPath->getData( "/phpsysinfo/Vitals/LoadAvg" ) . "</p>\n"
|
|
|
130 |
. "</card>\n";
|
|
|
131 |
|
|
|
132 |
return $_text;
|
|
|
133 |
}
|
|
|
134 |
?>
|