ntimm

Call manager phone list

Discussion created by ntimm on Mar 24, 2012

Since the ucm probe can extract the phones but just displays in the gui I have a little script that will gather the data.  I actually write it to a db table but will also just print it out.

 

--local node = '172.16.10.200'
--local user = 'user'
--local pass = 'pass'
--local host = '172.16.10.200'
--local port = 8443
--local ccmrobot = '/mydomain/myhub/myrobot/cisco_ucm'

 

if rc == NIME_OK then
   print "Server Db Connect OK"
   ds = database.query(ucmd)
   rs = database.query(ucmq)
   x = #rs
   --print (x)
   if #rs > 0 then
    for i=1,#rs do
      t=rs[i]
      origin = t.origin
      robot = t.robot
      host = t.host
      port = t.port
      user = t.username
      pass = t.password
      node = t.node
      --build connection
      c = "Running for: "..origin.." "..host.." "..user.." "..pass.." "..port.." "..node..""
      print (c)
      mypds = pds.create()
      pds.putString (mypds,"host", host)
      pds.putInt (mypds,"port", port)
      pds.putString (mypds,"user", user)
      pds.putString (mypds,"pass", pass)
      pds.putString (mypds,"node", node)
      result,rc=nimbus.request(robot, "get_phoneinfo",mypds)
      if result then
         for k,v in pairs(result.phone_list) do
            --print (k)
            --for nk,nv in pairs(v) do
            --print (nk..": "..nv)
            class = (v.Class)
            if v.Description then
               desc = (v.Description)
            else
               desc = 'None'
            end
            name = (v.Name)
            ip = (v.IpAddress)
            product = (v.Product)
            model = (v.Model)
            if (v.DirNumber) then
               dirn = (v.DirNumber)
            else
               dirn = 'NA'
            end
            status = (v.Status)
            if (v.LoginUserId) then
               user = (v.LoginUserId)
            else
               user = 'None'       
            end
            myInsert =  "INSERT INTO ucm_phones VALUES ('"..origin.."','"..node.."','"..name.."','"..desc.."','"..ip.."','"..dirn.."','"..status.."','"..user.."','"..model.."','"..product.."')"
            print (myInsert)
            database.query(myInsert)
         end
      else
         print "No Probe Callback Connect"
      end
      pds.delete(mypds)
    end
   end
database.close()
end

Outcomes