36.sh 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/bin/bash
  2. # private memory effiency and fragmentation with ul_dump w/ or w/o PKG_MALLOC
  3. # Copyright (C) 2008 1&1 Internet AG
  4. #
  5. # This file is part of Kamailio, a free SIP server.
  6. #
  7. # Kamailio is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version
  11. #
  12. # Kamailio is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  20. source include/common
  21. source include/require
  22. source include/database
  23. if ! (check_kamailio && check_module "db_mysql" && check_mysql); then
  24. exit 0
  25. fi ;
  26. CFG=11.cfg
  27. cp $CFG $CFG.bak
  28. echo "loadmodule \"db_mysql/db_mysql.so\"" >> $CFG
  29. # 1768 contacts should fit into 1 MB of PKG memory
  30. $BIN -L $MOD_DIR -Y $RUN_DIR -P $PIDFILE -V | grep "PKG_MALLOC" > /dev/null
  31. if [ $? -eq 0 ]; then
  32. NR=176
  33. else
  34. NR=277
  35. fi;
  36. COUNTER=0
  37. while [ $COUNTER -lt $NR ]; do
  38. COUNTER=$(($COUNTER+1))
  39. $MYSQL "insert into location (username, domain, contact, user_agent) values ('foobar-$COUNTER-$RANDOM', 'local', 'foobar-$COUNTER-$RANDOM@$DOMAIN', '___test___'); \
  40. insert into location (username, domain, contact, user_agent) values ('foobar-$COUNTER-$RANDOM', 'local', 'foobar-$COUNTER-$RANDOM@$DOMAIN', '___test___'); \
  41. insert into location (username, domain, contact, user_agent) values ('foobar-$COUNTER-$RANDOM', 'local', 'foobar-$COUNTER-$RANDOM@$DOMAIN', '___test___'); \
  42. insert into location (username, domain, contact, user_agent) values ('foobar-$COUNTER-$RANDOM', 'local', 'foobar-$COUNTER-$RANDOM@$DOMAIN', '___test___'); \
  43. insert into location (username, domain, contact, user_agent) values ('foobar-$COUNTER-$RANDOM', 'local', 'foobar-$COUNTER-$RANDOM@$DOMAIN', '___test___'); \
  44. insert into location (username, domain, contact, user_agent) values ('foobar-$COUNTER-$RANDOM', 'local', 'foobar-$COUNTER-$RANDOM@$DOMAIN', '___test___'); \
  45. insert into location (username, domain, contact, user_agent) values ('foobar-$COUNTER-$RANDOM', 'local', 'foobar-$COUNTER-$RANDOM@$DOMAIN', '___test___'); \
  46. insert into location (username, domain, contact, user_agent) values ('foobar-$COUNTER-$RANDOM', 'local', 'foobar-$COUNTER-$RANDOM@$DOMAIN', '___test___'); \
  47. insert into location (username, domain, contact, user_agent) values ('foobar-$COUNTER-$RANDOM', 'local', 'foobar-$COUNTER-$RANDOM@$DOMAIN', '___test___'); \
  48. insert into location (username, domain, contact, user_agent) values ('foobar-$COUNTER-$RANDOM', 'local', 'foobar-$COUNTER-$RANDOM@$DOMAIN', '___test___');"
  49. done
  50. $BIN -L $MOD_DIR -Y $RUN_DIR -P $PIDFILE -w . -f $CFG > /dev/null
  51. ret=$?
  52. if [ $ret -eq 0 ]; then
  53. sleep 1
  54. for ((i=1;i<=100;i+=1)); do
  55. tmp=$($CTL fifo ul_dump | grep "User-agent:: ___test___" | wc -l)
  56. NR_=$(($NR * 10))
  57. if ! [ $tmp -eq $NR_ ]; then
  58. ret=1
  59. break;
  60. fi;
  61. done
  62. fi;
  63. sleep 1
  64. kill_kamailio
  65. $MYSQL "delete from location where user_agent = '___test___'"
  66. mv $CFG.bak $CFG
  67. exit $ret