NerveCenter Community

A forum for NerveCenter customers
It is currently Fri Oct 31, 2014 11:26 am

All times are UTC - 5 hours [ DST ]


Forum rules


Please click here to view the forum rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Analyzing NerveCenter with TraceQueues and TraceCounters
Posted: Fri Jun 03, 2011 3:32 pm 
Team Member

Joined: Wed Feb 03, 2010 6:23 pm
Posts: 16
NerveCenter has the ability to trace activity during run time. This tracing can be turned on dynamically as needed. The two files most useful for analyzing performance of the NerveCenter system are TraceQueues.log and TraceCounters.log.

Tracing is useful when you want to understand how your server is behaving or you want to see how a new model is performing.

To enable TraceCounters logging:

Connect to the server with the nccmd application.

nccmd -s <servername> -u <username> -p <password> -n <port_number: 3250 default>

From there, enter the command:

trace server counters on

This will turn on trace counters for as long as the server runs or until you turn them off in nccmd. Use the command trace server -? to learn all the options available for tracing server information.

To enable TraceQueues logging:

Connect to the server with the nccmd application.

nccmd -s <servername> -u <username> -p <password> -n <port_number: 3250 default>

From there, enter the command:

trace server queues on


The TraceCounters file can be found at the following location. For TraceQueues the directory path is the same, just change the filename from TraceCounters.log to TraceQueues.log

For UNIX systems: /opt/OSInc/userfiles/logs/TraceCounters.log

For Windows systems: \ProgramFiles\OpenService\NerveCenter\Log\TraceCounters.log

[If you have installed the server on a Windows 64 bit system, you will find the file under the \Program Files (x86) directory path.]


Top
 Profile  
 
 Post subject: Re: Analyzing NerveCenter with TraceQueues and TraceCounters
Posted: Fri Jun 03, 2011 3:41 pm 
Team Member

Joined: Wed Feb 03, 2010 6:23 pm
Posts: 16
Using this code segment you can convert the TraceQueues.log file to a .cvs file to import into a spreadsheet. That will make things much easier to read. Feel free to edit the Perl as you like.

Code:


#!/usr/bin/perl -w
use strict;

use vars qw (%file_handle);

#---------------------------------------------------------------------------
# ParseTraceQueues
#   Separate the TraceQueues.log file, produced by a NerveCenter
#   Server, into separate text files.
#
# Created for NerveCenter v5.1 by LogMatrix, Marlborough MA. 01752 USA.
# Copyright (C) 2011. LogMatrix, Inc.
#
# This script may be freely modified as long as this header is retained.
#
#---------------------------------------------------------------------------
# Usage:
#   From the directory where NerveCenter's TraceQueues.log file is found:
#   C:> Parse_TraceQueues.pl [append]
#   % Parse_TraceQueues.pl [append]
#
# If "append" is given as the argument, the produced spreadsheet files
# are not reset. Otherwise, the text files are re-created and
# any/all prior data is lost.
#

#---------------------------------------------------------------------------
# Access TraceQueues.log file or exit. Change to appropriate entry if using Windows or UNIX OS
# %filehandle contains the hash of file handles for the .txt files
my %filehandle;

my $FH;
my $Unix_TraceQueues_Log = "./TraceQueues.log";
my $Windows_TraceQueues_Log = ".\\TraceQueues.log";

my $TraceQueues_Log = $Unix_TraceQueues_Log;

open(FH, $TraceQueues_Log) or die "Cannot open $TraceQueues_Log\n";

#---------------------------------------------------------------------------
# Look for optional "append"
my $append = 0;

my $arg = shift;

if ( defined $arg ) {
  if ( $arg eq "append" ) {
    $append = 1;
  } else {
    print "Usage:\n\tParse_TraceQueues.pl [append]\n";
    exit 0;
  }
}

#-------------------------------------------------------------------------
# Prepare file handles

my $PM;   # Poll_Manager.txt
my $AM;   # Alarm_Manager.txt
my $L2F;  # Log_to_file_thread.txt
my $FF;   # Flat_File.txt
my $DT;   # Deserialize_Thread.txt
my $PRO;  # Protocol_Manager.txt
my $PA;   # PA_Resync.txt
my $ACT;  # Action_Manager.txt
my $SVR;  # Server.txt
my $TM;   # Trap_Manager.txt
my $INC;  # Inform_NC_Thread.txt
my $OPC;  # OpC_Manager.txt
my $AF;   # Alarm_Filter.txt
my $SNMP; # SNMP_Manager.txt
my $ICMP; # ICMP_Manager.txt
my $IOV;  # Inform_OV_Manager.txt
my $V3;   # V3_Ops_Manager.txt


