Commit 0bd15569 authored by Arijit (Harry) Sadhu's avatar Arijit (Harry) Sadhu
Browse files

Modified debugd to create output with client tags for every entry.

  Created depugs which uses this output to create a CSV file for statistics.
Detail:
  New option debugd -p to create client tagged output.
  debugs to be used in conjunction with debugd to create CSV file with
  entries specied by the suffixes in command, use debugs -h for help,
  output several files of specied prefix but with suffix with client
  tag and file type, <name>x.csv and <name>x.log, the log file has the
  entry no specified in csv and timestamp.
Admin:
  Tested with V1 browser with memdump to create mem usage plot.

Version 0.09. Tagged as 'remotedb-0_09'
parent 33bf658c
/* (0.08)
/* (0.09)
*
* This file is automatically maintained by srccommit, do not edit manually.
*
*/
#define Module_MajorVersion_CMHG 0.08
#define Module_MajorVersion_CMHG 0.09
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 21 Jan 2000
#define Module_Date_CMHG 17 Jan 2001
#define Module_MajorVersion "0.08"
#define Module_Version 8
#define Module_MajorVersion "0.09"
#define Module_Version 9
#define Module_MinorVersion ""
#define Module_Date "21 Jan 2000"
#define Module_Date "17 Jan 2001"
#define Module_FullVersion "0.08"
#define Module_ApplicationDate2 "17-Jan-01"
#define Module_ApplicationDate4 "17-Jan-2001"
#define Module_ComponentName "remotedb"
#define Module_ComponentPath "RiscOS/Sources/Lib/remotedb"
#define Module_FullVersion "0.09"
#define Module_HelpVersion "0.09 (17 Jan 2001)"
......@@ -9,7 +9,7 @@ $banner='# Debug daemon 0.02';
# modname Name of module if is debug end
# defspec Default module name, IP address
$usage="Usage: $0 [-r] [-d] [port [address]]\n";
$usage="Usage: $0 [-r] [-d] [-p] [port [address]]\n";
$timeout= undef;
$rfdmask='';
......@@ -25,6 +25,8 @@ while($ARGV[0]=~/^-/) {
$debug={fh => \*STDERR};
@conns[0]=$debug;
vec($rfdmask,fileno($debug->{fh}),1)=1;
} elsif($arg eq '-p') {
$pipe = 1;
} else {
die$usage;
};
......@@ -88,6 +90,9 @@ for (;;) {
my $line=$1;
$line=~s/\r$//;
# doprint($hash,":ack\n") if($hash->{version} >= 0.04);
if ($pipe) {
print "$x $line\n";
}
doprint($debug,"Got line '$line', version $hash->{version}\n");
if($line=~/^([^:].*)$/||$line=~/^:(:.*)$/) {
$line=$1;
......@@ -139,6 +144,8 @@ for (;;) {
doprint($hash,"# Bad connect line\n");
};
};
} elsif($line=~/^:default\s+(.*)$/) {
$hash->{defname}=$1;
} elsif($line=~/^:debug$/i) {
$debug=$hash;
} elsif($line=~/^:info$/i) {
......
#!/usr/local/bin/perl
if(!$ARGV[0] || $ARGV[0] =~ /-h/){
print'Usage: debugd -p [port]|debugs [PREFIX] [PATTERN]...
Creates csv files for usage graphs out of debugd.
Searches for PATTERN and saves in PREFIX with suffixes added as X.csv where X is the debugd input number.
Example: debugd -p 9000|debugs /tmp/csvs/output "total space" "total allocated space"
Uses pipe output of debugd -p and saves csv and log files with appropriate unix time stamps and suffixes according to the debugd input number.
';
exit 0;
}
#Arijit Sadhu (Harry) 29/8/200
#output file prexif (saves files as outpt0.csv)
#my $output = "/tmp/csvs/output";
my $output = shift(@ARGV);
#tags looked for
#my @tags = (
# "total space",
# "total allocated space",
# "total non-inuse space",
# "total non-inuse chunks",
# "top releasable space",
# "mmap regions",
# "mmap space",
# "mm_malloc",
# "mm_calloc",
# "mm_realloc",
# "mm_free",
# "mm_free0"
# );
my @tags = @ARGV;
splice(@ARGV, 0);
my @field = {}; #field (tag) value array
splice(@field, 0);
my $line = 0; #source line number
my $time = 0; #current time in unix time
my $file = -1; #file number (from debugd connection number)
my @files = {}; #file tracking array
splice(@files, 0);
my $i; #loop counter
#my CSV; #csv file filehandle
#my LOG; #log file filehandle
use FileHandle;
autoflush CSV 1;
autoflush LOG 1;
#open default files
open(LOG, ">$output.log");
open(CSV, ">$output.csv");
print CSV "Line,Time," . join(",", @tags) . "\n";
while(<>){
#ignore blank lines
if(/^$/){
next;
}
#use appropriate files
if(s/^(\d*) //){
if($file != $1){
$file = $1;
close(CSV);
close(LOG);
if($files[$file]){
open(LOG, ">>$output$file.log");
open(CSV, ">>$output$file.csv");
}else{
open(LOG, ">$output$file.log");
open(CSV, ">$output$file.csv");
print CSV "Line,Time," . join(",", @tags) . "\n";
$files[$file] = 1;
}
}
$file = $1;
}
#retrive time
$time = time;
#print log file
print LOG "$line,$time, " . $_;
#look for tags
for $i (0 .. (@tags - 1)){
#retrieve tag
if(/@tags[$i]\D*(\d+)\D/i){
$field[$i] = $1;
#print csv on last field
if($i == (@tags - 1)){
print CSV "$line,$time," . join(",", @field) . "\n";
#clear field
for(@field){
$_ = 0;
}
}
}
}
#line count
$line++;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment