OpenSIPS / opensips-cli

OpenSIPS CLI tool - an interactive command line tool that can be used to control and monitor OpenSIPS servers.
GNU General Public License v3.0
84 stars 46 forks source link

Missing db_virtual in mi db_get #94

Closed bctff closed 2 years ago

bctff commented 2 years ago

Sample config with set2 including 2 db_urls

 #### Virtual database pool connector
loadmodule "db_virtual.so"
modparam("db_virtual", "db_probe_time", 30)
modparam("db_virtual", "db_max_consec_retrys",1)

modparam("db_virtual", "db_urls", "define set1 FAILOVER")
modparam("db_virtual", "db_urls", "unixodbc://opensips:xxxxxxxx@10.20.1.100/db100tds")

modparam("db_virtual", "db_urls", "define set2 FAILOVER")
modparam("db_virtual", "db_urls", "unixodbc://opensips:xxxxxxxx@10.1.1.100/atlloadbalancer")
modparam("db_virtual", "db_urls", "unixodbc://opensips:xxxxxxxx@10.0.1.100/laxloadbalancer")

modparam("db_virtual", "db_urls", "define set9 FAILOVER")
modparam("db_virtual", "db_urls", "mysql://opensips:xxxxxxxx@10.0.1.200/Replicate")

When we run the command line tool, the "atlloadbalancer" is not displayed. Only the second one "laxloadbalancer" is displayed in set2

opensips-cli -x mi  db_get
{
    "SETS": [
        {
            "index": 0,
            "name": "unixodbc://opensips:xxxxxxxx@10.20.1.100/db100tds",
            "mode": "FAILOVER",
            "can": 1,
            "may": 1,
            "r_rec": 1
        },
        {
            "index": 1,
            "name": "unixodbc://opensips:xxxxxxxx@10.0.1.100/laxloadbalancer",
            "mode": "FAILOVER",
            "can": 1,
            "may": 1,
            "r_rec": 1
        },
        {
            "index": 2,
            "name": "mysql://opensips:xxxxxxxx@10.0.1.200/Replicate",
            "mode": "FAILOVER",
            "can": 1,
            "may": 1,
            "r_rec": 0
        }
    ],
    "DBS": [
        {}
    ]
}

We think this is because of a display issue with the json generation. This works:

opensips-cli -x mi  db_set 0 0 0 1      # db100
opensips-cli -x mi  db_set 1 0 0 1      # ATL (invisible)
opensips-cli -x mi  db_set 1 1 0 1      # LAX

We think the generated JSON should instead look like this (or similar)

{
   "SETS":{
      "set0":[
         {
            "index":0,
            "name":"unixodbc://opensips:xxxxxxxx@10.20.1.100/db100tds",
            "mode":"FAILOVER",
            "can":1,
            "may":0,
            "r_rec":1
         }
      ],
      "set1":[
         {
            "index":0,
            "name":"unixodbc://opensips:xxxxxxxx@10.1.1.100/atlloadbalancer",
            "mode":"FAILOVER",
            "can":1,
            "may":0,
            "r_rec":1
         },
         {
            "index":1,
            "name":"unixodbc://opensips:xxxxxxxx@10.0.1.100/laxloadbalancer",
            "mode":"FAILOVER",
            "can":1,
            "may":0,
            "r_rec":1
         }
      ],
      "set9":[
         {
            "index":2,
            "name":"mysql://opensips:xxxxxxxx@10.0.1.200/Replicate",
            "mode":"FAILOVER",
            "can":1,
            "may":1,
            "r_rec":0
         }
      ]
   },
   "DBS":[
      {

      }
   ]
}
bogdan-iancu commented 2 years ago

@bctff, thanks for the report. The problem is not in the CLI, but in OpenSIPS itself. And the problem was more foo than reported :). I did a fix in OpenSIPS and backported all the way to 3.1 ( see https://github.com/OpenSIPS/opensips/commit/8ab71077ba4fc5eb37d2dfb08e3c7f148e7eadf5).

bctff commented 2 years ago

Thank you so much for the information Bogdan! Apologies for the confusion with the cli tool