sub openProtocol_txt {
    my $index = $_[0];
    my $filename = $_[1];
    my $append = $_[2];
    my $fh;
   
    #print "append = $append filename = <$filename>  index = $index\n";
   
    if ( $append & open ( $fh, $filename)) {
        close ($fh);
        open ( $filehandle { $index }, ">>$filename");
    } else {
        open ( $filehandle { $index }, ">$filename");

    }
   return $filehandle { $index };
}

$PM = openProtocol_txt ( "PM", "Poll_Manager.txt", $append );
$AM = openProtocol_txt ( "AM", "Alarm_Manager.txt", $append);
$TM = openProtocol_txt ( "TM", "Trap_Manager.txt", $append);
$AF = openProtocol_txt ( "AF", "Alarm_Filter.txt",$append);
$V3 = openProtocol_txt ( "V3", "V3_Ops_Manager.txt", $append);
$FF = openProtocol_txt ( "FF", "Flat_File.txt", $append);
$DT = openProtocol_txt ( "DT", "Deserialize_Thread.txt", $append);
$PA = openProtocol_txt ( "PA", "PA_resync.txt", $append);

$PRO = openProtocol_txt ( "PRO", "Protocol_Manager.txt", $append);
$ACT = openProtocol_txt ( "ACT", "Action_Manager", $append);
$OPC = openProtocol_txt ( "OPC", "Opc_Manager.txt", $append);
$INC = openProtocol_txt ( "INC", "Inform_NC_Thread.txt", $append);
$SVR = openProtocol_txt ( "SVR", "Server.txt", $append);
$L2F = openProtocol_txt ( "L2F", "LogtofileThread.txt", $append);
$IOV = openProtocol_txt ( "IOV", "Inform_OV_Manager.txt",$append);

$SNMP = openProtocol_txt ( "SNMP", "SNMP_Manager.txt", $append);
$ICMP = openProtocol_txt ( "ICMP", "ICMP_Manager.txt", $append);


while(<FH>) {
    if($_ =~ /Poll Manager/) {chomp; print $PM "$_\n"; }
    elsif($_ =~ /Alarm Manager/) {chomp; print $AM "$_\n"; }
    elsif($_ =~ /Log to file Thread/) {chomp; print $L2F "$_\n"; }
    elsif($_ =~ /Flat File/) {chomp; print $FF "$_\n"; }
    elsif($_ =~ /Deserialize Thread/) {chomp; print $DT "$_\n"; }
    elsif($_ =~ /Protocol Manager/) {chomp; print $PRO "$_\n"; }
    elsif($_ =~ /PA Resync/) {chomp; print $PA "$_\n"; }
    elsif($_ =~ /Action Manager/) {chomp; print $ACT "$_\n"; }
    elsif($_ =~ /Server/) {chomp; print $SVR "$_\n"; }
    elsif($_ =~ /Trap Manager/) {chomp; print $TM "$_\n"; }
    elsif($_ =~ /Inform NC Thread/) {chomp; print $INC "$_\n"; }
    elsif($_ =~ /OpC Manager/) {chomp; print $OPC "$_\n"; }
    elsif($_ =~ /Alarm Filter/) {chomp; print $AF "$_\n"; }
    elsif($_ =~ /Inform OV Manager/) {chomp; print $IOV "$_\n"; }
    elsif($_ =~ /V3 Ops Manager/) {chomp; print $V3 "$_\n"; }
    elsif($_ =~ /SNMP Agent Manager/) {chomp; print $SNMP "$_\n"; }
    elsif($_ =~ /ICMP Manager/) {chomp; print $ICMP "$_\n"; }

}

#--------------------------------------------------------------------
# Close the File Handles
#
close(FH);

close($PM);
close ($AM);
close ($L2F);
close ($SNMP);
close($FF);
close($DT);
close($PRO);
close($PA);
close($ACT);
close($SVR);
close($TM);
close($INC);
close($OPC);
close($AF);
close($ICMP);
close($IOV);
close($V3)





Top
 Profile  
 
 Post subject: Re: Analyzing NerveCenter with TraceQueues and TraceCounters
