These instructions explain how to run a tool to monitor data on a TMG system. 
This tool monitors different statistics periodically, including Call information, ISUP interface status and call status per CIC group. The data to monitor can be changed in the tbstatus.yml configuration file.

Steps to enable:
1. Transfer the .zip file to the TMG800, TMG3200 or TMG7800-CTRL you want monitor using sFTP (Filezilla or Winscp)

2. Uncompress the file
       tar xzf tbstatus_monitor.tgz

3. cd tbstatus_monitor

4. chmod +x tbstatus.rb

5. modify the tbstatus.yml file to define what to monitor, in particular:
-slog_file: .csv or .sqlite
-slog_update_interval: to specify when the data will be accessed.
-paths, to identify which paramters to capture.
=>To enable a new parameter, remove the '#' to uncomment the parameter

5a. If using .sqlite
- yum install sqlite-devel
- gem install sqlite3
From a script:
- can use a sqlite API if supported (ex. Ruby sqlite, Python sqlite, etc)
- from a shell script, can call sqlite3 application:
  ex. sqlite3 file.sqlite 'SELECT * FROM "/path" ORDER BY oid DESC LIMIT 10'
- get the 10 newest entries : SELECT * FROM "/path" ORDER BY oid DESC LIMIT 10
- get the 10 oldest entries : SELECT * FROM "/path" ORDER BY oid ASC LIMIT 10

For step 6, you have two choices:
6a. Start the tbstatus monitor tool in daemon mode
nohup ./tbstatus.rb -d &

To stop it, you must kill the process, for example:
[root@TB007036 ~]# ps -ef | grep tbstatus
root 20800 15165 0 04:17 pts/0 00:00:01 /usr/bin/ruby ./tbstatus.rb -d
root 23191 15165 0 04:46 pts/0 00:00:00 grep tbstatus
[root@TB007036 ~]# kill -9 20800

6b. Start the tbstatus monitor tool in toolpack system. This will automatically start or stop the tool at the same time as the toolpack service:
From the web interface: Host -> Applications -> Create New Application
Name: tbstatus_monitor
Application Type: user-specific
bin path: /root/tbstatus_monitor/tbstatus.rb
working path: /root/tbstatus_monitor
Command line arguments: -f tbstatus.yml -d

7. Multiple .csv files will be created according to the .yml file in the same folder. They will be rotated and zipped according to the yml configuration. 
These files can be extracted from the unit with sFTP, or SSH scp commands to be analyzed by an external system.

