diff options
author | stderr64 <linuxwizard@voidnet.dy.fi> | 2023-12-26 00:06:46 +0200 |
---|---|---|
committer | stderr64 <linuxwizard@voidnet.dy.fi> | 2023-12-26 00:06:46 +0200 |
commit | 12499a35529c7098fe53aa6601190d81f01dbb85 (patch) | |
tree | daf351ecd2bacad1a539cb9744a3437e2ebeecd0 | |
download | osstat-12499a35529c7098fe53aa6601190d81f01dbb85.tar.gz osstat-12499a35529c7098fe53aa6601190d81f01dbb85.tar.zst |
First commit
-rwxr-xr-x | osstat.pl | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/osstat.pl b/osstat.pl new file mode 100755 index 0000000..1a0df42 --- /dev/null +++ b/osstat.pl @@ -0,0 +1,46 @@ +#!/usr/bin/perl +use POSIX; +use IO::File; + +print( "Content-Type: text/html; charset=utf-8\r\n\r\n" ); + +my $full_output = "<!DOCTYPE html>\n<html lang=\"en\" style=\"background-color: #000000;\">\n<body style=\"font-family: Arial; background-color: #000000;\">\n<title>Stats</title><div style=\"margin: auto; position: relative; width: 100%;\">\n<table border=\"2px\" style=\"width: 100%\"><tr><th><center><h1 style=\"color: #FFFFFF;\"><u>Stats</u></h1></center></th></tr>\n<tr><td><center><span style=\"color: #FFFFFF; font-size: 18px;\">"; + +my $ver = IO::File->new( "/proc/version", "r" ) or die "Failed to open /proc/version"; +$full_output .= <$ver>."<br/>"; +undef $ver; +my $utime = IO::File->new( "/proc/uptime", "r" ) or die "Failed to open /proc/uptime"; +my @tdata = split( m/ /, <$utime> ); +my $thours = int($tdata[0]) / 60 / 60; +my $tmins = int($tdata[1]) / 60 / 60; +undef $utime; +undef $tdata; +$full_output .= "Uptime: ".int($thours)." hours ".int($tmins)." minutes<br/>"; +undef $thours; +undef $tmins; +my $cpu = IO::File->new( "/proc/cpuinfo", "r" ) or die "Failed to open /proc/cpuinfo"; +my $fline = ""; +my @spl_speed = ""; +my $ccount = 1; +while ( $fline = <$cpu> ){ + if ( $fline =~ m/cpu mhz/i ){ + @spl_speed = split( m/: /, $fline ); + $full_output .= "Core ".$ccount. " speed: ".$spl_speed[1]."<br/>"; + $ccount++; + } +} +undef $cpu; +undef $fline; +undef $ccount; +undef @spl_speed; +my $minfo = IO::File->new( "/proc/meminfo", "r" ) or die "Failed to open /proc/meminfo"; +my $minfoline = ""; +while ( $minfoline = <$minfo> ){ + $full_output .= $minfoline."<br/>"; +} +undef $minfoline; +undef $minfo; +$full_output .= "</span></center></td></tr>\n</table>\n</div>\n</body>\n</html>"; +print( $full_output ); +undef $full_output; +exit( 0 ); |