GithubHelp home page GithubHelp logo

amorenoz / ovsdb-mon Goto Github PK

View Code? Open in Web Editor NEW
23.0 4.0 4.0 1015 KB

An OVSDB database visualization tool based on auto-generated schema bindings

License: Apache License 2.0

Makefile 4.05% Go 92.72% Dockerfile 3.22%
ovn ovsdb ovs golang

ovsdb-mon's Introduction

ovsdb-mon

ovsdb-mon is an OVSDB monitoring and visulization tool based on libovsdb

Building ovsdb-mon

A common usage for this tool is to monitor an OVN database. However, it is generic enough to be used with any OVSDB schema. By default, ovsdb-mon uses the schema defined in schemas/ovn-nb.ovsschema. If you want to use your own, simply download it from your ovsdb server and replace the existing one

 ovsdb-client get-schema ${SERVER} ${DATABASE} > schemas/my.ovsschema

Then, just build the program specifying a schema file

 make SCHEMA=schemas/my.ovsschema

This will use modelgen to generate a native model of the DB and use it to build ovsdb-mon

Using ovsdb-mon

Usage of ovsdb-mon:

./bin/ovsdb-mon [FLAGS] [COMMAND]
FLAGS:
  -auto
        Autostart: If set to true, it will start monitoring from the begining
  -db string
        Database connection. Default: unix:/${OVS_RUNDIR}/ovnnb_db.sock
  -monitor string
        Only monitor these comma-separated tables
  -no-monitor string
        Do not monitor these comma-separated tables
COMMAND:
        If provided, it will run the command and exit. If not, it will enter interactive mode
        For a full description of available commands use the command 'help'

By default it will open an interactive terminal where you can monitor the activity of the DB and inspect it:

./bin/ovsdb-mon  --db tcp:172.19.0.4:6641
OVN Monitoring Shell
>>> help
Commands:
  clear      clear the screen
  exit       exit the program
  help       display help
  list       List the content of a specific table
  save       Save events
  show       Print available tables
  start      Start monitoring activity of the OVN DB
  stop       Stop monitoring activity of the OVN DB

The result looks like this:

Demo

Kubernetes

Use the yaml and scripts provided in the dist folder in order to deploy pods that provide a ready to use binary for the K8 cluster.

[ -n ${KUBECONFIG} ] || echo Make sure kubectl command can reach the cluster
cd dist
source ./ovsdb-mon-ovn.source
source ./ovsdb-mon-ovs.source

Note: Pod Security Admission must be taken into account when deploying ovsdb-mon, since it needs to access the host network. Being so, a namespace will be created with the required labels, and used by ovsdb-mon pod(s). For more info, see the pod-security-admission documentation.

Local machine (e.g: Openstack node)

If there is an OVN control plane or OVS running locally, run the following command to spin up the container:

For OVN and OVS (e.g: controller):

$ podman run --detach --name ovsdb-mon --rm --network=host -v /var/lib/openvswitch/ovn:/var/lib/openvswitch/ovn -v /var/run/openvswitch:/var/run/openvswitch quay.io/amorenoz/ovsdb-mon:latest

For OVS-only (e.g: compute):

$ podman run --detach --name ovsdb-mon --rm --network=host -v /var/run/openvswitch:/var/run/openvswitch quay.io/amorenoz/ovsdb-mon:latest

Note: The paths where OVS and OVN socket files are placed might be different in your distro. The container will try some common places but if it doesn't work for you, please raise an Issue.

To start monitoring run:

OVN_NorthBound:

$ podman exec -it ovsdb-mon ovsdb-mon.OVN_Northbound

OVN_SouthBound:

$ podman exec -it ovsdb-mon ovsdb-mon.OVN_Southbound

OVS:

$ podman exec -it ovsdb-mon ovsdb-mon.Open_vSwitch

ovsdb-mon's People

Contributors

amorenoz avatar flavio-fernandes avatar halfcrazy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ovsdb-mon's Issues

Error from server (Forbidden): error when creating ./ovsdb-mon-ovn.yaml

With latest release of Openshift, additional changes will be needed to yaml files, so pod are permitted to use host networking.

 source ./ovsdb-mon-ovn.source
Error from server (Forbidden): error when creating "./ovsdb-mon-ovn.yaml": pods "ovsdb-mon-ovn" is forbidden: violates PodSecurity "restricted:latest": host namespaces (hostNetwork=true), allowPrivilegeEscalation != false (container "ovsdb-mon-ovn" must set securityContext.allowPrivilegeEscalation=false), unrestricted capabilities (container "ovsdb-mon-ovn" must set securityContext.capabilities.drop=["ALL"]), restricted volume types (volumes "run-ovn", "run-ovs" use restricted volume type "hostPath"), runAsNonRoot != true (pod or container "ovsdb-mon-ovn" must set securityContext.runAsNonRoot=true), seccompProfile (pod or container "ovsdb-mon-ovn" must set securityContext.seccompProfile.type to "RuntimeDefault" or "Localhost")
bad k8s?

Issue running ovsdb-mon

Hi,

I am getting the following error when I run ovsdb-mon. Are there any additional logs I can provide?

gmckee@usc01a-lab-ovn04:~/Projects/ovsdb-mon/bin$ sudo ./ovsdb-mon -db unix:/var/run/ovn/ovnnb_db.sock
2022/12/07 21:37:43 libovsdb: trying to connect to DB unix:/var/run/ovn/ovnnb_db.sock
2022/12/07 21:37:43 libovsdb: connected to unix:/var/run/ovn/ovnnb_db.sock
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x48 pc=0x68338c]

goroutine 1 [running]:
main.(*OvsdbShell).exactFieldName(0xc00022bd70?, {0xc0000e2330?, 0xc000147870?}, {0xc000147a4c, 0x4})
	/home/gmckee/Projects/ovsdb-mon/cmd/ovsdb-mon/shell.go:381 +0x6c
main.(*OvsdbShell).Run(0xc000133260, {0x78ba40?, 0xc000133340?}, {0xc00009c170, 0x0, 0x0})
	/home/gmckee/Projects/ovsdb-mon/cmd/ovsdb-mon/shell.go:142 +0x1025
main.main()
	/home/gmckee/Projects/ovsdb-mon/cmd/ovsdb-mon/ovsdb-mon.go:68 +0x37c
