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")
|
|
|
|
for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p');
|
|
|
|
do
|
|
|
|
echo "$config" | grep -q "route-map $route_map_name permit 2"
|
|
|
|
c=$((c+$?))
|
|
|
|
echo "$config" | grep -q "route-map $route_map_name deny 3"
|
|
|
|
c=$((c+$?))
|
|
|
|
done
|
|
|
|
return $c
|
|
|
|
}
|
|
|
|
|
|
|
|
function check_installed()
|
|
|
|
{
|
|
|
|
c=0
|
|
|
|
e=0
|
|
|
|
config=$(vtysh -c "show run")
|
|
|
|
for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p');
|
|
|
|
do
|
|
|
|
echo "$config" | grep -q "route-map $route_map_name permit 2"
|
|
|
|
c=$((c+$?))
|
|
|
|
e=$((e+1))
|
|
|
|
echo "$config" | grep -q "route-map $route_map_name deny 3"
|
|
|
|
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
|