Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
presence:pua-modules [2007/04/04 13:27] – 81.180.83.75 | presence:pua-modules [2009/06/21 21:53] (current) – Updated to show additional parameters required for fifo 210.48.96.100 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Presence User Agent Modules ====== | ||
+ | It was designed with extensibility in mind, not to be tied to SIP or Kamailio (OpenSER) specific entities. | ||
+ | |||
+ | At this moment, there are three modules: | ||
+ | |||
+ | * [b]pua[/b] ([[http:// | ||
+ | * [b]pua_mi[/ | ||
+ | * [b]pua_usrloc[/ | ||
+ | * [b]pua_xmpp[/ | ||
+ | * [b]pua_bla[/ | ||
+ | |||
+ | |||
+ | ===== Publish Presence Information Via Management Interface ===== | ||
+ | |||
+ | There two new components involved, so small examples to get it started should make people attracted a bit and willing to test. Below is presented the config file and two shell scripts which are able to publish details from the operating system and from Kamailio (OpenSER) statistics. | ||
+ | |||
+ | Beware that you have to create the tables required by [[http:// | ||
+ | |||
+ | ==== Kamailio (OpenSER) Configuration file ==== | ||
+ | |||
+ | The configuration file is based on default config file which comes with Kamailio (OpenSER). It should allow to identify quickly the changes done to add presence capabilities. | ||
+ | |||
+ | [color=brown]NOTE: | ||
+ | |||
+ | <code c> | ||
+ | # | ||
+ | # simple quick-start config script + presence + pua usage | ||
+ | # | ||
+ | |||
+ | # ----------- global configuration parameters ------------------------ | ||
+ | |||
+ | /* Uncomment these lines to enter debugging mode */ | ||
+ | debug=3 | ||
+ | fork=yes | ||
+ | log_stderror=no | ||
+ | |||
+ | check_via=no # | ||
+ | dns=no | ||
+ | rev_dns=no | ||
+ | listen=udp: | ||
+ | children=2 | ||
+ | disable_tcp=yes | ||
+ | |||
+ | # | ||
+ | # uncomment the following lines for TLS support | ||
+ | # | ||
+ | #listen = tls: | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | #tls_method = TLSv1 | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | |||
+ | # ------------------ module loading ---------------------------------- | ||
+ | mpath="/ | ||
+ | |||
+ | loadmodule " | ||
+ | loadmodule " | ||
+ | loadmodule " | ||
+ | loadmodule " | ||
+ | loadmodule " | ||
+ | loadmodule " | ||
+ | loadmodule " | ||
+ | loadmodule " | ||
+ | loadmodule " | ||
+ | loadmodule " | ||
+ | loadmodule " | ||
+ | loadmodule " | ||
+ | loadmodule " | ||
+ | loadmodule " | ||
+ | |||
+ | # Uncomment this if you want digest authentication | ||
+ | # mysql.so must be loaded ! | ||
+ | #loadmodule " | ||
+ | #loadmodule " | ||
+ | |||
+ | # ----------------- setting module-specific parameters --------------- | ||
+ | modparam(" | ||
+ | |||
+ | # -- usrloc params -- | ||
+ | # Uncomment this if you want to use SQL database | ||
+ | # for persistent storage and comment the previous line | ||
+ | modparam(" | ||
+ | |||
+ | # -- auth params -- | ||
+ | # Uncomment if you are using auth module | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # If you set " | ||
+ | # uncomment also the following parameter) | ||
+ | # | ||
+ | # | ||
+ | |||
+ | # -- rr params -- | ||
+ | # add value to ;lr param to make some broken UAs happy | ||
+ | modparam(" | ||
+ | |||
+ | modparam(" | ||
+ | |||
+ | # -- presence params -- | ||
+ | modparam(" | ||
+ | " | ||
+ | modparam(" | ||
+ | modparam(" | ||
+ | modparam(" | ||
+ | |||
+ | # ------------------------- | ||
+ | |||
+ | # main routing logic | ||
+ | |||
+ | route{ | ||
+ | |||
+ | |||
+ | # initial sanity checks -- messages with | ||
+ | # max_forwards==0, | ||
+ | if (!mf_process_maxfwd_header(" | ||
+ | sl_send_reply(" | ||
+ | exit; | ||
+ | }; | ||
+ | |||
+ | if (msg:len >= 2048 ) { | ||
+ | sl_send_reply(" | ||
+ | exit; | ||
+ | }; | ||
+ | |||
+ | # we record-route all messages -- to make sure that | ||
+ | # subsequent messages will go through our proxy; that's | ||
+ | # particularly good if upstream and downstream entities | ||
+ | # use different transport protocol | ||
+ | if (!method==" | ||
+ | record_route(); | ||
+ | |||
+ | # subsequent messages withing a dialog should take the | ||
+ | # path determined by record-routing | ||
+ | if (loose_route()) { | ||
+ | # mark routing logic in request | ||
+ | append_hf(" | ||
+ | route(1); | ||
+ | }; | ||
+ | if(method == " | ||
+ | setflag(5); | ||
+ | |||
+ | #if (!uri==myself) { | ||
+ | # mark routing logic in request | ||
+ | # | ||
+ | # if you have some interdomain connections via TLS | ||
+ | # | ||
+ | # | ||
+ | # exit; | ||
+ | #} else if(uri=~" | ||
+ | # | ||
+ | # exit; | ||
+ | #} | ||
+ | # | ||
+ | #}; | ||
+ | |||
+ | # if the request is for other domain use UsrLoc | ||
+ | # (in case, it does not work, use the following command | ||
+ | # with proper names and addresses in it) | ||
+ | if (uri==myself) { | ||
+ | |||
+ | if( is_method(" | ||
+ | route(2); | ||
+ | |||
+ | if (method==" | ||
+ | |||
+ | # Uncomment this if you want to use digest authentication | ||
+ | #if (!www_authorize(" | ||
+ | # | ||
+ | # exit; | ||
+ | #}; | ||
+ | |||
+ | # make pua_usrloc send PUBLISH for phones which do not support presence | ||
+ | if(!search(" | ||
+ | pua_set_publish(); | ||
+ | |||
+ | save(" | ||
+ | exit; | ||
+ | }; | ||
+ | |||
+ | # native SIP destinations are handled using our USRLOC DB | ||
+ | if (!lookup(" | ||
+ | sl_send_reply(" | ||
+ | exit; | ||
+ | }; | ||
+ | append_hf(" | ||
+ | }; | ||
+ | |||
+ | route(1); | ||
+ | } | ||
+ | |||
+ | |||
+ | route[1] { | ||
+ | # send it out now; use stateful forwarding as it works reliably | ||
+ | # even for UDP2TCP | ||
+ | if (!t_relay()) { | ||
+ | sl_reply_error(); | ||
+ | }; | ||
+ | exit; | ||
+ | } | ||
+ | |||
+ | route[2] | ||
+ | { | ||
+ | sl_send_reply(" | ||
+ | if (!t_newtran()) | ||
+ | { | ||
+ | sl_reply_error(); | ||
+ | exit; | ||
+ | }; | ||
+ | |||
+ | append_to_reply(" | ||
+ | if(is_method(" | ||
+ | { | ||
+ | handle_publish(); | ||
+ | t_release(); | ||
+ | } | ||
+ | else | ||
+ | if( is_method(" | ||
+ | { | ||
+ | handle_subscribe(); | ||
+ | t_release(); | ||
+ | } | ||
+ | |||
+ | exit; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==== Publish Details From System ==== | ||
+ | |||
+ | The following scrip makes usage of FIFO transport for Management Interface (MI) to publish details from the system: | ||
+ | * [b]U[/b] - logged in users | ||
+ | * [b]C[/b] - CPU in usage by system | ||
+ | * [b]M[/b] - free memory available | ||
+ | * [b]L[/b] - average load in system | ||
+ | |||
+ | To see them, you have to subscribe to user [b]system[/ | ||
+ | |||
+ | The [b]kamailio-publish-system.sh[/ | ||
+ | |||
+ | < | ||
+ | #!/bin/bash | ||
+ | # buld a FIFO command to PUBLISH number of users, load, system CPU usage | ||
+ | # and freem memory in the system | ||
+ | # | ||
+ | |||
+ | #config values | ||
+ | OP_SYSUSER=" | ||
+ | OP_SIPURI=" | ||
+ | OP_EXPIRES=" | ||
+ | |||
+ | # load values | ||
+ | top -n1 | head -n 4 >/ | ||
+ | OP_USERS=`cat / | ||
+ | OP_LOAD=`cat / | ||
+ | OP_SCPU=`cat / | ||
+ | OP_FMEM=`cat / | ||
+ | |||
+ | #build reply fifo file | ||
+ | rm -f / | ||
+ | mkfifo / | ||
+ | cat / | ||
+ | |||
+ | cat >/ | ||
+ | : | ||
+ | $OP_SIPURI | ||
+ | $OP_EXPIRES | ||
+ | presence | ||
+ | application/ | ||
+ | . | ||
+ | . | ||
+ | <?xml version=' | ||
+ | |||
+ | EOF | ||
+ | |||
+ | </ | ||
+ | |||
+ | ==== Publish Details From Kamailio (OpenSER) Statistics ==== | ||
+ | |||
+ | The following scrip makes usage of FIFO transport for Management Interface (MI) to publish details from Kamailio (OpenSER) statistics: | ||
+ | * [b]U[/b] - user location records | ||
+ | * [b]T[/b] - active transactions | ||
+ | * [b]R[/b] - processed SIP requests | ||
+ | |||
+ | To see them, you have to subscribe to user [b]system[/ | ||
+ | |||
+ | The [b]kamailio-publish-stats.sh[/ | ||
+ | |||
+ | < | ||
+ | #!/bin/bash | ||
+ | # buld a FIFO command to PUBLISH number of users, load, system CPU usage | ||
+ | # and freem memory in the system | ||
+ | # | ||
+ | |||
+ | #config values | ||
+ | OP_SYSUSER=" | ||
+ | OP_SIPURI=" | ||
+ | OP_EXPIRES=" | ||
+ | OSERCTL="/ | ||
+ | |||
+ | # load values | ||
+ | $OSERCTL | ||
+ | OP_REQS=`cat / | ||
+ | OP_TRANS=`cat / | ||
+ | OP_URECS=`cat / | ||
+ | |||
+ | #build reply fifo file | ||
+ | rm -f / | ||
+ | mkfifo / | ||
+ | cat / | ||
+ | |||
+ | cat >/ | ||
+ | : | ||
+ | $OP_SIPURI | ||
+ | $OP_EXPIRES | ||
+ | presence | ||
+ | application/ | ||
+ | . | ||
+ | . | ||
+ | <?xml version=' | ||
+ | |||
+ | EOF | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | ==== Using With X-Lite 3.0 ==== | ||
+ | |||
+ | Below are links to two screenshots of using X-Lite to view published information by the two scripts above: | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | {{http:// | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | {{http:// | ||
+ | |||
+ | |||
+ | |||
+ | ===== Download Files ===== | ||
+ | |||
+ | Config file and shell scripts can be downloaded from [[http:// | ||
+ | |||
+ | ===== Presence-Related Stuff ===== | ||
+ | |||
+ | {{indexmenu> |