Thursday, November 07, 2019

Parsing Log/Text files

One of the team member was looking for ways to parse through logs to find errors in a big dump of files. I had to go to basics to get the results

Problem Statement: Find all the entries for "Error" and "failed"  in big dump of CSV/Log files. 

Solution: Old school technique ( Use Log parser)

run below commands 

C:\Program Files (x86)\Log Parser 2.2>LOGPARSER "Select Text INTO ERROR.csv from
 D:\xyz\*.log* where Text like '%ERROR%'" -i:TEXTLINE -q:Off

Statistics:
-----------
Elements processed: 14128022
Elements output:    9845
Execution time:     81.36 seconds (00:01:21.36)


C:\Program Files (x86)\Log Parser 2.2>LOGPARSER "Select Text INTO failed.csv fro
m D:\xyz\*.log* where Text like '%failed%'" -i:TEXTLINE -q:Off

Statistics:
-----------
Elements processed: 14128022
Elements output:    2025
Execution time:     76.43 seconds (00:01:16.43)

Monday, May 27, 2019

Profile not found. Tried ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile.

Error when installing NPM

 Profile not found. Tried ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile.



Fix:
Run command and try again
touch ~/.bash_profile 


Reason

https://github.com/nvm-sh/nvm/issues/1837

your system may not have a [.bash_profile file] where the command is set up. Simply create one with touch ~/.bash_profile and run the install script again
you might need to restart your terminal instance. Try opening a new tab/window in your terminal and retry."

Sunday, May 26, 2019

Maven tool is not set in Jenkins pipeline

Maven tool is not set in Jenkins pipeline


Scenario
Error when building the Jenkins pipeline  (Pipeline project style)

Error snippet:
+ mvn clean package
/var/jenkins_home/workspace/atmosphere pipeline/spring-boot-samples/spring-boot-sample-atmosphere@tmp/durable-7c163949/script.sh: 1: /var/jenkins_home/workspace/atmosphere pipeline/spring-boot-samples/spring-boot-sample-atmosphere@tmp/durable-7c163949/script.sh: mvn: not found


Solution
Use the below script to refer to Maven


node 

{
def mvn_version = ''
    
withEnv( ["PATH+MAVEN=${tool mvn_version}/bin"] ) 
  {   
      sh  'mvn clean package'
  }

}


Image of Jenkins Home ->Manage Jenkins ->Global Tool Configuration






FOR FREESTYLE PROJECT ( REFER TO MAVEN ERROR)






SSH into a running Linux container - docker

Looking for extensive set of commands, refer
http://phase2.github.io/devtools/common-tasks/ssh-into-a-container/


 In summary, use below commands as specified in article

  • Use docker ps to get the name of the existing container
  • Use the command docker exec -it {containername} /bin/bash to get a bash shell in the container
  • Generically, use docker exec -it {containername} {command} to execute whatever command you specify in the container.

running docker as root user 
docker exec -it --user root {container id} /bin/bash

Cannot run program "mvn" (in directory : error=2, No such file or directory

Note : In below scenario jenkins was deployed in Linux container

Scenario:  Jenkins build failed with error.

java.io.IOException: error=2, No such file or directory
 at java.lang.UNIXProcess.forkAndExec(Native Method)
 at java.lang.UNIXProcess.(UNIXProcess.java:247)
 at java.lang.ProcessImpl.start(ProcessImpl.java:134)
 at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
Caused: java.io.IOException: Cannot run program "mvn" (in directory "/var/jenkins_home/workspace/atmosphere"): error=2, No such file or directory



Fix:
The issue was due to absence of Maven files in container. To deploy Maven files , follow these steps:

  • Go to Global Tool Configuration (http://localhost:xxxx/configureTools/) or navigate Jenkins Home Page - > Manage Jenkins - > Global Tool Configuration
  • Scroll down and make the below configuration under Maven Section
  • Click Save
  • In Jenkins , go to teh Jenkins job and select configure
  • scroll down to BUILD Section and select MAVEN_HOME from dropdown
  • Rebuild Project



Friday, April 12, 2019

Debugging the Azure Event Grid based Azure Functions locally using Visual Studio



If you want to debug the Azure function locally in visual studio which are triggered by resources like Azure Blog storage e.g. when a file is created in Azure Blog storage account than you are in right place

Check this out

Azure Function Event Grid Trigger Local Debugging

Bad IL format - Azure function

First, try restarting the Azure Function app. 

The error generally shows up when changes are made to the function

Gray Failures: What is it and how to detect one?

If you are reading this article , i guess you are curious to know about gray failures and different methods to detect gray failures.  Hopefu...