-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
utils: add helper to interact with janus admin API #3097
base: master
Are you sure you want to change the base?
utils: add helper to interact with janus admin API #3097
Conversation
I created a |
This looks like a useful tool (some time ago I wrote a similar one in nodejs), but I'm not sure it belongs here. Maybe it could be its own separate repo? |
Why so? It's a shell script, it won't hurt to have it here (I think it's quite useful instead) and having its own repo would be overkill IMHO. |
Fair point 👍 |
IMHO this is a useful addition to the code base. @lionelnicolas I'd suggest adding the admin endpoint as a parameter (default value should be |
7e4b29f
to
af85bee
Compare
Done |
👍 use ping to do health check |
af85bee
to
bc1c534
Compare
Good idea. If you want to use that for an health check, I've added diff --git a/utils/janus-admin-cli b/utils/janus-admin-cli
index 5355683d..9c9a744b 100755
--- a/utils/janus-admin-cli
+++ b/utils/janus-admin-cli
@@ -13,11 +13,12 @@ janus_addr="${JANUS_HOST:-localhost}"
janus_port="${JANUS_ADMIN_PORT:-7088}"
janus_pass="${JANUS_ADMIN_SECRET:-janusoverlord}"
janus_endpoint="${JANUS_ADMIN_ENDPOINT:-/admin}"
+janus_timeout="${JANUS_ADMIN_TIMEOUT:-5}"
# define usage
usage() {
cat <<EOF
-usage: $0 [-h] [-a JANUS_ADDR] [-p JANUS_ADMIN_PORT] [-s JANUS_ADMIN_SECRET] [-e JANUS_ADMIN_ENDPOINT] [-o NAME=VALUE] -r REQUEST
+usage: $0 [-h] [-a JANUS_ADDR] [-p JANUS_ADMIN_PORT] [-s JANUS_ADMIN_SECRET] [-e JANUS_ADMIN_ENDPOINT] [-t JANUS_ADMIN_TIMEOUT] [-o NAME=VALUE] -r REQUEST
-h show this help message
-r janus request (required)
@@ -26,6 +27,7 @@ usage: $0 [-h] [-a JANUS_ADDR] [-p JANUS_ADMIN_PORT] [-s JANUS_ADMIN_SECRET] [-e
-p janus HTTP admin port (default: ${janus_port})
-s janus admin secret (default: ${janus_pass})
-e janus admin endpoint (default: ${janus_endpoint})
+ -t janus response timeout (default: ${janus_timeout})
EOF
exit ${1:-1}
@@ -44,7 +46,7 @@ rand_str() {
}
# parse parameters
-while getopts "ha:p:s:e:o:r:" opt; do
+while getopts "ha:p:s:e:t:o:r:" opt; do
case $opt in
h) usage 0 ;;
r) janus_request="${OPTARG}" ;;
@@ -53,6 +55,7 @@ while getopts "ha:p:s:e:o:r:" opt; do
p) janus_port="${OPTARG}" ;;
s) janus_pass="${OPTARG}" ;;
e) janus_endpoint="${OPTARG}" ;;
+ t) janus_timeout="${OPTARG}" ;;
esac
done
@@ -103,6 +106,7 @@ curl \
--silent \
--fail \
--show-error \
+ --max-time ${janus_timeout} \
--write-out '\n' \
--data "${http_payload}" \
http://${janus_addr}:${janus_port}${janus_endpoint}${http_session_id}${http_handle_id} |
@lionelnicolas could you add some text to the Admin API documentation too, maybe as a new section there, so that people interested in the Admin API are aware of this tool they can use as an alternative to the demo page? In currently ends here in the |
bc1c534
to
a264190
Compare
Done. @lminiero Let me know if you want me to reword or add/remove stuff |
a264190
to
cf88865
Compare
bump |
Apologies for the awful delay in this response, I simply forgot about this... 🙈
As a couple of additonal notes, this seems hardcoded to plain HTTP, but some may have the Admin API exposed via HTTPS. In that case, adding a Sorry again for this late response! |
Sorry I missed the notification. I'll take a look by end of week. |
Useful for live-enable/disable locks and refcount debugging on production, or start a PCAP dump, when the admin API is not easily accessible (e.g. janus running in a kubernetes pod). Using this you can simply:
See https://janus.conf.meetecho.com/docs/admin.html for more commands.
Janus admin connection can be configure using parameters or env vars (
JANUS_HOST
,JANUS_ADMIN_PORT
,JANUS_ADMIN_SECRET
,JANUS_ADMIN_ENDPOINT
)Examples: