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"
|
|
|
45 |
. " <Users>" . htmlspecialchars( $sysinfo->users(), ENT_QUOTES ) . "</Users>\n"
|
|
|
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 = "";
|
648 |
richard |
65 |
$cert_ca_expiration_date = exec ("sudo /usr/bin/openssl x509 -noout -in /etc/pki/tls/certs/alcasar.crt -dates|grep After|cut -d\"=\" -f2");
|
325 |
richard |
66 |
if( $XPath->match( "/phpsysinfo/Vitals/CPULoad" ) )
|
|
|
67 |
$strLoadbar = "<br>" . create_bargraph( $XPath->getData( "/phpsysinfo/Vitals/CPULoad" ), 100, $scale_factor ) . " " . $XPath->getData( "/phpsysinfo/Vitals/CPULoad" ) . "%";
|
|
|
68 |
|
|
|
69 |
$_text = "<table border=\"0\" width=\"100%\" align=\"center\">\n"
|
|
|
70 |
. " <tr>\n"
|
|
|
71 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['hostname'] . "</font></td>\n"
|
|
|
72 |
. " <td><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/Vitals/Hostname" ) . "</font></td>\n"
|
|
|
73 |
. " </tr>\n"
|
648 |
richard |
74 |
. " <tr>\n"
|
|
|
75 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['cert_expiration_date'] . "</font></td>\n"
|
|
|
76 |
. " <td><font size=\"-1\">" . $cert_ca_expiration_date . "</font></td>\n"
|
|
|
77 |
. " </tr>\n"
|
325 |
richard |
78 |
// . " <tr>\n"
|
|
|
79 |
// . " <td valign=\"top\"><font size=\"-1\">" . $text['ip'] . "</font></td>\n"
|
|
|
80 |
// . " <td><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/Vitals/IPAddr" ) . "</font></td>\n"
|
|
|
81 |
// . " </tr>\n"
|
|
|
82 |
. " <tr>\n"
|
|
|
83 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['kversion'] . "</font></td>\n"
|
|
|
84 |
. " <td><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/Vitals/Kernel" ) . "</font></td>\n"
|
|
|
85 |
. " </tr>\n"
|
|
|
86 |
. " <tr>\n"
|
|
|
87 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['dversion'] . "</font></td>\n"
|
|
|
88 |
. " <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"
|
|
|
89 |
. " </tr>\n"
|
|
|
90 |
. " <tr>\n"
|
|
|
91 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['uptime'] . "</font></td>\n"
|
|
|
92 |
. " <td><font size=\"-1\">" . uptime( $XPath->getData( "/phpsysinfo/Vitals/Uptime" ) ) . "</font></td>\n"
|
|
|
93 |
. " </tr>\n"
|
|
|
94 |
. " <tr>\n"
|
|
|
95 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['users'] . "</font></td>\n"
|
|
|
96 |
. " <td><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/Vitals/Users" ) . "</font></td>\n"
|
|
|
97 |
. " </tr>\n"
|
|
|
98 |
. " <tr>\n"
|
|
|
99 |
. " <td valign=\"top\"><font size=\"-1\">" . $text['loadavg'] . "</font></td>\n"
|
|
|
100 |
. " <td><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/Vitals/LoadAvg" ) . $strLoadbar . "</font></td>\n"
|
|
|
101 |
. " </tr>\n"
|
|
|
102 |
. "</table>\n";
|
|
|
103 |
|
|
|
104 |
return $_text;
|
|
|
105 |
}
|
|
|
106 |
|
|
|
107 |
function wml_vitals () {
|
|
|
108 |
global $XPath;
|
|
|
109 |
global $text;
|
|
|
110 |
|
|
|
111 |
$_text = "<card id=\"vitals\" title=\"" . $text['vitals'] . "\">\n"
|
|
|
112 |
. "<p>" . $text['hostname'] . ":<br/>\n"
|
|
|
113 |
. "- " . $XPath->getData( "/phpsysinfo/Vitals/Hostname" ) . "</p>\n"
|
|
|
114 |
. "<p>" . $text['ip'] . ":<br/>\n"
|
|
|
115 |
. "- " . $XPath->getData( "/phpsysinfo/Vitals/IPAddr" ) . "</p>\n"
|
|
|
116 |
. "<p>" . $text['kversion'] . ":<br/>\n"
|
|
|
117 |
. "- " . $XPath->getData( "/phpsysinfo/Vitals/Kernel" ) . "</p>\n"
|
|
|
118 |
. "<p>" . $text['uptime'] . ":<br/>\n"
|
|
|
119 |
. "- " . uptime( $XPath->getData( "/phpsysinfo/Vitals/Uptime" ) ) . "</p>\n"
|
|
|
120 |
. "<p>" . $text['users'] . ":<br/>"
|
|
|
121 |
. "- " . $XPath->getData( "/phpsysinfo/Vitals/Users" ) . "</p>\n"
|
|
|
122 |
. "<p>" . $text['loadavg'] . ":<br/>"
|
|
|
123 |
. "- " . $XPath->getData( "/phpsysinfo/Vitals/LoadAvg" ) . "</p>\n"
|
|
|
124 |
. "</card>\n";
|
|
|
125 |
|
|
|
126 |
return $_text;
|
|
|
127 |
}
|
|
|
128 |
?>
|