misc: bug fixes and improvements for stats Fuse fs

Added syslogs
Added support for symlinks
Relocated make commands in a local Makefile
Dumping stats on index instead of paths
Updated README
Added go.mod and go.sum with relevant dependencies for the module

Type: fix
Change-Id: I2c91317939b2f4d765771ab7038372ae27d3109d
Signed-off-by: Arthur de Kerhor <arthurdekerhor@gmail.com>
This commit is contained in:
Arthur de Kerhor
2021-03-24 07:32:07 -07:00
committed by Beno�t Ganne
parent 2f64790c59
commit 9cfbd3b786
8 changed files with 272 additions and 127 deletions

View File

@ -25,6 +25,8 @@ package main
import (
"flag"
"fmt"
"log"
"log/syslog"
"os"
"os/signal"
"runtime"
@ -36,20 +38,32 @@ import (
"github.com/hanwen/go-fuse/v2/fs"
)
func LogMsg(msg string) {
fmt.Fprint(os.Stderr, msg)
log.Print(msg)
}
func main() {
syslogger, err := syslog.New(syslog.LOG_ERR|syslog.LOG_DAEMON, "statsfs")
if err != nil {
log.Fatalln(err)
}
log.SetOutput(syslogger)
statsSocket := flag.String("socket", statsclient.DefaultSocketName, "Path to VPP stats socket")
debug := flag.Bool("debug", false, "print debugging messages.")
flag.Parse()
if flag.NArg() < 1 {
fmt.Fprintf(os.Stderr, "usage: %s MOUNTPOINT\n", os.Args[0])
LogMsg(fmt.Sprintf("usage: %s MOUNTPOINT\n", os.Args[0]))
os.Exit(2)
}
//Conection to the stat segment socket.
sc := statsclient.NewStatsClient(*statsSocket)
fmt.Printf("Waiting for the VPP socket to be available. Be sure a VPP instance is running.\n")
fmt.Println("Waiting for the VPP socket to be available. Be sure a VPP instance is running.")
c, err := core.ConnectStats(sc)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to connect to the stats socket: %v\n", err)
LogMsg(fmt.Sprintf("Failed to connect to the stats socket: %v\n", err))
os.Exit(1)
}
defer c.Disconnect()
@ -57,7 +71,7 @@ func main() {
//Creating the filesystem instance
root, err := NewStatsFileSystem(sc)
if err != nil {
fmt.Fprintf(os.Stderr, "NewStatsFileSystem failed: %v\n", err)
LogMsg(fmt.Sprintf("NewStatsFileSystem failed: %v\n", err))
os.Exit(1)
}
@ -67,7 +81,7 @@ func main() {
opts.AllowOther = true
server, err := fs.Mount(flag.Arg(0), root, opts)
if err != nil {
fmt.Fprintf(os.Stderr, "Mount fail: %v\n", err)
LogMsg(fmt.Sprintf("Mount fail: %v\n", err))
os.Exit(1)
}
@ -86,6 +100,6 @@ func main() {
if err == nil || !strings.Contains(err.Error(), "Device or resource busy") {
break
}
fmt.Fprintf(os.Stderr, "Unmount fail: %v\n", err)
LogMsg(fmt.Sprintf("Unmount fail: %v\n", err))
}
}