{"id":2741,"date":"2021-02-22T13:05:51","date_gmt":"2021-02-22T13:05:51","guid":{"rendered":"https:\/\/www.cyber-cottage.co.uk\/?p=2741"},"modified":"2021-02-24T13:01:50","modified_gmt":"2021-02-24T13:01:50","slug":"freestats-installation","status":"publish","type":"post","link":"https:\/\/www.cyber-cottage.co.uk\/?p=2741","title":{"rendered":"FreeStats Installation"},"content":{"rendered":"\n<p>Installing FreeStats requires a good working knowledge of Asterisk and Freepbx. Documented here is the step by step process. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> \n To install Asterisk FreeStats you need:\n\n Enable writing queue logs to the MySQL database through ODBC . (more: Asterisk: queue _log in MySQL via unixODBC )\n Set the username and password of the database in the Asterisk \n\nCall Center Stats config.\n Let's turn on the Asterisk queue log in the MySQL database \n By default, queue statistics data is saved to the queue_log file. \n Let's assign a MySQL database table for data storage - asteriskcdrdb.queuelog\n CREATE TABLE IF NOT EXISTS <code>asteriskcdrdb.queuelog<\/code> (\n  <code>id<\/code> INT NOT NULL AUTO_INCREMENT,\n  <code>time<\/code> char (32) DEFAULT NULL,\n  <code>callid<\/code> char (64) DEFAULT NULL,\n  <code>queuename<\/code> char (64) DEFAULT NULL,\n  <code>agent<\/code> char (64) DEFAULT NULL,\n  <code>event<\/code> char (32) DEFAULT NULL,\n  <code>data<\/code> char (64) DEFAULT NULL,\n  <code>data1<\/code> char (64) DEFAULT NULL,\n  <code>data2<\/code> char (64) DEFAULT NULL,\n  <code>data3<\/code> char (64) DEFAULT NULL,\n  <code>data4<\/code> char (64) DEFAULT NULL,\n  <code>data5<\/code> char (64) DEFAULT NULL,\n  PRIMARY KEY (id)\n  ) ENGINE = MyISAM DEFAULT CHARSET = utf8;\n CREATE TABLE IF NOT EXISTS <code>agents_new<\/code> (\n  <code>id<\/code> MEDIUMINT NOT NULL AUTO_INCREMENT,\n  <code>agent<\/code> char (64) DEFAULT NULL,\n  PRIMARY KEY (id)\n  ) ENGINE = MyISAM DEFAULT CHARSET = utf8;\n CREATE TABLE IF NOT EXISTS <code>queues_new<\/code> (\n  <code>id<\/code> MEDIUMINT NOT NULL AUTO_INCREMENT,\n  <code>queuename<\/code> char (64) DEFAULT NULL,\n  PRIMARY KEY (id)\n  ) ENGINE = MyISAM DEFAULT CHARSET = utf8; \n\nWe have included in the download a file to do this for you. to install it just run the following command\nmysql -ufreepbxuser -pSECRECT  &lt; .\/freestats.sql\n \nIn the \/etc\/asterisk\/asterisk.conf file , add to the options section:\n [options]\n queue_adaptive_realtime=yes\n \n edit \/etc\/asterisk\/logger_general_custom.conf \n and add\n \nqueue_adaptive_realtime = yes\nqueue_log_to_file = yes\nqueue_log => odbc,asteriskcdrdb,queuelog\n\nIn the realtime configuration file \/etc\/asterisk\/extconfig_custom.conf, we define the driver, family, and target table:\n[settings]\nqueue_log => odbc,asteriskcdrdb,queuelog \n; where asterisk is the db config, for example in \/etc\/asterisk\/res_odbc_custom.conf\n\nIn freepbx the following are already set you just need to add the settings to \/etc\/asterisk\/extconfig_custom.conf as above\n\nIf extconfig.conf does not exist, create it with the command: \ntouch \/etc\/asterisk\/extconfig.conf \nand set permissions:\nchown asterisk.  \/etc\/asterisk\/extconfig.conf \n\/etc\/asterisk\/res_odbc_custom.conf \n[asteriskcdrdb]\nenabled => yes\ndsn => asteriskcdrdb\nusername => dbuser\npassword => dbpass\npre-connect => yes \n\nwhere is DSN , settings from file\n\/etc\/odbc.ini \n[asteriskcdrdb]\nDescription = MySQL connection to 'asteriskcdrdb' database\ndriver = MySQL\nserver = localhost\ndatabase = asteriskcdrdb\nPort = 3306\nSocket = \/var\/lib\/mysql\/mysql.sock \n \nApply configuration with \n\nasterisk -rx 'core restart now'\n \nNOTE 'core restart now' - drops all current calls\nCheck the connection of Asterisk with the database through odbc :\nasterisk -rx 'odbc show'\nODBC DSN Settings\nName:   asteriskcdrdb\nDSN:    MySQL-asteriskcdrdb\nNumber of active connections: 3 (out of 5)\nLogging: Disabled\n\nNow move freestats and set permissions:\nmv freestats \/var\/www\/html\/\nAsterisk FreeStats config \n \nEdit the config.php file according to your data, where\n $ DBServer - host (localhost)\n $ DBUser - DB user.\n $ DBPass - DB Password.\n $ DBName - DB name.\n $ DBTable - The name of the database table.\n example:\n $ DBServer = 'localhost' ;\n $ DBUser = 'freepbxuser' ;\n $ DBPass = 'STRONG_SECRET' ;\n $ DBName = 'asteriskcdrdb' ;\n $ DBTable = 'queuelog' ; \n\nOpen statistics in your favorite web browser:\nhttp(s):\/\/ip.address\/freestats\nTo add agents and queues, click the appropriate buttons: \nSync : \nThe query will fetch the unique names of agents and queues and place them in the agents_new and queues_new tables . \nIn order for entities to appear , there must be at least one entry in the queuelog table about the incoming call to the queue. \nIn the future, if you have new agents or queues, simply synchronize the data to display statistics on them. Call data is saved regardless of synchronization, because the Asterisk queue logger is responsible for this.\nFreePBX conversation recordings in the statistics interface \nTo display conversation records in statistics, copy the following context into the \/etc\/asterisk\/extensions_override_freepbx.conf file. \nThe example shows the context [sub-record-check] of FreePBX Distro 14.\nextensions_override_freepbx.conf\nOr modify the context from your system in the same way by adding a custom queue event - REC . \nexten = > recordcheck, n, Queuelog ( recordcheck, $ {UNIQUEID} , NONE, REC, $ {CALLFILENAME} ) \n You cannot edit the FreePBX context directly in the extensions_additional.conf file, but you can put the modified version in extensions_override_freepbx.conf\nIf you use Asterisk 'clean' , you can do the same in the context of calling the queue by adding instead of the ${CALLFILENAME} variable the name of the conversation recording file in accordance with the scheme you use. \nAdditional information about queue log and QueueLog () command.\n \nAuthorization through accounts FreePBX \nTo enable authorization with the password FreePBX, uncomment the following code in the config.php file and change the password freepbxpassword to the password of your installation. The password can be viewed in the \/etc\/asterisk\/res_odbc_additional.conf file (for the latest freepbx versions).\n\nConfigure AMI and AJAM for Realtime module \nThe php-curl package must be installed. \nThe ajam_cookie file must be created in the root directory of the application:\ntouch ajam_cookie &amp;&amp; chmod 777 ajam_cookie \nAsterisk  needs to have AJAM  enabled  \/etc\/asterisk\/manager.conf\nas below in freepbx go to advanced settings and set \"Enable Static Content\" to yes \n[general]\n enabled = yes\n port = 5038\n bindaddr = 0.0.0.0\n  webenabled = yes\n  httptimeout = 60 \n create user AMI\n [ajamuser]\n  secret = PASSWORD\n  deny = 0.0.0.0\/0.0.0.0\n  permit = 127.0.0.1\/255.255.255.0\n  read = system, agent, reporting\n  write = system, agent, reporting \n \nand enable the built-in http server in \n \n\/etc\/asterisk\/http.conf\n [general]\n  enabled = yes\n  enablestatic = yes\n  bindaddr = 0.0.0.0\n  bindport = 8088\n  prefix = asterisk \n To test AJAM Interface is active \n  freepbx * CLI> http show status \n  HTTP Server Status:\n  Prefix: \/ asterisk\n  Server: Asterisk \/ 15.5.0\n  Server Enabled and Bound to 0.0.0.0:8088\n HTTPS Server Enabled and Bound to [::]: 8089\n Enabled URI's:\n  \/ asterisk \/ httpstatus => Asterisk HTTP General Status\n  \/ asterisk \/ amanager => HTML Manager Event Interface w \/ Digest authentication\n  \/ asterisk \/ arawman => Raw HTTP Manager Event Interface w \/ Digest authentication\n  \/ asterisk \/ manager => HTML Manager Event Interface\n  \/ asterisk \/ rawman => Raw HTTP Manager Event Interface\n  \/ asterisk \/ static \/ \u2026 => Asterisk HTTP Static Delivery\n  \/ asterisk \/ amxml => XML Manager Event Interface w \/ Digest authentication\n  \/ asterisk \/ mxml => XML Manager Event Interface\n  \/ asterisk \/ ws => Asterisk HTTP WebSocket\n Enabled Redirects:\n    None.\n Finally, set the data to connect to AMI \/ AJAM in the application config.php file :\n $ config [ 'urlraw' ] = 'http:\/\/127.0.0.1:8088\/asterisk\/rawman' ;\n  $ config [ 'admin' ] = 'ajamuser' ;\n  $ config [ 'secret' ] = 'PASSWORD' ;\n  $ config [ 'authtype' ] = 'plaintext' ;\n  $ config [ 'cookiefile' ] = null ;\n  $ config [ 'debug' ] = false ; <\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Installing FreeStats requires a good working knowledge of Asterisk and Freepbx. Documented here is the step by step process. To install Asterisk FreeStats you need: Enable writing queue logs to the MySQL database through ODBC . (more: Asterisk: queue _log in MySQL via unixODBC ) Set the username and password of the database in the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"content-type":"","advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[4],"tags":[],"class_list":["post-2741","post","type-post","status-publish","format-standard","hentry","category-products-and-services"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p5daZy-Id","jetpack_sharing_enabled":true,"jetpack_likes_enabled":false,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.cyber-cottage.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/2741","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cyber-cottage.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cyber-cottage.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cyber-cottage.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cyber-cottage.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2741"}],"version-history":[{"count":2,"href":"https:\/\/www.cyber-cottage.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/2741\/revisions"}],"predecessor-version":[{"id":2752,"href":"https:\/\/www.cyber-cottage.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/2741\/revisions\/2752"}],"wp:attachment":[{"href":"https:\/\/www.cyber-cottage.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2741"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cyber-cottage.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2741"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cyber-cottage.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2741"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}