From 94d4484988eb9b138518458078d153e48beae788 Mon Sep 17 00:00:00 2001 From: "Pavel D. Kuzin" Date: Thu, 30 Dec 2021 15:32:26 +0300 Subject: [PATCH 01/13] routing-instance selection --- htdocs/index.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/index.php b/htdocs/index.php index 32bea0f..40a6317 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -302,6 +302,8 @@ function load() { $url = @parse_url($url); + $routing_instance = $_CONFIG['routers'][$router]['routing-instance']; + $os = $_CONFIG['routers'][$router]['os']; if ($command == 'graph' AND isset($queries[$os][$protocol]['bgp'])) @@ -377,7 +379,11 @@ function load() { if ($os == 'junos') { // @see JunOS Routing Table Names (http://www.net-gyver.com/?p=602) - $table = ($protocol == 'ipv6') ? 'inet6.0' : 'inet.0'; + if ($routing_instance){ + $table = ($protocol == 'ipv6') ? $routing_instance.'.inet6.0' : $routing_instance.'.inet.0'; + }else{ + $table = ($protocol == 'ipv6') ? 'inet6.0' : 'inet.0'; + } if (preg_match("/^show bgp n\w*\s+([\d\.A-Fa-f:]+)$/", $exec, $exec_exp)) { From 66f7e7b5636ab91969c51b0ad84e8562780fef2b Mon Sep 17 00:00:00 2001 From: "Pavel D. Kuzin" Date: Thu, 30 Dec 2021 16:15:08 +0300 Subject: [PATCH 02/13] routing-instance selection --- htdocs/index.php | 70 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 59 insertions(+), 11 deletions(-) diff --git a/htdocs/index.php b/htdocs/index.php index 40a6317..7e45dbf 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -387,35 +387,67 @@ function load() { if (preg_match("/^show bgp n\w*\s+([\d\.A-Fa-f:]+)$/", $exec, $exec_exp)) { - $exec = 'show bgp neighbor '.$exec_exp[1]; + if ($routing_instance){ + $exec = 'show bgp neighbor instance '.$routing_instance.' '.$exec_exp[1]; + }else{ + $exec = 'show bgp neighbor '.$exec_exp[1]; + } } else if (preg_match("/^show bgp n\w*\s+([\d\.A-Fa-f:]+) ro\w*$/", $exec, $exec_exp)) { - $exec = 'show route receive-protocol bgp '.$exec_exp[1]; + if ($routing_instance){ + $exec = 'show route instance '.$routing_instance.' receive-protocol bgp '.$exec_exp[1]; + }else{ + $exec = 'show route receive-protocol bgp '.$exec_exp[1]; + } } else if (preg_match("/^show bgp neighbors ([\d\.A-Fa-f:]+) routes all$/", $exec, $exec_exp)) { - $exec = 'show route receive-protocol bgp '.$exec_exp[1].' all'; + if ($routing_instance){ + $exec = 'show route instance '.$routing_instance.' receive-protocol bgp '.$exec_exp[1].' all'; + }else{ + $exec = 'show route receive-protocol bgp '.$exec_exp[1].' all'; + } } else if (preg_match("/^show bgp neighbors ([\d\.A-Fa-f:]+) routes damping suppressed$/", $exec, $exec_exp)) { - $exec = 'show route receive-protocol bgp '.$exec_exp[1].' damping suppressed'; + if ($routing_instance){ + $exec = 'show route instance '.$routing_instance.$exec_exp[1].' damping suppressed'; + }else{ + $exec = 'show route receive-protocol bgp '.$exec_exp[1].' damping suppressed'; + } } else if (preg_match("/^show bgp n\w*\s+([\d\.A-Fa-f:]+) advertised-routes ([\d\.A-Fa-f:\/]+)$/", $exec, $exec_exp)) { - $exec = 'show route advertising-protocol bgp '.$exec_exp[1].' '.$exec_exp[2].' exact detail'; + if ($routing_instance){ + $exec = 'show route instance '.$routing_instance.' advertising-protocol bgp '.$exec_exp[1].' '.$exec_exp[2].' exact detail'; + }else{ + $exec = 'show route advertising-protocol bgp '.$exec_exp[1].' '.$exec_exp[2].' exact detail'; + } } else if (preg_match("/^show bgp n\w*\s+([\d\.A-Fa-f:]+) receive-protocol ([\d\.A-Fa-f:\/]+)$/", $exec, $exec_exp)) { - $exec = 'show route receive-protocol bgp '.$exec_exp[1].' '.$exec_exp[2].' exact detail'; + if ($routing_instance){ + $exec = 'show route instance '.$routing_instance.' receive-protocol bgp '.$exec_exp[1].' '.$exec_exp[2].' exact detail'; + }else{ + $exec = 'show route receive-protocol bgp '.$exec_exp[1].' '.$exec_exp[2].' exact detail'; + } } else if (preg_match("/^show bgp n\w*\s+([\d\.A-Fa-f:]+) a[\w\-]*$/", $exec, $exec_exp)) { - $exec = 'show route advertising-protocol bgp '.$exec_exp[1]; + if ($routing_instance){ + $exec = 'show route instance '.$routing_instance.' advertising-protocol bgp '.$exec_exp[1]; + }else{ + $exec = 'show route advertising-protocol bgp '.$exec_exp[1]; + } } else if (preg_match("/^show bgp\s+([\d\.A-Fa-f:]+\/\d+)$/", $exec, $exec_exp)) { - $exec = 'show route protocol bgp '.$exec_exp[1].' terse exact'; + if ($routing_instance){ + $exec = 'show route instance '.$routing_instance.' protocol bgp '.$exec_exp[1].' terse exact'; + }else{ + $exec = 'show route protocol bgp '.$exec_exp[1].' terse exact'; + } } else if (preg_match("/^show bgp\s+([\d\.A-Fa-f:]+)$/", $exec, $exec_exp)) { @@ -423,7 +455,11 @@ function load() { } else if (preg_match("/^show bgp\s+([\d\.A-Fa-f:\/]+) exact$/", $exec, $exec_exp)) { - $exec = 'show route protocol bgp '.$exec_exp[1].' exact detail all'; + if ($routing_instance){ + $exec = 'show route instance '.$routing_instance.' protocol bgp '.$exec_exp[1].' exact detail all'; + }else{ + $exec = 'show route protocol bgp '.$exec_exp[1].' exact detail all'; + } } else if (preg_match("/^show bgp re\s+(.*)$/", $exec, $exec_exp)) { @@ -439,7 +475,19 @@ function load() { $re = $re.".*\$"; } - $exec = 'show route aspath-regex "'.str_replace('_', ' ', $re).'" all'; + if ($routing_instance){ + $exec = 'show route instance '.$routing_instance.' aspath-regex "'.str_replace('_', ' ', $re).'" all'; + }else{ + $exec = 'show route aspath-regex "'.str_replace('_', ' ', $re).'" all'; + } + } + else if (preg_match("/^show bgp summary$/", $exec, $exec_exp)) + { + if ($routing_instance){ + $exec = 'show bgp summary instance '.$routing_instance; + }else{ + $exec = 'show bgp summary'; + } } } @@ -1392,7 +1440,7 @@ function ($matches) use ($lastip) { return $output; } - if ($exec == 'show bgp summary') + if (preg_match("/^show bgp summary( instance .*)?$/", $exec)) { // JunOS if (preg_match("/^([\dA-Fa-f:][\d\.A-Fa-f:]+)\s+/", $output, $lastip_exp)) From 47bff7f8f07eebf1f4a5a458af1027ae515b24ef Mon Sep 17 00:00:00 2001 From: "Pavel D. Kuzin" Date: Thu, 30 Dec 2021 16:26:52 +0300 Subject: [PATCH 03/13] routing-instance selection --- htdocs/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/index.php b/htdocs/index.php index 7e45dbf..87b6128 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -1440,7 +1440,7 @@ function ($matches) use ($lastip) { return $output; } - if (preg_match("/^show bgp summary( instance .*)?$/", $exec)) + if (preg_match("/^show bgp summary(?:\s+instance\s+[\d\w-]*)?$/", $exec)) { // JunOS if (preg_match("/^([\dA-Fa-f:][\d\.A-Fa-f:]+)\s+/", $output, $lastip_exp)) @@ -1813,7 +1813,7 @@ function ($matches) { return $output; } - if (preg_match("/^show bgp n\w*\s+([\d\.A-Fa-f:]+)/i", $exec, $ip_exp)) + if (preg_match("/^show bgp n\w*\s+(?:instance\s+[\d\w-]*)?\s*([\d\.A-Fa-f:]+)/i", $exec, $ip_exp)) { $ip = $ip_exp[1]; From 5a8fb6073449d25449b810675507ad1dde6bdaca Mon Sep 17 00:00:00 2001 From: "Pavel D. Kuzin" Date: Thu, 30 Dec 2021 16:30:39 +0300 Subject: [PATCH 04/13] routing-instance selection --- htdocs/index.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/htdocs/index.php b/htdocs/index.php index 87b6128..273acfd 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -395,11 +395,7 @@ function load() { } else if (preg_match("/^show bgp n\w*\s+([\d\.A-Fa-f:]+) ro\w*$/", $exec, $exec_exp)) { - if ($routing_instance){ - $exec = 'show route instance '.$routing_instance.' receive-protocol bgp '.$exec_exp[1]; - }else{ - $exec = 'show route receive-protocol bgp '.$exec_exp[1]; - } + $exec = 'show route receive-protocol bgp '.$exec_exp[1]; } else if (preg_match("/^show bgp neighbors ([\d\.A-Fa-f:]+) routes all$/", $exec, $exec_exp)) { From 809eb7eff1ac9ae461bfcbfb9818031543d954de Mon Sep 17 00:00:00 2001 From: "Pavel D. Kuzin" Date: Thu, 30 Dec 2021 16:43:00 +0300 Subject: [PATCH 05/13] routing-instance selection --- htdocs/index.php | 38 +++++++------------------------------- 1 file changed, 7 insertions(+), 31 deletions(-) diff --git a/htdocs/index.php b/htdocs/index.php index 273acfd..ef75fe4 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -395,55 +395,31 @@ function load() { } else if (preg_match("/^show bgp n\w*\s+([\d\.A-Fa-f:]+) ro\w*$/", $exec, $exec_exp)) { - $exec = 'show route receive-protocol bgp '.$exec_exp[1]; + $exec = 'show route receive-protocol bgp '.$exec_exp[1]; } else if (preg_match("/^show bgp neighbors ([\d\.A-Fa-f:]+) routes all$/", $exec, $exec_exp)) { - if ($routing_instance){ - $exec = 'show route instance '.$routing_instance.' receive-protocol bgp '.$exec_exp[1].' all'; - }else{ - $exec = 'show route receive-protocol bgp '.$exec_exp[1].' all'; - } + $exec = 'show route receive-protocol bgp '.$exec_exp[1].' all'; } else if (preg_match("/^show bgp neighbors ([\d\.A-Fa-f:]+) routes damping suppressed$/", $exec, $exec_exp)) { - if ($routing_instance){ - $exec = 'show route instance '.$routing_instance.$exec_exp[1].' damping suppressed'; - }else{ - $exec = 'show route receive-protocol bgp '.$exec_exp[1].' damping suppressed'; - } + $exec = 'show route receive-protocol bgp '.$exec_exp[1].' damping suppressed'; } else if (preg_match("/^show bgp n\w*\s+([\d\.A-Fa-f:]+) advertised-routes ([\d\.A-Fa-f:\/]+)$/", $exec, $exec_exp)) { - if ($routing_instance){ - $exec = 'show route instance '.$routing_instance.' advertising-protocol bgp '.$exec_exp[1].' '.$exec_exp[2].' exact detail'; - }else{ - $exec = 'show route advertising-protocol bgp '.$exec_exp[1].' '.$exec_exp[2].' exact detail'; - } + $exec = 'show route advertising-protocol bgp '.$exec_exp[1].' '.$exec_exp[2].' exact detail'; } else if (preg_match("/^show bgp n\w*\s+([\d\.A-Fa-f:]+) receive-protocol ([\d\.A-Fa-f:\/]+)$/", $exec, $exec_exp)) { - if ($routing_instance){ - $exec = 'show route instance '.$routing_instance.' receive-protocol bgp '.$exec_exp[1].' '.$exec_exp[2].' exact detail'; - }else{ - $exec = 'show route receive-protocol bgp '.$exec_exp[1].' '.$exec_exp[2].' exact detail'; - } + $exec = 'show route receive-protocol bgp '.$exec_exp[1].' '.$exec_exp[2].' exact detail'; } else if (preg_match("/^show bgp n\w*\s+([\d\.A-Fa-f:]+) a[\w\-]*$/", $exec, $exec_exp)) { - if ($routing_instance){ - $exec = 'show route instance '.$routing_instance.' advertising-protocol bgp '.$exec_exp[1]; - }else{ - $exec = 'show route advertising-protocol bgp '.$exec_exp[1]; - } + $exec = 'show route advertising-protocol bgp '.$exec_exp[1]; } else if (preg_match("/^show bgp\s+([\d\.A-Fa-f:]+\/\d+)$/", $exec, $exec_exp)) { - if ($routing_instance){ - $exec = 'show route instance '.$routing_instance.' protocol bgp '.$exec_exp[1].' terse exact'; - }else{ - $exec = 'show route protocol bgp '.$exec_exp[1].' terse exact'; - } + $exec = 'show route protocol bgp '.$exec_exp[1].' terse exact'; } else if (preg_match("/^show bgp\s+([\d\.A-Fa-f:]+)$/", $exec, $exec_exp)) { From 64d5399f15e4a134ee1760d76940b22764b0c05b Mon Sep 17 00:00:00 2001 From: "Pavel D. Kuzin" Date: Thu, 30 Dec 2021 16:54:25 +0300 Subject: [PATCH 06/13] routing-instance selection --- htdocs/index.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/htdocs/index.php b/htdocs/index.php index ef75fe4..00ee501 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -427,11 +427,7 @@ function load() { } else if (preg_match("/^show bgp\s+([\d\.A-Fa-f:\/]+) exact$/", $exec, $exec_exp)) { - if ($routing_instance){ - $exec = 'show route instance '.$routing_instance.' protocol bgp '.$exec_exp[1].' exact detail all'; - }else{ - $exec = 'show route protocol bgp '.$exec_exp[1].' exact detail all'; - } + $exec = 'show route protocol bgp '.$exec_exp[1].' exact detail all'; } else if (preg_match("/^show bgp re\s+(.*)$/", $exec, $exec_exp)) { From 86ff0d2ab341f66a8abed694cd350fc8107097bd Mon Sep 17 00:00:00 2001 From: "Pavel D. Kuzin" Date: Thu, 30 Dec 2021 17:11:26 +0300 Subject: [PATCH 07/13] routing-instance selection --- htdocs/index.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/index.php b/htdocs/index.php index 00ee501..5866f3a 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -395,31 +395,31 @@ function load() { } else if (preg_match("/^show bgp n\w*\s+([\d\.A-Fa-f:]+) ro\w*$/", $exec, $exec_exp)) { - $exec = 'show route receive-protocol bgp '.$exec_exp[1]; + $exec = 'show route receive-protocol bgp '.$exec_exp[1]." table ".$table; } else if (preg_match("/^show bgp neighbors ([\d\.A-Fa-f:]+) routes all$/", $exec, $exec_exp)) { - $exec = 'show route receive-protocol bgp '.$exec_exp[1].' all'; + $exec = 'show route receive-protocol bgp '.$exec_exp[1].' table '.$table.' all'; } else if (preg_match("/^show bgp neighbors ([\d\.A-Fa-f:]+) routes damping suppressed$/", $exec, $exec_exp)) { - $exec = 'show route receive-protocol bgp '.$exec_exp[1].' damping suppressed'; + $exec = 'show route receive-protocol bgp '.$exec_exp[1].' table '.$table.' damping suppressed'; } else if (preg_match("/^show bgp n\w*\s+([\d\.A-Fa-f:]+) advertised-routes ([\d\.A-Fa-f:\/]+)$/", $exec, $exec_exp)) { - $exec = 'show route advertising-protocol bgp '.$exec_exp[1].' '.$exec_exp[2].' exact detail'; + $exec = 'show route advertising-protocol bgp '.$exec_exp[1].' '.$exec_exp[2].' table '.$table.' exact detail'; } else if (preg_match("/^show bgp n\w*\s+([\d\.A-Fa-f:]+) receive-protocol ([\d\.A-Fa-f:\/]+)$/", $exec, $exec_exp)) { - $exec = 'show route receive-protocol bgp '.$exec_exp[1].' '.$exec_exp[2].' exact detail'; + $exec = 'show route receive-protocol bgp '.$exec_exp[1].' '.$exec_exp[2].' table '.$table.' exact detail'; } else if (preg_match("/^show bgp n\w*\s+([\d\.A-Fa-f:]+) a[\w\-]*$/", $exec, $exec_exp)) { - $exec = 'show route advertising-protocol bgp '.$exec_exp[1]; + $exec = 'show route advertising-protocol bgp '.$exec_exp[1].' table '.$table.; } else if (preg_match("/^show bgp\s+([\d\.A-Fa-f:]+\/\d+)$/", $exec, $exec_exp)) { - $exec = 'show route protocol bgp '.$exec_exp[1].' terse exact'; + $exec = 'show route protocol bgp '.$exec_exp[1].' table '.$table.' terse exact'; } else if (preg_match("/^show bgp\s+([\d\.A-Fa-f:]+)$/", $exec, $exec_exp)) { @@ -427,7 +427,7 @@ function load() { } else if (preg_match("/^show bgp\s+([\d\.A-Fa-f:\/]+) exact$/", $exec, $exec_exp)) { - $exec = 'show route protocol bgp '.$exec_exp[1].' exact detail all'; + $exec = 'show route protocol bgp '.$exec_exp[1].' table '.$table.' exact detail all'; } else if (preg_match("/^show bgp re\s+(.*)$/", $exec, $exec_exp)) { From 36f5a904319fbe877edc8e74c82963e30a774201 Mon Sep 17 00:00:00 2001 From: "Pavel D. Kuzin" Date: Thu, 30 Dec 2021 17:12:13 +0300 Subject: [PATCH 08/13] routing-instance selection --- htdocs/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/index.php b/htdocs/index.php index 5866f3a..1e7e657 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -415,7 +415,7 @@ function load() { } else if (preg_match("/^show bgp n\w*\s+([\d\.A-Fa-f:]+) a[\w\-]*$/", $exec, $exec_exp)) { - $exec = 'show route advertising-protocol bgp '.$exec_exp[1].' table '.$table.; + $exec = 'show route advertising-protocol bgp '.$exec_exp[1].' table '.$table; } else if (preg_match("/^show bgp\s+([\d\.A-Fa-f:]+\/\d+)$/", $exec, $exec_exp)) { From cb152e8d469f3742435a832b1fa41b400645d366 Mon Sep 17 00:00:00 2001 From: "Pavel D. Kuzin" Date: Thu, 30 Dec 2021 17:18:41 +0300 Subject: [PATCH 09/13] routing-instance selection --- htdocs/index.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/index.php b/htdocs/index.php index 1e7e657..1c482be 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -457,6 +457,10 @@ function load() { $exec = 'show bgp summary'; } } + else if (preg_match("/^show route advertising-protocol bgp\s+([\d\.A-Fa-f:\/]+)$/", $exec, $exec_exp)) + { + $exec = 'show route advertising-protocol '.$exec_exp[1].' table '.$table; + } } if ($command == 'graph') From 70b25e79910f825f222f4c08a5e1cee2a8b2e065 Mon Sep 17 00:00:00 2001 From: "Pavel D. Kuzin" Date: Thu, 30 Dec 2021 17:19:30 +0300 Subject: [PATCH 10/13] routing-instance selection --- htdocs/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/index.php b/htdocs/index.php index 1c482be..e385f5b 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -459,7 +459,7 @@ function load() { } else if (preg_match("/^show route advertising-protocol bgp\s+([\d\.A-Fa-f:\/]+)$/", $exec, $exec_exp)) { - $exec = 'show route advertising-protocol '.$exec_exp[1].' table '.$table; + $exec = 'show route advertising-protocol bgp '.$exec_exp[1].' table '.$table; } } From d7266164c229ea8054e3c4c13a7232d2ede99eb7 Mon Sep 17 00:00:00 2001 From: "Pavel D. Kuzin" Date: Thu, 30 Dec 2021 17:20:49 +0300 Subject: [PATCH 11/13] routing-instance selection --- htdocs/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/index.php b/htdocs/index.php index e385f5b..c27d608 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -1578,7 +1578,7 @@ function ($matches) { } // JunOS - if (preg_match("/^show route advertising-protocol bgp\s+([\d\.A-Fa-f:]+)$/i", $exec, $ip_exp)) + if (preg_match("/^show route advertising-protocol bgp\s+([\d\.A-Fa-f:]+)(?:\s+instance\s+[\d\w-]*)?$/i", $exec, $ip_exp)) { $ip = $ip_exp[1]; From c1c7ef41eaeb974c9f756b681b9d4ed9104366a0 Mon Sep 17 00:00:00 2001 From: "Pavel D. Kuzin" Date: Thu, 30 Dec 2021 17:22:41 +0300 Subject: [PATCH 12/13] routing-instance selection --- htdocs/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/index.php b/htdocs/index.php index c27d608..4f8949c 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -1578,7 +1578,7 @@ function ($matches) { } // JunOS - if (preg_match("/^show route advertising-protocol bgp\s+([\d\.A-Fa-f:]+)(?:\s+instance\s+[\d\w-]*)?$/i", $exec, $ip_exp)) + if (preg_match("/^show route advertising-protocol bgp\s+([\d\.A-Fa-f:]+)(?:\s+table\s+[\d\w\-\.]*)?$/i", $exec, $ip_exp)) { $ip = $ip_exp[1]; From dd11b6ed9814d748ff4a39b01468169b18cc361b Mon Sep 17 00:00:00 2001 From: "Pavel D. Kuzin" Date: Fri, 31 Dec 2021 00:12:56 +0300 Subject: [PATCH 13/13] routing-instance selection --- htdocs/index.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/index.php b/htdocs/index.php index 4f8949c..eab7202 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -461,6 +461,15 @@ function load() { { $exec = 'show route advertising-protocol bgp '.$exec_exp[1].' table '.$table; } + else if (preg_match("/^traceroute (ip|ipv6) ([\d\.A-Fa-f:\/]+)$/", $exec, $exec_exp)) + { + if ($routing_instance){ + $exec = 'traceroute '.$exec_exp[1].' routing-instance '.$routing_instance.' '.$exec_exp[2]; + }else{ + $exec = 'traceroute '.$exec_exp[1].' '.$exec_exp[2]; + } + } + } if ($command == 'graph')