summaryrefslogtreecommitdiffstats
path: root/extras/vpp_stats_fs/cmd.go
diff options
context:
space:
mode:
authorArthur de Kerhor <arthurdekerhor@gmail.com>2021-03-24 07:32:07 -0700
committerBeno�t Ganne <bganne@cisco.com>2021-06-03 07:25:04 +0000
commit9cfbd3b7869db3ca5131c6fd0c0f77b787fa4312 (patch)
tree2c43941190db870ccb73a54df420756197bd330c /extras/vpp_stats_fs/cmd.go
parent2f64790c596036877d1fc70a1cae0f96b655af19 (diff)
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>
Diffstat (limited to 'extras/vpp_stats_fs/cmd.go')
-rw-r--r--extras/vpp_stats_fs/cmd.go26
1 files changed, 20 insertions, 6 deletions
diff --git a/extras/vpp_stats_fs/cmd.go b/extras/vpp_stats_fs/cmd.go
index 826b011b00d..38d1b3db62f 100644
--- a/extras/vpp_stats_fs/cmd.go
+++ b/extras/vpp_stats_fs/cmd.go
@@ -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))
}
}