I've configured Netwatch to additionally ping host in On Down event, which works flawlessly. Additionally, i've configured a script nwatch-ltegateway that checks first n hops to provided host.
It works when called from Test or On Up events, but if called from On Down, then On Down event fails with no error in log.
I believe it should work, at least because ping works as expected, but i'm new to ROS scripting, so I'm missing something for sure...
Please, help me find the reason of On Down failure when nwatch-ltegateway is called from there and possibly fix that.
UPD230113 Thanks to @zainarbani i've captured an error, and thanks to @rextended the real cause was successfully identified and fixed. Scripts were updated.ROS 7.6 stable
Netwatch is called in 10sec interval and has 4sec timeout.
Netwatch.OnDown:
Code: Select all
:local hostip 1.0.0.1
:local countup value=0
:while (($countup < 10) && ([:ping address=$hostip interval=1 count=3]=0)) do={
:set countup value=($countup+1);
:log error "Ping No $countup failed to $hostip";
/system script run nwatch-ltegateway;
}
:if ($countup < 10) do={
:log info "Host $hostip recovered after ping No $countup.";
} else={
:log warning "Generating supout.rif before lte reset"
/system script run nwatch-report;
:log error "<alert> Host $hostip not recovered, will reset...";
/system script run ltereset;
}
nwatch-ltegateway with "Don't require permissions" checked;
Code: Select all
#check lte gateway
:local hostip 1.1.1.1
:local ttl value=1;
:local traceGwResult
:local lteGatewayL
:local gwLoss
:do {
:set traceGwResult [tool/traceroute address=$hostip max-hops=$ttl count=5 duration=4 as-value];
:if ($ttl > 1) do={
:set traceGwResult [:pick $traceGwResult ($ttl-1)];
}
:set lteGatewayL ($traceGwResult->"address")
:set gwLoss ($traceGwResult->"loss")
:set ttl value=($ttl+1);
} while=(($ttl < 4) && ($gwLoss = 1000));
:if ($gwLoss > 0) do={
:set ttl value=($ttl-1);
:if ($gwLoss = 1000) do={
:log error "LTE: $ttl hops are unreachable";
} else={
:log warning "LTE: Link is unstable (gw:$lteGatewayL, hop:$ttl, loss: $gwLoss)";
}
/system script run nwatch-ltestats;
}
:local traceStr [:tostr $traceGwResult]
:log debug "<trace> traceroute: ($traceStr)";
nwatch-ltestats with "Don't require permissions" checked:
Code: Select all
/int lte monitor numbers=0 duration=1 once do={
:set $caband [:tostr $"ca-band"];
:log debug ("<trace> (rsrp:$rsrp;rsrq:$rsrq;rssi:$rssi;sinr:$sinr;uptime:".$"session-uptime".";cqi:$cqi;cellid:".$"current-cellid".";enb-id:".$"enb-id".";phy-cell:".$"phy-cellid".";band:".$"primary-band".";ca-band:$caband;operator:".$"current-operator".";data-class:".$"data-class".";modulation:".$"dl-modulation".";mcs:$mcs;revision:$revision;ri:$ri;sector:".$"sector-id".")");
}