2019-07-26 16:31:56 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-04-23 11:42:22 -05:00
|
|
|
function check_not_installed()
|
|
|
|
{
|
|
|
|
c=0
|
|
|
|
config=$(vtysh -c "show run")
|
2020-11-23 11:30:39 -06:00
|
|
|
for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p' | egrep 'V4|V6');
|
2020-04-23 11:42:22 -05:00
|
|
|
do
|
2021-01-08 16:03:26 -06:00
|
|
|
echo "$config" | grep -q "route-map $route_map_name permit 20"
|
2020-04-23 11:42:22 -05:00
|
|
|
c=$((c+$?))
|
2021-01-08 16:03:26 -06:00
|
|
|
echo "$config" | grep -q "route-map $route_map_name deny 30"
|
2020-04-23 11:42:22 -05:00
|
|
|
c=$((c+$?))
|
|
|
|
done
|
|
|
|
return $c
|
|
|
|
}
|
|
|
|
|
|
|
|
function check_installed()
|
|
|
|
{
|
|
|
|
c=0
|
|
|
|
e=0
|
|
|
|
config=$(vtysh -c "show run")
|
2020-11-23 11:30:39 -06:00
|
|
|
for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p' | egrep 'V4|V6');
|
2020-04-23 11:42:22 -05:00
|
|
|
do
|
2021-01-08 16:03:26 -06:00
|
|
|
echo "$config" | grep -q "route-map $route_map_name permit 20"
|
2020-04-23 11:42:22 -05:00
|
|
|
c=$((c+$?))
|
|
|
|
e=$((e+1))
|
2021-01-08 16:03:26 -06:00
|
|
|
echo "$config" | grep -q "route-map $route_map_name deny 30"
|
2020-04-23 11:42:22 -05:00
|
|
|
c=$((c+$?))
|
|
|
|
e=$((e+1))
|
|
|
|
done
|
|
|
|
return $((e-c))
|
|
|
|
}
|
|
|
|
|
2019-07-26 16:31:56 -05:00
|
|
|
echo "Traffic Shift Check:"
|
|
|
|
|
2020-04-23 11:42:22 -05:00
|
|
|
check_not_installed
|
|
|
|
not_installed=$?
|
|
|
|
|
|
|
|
check_installed
|
|
|
|
installed=$?
|
|
|
|
|
|
|
|
if [[ $installed -eq 0 ]];
|
2019-07-26 16:31:56 -05:00
|
|
|
then
|
|
|
|
echo "System Mode: Normal"
|
2020-04-23 11:42:22 -05:00
|
|
|
elif [[ $not_installed -eq 0 ]];
|
2019-07-26 16:31:56 -05:00
|
|
|
then
|
|
|
|
echo "System Mode: Maintenance"
|
|
|
|
else
|
|
|
|
echo "System Mode: Not consistent"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo
|