Posted: Fri Jun 03, 2011 3:47 pm 
Team Member

Joined: Wed Feb 03, 2010 6:23 pm
Posts: 16
Using this code segment you can convert the TraceCounters.log file into .cvs files to import into a spread sheet.

Code:

#!/usr/bin/perl
use strict;
#---------------------------------------------------------------------------
# ParseTraceCounters
#   Separate the TraceCounters.log file, produced by a NerveCenter
#   Server, into separate spreadsheet files.
#
# Created for NerveCenter v5.1 by LogMatrix, Marlborough MA. 01752 USA.
# Copyright (C) 2011. LogMatrix, Inc.
#
# This script may be freely modified as long as this header is retained.
#
#---------------------------------------------------------------------------
# Usage:
#   From the directory where NerveCenter's TraceCounters.log file is found:
#   C:> Parse_TraceCounters.pl [append]
#   % Parse_TraceCounters.pl [append]
#
# If "append" is given as the argument, the produced spreadsheet files
# are not reset. Otherwise, the spreadsheet files are re-created and
# any/all prior data is lost.
#

#---------------------------------------------------------------------------
# Access TraceCounters.log file or exit.

my $FH;
my $UNIX_LOG_FILE = "./TraceCounters.log";
my $Windows_Log_File = ".\\TraceCounters.log";
# The Default operating system for the script is UNIX.  Manually edit for Windows
# We should add a switch to the program (UNIX or Windows)
my $LogFile = $UNIX_LOG_FILE;
# my $LogFile = $Windows_Log_File;
   
open(FH,$LogFile) or die "Cannot open $LogFile\n";

#---------------------------------------------------------------------------
# Look for optional "append"

my $append = 0;

my $arg = shift;

if ( defined $arg ) {
  if ( $arg eq "append" ) {
    $append = 1;
  } else {
    print "Usage:\n\tParse_TraceCounters.pl [append]\n";
    exit 0;
  }
}

#---------------------------------------------------------------------------
# Prepare spreadsheet handles

my $RE; # Resync.csv
my $AC; # Actions.csv
my $CL; # Client.csv
my $AR; # Alarms.csv
my $TRI;# Triggers.csv
my $OPC;# OPC.csv
my $IN; # Informs.csv
my $SN; # SNMP.csv
my $IC; # ICMP.csv
my $TR; # Traps.csv
my $DB; # DB.csv
my $PR; # Protocol.csv
my $HP; # HPOV.csv

#---------------------------------------------------------------------------
# Open/Initialize spreadsheets
#   Give each spreadsheet a header row if creating it.
#   Open in append mode if requested, otherwise re-create file.


sub openResync_csv {
  if ( $append && open( RE, "<Resync.csv" ) ) {
    close( RE );
    open( RE, ">>Resync.csv" );
  } else {
    open( RE, ">Resync.csv" );
    print RE "Date/Time,Received,Added,Updated,Deleted\n";
  }
}

sub updateResync_csv {
  my $line = shift;
  chomp $line;
  $line =~ s/=/,/g;
  $line =~ s/\s-\s/,/g;
  $line =~ s/:\s/,/g;
  my @cells=split('\,', $line);
  print RE "$cells[0],$cells[3],$cells[5],$cells[7],$cells[9]\n";
}

openResync_csv;

sub openActions_csv {
  if ( $append && open( AC, "<Actions.csv" ) ) {
    close( AC );
    open( AC, ">>Actions.csv" );
  } else {
    open( AC, ">Actions.csv" );
    print AC "Date/Time,Requested,Completed,Queued\n";
  }
}

sub updateActions_csv {
  my $line = shift;
  chomp $line;
  $line =~ s/=/,/g;
  $line =~ s/\s-\s/,/g;
  $line =~ s/:\s/,/g;
  my @cells=split('\,', $line);
  print AC "$cells[0],$cells[3],$cells[5],$cells[7]\n";
}

openActions_csv;

sub openClient_csv {
  if ( $append && open( AC, "<Client.csv" ) ) {
    close( CL );
    open( CL, ">>Client.csv" );
  } else {
    open( CL, ">Client.csv" );
    print CL "Date/Time,Connections,Messages Sent\n";
  }
}

