kamctl.unixsock 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #
  2. # $Id$
  3. #
  4. # control tool for maintaining Kamailio
  5. #
  6. #===================================================================
  7. ##### ----------------------------------------------- #####
  8. ### UNIXSOCK specific variables and functions
  9. #
  10. ##### ----------------------------------------------- #####
  11. ### load CTL base
  12. #
  13. if [ -f "$MYLIBDIR/kamctl.ctlbase" ]; then
  14. . "$MYLIBDIR/kamctl.ctlbase"
  15. else
  16. mwarn "Cannot load CTL core functions '$MYLIBDIR/kamctl.ctlbase' ..."
  17. # exit -1
  18. fi
  19. #
  20. ##### ----------------------------------------------- #####
  21. ### parameters
  22. #
  23. export CHROOT_DIR # needed for kamunix
  24. if [ -z "$OSER_UNIXSOCK" ]; then
  25. OSER_UNIXSOCK=$CHROOT_DIR/tmp/kamailio.sock
  26. fi
  27. if [ -z "$OSERUNIX" ]; then
  28. OSERUNIX=kamunix
  29. fi
  30. #
  31. ##### ----------------------------------------------- #####
  32. ### functions
  33. #
  34. usage_unixsock() {
  35. echo
  36. mecho " -- command 'unixsock'"
  37. echo
  38. cat <<EOF
  39. unixsock ........................... send raw unixsock command
  40. EOF
  41. }
  42. USAGE_FUNCTIONS="$USAGE_FUNCTIONS usage_unixsock"
  43. unixsock_cmd()
  44. {
  45. mdbg "entering unixsock_cmd $*"
  46. if [ "$#" -lt 1 ]; then
  47. merr "unixsock_cmd must take at least command name as parameter"
  48. exit
  49. fi
  50. # construct the command now
  51. CMD=":$1:\n";
  52. shift
  53. while [ -n "$1" ] ; do
  54. CMD="${CMD}${1}\n"
  55. shift
  56. done
  57. CMD="${CMD}\n"
  58. printf "$CMD" | $OSERUNIX $OSER_UNIXSOCK | filter_fl
  59. mdbg "UNIXSOCK command was:\n$CMD"
  60. }
  61. CTLCMD=unixsock_cmd
  62. unixsock_kamailio_monitor() {
  63. attempt=0
  64. if [ "$2" == "" ]; then
  65. loops=-1;
  66. else
  67. loops=$2;
  68. fi
  69. clear
  70. while [ $loops -ne $attempt ] ; do
  71. attempt=$(($attempt + 1))
  72. #clear
  73. tput cup 0 0
  74. # print_stats $attempt
  75. mecho "[cycle #: $attempt; if constant make sure server lives]"
  76. unixsock_cmd version
  77. unixsock_cmd uptime
  78. mecho "Transaction Statistics"
  79. unixsock_cmd get_statistics UAS_transactions
  80. unixsock_cmd get_statistics UAC_transactions
  81. unixsock_cmd get_statistics inuse_transactions
  82. mecho "Stateless Server Statistics"
  83. unixsock_cmd get_statistics sent_replies
  84. unixsock_cmd get_statistics sent_err_replies
  85. unixsock_cmd get_statistics received_ACKs
  86. mecho "UsrLoc Stats"
  87. unixsock_cmd get_statistics registered_users
  88. unixsock_cmd get_statistics location-users
  89. unixsock_cmd get_statistics location-contacts
  90. unixsock_cmd get_statistics location-expires
  91. if [ $loops -ne $attempt ] ; then
  92. sleep $WATCH_PERIOD
  93. fi
  94. done
  95. exit 0
  96. }
  97. KAMAILIO_MONITOR=unixsock_kamailio_monitor