Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # Set Warnings
- TEMPS=50
- VOLTS=4
- TX=3
- RX="-25"
- BIAS=15
- # Set Telegram
- #BOT_TOKEN="TOKEN"
- #CHAT_ID="ID"
- # Telegram send message
- #send_telegram_message() {
- # message="$1"
- # curl -s -X POST "https://api.telegram.org/bot$BOT_TOKEN/sendMessage" \
- # -H 'Content-Type: application/json' \
- # -d '{"chat_id":"'"$CHAT_ID"'", "text":"'"$message"'", "parse_mode": "html", "protect_content": true}' \
- # >/dev/null 2>&1
- #}
- # Router URL
- LOGIN_URL="http://192.168.1.1/boaform/admin/formLogin?username=admin&password=admin&save=Login&submit-url=%2Fadmin%2Flogin.asp"
- STATUS_URL="http://192.168.1.1/status_pon.asp"
- # Fetch the content of the status page using the authenticated session
- curl -s "$LOGIN_URL" > /dev/null
- # Fetch the content of the status page using the authenticated session
- html_content=$(curl -s "$STATUS_URL")
- # Define an array of the parameters you want to extract
- #parameters=("Temperature" "Voltage" "Tx Power" "Rx Power" "Bias Current")
- # Loop through the parameters
- #for param in "${parameters[@]}"; do
- echo
- for param in "Temperature" "Tx Power" "Rx Power" "Voltage" "Bias Current"; do
- # Use grep to find the line with the parameter and then use sed to extract the value
- value=$(echo "$html_content" | grep -A1 "$param" | tail -n1 | sed -n 's/.*>\(.*\)<\/.*/\1/p')
- # Extract the numerical part of the value (including negative sign)
- numerical_value=$(echo $value | awk '{print $1}')
- # Extract the unit of the value
- unit=$(echo $value | awk '{print $2}')
- # Round off the value to 2 decimal points
- rounded_value=$(printf "%.2f" $numerical_value)
- echo $param: $rounded_value $unit
- # Add individual checks for each parameter
- # if [ "$param" == "Temperature" ] && (( $(echo "$rounded_value > $TEMPS" | bc -l) )); then
- # send_telegram_message "<b>**WARNING**</b> \n <b>$param:</b> $rounded_value $unit"
- # elif [ "$param" == "Voltage" ] && (( $(echo "$rounded_value > $VOLTS" | bc -l) )); then
- # send_telegram_message "<b>**WARNING**</b> \n <b>$param:</b> $rounded_value $unit"
- # elif [ "$param" == "Tx Power" ] && (( $(echo "$rounded_value > $TX" | bc -l) )); then
- # send_telegram_message "<b>**WARNING**</b> \n <b>$param:</b> $rounded_value $unit"
- # elif [ "$param" == "Rx Power" ] && (( $(echo "$rounded_value < $RX" | bc -l) )); then
- # send_telegram_message "<b>**WARNING**</b> \n <b>$param:</b> $rounded_value $unit"
- # elif [ "$param" == "Bias Current" ] && (( $(echo "$rounded_value > $BIAS" | bc -l) )); then
- # send_telegram_message "<b>**WARNING**</b> \n <b>$param:</b> $rounded_value $unit"
- # fi
- done
- echo
- echo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement