Relatório do sistema (Shel Script + PHP)
Relatório de seu sistema utilizando linguagem PHP e shell script. Pode ser visualizado por qualquer ponto de sua intranet ou inclusive pela web, de forma bem simples e totalmente visual.
Parte 6: Código PHP + shell pronto para ser usado
O código abaixo retorna as seguintes informações:
- uptime
- Nome do servidor / arquitetura / distribuição
- Processador
- memória existente / utilizada
- HD - tamanho / % usada
- fstab
- PCI´s existentes no computador
- Programas ativos
- Usuários logados
- Usuários do samba logados
- Arquivos utilizados do samba no momento
- Interface de rede
- Portas abertas
- Firewall
- Backups ativos
<html>
<head>
<title>Relatório Servidor :: DEBIAN</title>
</head>
<body>
<p> </p>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="0" class="a">
<tr>
<td class="a"><div align="center"><strong>SERVIDOR DEBIAN</strong> </div></td>
</tr>
<tr>
<td class="a"> </td>
</tr>
<tr>
<td class="a"><strong>Uptime:</strong></td>
</tr>
<tr>
<td class="a"><?php
echo '<pre>';
system('uptime');
?></td>
</tr>
<tr>
<td class="a"><hr /></td>
</tr>
<tr>
<td class="a"><strong>Servidor:</strong></td>
</tr>
<tr>
<td class="a"><?php
echo '<pre>';
system('uname -a');
?></td>
</tr>
<tr>
<td class="a"><hr /></td>
</tr>
<tr>
<td class="a"><strong>Processador:</strong></td>
</tr>
<tr>
<td class="a"><?php
system('cat /proc/cpuinfo');
?>
</td>
</tr>
<tr>
<td class="a"><hr /></td>
</tr>
<tr>
<td class="a"><strong>Memória:</strong></td>
</tr>
<tr>
<td class="a"><?php
echo '<pre>';
system('vmstat -S M 1 5');
?></td>
<tr>
<td class="a"><hr width="50%" /></td>
</tr>
<tr>
<td class="a"><?php
echo '<pre>';
system('free');
?></td>
</tr>
<tr>
<td class="a"><hr align="center" width="50%" noshade="noshade" /></td>
</tr>
<tr>
<td class="a"><?php echo '<pre>';
system('vmstat -s');?></td>
</tr>
<tr>
<td class="a"><hr /></td>
</tr>
<tr>
<td class="a"><strong>HD:</strong></td>
</tr>
<tr>
<td class="a"><?php
echo '<pre>';
system('df -Th');
?></td>
</tr>
</tr>
<tr>
<td class="a"><hr width="50%" /></td>
</tr>
<tr>
<td class="a"><?php
echo '<pre>';
system('cat /etc/fstab');
?></td>
</tr>
<tr>
<td class="a"><hr /></td>
</tr>
<tr>
<td class="a"><strong>PCI:</strong></td>
</tr>
<tr>
<td class="a"><?php
echo '<pre>';
system('lspci');
?></td>
</tr>
<tr>
<td class="a"><hr /></td>
</tr>
<tr>
<td class="a"><strong>Programas Ativos: </strong></td>
</tr>
<tr>
<td class="a"><?php
echo '<pre>';
system('ps -A');
?></td>
</tr>
<tr>
<td class="a"><hr /></td>
</tr>
<tr>
<td class="a"><strong>Usuarios Logados: </strong></td>
</tr>
<tr>
<td class="a"><?php
echo '<pre>';
system('who');
?></td>
</tr>
<tr>
<td class="a"><hr align="center" width="50%" /></td>
</tr>
<tr>
<td class="a"><?php
echo '<pre>';
system('smbstatus');
?></td>
</tr>
<tr>
<td class="a"><hr /></td>
</tr>
<tr>
<td class="a"><strong>Interface de Rede: </strong></td>
</tr>
<tr>
<td class="a"><?php
echo '<pre>';
system('/sbin/ifconfig');
?></td>
</tr>
<tr>
<td class="a"><hr /></td>
</tr>
<tr>
<td class="a"><strong>Portas Abertas: </strong></td>
</tr>
<tr>
<td class="a"><?php
echo '<pre>';
system('nmap localhost');
?></td>
</tr>
<tr>
<td class="a"><hr /></td>
</tr>
<tr>
<td class="a"><strong>FIREWALL: [1] Ligado [0] Desligado </strong></td>
</tr>
<tr>
<td class="a"><strong>rpfilter</strong>:
<?php
system('cat /proc/sys/net/ipv4/conf/default/rp_filter');
?></td>
</tr>
<tr>
<td class="a"><strong>ipforward</strong>:
<?php
system('cat /proc/sys/net/ipv4/ip_forward');
?></td>
</tr>
<tr>
<td class="a"> </td>
</tr>
<tr>
<td class="a"><strong>matches:</strong></td>
</tr>
<tr>
<td class="a"><?php
echo '<pre>';
system('cat /proc/net/ip_tables_matches');
?></td>
</tr>
<tr>
<td class="a"> </td>
</tr>
<tr>
<td class="a"><strong>Names</strong>:</td>
</tr>
<tr>
<td class="a"><?php
echo '<pre>';
system('cat /proc/net/ip_tables_names');
?></td>
</tr>
<tr>
<td class="a"> </td>
</tr>
<tr>
<td class="a"><strong>Targets:</strong></td>
</tr>
<tr>
<td class="a"><?php
echo '<pre>';
system('cat /proc/net/ip_tables_targets');
?></td>
</tr>
<tr>
<td class="a"> </td>
</tr>
<tr>
<td class="a"><hr /></td>
</tr>
<tr>
<td class="a"><strong>Backups ativos </strong></td>
</tr>
<tr>
<tr>
<td class="a">
<?php
system('ls /mnt/sdb2/BACKUP');
?></td>
<td class="a"><div align="right"><em> brunos.ti@gmail.com </em></div></td>
</tr>
</table>
</body>
</html>
<head>
<title>Relatório Servidor :: DEBIAN</title>
</head>
<body>
<p> </p>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="0" class="a">
<tr>
<td class="a"><div align="center"><strong>SERVIDOR DEBIAN</strong> </div></td>
</tr>
<tr>
<td class="a"> </td>
</tr>
<tr>
<td class="a"><strong>Uptime:</strong></td>
</tr>
<tr>
<td class="a"><?php
echo '<pre>';
system('uptime');
?></td>
</tr>
<tr>
<td class="a"><hr /></td>
</tr>
<tr>
<td class="a"><strong>Servidor:</strong></td>
</tr>
<tr>
<td class="a"><?php
echo '<pre>';
system('uname -a');
?></td>
</tr>
<tr>
<td class="a"><hr /></td>
</tr>
<tr>
<td class="a"><strong>Processador:</strong></td>
</tr>
<tr>
<td class="a"><?php
system('cat /proc/cpuinfo');
?>
</td>
</tr>
<tr>
<td class="a"><hr /></td>
</tr>
<tr>
<td class="a"><strong>Memória:</strong></td>
</tr>
<tr>
<td class="a"><?php
echo '<pre>';
system('vmstat -S M 1 5');
?></td>
<tr>
<td class="a"><hr width="50%" /></td>
</tr>
<tr>
<td class="a"><?php
echo '<pre>';
system('free');
?></td>
</tr>
<tr>
<td class="a"><hr align="center" width="50%" noshade="noshade" /></td>
</tr>
<tr>
<td class="a"><?php echo '<pre>';
system('vmstat -s');?></td>
</tr>
<tr>
<td class="a"><hr /></td>
</tr>
<tr>
<td class="a"><strong>HD:</strong></td>
</tr>
<tr>
<td class="a"><?php
echo '<pre>';
system('df -Th');
?></td>
</tr>
</tr>
<tr>
<td class="a"><hr width="50%" /></td>
</tr>
<tr>
<td class="a"><?php
echo '<pre>';
system('cat /etc/fstab');
?></td>
</tr>
<tr>
<td class="a"><hr /></td>
</tr>
<tr>
<td class="a"><strong>PCI:</strong></td>
</tr>
<tr>
<td class="a"><?php
echo '<pre>';
system('lspci');
?></td>
</tr>
<tr>
<td class="a"><hr /></td>
</tr>
<tr>
<td class="a"><strong>Programas Ativos: </strong></td>
</tr>
<tr>
<td class="a"><?php
echo '<pre>';
system('ps -A');
?></td>
</tr>
<tr>
<td class="a"><hr /></td>
</tr>
<tr>
<td class="a"><strong>Usuarios Logados: </strong></td>
</tr>
<tr>
<td class="a"><?php
echo '<pre>';
system('who');
?></td>
</tr>
<tr>
<td class="a"><hr align="center" width="50%" /></td>
</tr>
<tr>
<td class="a"><?php
echo '<pre>';
system('smbstatus');
?></td>
</tr>
<tr>
<td class="a"><hr /></td>
</tr>
<tr>
<td class="a"><strong>Interface de Rede: </strong></td>
</tr>
<tr>
<td class="a"><?php
echo '<pre>';
system('/sbin/ifconfig');
?></td>
</tr>
<tr>
<td class="a"><hr /></td>
</tr>
<tr>
<td class="a"><strong>Portas Abertas: </strong></td>
</tr>
<tr>
<td class="a"><?php
echo '<pre>';
system('nmap localhost');
?></td>
</tr>
<tr>
<td class="a"><hr /></td>
</tr>
<tr>
<td class="a"><strong>FIREWALL: [1] Ligado [0] Desligado </strong></td>
</tr>
<tr>
<td class="a"><strong>rpfilter</strong>:
<?php
system('cat /proc/sys/net/ipv4/conf/default/rp_filter');
?></td>
</tr>
<tr>
<td class="a"><strong>ipforward</strong>:
<?php
system('cat /proc/sys/net/ipv4/ip_forward');
?></td>
</tr>
<tr>
<td class="a"> </td>
</tr>
<tr>
<td class="a"><strong>matches:</strong></td>
</tr>
<tr>
<td class="a"><?php
echo '<pre>';
system('cat /proc/net/ip_tables_matches');
?></td>
</tr>
<tr>
<td class="a"> </td>
</tr>
<tr>
<td class="a"><strong>Names</strong>:</td>
</tr>
<tr>
<td class="a"><?php
echo '<pre>';
system('cat /proc/net/ip_tables_names');
?></td>
</tr>
<tr>
<td class="a"> </td>
</tr>
<tr>
<td class="a"><strong>Targets:</strong></td>
</tr>
<tr>
<td class="a"><?php
echo '<pre>';
system('cat /proc/net/ip_tables_targets');
?></td>
</tr>
<tr>
<td class="a"> </td>
</tr>
<tr>
<td class="a"><hr /></td>
</tr>
<tr>
<td class="a"><strong>Backups ativos </strong></td>
</tr>
<tr>
<tr>
<td class="a">
<?php
system('ls /mnt/sdb2/BACKUP');
?></td>
<td class="a"><div align="right"><em> brunos.ti@gmail.com </em></div></td>
</tr>
</table>
</body>
</html>
mas gostaria de acrescentar que tem um projeto sobre isso que vc disse que é muito bom e bonito é o phpsysinfo
segue em exemplo pra verem como é
http://200.205.201.2/sysinfo/