summaryrefslogtreecommitdiffstats
path: root/etc/inc
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2005-05-31 22:40:13 +0000
committerScott Ullrich <sullrich@pfsense.org>2005-05-31 22:40:13 +0000
commit10655b3c779e3d2c9278ed3a983ca3587ad03a20 (patch)
tree41e319f113629b2b120d85c8874ba3e6939a5bc7 /etc/inc
parent69b8e1d444fde60ed739d034ae3f91b4b1d16e2c (diff)
downloadpfsense-10655b3c779e3d2c9278ed3a983ca3587ad03a20.zip
pfsense-10655b3c779e3d2c9278ed3a983ca3587ad03a20.tar.gz
Speedup get_carp_interface_status() by caching the full ifconfig file and then using it for each seqsequent request during the php session
Diffstat (limited to 'etc/inc')
-rw-r--r--etc/inc/pfsense-utils.inc18
1 files changed, 15 insertions, 3 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc
index 31a9c59..2f3b7f7 100644
--- a/etc/inc/pfsense-utils.inc
+++ b/etc/inc/pfsense-utils.inc
@@ -369,9 +369,21 @@ function filter_translate_type_to_real_interface($interface) {
* get_carp_interface_status($carpinterface): returns the status of a carp ip
*/
function get_carp_interface_status($carpinterface) {
- $result = does_interface_exist($carpinterface);
- if($result <> true) return false;
- $status = exec_command("/sbin/ifconfig {$carpinterface} | /usr/bin/grep \"carp:\" | /usr/bin/cut -d\" \" -f2");
+ /* basically cache the contents of ifconfig statement
+ to speed up this routine */
+ global $carp_query;
+ if($carp_query == "")
+ $carp_query = split("\n", `/sbin/ifconfig | /usr/bin/grep carp`);
+ $found_interface = 0;
+ foreach($carp_query as $int) {
+ if($found_interface == 1) {
+ if(stristr($int, "MASTER") == true) return "MASTER";
+ if(stristr($int, "BACKUP") == true) return "BACKUP";
+ if(stristr($int, "INIT") == true) return "INIT";
+ return false;
+ }
+ if(stristr($int, $carpinterface) == true) $found_interface=1;
+ }
return $status;
}
OpenPOWER on IntegriCloud