From 8e43c6692a6525947fe50995e87a9f6a59d99bf9 Mon Sep 17 00:00:00 2001 From: Renato Botelho Date: Wed, 24 Jul 2013 14:42:55 -0300 Subject: Make filter option easier to use on other commands, enable it on fib --- config/openbgpd/openbgpd_status.php | 53 +++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 20 deletions(-) (limited to 'config/openbgpd') diff --git a/config/openbgpd/openbgpd_status.php b/config/openbgpd/openbgpd_status.php index 834f2116..aaa37d26 100644 --- a/config/openbgpd/openbgpd_status.php +++ b/config/openbgpd/openbgpd_status.php @@ -34,16 +34,18 @@ $commands = array(); defCmdT("summary", "OpenBGPD Summary", "/usr/local/sbin/bgpctl show summary"); defCmdT("interfaces", "OpenBGPD Interfaces", "/usr/local/sbin/bgpctl show interfaces"); -defCmdT("routing", "OpenBGPD Routing", "/usr/local/sbin/bgpctl show rib | /usr/bin/sed '1,4d'"); -defCmdT("forwarding", "OpenBGPD Forwarding", "/usr/local/sbin/bgpctl show fib"); +defCmdT("routing", "OpenBGPD Routing", "/usr/local/sbin/bgpctl show rib | /usr/bin/sed '1,4d'", true); +defCmdT("forwarding", "OpenBGPD Forwarding", "/usr/local/sbin/bgpctl show fib | /usr/bin/sed '1,5d'", true); defCmdT("network", "OpenBGPD Network", "/usr/local/sbin/bgpctl show network"); defCmdT("nexthops", "OpenBGPD Nexthops", "/usr/local/sbin/bgpctl show nexthop"); defCmdT("ip", "OpenBGPD IP", "/usr/local/sbin/bgpctl show ip bgp"); defCmdT("neighbors", "OpenBGPD Neighbors", "/usr/local/sbin/bgpctl show neighbor"); if (isset($_REQUEST['isAjax'])) { - if (isset($_REQUEST['cmd']) && isset($commands[$_REQUEST['cmd']])) + if (isset($_REQUEST['cmd']) && isset($commands[$_REQUEST['cmd']])) { + echo "{$_REQUEST['cmd']}\n"; echo htmlspecialchars_decode(doCmdT($commands[$_REQUEST['cmd']][1], $_REQUEST['limit'], $_REQUEST['filter'])); + } exit; } @@ -87,25 +89,25 @@ function countCmdT($command) { return $c; } -function showCmdT($idx, $title, $command) { +function showCmdT($idx, $title, $command, $has_filter) { echo "

\n"; echo " \n"; echo "\n"; echo "\n"; $limit_default = "all"; - if ($idx == "routing") { + if ($has_filter) { $limit_options = array("10", "50", "100", "200", "500", "1000", "all"); $limit_default = "100"; echo "\n"; + echo " of " . countCmdT($command) . " items\n"; echo "\n"; } @@ -116,10 +118,10 @@ function showCmdT($idx, $title, $command) { } /* Define a command, with a title, to be executed later. */ -function defCmdT($idx, $title, $command) { +function defCmdT($idx, $title, $command, $has_filter = false) { global $commands; $title = htmlspecialchars($title,ENT_NOQUOTES); - $commands[$idx] = array($title, $command); + $commands[$idx] = array($title, $command, $has_filter); } /* List all of the commands as an index. */ @@ -136,7 +138,7 @@ function listCmds() { function execCmds() { global $commands; foreach ($commands as $idx => $command) - showCmdT($idx, $command[0], $command[1]); + showCmdT($idx, $command[0], $command[1], $command[2]); } ?> @@ -180,23 +182,34 @@ function execCmds() {
" . $title . "
\n"; - echo "Display \n"; foreach ($limit_options as $item) echo "\n"; - echo " of " . countCmdT($command) . " routesFilter expression: \n"; - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; echo "