Cat24.net logo putting VoIP to work


Add the LogzMon Log Viewer to freePBX and trixbox

The log viewing option in freePBX and trixbox is very limited and there has been discussion in the trixbox forum about better ways of extracting information from the asterisk log /var/log/asterisk/full. LogzMon is an open source / GPLV3 licensed log viewing program and it seems to work well. It makes reading log files a lot easier. It can be installed easily on a trixbox server and a simple hack incorporates it into freePBX. Note this hack will be overwritten if you update freePBX. Methodica LogzMon is written by Hans E. Herger

Introduction

This information is taken from the Methodica LogzMon website.

Methodica LogzMon is a log file viewer and a simple log file monitor. The log files are scanned and read from the web server. The results are submitted to the client where a standard browser is needed.

 (1) REGular EXpression. In the Unix/Linux world, standard format for search patterns.
 (2) PHP: Hypertext Preprocessor
 (3) CSS: Cascading Style Sheets
 (4) LogzMon has been tested with IE 6.0/7.0, Mozilla 1.7+, Firefox 1.5/2.0, Opera 8+.

^ Top of Page ^

Download

Download the latest version of LogzMon from the LogzMon website.

 cd /var/www/html/admin
 wget http://tools.methodica.info/logviewer/download/logzmon_1_4.tar

Install

 cd /var/www/html/admin
 tar -xvf logzmon_1_4.tar

^ Top of Page ^

Configure

The first line below is commented out with // - You can leave this as you don’t actually need to set a user (as long as you leave the user setting blank in index.html

NOTE: You MUST have valid entries here otherwise the php fails to run and you get a blank page. So rem the lines out with a // or put valid entries in place.

 //	if ($user=='ADMINISTRATOR.YOURDOMAIN.COM') {
		$logfiles = array (
		  array ('/var/www2/www2.yourdomain.com/logs/speciallogs.txt','(special)'),
		);
		$logdirs = array (
		  array ('/var/www/www.yourdomain.com/logs',''),
		  array ('/var/www2/www.yourdomain.com/logs',''),
		);
		$archivedirs = array (
		  array ('/var/www/www.yourdomain.com/logs',''),
		  array ('/var/www/www2.yourdomain.com/logs','(www2)'),
		);

A typical trixbox config could be to change the lines above as follows:

 //	if ($user=='ADMINISTRATOR.YOURDOMAIN.COM') {
		$logfiles = array (
	//	  array ('/var/www2/www2.yourdomain.com/logs/speciallogs.txt','(special)'),
		);
		$logdirs = array (
                 array ('/var/log/asterisk',''),
                 array ('/var/log',''),
                 array ('/var/log/asterisk/cdr-csv',''),
                 array ('/etc/asterisk',''),
		);
		$archivedirs = array (
	//	  array ('/var/www/www.yourdomain.com/logs',''),
	//	  array ('/var/www/www2.yourdomain.com/logs','(www2)'),
		);
  array ('/var/log/asterisk/full','(asterisk log)'),
  array ('/var/log/asterisk',''),
  array ('/var/log/asterisk/cdr-csv',''),
  array ('/var/log',''),  
  array ('/etc/asterisk',''),
  array ('/etc/asterisk',''),

is correct, but,

  array ('/etc/asterisk/',''), 

is incorrect.

  define('logext','__1_2_log_csv_conf_txt_',true);
  define('arcext','_gz_tar_',true);
  define('host_name','my trixbox host name');
  define('host_name_url','http://192.168.0.100');

Edit index.html

Two index files are contained in LogzMon use one and delete the other, they only differ in the file ending. The index file contains a line

<meta HTTP-EQUIV=REFRESH CONTENT=“0;URL=logviewer.php?mode=init&user=”>

Just remove the user setting so that it appears as above.

Test

  http://your_trixbox_ip/admin/logviewer

^ Top of Page ^

Set up expressions for highlighting

  $filters = array (
  array ('/_heartbeat\.htm|/favicon.ico |/img/|/scr/|/css/','hide',''),
  array ('started','white','green',''),
  array ('unable','green','red',''),
  array ('load','white','blue',''),
  array ('sip','black','orange',''),
  array ('iax','black','orange',''),
  array ('zap','black','orange',''),
  array ('voice','','pink'),
  array ('eth','','pink'),
  array ('raid','','pink'),
  array ('pci','','pink'),
  		);

^ Top of Page ^

Some logging options

 dmesg > /var/log/boot.msg
  full => notice,warning,error,debug,verbose

If you want just debug messages you can create an additional log file by adding after the entry for ‘full’

  asteriskdebug => debug

Hack freePBX to provide LogViewer Link

Here is a simple hack to place a Logviewer link on the freePBX admin page. It works with TB 2.0 and 2.2. It’s just a hack if you update freePBX it will be overwritten.

  print_sub_tool( _("Management"), "manage.php" , $currentFile=='manage.php' );
  print_sub_tool( _("Setup")     , "config.php" , $currentFile=='config.php' && isset($_REQUEST['type']) && ($_REQUEST['type']=='setup' || $_REQUEST['type'] == ""), "config.php?type=setup", false );
  print_sub_tool( _("Tools")     , "config.php" , $currentFile=='config.php' && isset($_REQUEST['type']) && $_REQUEST['type']=='tool' , "config.php?type=tool", false );
  print_sub_tool( _("Logviewer")   , "./logviewer/index.html",0, NULL, true );
  print_sub_tool( _("Reports")   , "reports.php", $currentFile=='reports.php' );
  print_sub_tool( _("Panel")     , "panel.php"  , $currentFile=='panel.php' );
  print_sub_tool( _("Recordings"), "../recordings/index.php"  ,0, NULL, true );

Your version will not contain the line

  print_sub_tool( _("Logviewer")   , "./logviewer/index.html",0, NULL, true );

Comments and Criticisms

Please read the User Guide that is provided with this program. There are other ways of using and configuring this program. I have not tried to explore them all, if you find a better way please let me know, via my contact page here or on the trixbox forum.

If you have suggestions about using this with trixbox or freePBX please let me know so that I can update this how-to. If you have suggestions about LogzMon itself you may want to let the author know via the Contact link on the Methodica LogzMon website.