-
-
Save mmhan/2895018 to your computer and use it in GitHub Desktop.
Reading the input from logfile. Printing the unique login ID from the past 10 mins.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'file' | |
class UserAccessLogTest << GenericTest | |
def initialize (args) | |
set_measure_count 1 | |
@file_path = get_value_for_params "LOG_FILE_PATH" | |
end | |
def compute_measures(params) | |
unless File.exists? @file_path && File.readable? @file_path | |
puts "#{@file_path} does not exist/is not readable" | |
else | |
measure_list = [] | |
begin | |
IO.readlines(@file_path).each do |line| | |
puts line if line | |
end | |
rescue | |
puts 'something\'s wrong' | |
end | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
import java.io.*; | |
import java.util.StringTokenizer; | |
public class UserAccessLogTest extends GenericTest | |
{ | |
private String filePath =""; | |
public UserAccessLogTest(String args[]) | |
{ | |
super(args); | |
setMeasureCount(1); | |
//getting the file path | |
filePath = getValueForParam("Log_File_Path"); | |
} | |
public void computeMeasures(Hashtable paramlist) | |
{ | |
//loading the file from specified path | |
File f = new File (filePath); | |
//Checking if the file does not exist | |
boolean exists = f.exists (); | |
if (!exists) | |
{ | |
//It returns false if the file does not exist | |
System.out.println ("The file you are searching for does not exist "+ exists); | |
return; | |
} | |
// logic to read the file line by line parse and get the necessary information | |
else | |
{ | |
ArrayList measureList = new ArrayList(); | |
//Reading the file line by line. | |
try | |
{ | |
BufferedReader input = new BufferedReader(new FileReader(filePath)); | |
String line = ""; | |
//Read the file and populate the data. | |
while ((line = input.readLine()) != null) | |
{ | |
System.out.println (line); | |
} | |
} | |
catch (Exception e) | |
{ | |
return; | |
} | |
//measureList.add(//your measure value here); | |
//addNewMeasure(measureList); | |
} } | |
public static void main(String args[] ) | |
{ | |
UserAccessLogTest aa = new UserAccessLogTest(args); | |
aa.computeMeasures(new Hashtable()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment