403Webshell
Server IP : 66.29.132.122  /  Your IP : 3.141.25.133
Web Server : LiteSpeed
System : Linux business142.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : admazpex ( 531)
PHP Version : 7.2.34
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-mail-filter-avlb.sh
#!/bin/bash

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin

#variable

#test_email="/usr/lib64/nagios/plugins/nccustom/test.eml"
my_dir=$(dirname "${0}")
test_email=$my_dir/test.eml

ip=prod-sharedhostinglb-phx.jellyfish.systems
port=11330
#cust_parm

#input option

PROGNAME=${0##*/}

print_usage() {
    echo ""
    echo "Usage: $PROGNAME [-f Diff path or test_email] [-p Port]"
    echo "Usage: $PROGNAME [-i Ip] [-c running a ping_only check and custom parameters to CURL]"
    echo "Usage: $PROGNAME  --help"
}

print_help() {
    print_usage
    echo ""
    echo "This script for rspamd accessability monitoring from shared hosting servers (see TOP-841)"
    echo ""
    echo "-f Different path and file."
    echo "-i Different Host/IP"
    echo "-p Different Port"
    echo "-c Additional parameters for cURL (add keyword ping_only w/out spaces for request /ping at endpoint)"
    echo "--help Print this help screen"
    echo ""
    exit 3
}

while [ $# -gt 0 ]; do

    case "$1" in
        -f)
         test_email=$2; shift
         ;;

        -i)
        ip=$2; shift
        ;;

        -p)
        port=$2; shift
        ;;

        -c)
        cust_parm=$2; shift
        ;;

        --help)
        print_help
         ;;

        -h)
        print_help
         ;;

        *)
        echo >&2 "Unknown argument: $1"
        print_usage
        exit 3
        ;;

        esac
        shift
done


#main

if [[ "${cust_parm}" == *"ping_only"* ]]; then
    result=$(curl https://"${ip}":"${port}"/ping -s "${cust_parm//ping_only}")
    if [[ "${result}" == *"pong"* ]]; then
        echo "OK, mail filtration endpoint ${ip}:${port} is reachable"
        exit 0
    else
        echo "CRITICAL, mail filtration endpoint ${ip}:${port} is NOT available"
        exit 2
    fi
else
    mapfile -t result < <(curl https://"${ip}":"${port}"/checkv2 -X POST --data-binary @- < "${test_email}" -s "${cust_parm}" | jq '"action=\(.action) score=\(.score)"')
    if printf "%s\n" "${result[@]}" |grep action |grep score  > /dev/null;then
        echo "OK: ${result[*]}"
        exit 0
    else
        echo "CRITICAL:action/score can't be retrieved from ${ip}:${port} for some reason"
        exit 2
    fi
fi

Youez - 2016 - github.com/yon3zu
LinuXploit