sub updateClient_csv {
  my $line = shift;
  chomp $line;
  $line =~ s/=/,/g;
  $line =~ s/\s-\s/,/g;
  $line =~ s/:\s/,/g;
  my @cells=split('\,', $line);
  print CL "$cells[0],$cells[3],$cells[5]\n";
}

openClient_csv;

sub openAlarms_csv {
  if ( $append && open( AL, "<Alarms.csv" ) ) {
    close( AL );
    open( AL, ">>Alarms.csv" );
  } else {
    open( AL, ">Alarms.csv" );
    print AL "Date/Time,Transitioned\n";
  }
}

sub updateAlarms_csv {
  my $line = shift;
  chomp $line;
  $line =~ s/=/,/g;
  $line =~ s/\s-\s/,/g;
  $line =~ s/:\s/,/g;
  my @cells=split('\,', $line);
  print AL "$cells[0],$cells[3]\n";
}

openAlarms_csv;

sub openTriggers_csv {
  if ( $append && open( TRI, "<Triggers.csv" ) ) {
    close( TRI );
    open( TRI, ">>Triggers.csv" );
  } else {
    open( TRI, ">Triggers.csv" );
    print TRI "Date/Time,Processed,Poll Fired,OPC Mask Fired,Mask Fired,Action Fired\n";
  }
}

sub updateTriggers_csv {
  my $line = shift;
  chomp $line;
  $line =~ s/=/,/g;
  $line =~ s/\s-\s/,/g;
  $line =~ s/:\s/,/g;
  $line =~ s/\.\s/,/g;
  my @cells=split('\,', $line);
  print TRI "$cells[0],$cells[3],$cells[5],$cells[7],$cells[9],$cells[11]\n";
}

openTriggers_csv;

sub openOPC_csv {
  if ( $append && open( OPC, "<OPC.csv" ) ) {
    close( OPC );
    open( OPC, ">>OPC.csv" );
  } else {
    open( OPC, ">OPC.csv" );
    print OPC "Date/Time,Received,Processed\n";
  }
}

sub updateOPC_csv {
  my $line = shift;
  chomp $line;
  $line =~ s/=/,/g;
  $line =~ s/\s-\s/,/g;
  $line =~ s/:\s/,/g;
  $line =~ s/\.\s/,/g;
  my @cells=split('\,', $line);
  print OPC "$cells[0],$cells[3],$cells[5]\n";
}

openOPC_csv;

sub openInforms_csv {
  if ( $append && open( IN, "<Informs.csv" ) ) {
    close( IN );
    open( IN, ">>Informs.csv" );
  } else {
    open( IN, ">Informs.csv" );
    print IN "Date/Time,Received,Processed,OV Received,OV Pending,OV Sent,PA Requested,PA Send,OPC Requested,OPC Sent\n";
  }
}

sub updateInforms_csv {
  my $line = shift;
  chomp $line;
  $line =~ s/=/,/g;
  $line =~ s/\s-\s/,/g;
  $line =~ s/:\s/,/g;
  $line =~ s/\.\s/,/g;
  my @cells=split('\,', $line);
  print IN "$cells[0],$cells[3],$cells[5],$cells[7],$cells[9],$cells[11],$cells[13],$cells[15],$cells[17],$cells[19]\n";
}

openInforms_csv;

sub openSNMP_csv {
  if ( $append && open( SN, "<SNMP.csv" ) ) {
    close( SN );
    open( SN, ">>SNMP.csv" );
  } else {
    open( SN, ">SNMP.csv" );
    print SN "Date/Time,Requests,Responses,Errors,Pending,Retries,Timeouts,Dropped\n";
  }
}

sub updateSNMP_csv {
  my $line = shift;
  chomp $line;
  $line =~ s/=/,/g;
  $line =~ s/\s-\s/,/g;
  $line =~ s/:\s/,/g;
  my @cells=split('\,', $line);
  print SN "$cells[0],$cells[3],$cells[5],$cells[7],$cells[9],$cells[11],$cells[13],$cells[15]\n";
}

openSNMP_csv;

sub openICMP_csv {
  if ( $append && open( IC, "<ICMP.csv" ) ) {
    close( IC );
    open( IC, ">>ICMP.csv" );
  } else {
    open( IC, ">ICMP.csv" );
    print IC "Date/Time,Requests,Responses,Matched,Errors,Pending,Retries,Timeouts,Dropped\n";
  }
}

