📜 ⬆️ ⬇️

Non-serious home server statistics :)

cowsay
As a Friday post, let's teach a cow to talk :)

Using cowsay , we show the free space, the temperature of the screws and the processor, uptime.

In order to have fun, I decided to make a display of information about the home server in a playful way. All that happened we look under the cut.

A simple PHP script that can be viewed from anywhere through a browser deals with this kind of non-tricky information.
  ________________________________________________________________
 (Filesystem Size Used Avail Use% Mounted on)
 (/ dev / sda1 11G 1.9G 8.7G 18% /)
 (tmpfs 253M 0 253M 0% / lib / init / rw)
 (udev 10M 668K 9.4M 7% / dev)
 (tmpfs 253M 0 253M 0% / dev / shm)
 (/ dev / mapper / lvmvolume-arch)
 (3.7T 3.7T 5.2G 100% / arch)
 (/ dev / sda3 584G 579G 5.6G 100% /arch/.Downloading)
  -------------------------------------------------- --------------
         o ^ __ ^
          o (oo) \ _______
             (__) \) \ / \
                 || ---- w |
                 ||  ||

 CPU 31 C Intel (R) Pentium (R) III CPU - S 1400MHz

 / dev / sda 24 C SAMSUNG HD642JJ
 / dev / sdb 31 C Hitachi HDT721010SLA360
 / dev / sdc 20 C SAMSUNG HD154UI
 / dev / sdd 26 C ST31500541AS

 Linux server 2.6.26-2-686 # 1 SMP Wed Feb 10 08:59:21 UTC 2010 i686 GNU / Linux
 uptime: 10:43:29 up 16 days, 16:59, 1 user, load average: 0.02, 0.04, 0.00 

')


Source code



<?php
// cowsay disk usage
system( "df -h | perl /usr/games/cowthink -n" );
echo "\n" ;

// CPU thermal info
$cpu_thrminfo = exec( 'cat /proc/acpi/thermal_zone/THRM/temperature' );
$cpu_thrminfo = explode( ':' , $cpu_thrminfo);
echo "CPU\t\t" , trim($cpu_thrminfo[1]);

// CPU model name
$cpu_mdl = exec( "cat /proc/cpuinfo | grep -i 'model name'" );
$cpu_mdl = explode( ':' , $cpu_mdl);
echo "\t" , trim($cpu_mdl[1]), "\n" ;
echo "\n" ;

// HDD temperature
$hdd_list = exec( 'nc localhost 7634' );
$hdd_list = trim($hdd_list, '|' );
foreach (explode( '||' , $hdd_list) as $hdd_temp)
{
$hdd_temp = explode( '|' , $hdd_temp);
echo $hdd_temp[0], "\t" , $hdd_temp[2], ' ' , $hdd_temp[3], "\t" , $hdd_temp[1], "\n" ;
}

// uname && uptime
echo "\n" , `uname -a`;
echo 'uptime:' , `uptime`;
?>


* This source code was highlighted with Source Code Highlighter .


PS Work requires the running daemon hddtemp on port 7634.

Source: https://habr.com/ru/post/88126/


All Articles