Wednesday, January 8, 2014

Using Tail with Grep to monitor and view log files

I recently needed to monitor for exceptions on my system logs while doing load testing.

The tail command returns output from the last part of the log file.  The -f option (follow) continues to read more output at the end of the file as it is growing. Using tail with the '-f' option alone was overwhelming because it shows all the log data when all I wanted to monitor are the logs for exceptions.

The perfect solution is to use use tail with grep. The grep command searches file(s) for specific text.

Here is the command I used:

tail -f SystemOut.log | grep excep

This command returns only the logs with the text 'excep' from the SystemOut.log file.

You can also use the -v option with grep to invert the sense of matching, to select only the non-matching lines.

Here's an example:

tail -f SystemOut.log | grep -v "Alert Notice"

This command will return all the the logs that does not have the text "Alert Notice" on it.

You can check out more options for these commands from these links: tailgrep.

You can find practical grep examples here.

Saturday, January 4, 2014

How to open the menu of a DOJO Filtering Select widget

Just another Dojo example, nothing special, just for self-reference.

Create your dojo filtering select programmatically or declaratively. Then in your javascipt code use the Filtering Select's _startSearchFromInput or _startSearchAll method, depending on if you want the result list to show the type-ahead matches or if you want to show all values.

Here's an example of a declarative way of creating your filtering select widget for 'year' values.

	<!-- Dojo Filtering Select -->
	<select name="year" id="year" dojoType='dijit.form.FilteringSelect'>
		<option value="Year" selected="selected">YEAR</option>

The 'year' values for this filtering select will be populated by ajax.  See the javascript code below.

function buildYearFilteringSelect() {
	//fetch the 'YEAR' options
	var yearFS = dijit.byId("year"); = 0;
	var xhrArgs = {
    	    url: "AjaxGetYearJSONURL",
    	    handleAs: "json",
    	    preventCache: true,    	
    	    content: {
                "retrieveType": "YEAR"
    	    error: function (error) { 
    	    load: function (data) {
        	if(data.items != null && data.items.length > 0){	
[0] = new Option("YEAR", "Year");   			
        		for(var i=1;i<data.items.length;i++){
	   [] = 
	      	   	 		new Option(data.items[i].value, data.items[i].value);
			//use dojo.connect to call the _startSearchAll() method when the _onConnect event is triggered on the filtering select widget
			//then call the select() and focus() methods to automatically open the filtering select's menu
   			dojo.connect(yearFS, '_onConnect', function (val) {