sub updateICMP_csv {
  my $line = shift;
  chomp $line;
  $line =~ s/=/,/g;
  $line =~ s/\s-\s/,/g;
  $line =~ s/:\s/,/g;
  my @cells=split('\,', $line);
  print IC "$cells[0],$cells[3],$cells[5],$cells[7],$cells[9],$cells[11],$cells[13],$cells[15],$cells[17]\n";
}

openICMP_csv;

sub openTraps_csv {
  if ( $append && open( TR, "<Traps.csv" ) ) {
    close( TR );
    open( TR, ">>Traps.csv" );
  } else {
    open( TR, ">Traps.csv" );
    print TR "Date/Time,Received,Dropped,Errors,Unused\n";
  }
}

sub updateTraps_csv {
  my $line = shift;
  chomp $line;
  $line =~ s/=/,/g;
  $line =~ s/\s-\s/,/g;
  $line =~ s/:\s/,/g;
  my @cells=split('\,', $line);
  print TR "$cells[0],$cells[3],$cells[5],$cells[7],$cells[9]\n";
}

openTraps_csv;

sub openDB_csv {
  if ( $append && open( DB, "<DB.csv" ) ) {
    close( DB );
    open( DB, ">>DB.csv" );
  } else {
    open( DB, ">DB.csv" );
    print DB "Date/Time,Completed,Pending,Connections Restored,Connections Lost\n";
  }
}

sub updateDB_csv {
  my $line = shift;
  chomp $line;
  $line =~ s/=/,/g;
  $line =~ s/\s-\s/,/g;
  $line =~ s/:\s/,/g;
  my @cells=split('\,', $line);
  print DB "$cells[0],$cells[3],$cells[5],$cells[7],$cells[9]\n";
}

openDB_csv;

sub openProtocol_csv {
  if ( $append && open( PR, "<Protocol.csv" ) ) {
    close( PR );
    open( PR, ">>Protocol.csv" );
  } else {
    open( PR, ">Protocol.csv" );
    print PR "Date/Time,Timer Count\n";
  }
}

sub updateProtocol_csv {
  my $line = shift;
  chomp $line;
  $line =~ s/=/,/g;
  $line =~ s/\s-\s/,/g;
  $line =~ s/:\s/,/g;
  my @cells=split('\,', $line);
  print PR "$cells[0],$cells[3]\n";
}

openProtocol_csv;

sub openHPOV_csv {
  if ( $append && open( HP, "<HPOV.csv" ) ) {
    close( HP );
    open( HP, ">>HPOV.csv" );
  } else {
    open( HP, ">HPOV.csv" );
    print HP "Date/Time,Traps Received\n";
  }
}

sub updateHPOV_csv {
  my $line = shift;
  chomp $line;
  $line =~ s/=/,/g;
  $line =~ s/\s-\s/,/g;
  $line =~ s/:\s/,/g;
  my @cells=split('\,', $line);
  print HP "$cells[0],$cells[3]\n";
}

openHPOV_csv;

#---------------------------------------------------------------------------
# Process TraceCounters.log file.

while(<FH>) {
        if($_ =~ /Resync/) { updateResync_csv($_); }
        elsif($_ =~ /Actions/) { updateActions_csv($_); }
        elsif($_ =~ /Client/) { updateClient_csv($_); }
        elsif($_ =~ /Alarms/) { updateAlarms_csv($_); }
        elsif($_ =~ /Triggers/) { updateTriggers_csv($_); }
        elsif($_ =~ /OPC/) { updateOPC_csv($_); }
        elsif($_ =~ /Informs/) { updateInforms_csv($_); }
        elsif($_ =~ /SNMP/) { updateSNMP_csv($_); }
        elsif($_ =~ /ICMP_polls/) { updateICMP_csv($_); }
        elsif($_ =~ /Trap/) { updateTraps_csv($_); }
        elsif($_ =~ /DB/) { updateDB_csv($_); }
        elsif($_ =~ /DoTimer/) { updateProtocol_csv($_); }
        elsif($_ =~ /HP/) { updateHPOV_csv($_); }
}

#---------------------------------------------------------------------------
# Close spreadsheets and log file

close(RE);
close(AC);
close(CL);
close(AL);
close(TRI);
close(OPC);
close(IN);
close(SN);
close(IC);
close(TR);
close(DB);
close(PR);
close(HP);

close(FH);

#---------------------------------------------------------------------------
# ###



Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group