Demystifying iControl REST Part 7 - Understanding Transactions
Hi all,
I have question on the PEM rest API query.
[root@ip-10-1-1-8:Active:Standalone] config # tmsh show pem sessiondb all Pem::Sessiondb Blade number 0 TMM number 2 ------------------------------------- Subscriber Information ------------------------------------- Subscriber Id demouser1 Subscriber Id Type NAI Subscriber Type Dynamic ------------------------------------- Session Information ------------------------------------- IP Address 10.1.20.11 Policy Server Session Id Quota Server Session Id Session State provisioned Session Origin radius User-Name 3GPP-IMSI 3GPP-IMEISV 3GPP-User-Location-Info Called-Station-Id Calling-Station-Id NAS-IP-Address NAS-IPv6-Address Device Name Device OS Bytes Uplink 404726 Bytes Downlink 3060546 Flows Total 126 Flows Current 1 Flows Max 61 Transactions 36 ------------------------------------- Policy Name Policy Type -------------------------------------
.......
or query filer with "subscriber-id"
[root@ip-10-1-1-8:Active:Standalone] config # tmsh show pem sessiondb Subscriber-Id demouser1 Pem::Sessiondb Blade number 0 TMM number 2 ------------------------------------- Subscriber Information ------------------------------------- Subscriber Id demouser1 Subscriber Id Type NAI Subscriber Type Dynamic ------------------------------------- Session Information ------------------------------------- IP Address 10.1.20.11 Policy Server Session Id Quota Server Session Id Session State provisioned Session Origin radius User-Name 3GPP-IMSI 3GPP-IMEISV 3GPP-User-Location-Info Called-Station-Id Calling-Station-Id NAS-IP-Address NAS-IPv6-Address Device Name Device OS Bytes Uplink 404726 Bytes Downlink 3060546 Flows Total 126 Flows Current 1 Flows Max 61 Transactions 36 ------------------------------------- Policy Name Policy Type ------------------------------------- Student_block Predefined Student Predefined ------------------------------------- Total sessions found: 1
But i don't know how can i request in API uri. I had tried some but still failed.
Can you help to educate me how to convert this as rest API request?
root@ip-10-1-1-8:Active:Standalone] config # curl -k -u admin:admin -H "Content-Type: application/json" -X GET https://10.1.1.8/mgmt/tm/pem/sessiondb?Subscriber-Id=demosuer1 {"code":400,"message":"Query parameter Subscriber-Id is invalid.","errorStack":[],"apiError":1}[root@ip-10-1-1-8:Active:Standalone] config # curl -k -u admin:admin c^C [root@ip-10-1-1-8:Active:Standalone] config # curl -k -u admin:admin -H "Content-Type: application/json" -X GET https://10.1.1.8/mgmt/tm/pem/sessiondb {"code":400,"message":"At least one filtering argument or option 'all' must be specified","errorStack":[],"apiError":26214401}[root@ip-10-1-1-8:Active:Standalone] config # curl -k -u admin:admin -H "Content-Type: application/json" -X GET https://10.1.1.8/mgmt/tm/pem/sessiondb/all {"code":400,"message":"Found unexpected URI tmapi_mapper/pem/sessiondb/all.","errorStack":[],"apiError":1}[root@ip-10-1-1-8:Active:Standalone] config # [root@ip-10-1-1-8:Active:Standalone] config #
Hi,
I also have the same behavior, did you solve it?
- Taut_SRISOMCHAIAug 29, 2024Employee
Hi Marco_77
Yes,it solved. I got the suggestion from JRahm and it works!
"Try this format:/mgmt/tm/pem/sessiondb?options=subscriber-id+demouser1"
Here is the example.
>>>>>>>>>>>>>>
[root@ip-10-1-1-8:Active:Standalone] config # curl -k -u admin:admin -H "Content-Type: application/json" -X GET https://10.1.1.8/mgmt/tm/pem/sessiondb?options=subscriber-id+demouser1 | jq .
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1912 100 1912 0 0 9149 0 --:--:-- --:--:-- --:--:-- 9192
{
"kind": "tm:pem:sessiondb:sessiondbstats",
"selfLink": https://localhost/mgmt/tm/pem/sessiondb?options=subscriber-id+demouser1&ver=13.1.0.6,
"entries": {
https://localhost/mgmt/tm/pem/sessiondb/0: {
"nestedStats": {
"entries": {
"blade_number": {
"description": "0"
},
"bytes_from_client": {
"description": "2524741"
},
"bytes_to_client": {
"description": "16433442"
},
"custom_attr_count": {
"description": "0"
},
"err_code": {
"description": "0"
},
"flows_current": {
"description": "1"
},
"flows_max": {
"description": "125"
},
"flows_total": {
"description": "1100"
},
"operation": {
"description": "0"
},
"provisioned": {
"description": "yes"
},
"rt_domain": {
"description": "0"
},
"session_id": {
"description": "500890"
},
"session_ip": {
"description": "10.1.20.11"
},
"session_origin": {
"description": "1"
},
"session_origin_str": {
"description": "radius"
},
"session_state": {
"description": "1"
},
"session_state_str": {
"description": "provisioned"
},
"subscriber_id": {
"description": "demouser1"
},
"subscriber_id_type": {
"description": "3"
},
"subscriber_id_type_str": {
"description": "NAI"
},
"subscriber_type": {
"description": "2"
},
"tmm_number": {
"description": "2"
},
"transactions": {
"description": "150"
},
"version": {
"description": "2535959859"
},
https://localhost/mgmt/tm/pem/sessiondb/0/ip_info: {
"nestedStats": {
"entries": {
https://localhost/mgmt/tm/pem/sessiondb/0/ip_info/0: {
"nestedStats": {
"entries": {
"ip_address": {
"description": "10.1.20.11"
},
"ip_prefix_len": {
"description": "0"
},
"rt_domain": {
"description": "0"
}
}
}
}
}
}
},
https://localhost/mgmt/tm/pem/sessiondb/0/policy_info: {
"nestedStats": {
"entries": {
https://localhost/mgmt/tm/pem/sessiondb/0/policy_info/0: {
"nestedStats": {
"entries": {
"deleted": {
"description": "no"
},
"policy_name": {
"description": "Student_block"
},
"policy_type": {
"description": "2"
}
}
}
},
https://localhost/mgmt/tm/pem/sessiondb/0/policy_info/1: {
"nestedStats": {
"entries": {
"deleted": {
"description": "no"
},
"policy_name": {
"description": "Student"
},
"policy_type": {
"description": "2"
}
}
}
}
}
}
}
}
}
}
}
}
>>>>>>>>>>>>>>
Compare to the tmsh command
root@(ip-10-1-1-8)(cfg-sync Standalone)(Active)(/Common)(tmos)# show pem sessiondb subscriber-id demouser1
Pem::Sessiondb
Blade number 0
TMM number 2
-------------------------------------
Subscriber Information
-------------------------------------
Subscriber Id demouser1
Subscriber Id Type NAI
Subscriber Type Dynamic
-------------------------------------
Session Information
-------------------------------------
IP Address 10.1.20.11
Policy Server Session Id
Quota Server Session Id
Session State provisioned
Session Origin radius
User-Name
3GPP-IMSI
3GPP-IMEISV
3GPP-User-Location-Info
Called-Station-Id
Calling-Station-Id
NAS-IP-Address
NAS-IPv6-Address
Device Name
Device OS
Bytes Uplink 4387176
Bytes Downlink 20547896
Flows Total 1998
Flows Current 1
Flows Max 125
Transactions 200
-------------------------------------
Policy Name Policy Type
-------------------------------------
Student_block Predefined
Student Predefined
-------------------------------------
Total sessions found: 1
>>>>>>>>
Hope this helps!