Subversion Repositories ALCASAR

Rev

Rev 1478 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
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 = "";
1287 richard 65
	$date = exec ("/bin/date");
1743 clement.si 66
	$ndd = exec("/bin/openssl x509 -noout -subject -in /etc/pki/tls/certs/alcasar.crt | sed -n '/^subject/s/^.*CN=//p'");
648 richard 67
	$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 68
	if( $XPath->match( "/phpsysinfo/Vitals/CPULoad" ) )
69
		$strLoadbar = "<br>" . create_bargraph( $XPath->getData( "/phpsysinfo/Vitals/CPULoad" ), 100, $scale_factor ) . "&nbsp;" . $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"
1743 clement.si 77
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['domain'] . "</font></td>\n"
78
		. "    <td><font size=\"-1\">" . $ndd . "</font></td>\n"
79
		. "  </tr>\n"
80
		. "  <tr>\n"
648 richard 81
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['cert_expiration_date'] . "</font></td>\n"
82
		. "    <td><font size=\"-1\">" . $cert_ca_expiration_date . "</font></td>\n"
83
		. "  </tr>\n"
325 richard 84
//		. "  <tr>\n"
85
//		. "    <td valign=\"top\"><font size=\"-1\">" . $text['ip'] . "</font></td>\n"
86
//		. "    <td><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/Vitals/IPAddr" ) . "</font></td>\n"
87
//		. "  </tr>\n"
88
		. "  <tr>\n"
89
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['kversion'] . "</font></td>\n"
90
		. "    <td><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/Vitals/Kernel" ) . "</font></td>\n"
91
		. "  </tr>\n"
92
		. "  <tr>\n"
93
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['dversion'] . "</font></td>\n"
94
		. "    <td><img width=\"16\" height=\"16\" alt=\"\" src=\"" . $webpath . "images/" . $XPath->getData( "/phpsysinfo/Vitals/Distroicon" ) . "\">&nbsp;<font size=\"-1\">" . $XPath->getData("/phpsysinfo/Vitals/Distro") . "</font></td>\n"
95
		. "  </tr>\n"
96
		. "  <tr>\n"
1287 richard 97
		. "    <td valign=\"top\"><font size=\"-1\">" . "Date" . "</font></td>\n"
98
		. "    <td><font size=\"-1\">" . $date . "</font></td>\n"
99
		. "  </tr>\n"
100
		. "  <tr>\n"
325 richard 101
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['uptime'] . "</font></td>\n"
102
		. "    <td><font size=\"-1\">" . uptime( $XPath->getData( "/phpsysinfo/Vitals/Uptime" ) ) . "</font></td>\n"
103
		. "  </tr>\n"
1478 richard 104
//		. "  <tr>\n"
105
//		. "    <td valign=\"top\"><font size=\"-1\">" . $text['users'] . "</font></td>\n"
106
//		. "    <td><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/Vitals/Users" ) . "</font></td>\n"
107
//		. "  </tr>\n"
325 richard 108
		. "  <tr>\n"
109
		. "    <td valign=\"top\"><font size=\"-1\">" . $text['loadavg'] . "</font></td>\n"
110
		. "    <td><font size=\"-1\">" . $XPath->getData( "/phpsysinfo/Vitals/LoadAvg" ) . $strLoadbar . "</font></td>\n"
111
		. "  </tr>\n"
112
		. "</table>\n";
113
 
114
	return $_text;
115
} 
116
 
117
function wml_vitals () {
118
	global $XPath;
119
	global $text;
120
 
121
	$_text = "<card id=\"vitals\" title=\"" . $text['vitals']  . "\">\n"
122
		. "<p>" . $text['hostname'] . ":<br/>\n"
123
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/Hostname" ) . "</p>\n"
124
		. "<p>" . $text['ip'] . ":<br/>\n"
125
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/IPAddr" ) . "</p>\n"
126
		. "<p>" . $text['kversion'] . ":<br/>\n"
127
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/Kernel" ) . "</p>\n"
128
		. "<p>" . $text['uptime'] . ":<br/>\n"
129
		. "-&nbsp;" . uptime( $XPath->getData( "/phpsysinfo/Vitals/Uptime" ) ) . "</p>\n"
130
		. "<p>" . $text['users'] . ":<br/>"
131
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/Users" ) . "</p>\n"
132
		. "<p>" . $text['loadavg'] . ":<br/>"
133
		. "-&nbsp;" . $XPath->getData( "/phpsysinfo/Vitals/LoadAvg" ) . "</p>\n"
134
		. "</card>\n";
135
 
136
	return $_text;
137
}
138
?>