gmckee@usc01a-lab-ovn04:~/Projects/ovsdb-mon/bin$ systemctl status ovn-ovsdb-server-nb.service
● ovn-ovsdb-server-nb.service - Open vSwitch database server for OVN Northbound database
     Loaded: loaded (/lib/systemd/system/ovn-ovsdb-server-nb.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2022-11-24 00:03:08 UTC; 1 week 6 days ago
   Main PID: 3139 (ovsdb-server)
      Tasks: 1 (limit: 9289)
     Memory: 2.4M
        CPU: 1h 12min 57.382s
     CGroup: /system.slice/ovn-ovsdb-server-nb.service
             └─3139 ovsdb-server -vconsole:off -vfile:info --log-file=/var/log/ovn/ovsdb-server-nb.log --remote=punix:/var/run/ovn/ovnnb_db.sock --p>

Dec 06 00:00:12 usc01a-lab-ovn04 ovsdb-server[3139]: ovs|00193|vlog|INFO|closing log file
Dec 06 00:00:12 usc01a-lab-ovn04 ovsdb-server[3139]: ovs|00194|vlog|INFO|opened log file /var/log/ovn/ovsdb-server-nb.log
Dec 06 01:39:55 usc01a-lab-ovn04 ovsdb-server[3139]: ovs|00195|jsonrpc|WARN|unix#803: send error: Broken pipe
Dec 06 01:39:55 usc01a-lab-ovn04 ovsdb-server[3139]: ovs|00196|reconnect|WARN|unix#803: connection dropped (Broken pipe)
Dec 06 01:42:55 usc01a-lab-ovn04 ovsdb-server[3139]: ovs|00197|jsonrpc|WARN|unix#806: send error: Broken pipe
Dec 06 01:42:55 usc01a-lab-ovn04 ovsdb-server[3139]: ovs|00198|reconnect|WARN|unix#806: connection dropped (Broken pipe)
Dec 07 00:00:13 usc01a-lab-ovn04 ovsdb-server[3139]: ovs|00199|vlog|INFO|closing log file
Dec 07 00:00:13 usc01a-lab-ovn04 ovsdb-server[3139]: ovs|00200|vlog|INFO|opened log file /var/log/ovn/ovsdb-server-nb.log
Dec 07 18:03:29 usc01a-lab-ovn04 ovsdb-server[3139]: ovs|00201|jsonrpc|WARN|tcp:172.16.49.9:40520: error parsing stream: line 1, column 0, byte 2: i>
Dec 07 18:03:29 usc01a-lab-ovn04 ovsdb-server[3139]: ovs|00202|reconnect|WARN|tcp:172.16.49.9:40520: connection dropped (Protocol error)

OVN Version 22.03.0

$ ovn-nbctl --version
ovn-nbctl 22.03.0
Open vSwitch Library 2.17.0
DB Schema 6.1.0

[RFE] Ability to filter the displayed results in the list output

This could be useful in a large environment, rather then listing every port in a large environment then filtering the results we could like filter the results before returning the results.

For example:

>>> list Logical_Switch_Port --filter UUID=d85f590a-0e60-4c6e-a393-a564d0a10d8e UUID Name Up Enabled ExternalIDs
+--------------------------------------+----------------------------------------------+-------+---------+-------------------------------------------------------------------+
|                 UUID                 |                     NAME                     |  UP   | ENABLED |                            EXTERNALIDS                            |
+--------------------------------------+----------------------------------------------+-------+---------+-------------------------------------------------------------------+
| d85f590a-0e60-4c6e-a393-a564d0a10d8e | 4258bc9a-89d4-4e53-8213-340309de7787         | false | true    | map[neutron:cidrs:172.21.11.132/24                                |
|                                      |                                              |       |         | neutron:device_id:78db7605-c5a8-4122-97a2-85ba7ca4df6b            |
|                                      |                                              |       |         | neutron:device_owner:compute:nova                                 |
|                                      |                                              |       |         | neutron:network_name:neutron-88ab458a-4a46-4bb8-b12f-f3c1f8b8bd2c |
|                                      |                                              |       |         | neutron:port_name:                                                |
|                                      |                                              |       |         | neutron:project_id:23d9837907e347d58920de8b76162390               |
|                                      |                                              |       |         | neutron:revision_number:7                                         |
|                                      |                                              |       |         | neutron:security_group_ids:c09d7d8e-2844-4ea3-b5e8-39ce231061d1]  |
+--------------------------------------+----------------------------------------------+-------+---------+-------------------------------------------------------------------+

Rename to ovsdb-mon

This project should also work with OvS or OVN SB, or any other OVNDB. How about we rename the project and binary to reflect that?

cannot generate the model

Hello,
i'm trying to do make with default schema without success

Generating model based on schema schemas/ovn-nb.ovsschema

github.com/amorenoz/ovsdb-mon/model

model/model.go:14:33: undefined: model.ClientDBModel
model/model.go:15:15: undefined: model.NewClientDBModel
make: *** [Makefile:22: build] Error 1

go version go1.20.3 linux/amd64

Can you give me some help,
Regard,
Nicolas

Add Conditional Monitoring support

A common usage case for this tool is to monitor changes in the OVSDB db.

Pending the upcoming changes in libovsdb for conditional monitoring (ovn-org/libovsdb#222),
it will become easier to allow user to specify the table(s) she/he cares about. We should expose that functionality to
this awesome tool.

[RFE] Make tab complete case insensitive

Hi Team,

Using the tab complete function is fanatic but it's a small annoyance to have to use the correct case.

If it is an easy change I think it would be worth it.

Example:

list logical_Flow <tab> <tab> Won't work. 

Diff printing is broken

It seems to detect as a diff something that is not, e.g:

New update event on table Logical_Switch_Port  
 {                 
  UUID: "35abef59-644f-41a7-90c7-72f96d490961",
  Addresses: [                                                      
+  "0a:58:0a:f4:00:0c 10.244.0.12",                                 
  ],                                                                
  Dhcpv4Options: [                                                  
  ],                                                                
  Dhcpv6Options: [                                                                                                                                                                                                                                                                
  ],                                                                
  DynamicAddresses: [                                               
  ],                                                                
  Enabled: [                                                        
  ],                                                                
  ExternalIDs: {                                                    
+  namespace: "default",                                            
+  pod: "true",                                                     
  },                                                                
  HaChassisGroup: [                                                 
  ],                                                                
- Name: "",                                                         
+ Name: "default_echo-deployment-869b7bf9c7-7p6q6",                 
  Options: {                                                                    
+  requested-chassis: "ovn-worker2",                                
  },                                                                
  ParentName: [                                                     
  ],                                                                
  PortSecurity: [                                                   
+  "0a:58:0a:f4:00:0c 10.244.0.12",                                 
  ],                                                                
  Tag: [                                                            
  ],                                                                
  TagRequest: [                                                     
  ],                                                                
  Type: "",                                                         
  Up: [                                                             
+  false,                                                           
  ],                                                                
 }                                                                  
                                                                    
New update event on table Logical_Switch_Port                       
 {                                                                  
  UUID: "35abef59-644f-41a7-90c7-72f96d490961",                     
  Addresses: [                                                      
+  "0a:58:0a:f4:00:0c 10.244.0.12",                                 
  ],                                                                
  Dhcpv4Options: [                                                  
  ],                                                                
  Dhcpv6Options: [                                                  
  ],                                                                            
  DynamicAddresses: [                                                           
  ],                                                                            
  Enabled: [                                                                    
  ],                                                                            
  ExternalIDs: {                                                                
+  namespace: "default",                                                        
+  pod: "true",                                                                 
  },                                                                            
  HaChassisGroup: [                                                             
  ],                                                                            
- Name: "",                                                                     
+ Name: "default_echo-deployment-869b7bf9c7-7p6q6",                             
  Options: {                                                                    
+  requested-chassis: "ovn-worker2",                                            
  },                                                                            
  ParentName: [                                                                 
  ],                                                                            
  PortSecurity: [                                                               
+  "0a:58:0a:f4:00:0c 10.244.0.12",                                             
  ],                                                                            
  Tag: [                                                                        
  ],                                                                            
  TagRequest: [                                                                 
  ],                                                                            
  Type: "",                                                                     
  Up: [                                                                         
-  false,                                                                       
+  true,                                                                        
  ],                                                                            
 } 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.