GRAYBYTE WORDPRESS FILE MANAGER8272

Server IP : 149.255.58.128 / Your IP : 216.73.216.44
System : Linux cloud516.thundercloud.uk 5.14.0-427.26.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jul 17 15:51:13 EDT 2024 x86_64
PHP Version : 8.2.28
Disable Function : allow_url_include, apache_child_terminate, apache_setenv, exec, passthru, pcntl_exec, posix_kill, posix_mkfifo, posix_getpwuid, posix_setpgid, posix_setsid, posix_setuid, posix_setgid, posix_seteuid, posix_setegid, posix_uname, proc_close, proc_get_status, proc_open, proc_terminate, shell_exec, show_source, system
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Directory : /lib64/nagios/plugins/
Upload Files :
Current_dir [ Not Writeable ] Document_root [ Writeable ]

Command :


Current File : /lib64/nagios/plugins//check_iface.php
#!/usr/bin/php
<?php

// ############################################################################################
//  Author: Philip A. O'Malley, (C)2006 Awareness Software Limited.
// ############################################################################################

// Define our exit codes.

$nagios_exit = array( 'UNKNOWN' => 3, 'OK' => 0, 'WARNING' => 1, 'CRITICAL' => 2 );

// Translate CLI arguments to conventional actions.

$options = getopt("i:w:c:");

if(!array_key_exists("i", $options) or !array_key_exists("w", $options) or !array_key_exists("c", $options)) {
    echo "Usage: check_iface_nrpe.php -i iface -w warningmbitsec -c criticalmbitsec\n";
    exit($nagios_exit["UNKNOWN"]);
}
else {
    $interface = $options["i"];
    $warning_level = $options["w"];
    $critical_level = $options["c"];
}

// Blow the routine if we don't get an array.

if(!is_array($return = parseProc($interface))) {
    echo $return."\n";
    exit($nagios_exit["UNKNOWN"]);
}

// Into the interrogation of the data.

checkIfaceData($interface, $return, $warning_level, $critical_level);

// ############################################################################################
//  FUNCTION: checkIfaceData($array)
// ############################################################################################

function checkIfaceData($interface, $array, $warning_level, $critical_level) {

    global $nagios_exit;
    list($input_bits, $output_bits) = $array;

    $timestamp =  microtime_float();
    $iface_file = "/tmp/check_iface_".$interface;

    // See if we have a file of past data we can read.

    if(file_exists($iface_file)) {
        $iface_history = file_get_contents($iface_file);
        list($previous_timestamp, $previous_input_bits, $previous_output_bits) = explode(",", $iface_history);
    }

    // Write out our new data. We do this now in case the machine has rebooted and all the values
    // in /proc have been reset - so let's just write it out now.

    file_put_contents($iface_file, $timestamp.",".$input_bits.",".$output_bits);

    if(!isset($iface_history)) {
        echo "UNKNOWN: no historical data for interface ".$interface."\n";
        exit($nagios_exit["UNKNOWN"]);
    }

    // So, let's work out what's incremented.

    $diff_timestamp = $timestamp - $previous_timestamp;
    $diff_input_bits = $input_bits - $previous_input_bits;
    $diff_output_bits = $output_bits - $previous_output_bits;

    if($diff_timestamp < 0) {
        echo "UNKNOWN: a historical compare returned a negative value for interface ".$interface."\n";
        exit($nagios_exit["UNKNOWN"]);
    }

    if($diff_timestamp < 0) {
        echo "UNKNOWN: a historical compare returned a negative value for interface ".$interface."\n";
        exit($nagios_exit["UNKNOWN"]);
    }

    // If we have negative input bits then we've rolled round the 32-bit integer limit.

    if($diff_input_bits < 0) {
        $diff_input_bits = ($diff_input_bits*-1)+(4294967296-$previous_input_bits);
    }


    if($diff_output_bits < 0) {
        $diff_output_bits = ($diff_output_bits*-1)+(4294967296-$previous_output_bits);
    }

    $average_input_mbits = ((($diff_input_bits/$diff_timestamp)/1024)/1024);
    $average_output_mbits = ((($diff_output_bits/$diff_timestamp)/1024)/1024);

    // Let's see if our metrics fall into parameters.

    $performance_data  = "input=".number_format($average_input_mbits, 2)."Mbps;".$warning_level.";".$critical_level.";0;10000; ";
    $performance_data .= "output=".number_format($average_output_mbits, 2)."Mbps;".$warning_level.";".$critical_level.";0;10000;";

    if(($average_input_mbits > $critical_level) or ($average_output_mbits > $critical_level)) {
        echo "CRITICAL: ".number_format($average_input_mbits, 2)." Mbps input, ".number_format($average_output_mbits,2)." Mbps output | ".$performance_data."\n";
        exit($nagios_exit["CRITICAL"]);
    }
    elseif(($average_input_mbits > $warning_level) or ($average_output_mbits > $warning_level)) {
        echo "WARNING: ".number_format($average_input_mbits,2)." Mbps input, ".number_format($average_output_mbits,2)." Mbps output | ".$performance_data."\n";
        exit($nagios_exit["WARNING"]);
    }
    elseif(($average_input_mbits <= $warning_level) and ($average_output_mbits <= $warning_level)) {
        echo "OK: ".number_format($average_input_mbits,2)." Mbps input, ".number_format($average_output_mbits,2)." Mbps output | ".$performance_data."\n";
        exit($nagios_exit["OK"]);
    }
    else {
        echo "UNKNOWN: unexpected result.\n";
        exit($nagios_exit["UNKNOWN"]);
    }

}

// ############################################################################################
//  FUNCTION: microtime_float()
// ############################################################################################

function microtime_float()
{
    list($usec, $sec) = explode(" ", microtime());
    return ((float)$usec + (float)$sec);
}

// ############################################################################################
//  FUNCTION: parseProc($db_source)
// ############################################################################################

function parseProc($interface) {

    if(!$procfile = file_get_contents("/proc/net/dev")) {
        return "UNKNOWN: unable to parse /proc/net/dev.";
    }
    else {

        foreach(explode("\n", $procfile) as $lineid => $data) {

            if(strpos($data, $interface.":") !== FALSE) {
                $data = preg_replace('/'.$interface.':/', '', $data);
                $data = preg_replace("/\s+/", " ", $data);
                $data = ltrim($data);

                $line_explode = (explode(" ", $data));
                $input_bits = $line_explode[0]*8;
                $output_bits = $line_explode[8]*8;

            }

        }

    }

    if(!is_array($line_explode)) {
        return "UNKNOWN: no interface found in /proc/net/dev.";
    }

    return array($input_bits, $output_bits);

}

?>


[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
April 28 2024 11:20:59
0 / root
0755
eventhandlers
--
April 28 2024 11:20:59
0 / root
0755
check_apache2.sh
10.779 KB
January 30 2013 12:21:10
0 / root
0755
check_cpu.sh
4.36 KB
February 12 2019 08:36:33
0 / root
0755
check_crm.pl
6.467 KB
September 17 2015 13:45:51
0 / root
0755
check_disk
53.047 KB
March 28 2024 13:15:48
0 / root
0755
check_iface.php
5.883 KB
September 29 2015 14:20:25
0 / root
0755
check_jetbackup
7.843 KB
July 29 2024 11:13:24
0 / root
0755
check_load
35.703 KB
March 28 2024 13:15:48
0 / root
0755
check_mem.pl
6.235 KB
January 28 2013 15:36:20
0 / root
0755
check_mpt.sh
2.267 KB
February 18 2015 18:15:28
0 / root
0755
check_mqueue_exiqgrep.sh
0.97 KB
February 27 2023 18:26:09
0 / root
0755
check_mqueue_postfix.sh
1.082 KB
February 13 2019 10:23:20
0 / root
0755
check_mysql.pl
27.219 KB
January 30 2013 13:09:36
0 / root
0755
check_mysql_replication.sh
2.065 KB
May 20 2010 10:29:33
0 / root
0755
check_raid.pl
114.584 KB
November 20 2015 12:37:21
0 / root
0755
check_service.sh
10.078 KB
October 30 2024 17:54:56
0 / root
0755
check_swap
31.719 KB
March 28 2024 13:15:48
0 / root
0755
error_log
0.551 KB
May 03 2024 08:18:25
0 / root
0644
negate
27.617 KB
March 28 2024 13:15:48
0 / root
0755
urlize
23.359 KB
March 28 2024 13:15:48
0 / root
0755
utils.sh
2.729 KB
March 28 2024 13:15:40
0 / root
0755

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF