mirror of
https://github.com/alice-lg/birdwatcher.git
synced 2025-03-09 00:00:05 +01:00
fixed fieldname and ipv6 regex
This commit is contained in:
parent
757e2960a3
commit
8e31be933e
4 changed files with 14 additions and 8 deletions
|
@ -72,7 +72,7 @@ func Status() (Parsed, bool) {
|
|||
)
|
||||
}
|
||||
|
||||
birdStatus["lastReconfig"] = lastReconfig
|
||||
birdStatus["last_reconfig"] = lastReconfig
|
||||
|
||||
// Filter fields
|
||||
for _, field := range StatusConf.FilterFields {
|
||||
|
|
|
@ -244,7 +244,7 @@ func parseBgp(input string) Parsed {
|
|||
lines := getLinesFromString(input)
|
||||
route_changes := Parsed{}
|
||||
|
||||
bgp_rx := regexp.MustCompile(`^([\w\.]+)\s+BGP\s+(\w+)\s+(\w+)\s+([0-9]{4}-[0-9]{2}-[0-9]{2}\s+[0-9]{2}:[0-9]{2}:[0-9]{2})\s*(\w+)?.*$`)
|
||||
bgp_rx := regexp.MustCompile(`^([\w\.:]+)\s+BGP\s+(\w+)\s+(\w+)\s+([0-9]{4}-[0-9]{2}-[0-9]{2}\s+[0-9]{2}:[0-9]{2}:[0-9]{2})\s*(\w+)?.*$`)
|
||||
num_val_rx := regexp.MustCompile(`^\s+([^:]+):\s+([\d]+)\s*$`)
|
||||
str_val_rx := regexp.MustCompile(`^\s+([^:]+):\s+(.+)\s*$`)
|
||||
routes_rx := regexp.MustCompile(`^\s+Routes:\s+(\d+)\s+imported,\s+(\d+)\s+filtered,\s+(\d+)\s+exported,\s+(\d+)\s+preferred\s*$`)
|
||||
|
|
|
@ -24,6 +24,8 @@ func lastReconfigTimestampFromFileStat(filename string) string {
|
|||
func lastReconfigTimestampFromFileContent(filename string, regex string) string {
|
||||
rx := regexp.MustCompile(regex)
|
||||
|
||||
fmt.Println("Using regex:", regex)
|
||||
|
||||
// Read config file linewise
|
||||
file, err := os.Open(filename)
|
||||
if err != nil {
|
||||
|
@ -33,7 +35,11 @@ func lastReconfigTimestampFromFileContent(filename string, regex string) string
|
|||
|
||||
scanner := bufio.NewScanner(file)
|
||||
for scanner.Scan() {
|
||||
matches := rx.FindStringSubmatch(scanner.Text())
|
||||
txt := scanner.Text()
|
||||
fmt.Println("---------")
|
||||
fmt.Println(txt)
|
||||
|
||||
matches := rx.FindStringSubmatch(txt)
|
||||
if len(matches) > 0 {
|
||||
return matches[1]
|
||||
}
|
||||
|
|
|
@ -15,21 +15,21 @@ allow_from = []
|
|||
# Available sources: bird, config_regex, config_modified
|
||||
#
|
||||
reconfig_timestamp_source = "bird"
|
||||
reconfig_timestamp_match = "# Created (.*)"
|
||||
reconfig_timestamp_match = "# Created: (.*)"
|
||||
|
||||
# Remove fields e.g. last_reboot
|
||||
filter_fields = []
|
||||
|
||||
|
||||
[bird]
|
||||
listen = "0.0.0.0:29184"
|
||||
config = "/etc/bird.conf"
|
||||
listen = "0.0.0.0:29188"
|
||||
config = "./etc/bird.conf"
|
||||
birdc = "birdc"
|
||||
|
||||
|
||||
[bird6]
|
||||
listen = "0.0.0.0:29185"
|
||||
config = "/etc/bird6.conf"
|
||||
listen = "0.0.0.0:29189"
|
||||
config = "./etc/bird6.conf"
|
||||
birdc = "birdc6"
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue