diff --git a/web/includes/functions.php b/web/includes/functions.php index b85624335..2ead3d64e 100644 --- a/web/includes/functions.php +++ b/web/includes/functions.php @@ -1504,6 +1504,66 @@ function getDiskBlocks() { return( $space ); } +function systemStats() { + + $load = getLoad(); + $diskPercent = getDiskPercent(); + $pathMapPercent = getDiskPercent(ZM_PATH_MAP); + $cpus = getcpus(); + + $normalized_load = $load / $cpus; + + # Colorize the system load stat + if ( $normalized_load <= 0.75 ) { + $htmlLoad=$load; + } elseif ( $normalized_load <= 0.9 ) { + $htmlLoad="$load"; + } elseif ( $normalized_load <= 1.1 ) { + $htmlLoad="$load"; + } else { + $htmlLoad="$load"; + } + + # Colorize the disk space stat + if ( $diskPercent < 98 ) { + $htmlDiskPercent="$diskPercent%"; + } elseif ( $diskPercent <= 99 ) { + $htmlDiskPercent="$diskPercent%"; + } else { + $htmlDiskPercent="$diskPercent%"; + } + + # Colorize the PATH_MAP (usually /dev/shm) stat + if ( $pathMapPercent < 90 ) { + if ( disk_free_space(ZM_PATH_MAP) > 209715200 ) { # have to always have at least 200MiB free + $htmlPathMapPercent="$pathMapPercent%"; + } else { + $htmlPathMapPercent="$pathMapPercent%"; + } + } elseif ( $pathMapPercent < 100 ) { + $htmlPathMapPercent="$pathMapPercent%"; + } else { + $htmlPathMapPercent="$pathMapPercent%"; + } + + $htmlString = translate('Load').": $htmlLoad - ".translate('Disk').": $htmlDiskPercent - ".ZM_PATH_MAP.": $htmlPathMapPercent"; + + return( $htmlString ); +} + +function getcpus() { + + if (is_readable("/proc/cpuinfo") ) { # Works on Linux + preg_match_all('/^processor/m', file_get_contents('/proc/cpuinfo'), $matches); + $num_cpus = count($matches[0]); + } else { # Works on BSD + $matches = explode(":", shell_exec("sysctl hw.ncpu")); + $num_cpus = trim($matches[1]); + } + + return( $num_cpus ); +} + // Function to fix a problem whereby the built in PHP session handling // features want to put the sid as a hidden field after the form or // fieldset tag, neither of which will work with strict XHTML Basic. diff --git a/web/skins/classic/css/classic/views/console.css b/web/skins/classic/css/classic/views/console.css index 481a14944..fdf1cfb63 100644 --- a/web/skins/classic/css/classic/views/console.css +++ b/web/skins/classic/css/classic/views/console.css @@ -12,6 +12,19 @@ float: right; } +#systemStats .warning { + color: orange; +} + +#systemStats .error { + color: red; +} + +#systemStats .critical { + color: red; + text-decoration: blink; +} + #monitorSummary { float: left; text-align: left; diff --git a/web/skins/classic/css/dark/views/console.css b/web/skins/classic/css/dark/views/console.css index 9de9128b5..e28a15b79 100644 --- a/web/skins/classic/css/dark/views/console.css +++ b/web/skins/classic/css/dark/views/console.css @@ -12,6 +12,19 @@ float: right; } +#systemStats .warning { + color: orange; +} + +#systemStats .error { + color: red; +} + +#systemStats .critical { + color: red; + text-decoration: blink; +} + #monitorSummary { float: left; text-align: left; diff --git a/web/skins/classic/css/flat/views/console.css b/web/skins/classic/css/flat/views/console.css index 481a14944..fdf1cfb63 100644 --- a/web/skins/classic/css/flat/views/console.css +++ b/web/skins/classic/css/flat/views/console.css @@ -12,6 +12,19 @@ float: right; } +#systemStats .warning { + color: orange; +} + +#systemStats .error { + color: red; +} + +#systemStats .critical { + color: red; + text-decoration: blink; +} + #monitorSummary { float: left; text-align: left; diff --git a/web/skins/classic/views/console.php b/web/skins/classic/views/console.php index c5a3c9784..ccb845df3 100644 --- a/web/skins/classic/views/console.php +++ b/web/skins/classic/views/console.php @@ -154,7 +154,7 @@ xhtmlHeaders( __FILE__, translate('Console') );