What's new

VPNMON VPNMON-R2 v2.65 -Jan 27, 2024- DISCONTINUED - Upgrade to VPNMON-R3 Available! (#3)

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

I've updated to the latest version and I'm seeing "unknown operand" on the main page... doesn't seem to affect anything though

_ ______ _ ____ _______ _ __ ____ ___
| | / / __ \/ | / / |/ / __ \/ | / / / __ \__ \ v2.62
| | / / /_/ / |/ / /|_/ / / / / |/ /_____/ /_/ /_/ / (S)etup
| |/ / ____/ /| / / / / /_/ / /| /_____/ _, _/ __/ (R)eset
|___/_/ /_/ |_/_/ /_/\____/_/ |_/ /_/ |_/____/ (E)xit
____________
/General Info\_____________________________________________________

[: -1: unknown operand
[: -1: unknown operand
[: -1: unknown operand
[: -1: unknown operand
VPN State 1:2 2: 3: 4: 5: --- Public VPN IP:
WAN State 0:2 1:0 ----------------- Sched Reset: 01:00 / 60 Sec
Auto Start After Reboot Protection ----- Status: On / post-mount
__________
/Interfaces\_______________________________________________________

==WAN0 ppp0 Active
- WAN1 Port Inactive
------------------------------------------------------------------


Doesn't seem to be anything in the logs which would indicate an issue
VPNMON-R2 - A new update (v2.62) is available to download
VPNMON-R2 - API call made to update WAN0 city to xxx
VPNMON-R2 - API call made to update VPN city to xxx
VPNMON-R2 - A new update (v2.62) is available to download
VPNMON-R2 - Successfully updated VPNMON-R2 v2.59 to v2.62
VPNMON-R2 - API call made to update WAN0 city to xxx
VPNMON-R2 - API call made to update VPN city to xxx
VPNMON-R2 - Successfully wrote a new config file
VPNMON-R2 - Successfully wrote a new config file
 
I've updated to the latest version and I'm seeing "unknown operand" on the main page... doesn't seem to affect anything though

_ ______ _ ____ _______ _ __ ____ ___
| | / / __ \/ | / / |/ / __ \/ | / / / __ \__ \ v2.62
| | / / /_/ / |/ / /|_/ / / / / |/ /_____/ /_/ /_/ / (S)etup
| |/ / ____/ /| / / / / /_/ / /| /_____/ _, _/ __/ (R)eset
|___/_/ /_/ |_/_/ /_/\____/_/ |_/ /_/ |_/____/ (E)xit

____________
/General Info\_____________________________________________________

[: -1: unknown operand
[: -1: unknown operand
[: -1: unknown operand
[: -1: unknown operand
VPN State 1:2 2: 3: 4: 5: --- Public VPN IP:
WAN State 0:2 1:0 ----------------- Sched Reset: 01:00 / 60 Sec
Auto Start After Reboot Protection ----- Status: On / post-mount

__________
/Interfaces\_______________________________________________________


==WAN0 ppp0 Active
- WAN1 Port Inactive
------------------------------------------------------------------

Doesn't seem to be anything in the logs which would indicate an issue
VPNMON-R2 - A new update (v2.62) is available to download
VPNMON-R2 - API call made to update WAN0 city to xxx
VPNMON-R2 - API call made to update VPN city to xxx
VPNMON-R2 - A new update (v2.62) is available to download
VPNMON-R2 - Successfully updated VPNMON-R2 v2.59 to v2.62
VPNMON-R2 - API call made to update WAN0 city to xxx
VPNMON-R2 - API call made to update VPN city to xxx
VPNMON-R2 - Successfully wrote a new config file
VPNMON-R2 - Successfully wrote a new config file
How many slots do you have configured for VPN use? Have you tested each slot individually to ensure it makes a solid connection before turning on VPNMON? What happens after the interfaces section draws on the screen? Does it show each VPN slot along with its ping time?
 
How many slots do you have configured for VPN use? Have you tested each slot individually to ensure it makes a solid connection before turning on VPNMON? What happens after the interfaces section draws on the screen? Does it show each VPN slot along with its ping time?
I have only 1 slot configured... I did reboot the router before making my post just in case there was some kind of weird quirk.
VPNMON connects perfectly fine, connection is solid/no issues
When the screen refreshes, it looks like it normally did, ping times look normal
 
I have only 1 slot configured... I did reboot the router before making my post just in case there was some kind of weird quirk.
VPNMON connects perfectly fine, connection is solid/no issues
When the screen refreshes, it looks like it normally did, ping times look normal
So wait. Is it working normally now, or still giving you the operand errors?
 
Sorry, I wasn't quite clear in my previous message, the unknown operand still exists, but it doesn't seem to affect anything
I might give you a quick version to test to see if that error goes away if you're game?
 
@Viktor Jaep I also have missing operand errors:
Code:
/General Info\_____________________________________________________

  Wed Nov  1 14:28:45 GMT 2023 ------- Last Reset: 0d 06h:12m:02s
[: -1: unknown operand
[: -1: unknown operand
[: -1: unknown operand
[: -1: unknown operand
  VPN State 1:2 2: 3: 4: 5: --- Public VPN IP: xx.xxx.xxx.xxx
  WAN State 0:2 1:0 -------------------- Interval: 60 Sec
  Auto Start After Reboot Protection ----- Status: On / post-mount
 
@Viktor Jaep I also have missing operand errors:
Code:
/General Info\_____________________________________________________

  Wed Nov  1 14:28:45 GMT 2023 ------- Last Reset: 0d 06h:12m:02s
[: -1: unknown operand
[: -1: unknown operand
[: -1: unknown operand
[: -1: unknown operand
  VPN State 1:2 2: 3: 4: 5: --- Public VPN IP: xx.xxx.xxx.xxx
  WAN State 0:2 1:0 -------------------- Interval: 60 Sec
  Auto Start After Reboot Protection ----- Status: On / post-mount
Did this just start happening? Not doing it for me. I will put a test version out there in a few hours to see if that helps with this issue, K?
 
Did this just start happening? Not doing it for me. I will put a test version out there in a few hours to see if that helps with this issue, K?
I've been using this script for a while, but only noticed this after @TITAN mentioned it.
 
@TITAN @Ripshod ... sorry for the delay. Could you please give this a shot and let me know if you continue seeing the invalid operand errors?

Code:
curl --retry 3 "https://raw.githubusercontent.com/ViktorJp/VPNMON-R2/master/vpnmon-r2-2.63b1.sh" -o "/jffs/scripts/vpnmon-r2.sh" && chmod 755 "/jffs/scripts/vpnmon-r2.sh"

Return to stable if needed:
Code:
curl --retry 3 "https://raw.githubusercontent.com/ViktorJp/VPNMON-R2/master/vpnmon-r2-2.62.sh" -o "/jffs/scripts/vpnmon-r2.sh" && chmod 755 "/jffs/scripts/vpnmon-r2.sh"
 
@TITAN @Ripshod ... sorry for the delay. Could you please give this a shot and let me know if you continue seeing the invalid operand errors?

Code:
curl --retry 3 "https://raw.githubusercontent.com/ViktorJp/VPNMON-R2/master/vpnmon-r2-2.63b1.sh" -o "/jffs/scripts/vpnmon-r2.sh" && chmod 755 "/jffs/scripts/vpnmon-r2.sh"

Return to stable if needed:
Code:
curl --retry 3 "https://raw.githubusercontent.com/ViktorJp/VPNMON-R2/master/vpnmon-r2-2.62.sh" -o "/jffs/scripts/vpnmon-r2.sh" && chmod 755 "/jffs/scripts/vpnmon-r2.sh"
Still the same, unfortunately
 

Attachments

  • 1.png
    1.png
    44.3 KB · Views: 30
@TITAN @Ripshod ... sorry for the delay. Could you please give this a shot and let me know if you continue seeing the invalid operand errors?

Code:
curl --retry 3 "https://raw.githubusercontent.com/ViktorJp/VPNMON-R2/master/vpnmon-r2-2.63b1.sh" -o "/jffs/scripts/vpnmon-r2.sh" && chmod 755 "/jffs/scripts/vpnmon-r2.sh"

Return to stable if needed:
Code:
curl --retry 3 "https://raw.githubusercontent.com/ViktorJp/VPNMON-R2/master/vpnmon-r2-2.62.sh" -o "/jffs/scripts/vpnmon-r2.sh" && chmod 755 "/jffs/scripts/vpnmon-r2.sh"
No problem, happy to test it out

I have the same result as @Ripshod - note:I did not perform a reboot on the router (not sure that would make a difference)

Still nothing in the logs unfortunately. Is there any way to increase the logging level? maybe that could indicate what/where the issue is?

Code:
_    ______  _   ____  _______  _   __      ____ ___
  | |  / / __ \/ | / /  |/  / __ \/ | / /     / __ \__ \  v2.63b1
  | | / / /_/ /  |/ / /|_/ / / / /  |/ /_____/ /_/ /_/ / (S)etup
  | |/ / ____/ /|  / /  / / /_/ / /|  /_____/ _, _/ __/  (R)eset
  |___/_/   /_/ |_/_/  /_/\____/_/ |_/     /_/ |_/____/  (E)xit
 ____________
/General Info\_____________________________________________________


[: -1: unknown operand
[: -1: unknown operand
[: -1: unknown operand
[: -1: unknown operand
  VPN State 1:2 2: 3: 4: 5: --- Public VPN IP:
  WAN State 0:2 1:0 ----------------- Sched Reset: 01:00 / 60 Sec
  Auto Start After Reboot Protection ----- Status: On / post-mount
 __________
 
No problem, happy to test it out

I have the same result as @Ripshod - note:I did not perform a reboot on the router (not sure that would make a difference)

Still nothing in the logs unfortunately. Is there any way to increase the logging level? maybe that could indicate what/where the issue is?

Code:
_    ______  _   ____  _______  _   __      ____ ___
  | |  / / __ \/ | / /  |/  / __ \/ | / /     / __ \__ \  v2.63b1
  | | / / /_/ /  |/ / /|_/ / / / /  |/ /_____/ /_/ /_/ / (S)etup
  | |/ / ____/ /|  / /  / / /_/ / /|  /_____/ _, _/ __/  (R)eset
  |___/_/   /_/ |_/_/  /_/\____/_/ |_/     /_/ |_/____/  (E)xit
 ____________
/General Info\_____________________________________________________


[: -1: unknown operand
[: -1: unknown operand
[: -1: unknown operand
[: -1: unknown operand
  VPN State 1:2 2: 3: 4: 5: --- Public VPN IP:
  WAN State 0:2 1:0 ----------------- Sched Reset: 01:00 / 60 Sec
  Auto Start After Reboot Protection ----- Status: On / post-mount
 __________
The operand error's are from this code:

Code:
# Determine if a VPN Client is active, first by getting the VPN state from NVRAM
state1=$($timeoutcmd$timeoutsec nvram get vpn_client1_state); if [ $state1 -eq -1 ]; then state1=0; fi
state2=$($timeoutcmd$timeoutsec nvram get vpn_client2_state); if [ $state2 -eq -1 ]; then state2=0; fi
state3=$($timeoutcmd$timeoutsec nvram get vpn_client3_state); if [ $state3 -eq -1 ]; then state3=0; fi
state4=$($timeoutcmd$timeoutsec nvram get vpn_client4_state); if [ $state4 -eq -1 ]; then state4=0; fi
state5=$($timeoutcmd$timeoutsec nvram get vpn_client5_state); if [ $state5 -eq -1 ]; then state5=0; fi

perhaps it would be better written as

Code:
# Determine if a VPN Client is active, first by getting the VPN state from NVRAM
state1=$($timeoutcmd$timeoutsec nvram get vpn_client1_state); if [ -z "$state1" ] || [ $state1 -eq -1 ]; then state1=0; fi
state2=$($timeoutcmd$timeoutsec nvram get vpn_client2_state); if [ -z "$state2" ] || [ $state2 -eq -1 ]; then state2=0; fi
state3=$($timeoutcmd$timeoutsec nvram get vpn_client3_state); if [ -z "$state3" ] || [ $state3 -eq -1 ]; then state3=0; fi
state4=$($timeoutcmd$timeoutsec nvram get vpn_client4_state); if [ -z "$state4" ] || [ $state4 -eq -1 ]; then state4=0; fi
state5=$($timeoutcmd$timeoutsec nvram get vpn_client5_state); if [ -z "$state5" ] || [ $state5 -eq -1 ]; then state5=0; fi

because if $state is a null value it will cause an operand error when trying to compare it to the value of "-1". In this instance we must also consider the possibility for the $state to be a null value, hence why there is an operand error when the current code does not account for a "null" value.

@Viktor Jaep already discovered this issue with RTRMON script and patched it there. https://www.snbforums.com/threads/r...scanner-gt-axe-ax-speedtest.79738/post-864215

In RTRMON, people were getting
Code:
[: 2: unknown operand

I am sure @Viktor Jaep will patch this in VPNMON as soon as he has the free time.
 
Last edited:
@Viktor Jaep I also have missing operand errors:
Code:
/General Info\_____________________________________________________

  Wed Nov  1 14:28:45 GMT 2023 ------- Last Reset: 0d 06h:12m:02s
[: -1: unknown operand
[: -1: unknown operand
[: -1: unknown operand
[: -1: unknown operand
  VPN State 1:2 2: 3: 4: 5: --- Public VPN IP: xx.xxx.xxx.xxx
...
Code:
/General Info\_____________________________________________________

[: -1: unknown operand
[: -1: unknown operand
[: -1: unknown operand
[: -1: unknown operand
  VPN State 1:2 2: 3: 4: 5: --- Public VPN IP:

Given that the values from NVRAM variables "vpn_client[1-5]_state" seem to be somewhat "unpredictable" in some cases, and there are calls to get those values in many places, I'd suggest a more modular coding solution using a function like this one:
Bash:
_VPN_GetClientState_()
{
    if [ $# -lt 1 ] || [ -z "$1" ] || ! echo "$1" | grep -qE "^[1-5]$"
    then echo "**ERROR**" ; return 1 ; fi

    local nvramVal="$($timeoutcmd$timeoutsec nvram get "vpn_client${1}_state")"
    if [ -z "$nvramVal" ] || ! echo "$nvramVal" | grep -qE "^[0-9]$"
    then echo "0" ; else echo "$nvramVal" ; fi
    return 0
}

Then all current calls to get the VPN client states can be modified as follows:
Bash:
    state1="$(_VPN_GetClientState_ 1)"
    state2="$(_VPN_GetClientState_ 2)"
    state3="$(_VPN_GetClientState_ 3)"
    state4="$(_VPN_GetClientState_ 4)"
    state5="$(_VPN_GetClientState_ 5)"
There would be no longer a need to check for empty or "-1" values outside the function call, and any future fixes/adjustments for getting the VPN client states can be made in one place only.

My 2 cents.
 
Last edited:
Given that the values from NVRAM variables "vpn_client[1-5]_state" seem to be somewhat "unpredictable" in some cases, and there are calls to get those values in many places, I'd suggest a more modular coding solution using a function like this one:
Bash:
_VPN_GetClientState_()
{
    if [ $# -lt 1 ] || [ -z "$1" ] || ! echo "$1" | grep -qE "^[1-5]$"
    then echo "**ERROR**" ; return 1 ; fi

    local nvramVal="$($timeoutcmd$timeoutsec nvram get "vpn_client${1}_state")"
    if [ -z "$nvramVal" ] || ! echo "$nvramVal" | grep -qE "^[0-9]$"
    then echo "0" ; else echo "$nvramVal" ; fi
    return 0
}

Then all current calls to get the VPN client states can be modified as follows:
Bash:
    state1="$(_VPN_GetClientState_ 1)"
    state2="$(_VPN_GetClientState_ 2)"
    state3="$(_VPN_GetClientState_ 3)"
    state4="$(_VPN_GetClientState_ 4)"
    state5="$(_VPN_GetClientState_ 5)"
There would be longer a need to check for empty or "-1" values outside the function call, and any future fixes/adjustments for getting the VPN client states can be made in one place only.

My 2 cents.
That's not a bad suggestion, I was thinking the same thing in my mind. I just didn't have an elegant way to share it. I think your suggestion should definitely offer the flexibility @Viktor Jaep truly needs.
 
That's not a bad suggestion, I was thinking the same thing in my mind. I just didn't have an elegant way to share it. I think your suggestion should definitely offer the flexibility @Viktor Jaep truly needs.
I really appreciate the help and suggestions, @Martinski and @SomeWhereOverTheRainBow! I'm out of town on business and will definitely be implementing this change as soon as I get back. Great work! Yeah, I wasn't expecting nulls I guess. From my vantage point, there has always been a value there. Makes complete sense now.
 
I really appreciate the help and suggestions, @Martinski and @SomeWhereOverTheRainBow! I'm out of town on business and will definitely be implementing this change as soon as I get back. Great work! Yeah, I wasn't expecting nulls I guess. From my vantage point, there has always been a value there. Makes complete sense now.
I appreciate your desire to establish your own logic to VPN states within your script. I have come to learn when parsing the volatile memory of our routers, one must anticipate the unexpected. It is not always a clean cut way of doing that. I love @Martinski modular approach to handling this.
 
I appreciate your desire to establish your own logic to VPN states within your script. I have come to learn when parsing the volatile memory of our routers, one must anticipate the unexpected. It is not always a clean cut way of doing that. I love @Martinski modular approach to handling this.
Same! 😋
 
One addition I can provide to @Martinski suggestion is instead of returning "0" for empty or invalid values, you can introduce a default value or expected/anticipated value as an argument to the function, allowing you to specify the value you want to use when the NVRAM value is missing or invalid. This might make the function more flexible for all your use cases.

Bash:
_VPN_GetClientState_()
{
    if [ $# -lt 1 ] || [ -z "$1" ] || ! echo "$1" | grep -qE "^[1-5]$"; then
        echo "ERROR: Invalid argument" >&2
        return 1
    fi

    local default_value="${2:-0}"  # Use the provided default or default to 0
    local nvramVal="$($timeoutcmd$timeoutsec nvram get "vpn_client${1}_state")"

    if [ -z "$nvramVal" ] || ! echo "$nvramVal" | grep -qE "^[0-9]$"; then
        echo "$default_value"
    else
        echo "$nvramVal"
    fi
    return 0
}

If you want to give more consistency, cleaner error handling, and simpler way of handling using "a case base" condition to the original edits I did to the _VPN_GetClientState_, I would suggest:

Bash:
_VPN_GetClientState_() {
    case "$1" in
        [1-5])
            local nvramVal="$($timeoutcmd$timeoutsec nvram get "vpn_client${1}_state")"
            if [ -z "$nvramVal" ] || ! echo "$nvramVal" | grep -qE "^[0-9]$"; then
                echo "${2:-0}"  # Use the provided default or default to 0
            else
                echo "$nvramVal"
            fi
            return 0
            ;;
        *)
            echo "ERROR: Invalid client number. Please provide a number from 1 to 5." >&2
            return 1
            ;;
    esac
}

or even:

Bash:
_VPN_GetClientState_() {
    case "$1" in
        [1-5])
            local nvramVal="$($timeoutcmd$timeoutsec nvram get "vpn_client${1}_state")"
            case "$nvramVal" in
                [0-9])
                    echo "$nvramVal"
                    ;;
                "")
                    echo "${2:-0}"  # Use the provided default or default to 0
                    ;;
                *)
                    echo "WARNING: Unrecognized value in NVRAM: $nvramVal. Using default value." >&2
                    echo "${2:-0}"  # Use the provided default or default to 0
                    ;;
            esac
            return 0
            ;;
        *)
            echo "ERROR: Invalid client number. Please provide a number from 1 to 5." >&2
            return 1
            ;;
    esac
}

Now the function checks the value of $nvramVal and handles per different use case:
When $nvramVal is a valid number, it returns that value.
When $nvramVal is an empty string, it returns the default value or the value provided as the second argument (if any).
When $nvramVal has an unrecognized value, it issues a warning, returns the default value, and also provides information about the unrecognized value.

These case statements grant you the flexibility to handle different values of $nvramVal more explicitly.

When calling the function, you can provide an anticipated/default value as the second argument to specify what value to use when NVRAM data is missing or invalid.

Bash:
state1="$(_VPN_GetClientState_ 1 0)"
state2="$(_VPN_GetClientState_ 2 0)"
state3="$(_VPN_GetClientState_ 3 0)"
state4="$(_VPN_GetClientState_ 4 0)"
state5="$(_VPN_GetClientState_ 5 0)"

or even

Bash:
state1="$(_VPN_GetClientState_ 1)"
state2="$(_VPN_GetClientState_ 2)"
state3="$(_VPN_GetClientState_ 3)"
state4="$(_VPN_GetClientState_ 4)"
state5="$(_VPN_GetClientState_ 5)"

both of which will give you the value of zero if that is what you expect to assign when the value is "null".
 
Last edited:

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top