Thursday, February 7, 2019

Run specific Junit unit test on Maven

How to run specific test within Maven mvn 

  1. Click on the module Run... button
  2. Add your own argument : for ex, instead of clean deploy , write
     test  -Dtest=**PeriodicFlow*Test#simpleChatAndCheckChatExposureLatencyAndMCS  -DfailIfNoTests=false
    This argument stands for 
    For running the Java Test file PeriodicFlow (like PeriodicFlowAlphaTest , PeriodicFlowColoTest etc ) 
    and will run only this test method simpleChatAndCheckChatExposureLatencyAndMCS
  3. you can also run an entire file / package etc ...

Thursday, October 11, 2018

Working environment ... for mac / apple

Clipboard manager
https://clipy-app.com/

KeepPass
https://www.keepassx.org/downloads

CheatSheet
https://www.mediaatelier.com/CheatSheet/

BetterTouch (no free)
https://folivora.ai/downloads



brew cask install minikube

+ you'll need to install virtualbox:
brew cask install virtualbox

When starting the minikube use the bellow command
minikube start --kubernetes-version=v1.6.3 --cpus=4 --memory=4096 --disk-size=20g; eval $(minikube docker-env)

If you get the following error during the installation:Error: Unknown command: cask
​Run the following first, and then re-run the installation.
cd $(brew --repo); git fetch; git reset --hard origin/master; brew update​



Thursday, March 8, 2018

for loop example - for remote ssh

instead of mcollective:

for server in qtvr-els03  qtvr-els04  qtvr-els05  qtor-els601  qtor-els602  qtor-els603  qtvr-els005  qtvr-els0029 ; do ssh root@$server "hostname; /etc/init.d/elasticsearch status "; done


Or also
for server in `zoom --HF lpcluster=z2_elasticsearch_agent_manager_01 -f hostname`; do ssh $server 'echo $HOSTNAME'; done;



in another word:

for server in server1 server2 server3 ; do ssh root@$server "hostname; echo do something"; done


Very useful!

Tuesday, November 28, 2017

SSH Login without password

If you want to access a remote terminal without being required to type your password, you have to do the following:


ssh-keygen
You can accept all the default
This will create a file with a public key under your $HOME directory

$HOME/.ssh/id_rsa.pub
this look as following :
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDgDnpDHO5U/Ba8xKZezlm7OpwbV0WBvJXelshOO2LZJxZCI8h5QRlbjYws5Gy+oxuNftQHliXFFfHJlFtRk4xo27JkdeYmrI33qHjDSZ4fWx4RJA1HODBqcmscisMrv4D8ELdP0pFXkL8+GM8l2bxu8U1HS2yuC//33mxn7auo2GJUr1vOGzsLtp7qS/kdLqf2Vo4YG6MtNmEw8Y+tlbSe0zO0uRR7sTj9aq+YM+KtLU2xxzzffsiAMqlxXnZd6c/PmVsJ/1d1ypk3Xrx69R7OlTB5rWApqB/eK9Mc53uCqUhFrzkKWWNyoP3/jEwJGJTfpuhL4gYmJtKdAl3RuXl4EB

Then, in order to enable ssh to a remote host without being required to type a password, you just have to add this public key to the remote host :

Type: 
ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host
like for ex 
ssh-copy-id -i ~/.ssh/id_rsa.pub root@qtvr-els003 

This will automatically append your public key into the remote file (but this is something you can do manually as well) 

[root@qtvr-els0003 ~]# cat ~/.ssh/authorized_keys
# HEADER: This file was autogenerated at Mon Oct 30 10:42:29 +0200 2017
# HEADER: by puppet.  While it can still be managed manually, it
# HEADER: is definitely not recommended.
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAuTtqxO/t+gebf+INEaBQwUmfckztextfJTBA3BstQifX6aqtnelgf9Mqu3OtjFhg3ddgErz2ft1aF6x/rF8Q0kzq8OR8ohmZrIPW+ZjxbOc9uvW1sniChCJFCtua+Hmm84zlIHwwwM0nK1jzBazVJ/zQR4jtY3V9F/sIVGTxowgiSNlszveeWWs0EN6xc5Uh7vE4ZICoXMKEkNhb30k9WZ0H2sNALzAghgmjSUv7CK/fGZ1UHG0Kh6z7J9aensCOHEKS5carGBFjrtfCI/ArCxwwwwqMg/ukJ8fWd2ekVNwKrm+J0iCVBlZ9pA6wV2BkJF77ZBlfPlW6q5T7r8Q23kJ2M5w== root@tlvmanager.tlv.lpnet.com
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDgDnpDHO5U/Ba8xKZezlm7OpwbV0WBvJXelshOO2LZJxZCI8h5QRlbjYws5Gy+oxuNftQHliXFFfHJlFtRk4xo27JkdeYmrI33qHjDSZ4fWx4RJA1HODBqcmscisMrv4D8ELdP0pFXkL8+GM8l2bxu8U1HS2yuC//33mxn7auo2GJUr1vOGzsLtp7qS/kdLqf2Vo4YG6MtNmEw8Y+tlbSe0zO0uRR7sTj9aq+YM+KtLU2xxzzffsiAMqlxXnZd6c/PmVsJ/1d1ypk3Xrx69R7OlTB5rWApqB/eK9Mc53uCqUhFrzkKWWNyoP3/jEwJGJTfpuhL4gYmJtKdAl3RuXl4EB


For MAC OS User: 
I found this link for installing the ssh-copy-id command, which was missing from my laptop: 

https://stackoverflow.com/questions/25655450/how-do-you-install-ssh-copy-id-on-a-mac

Basically, download the code from here and make it accessible for all users: 

sudo curl https://raw.githubusercontent.com/beautifulcode/ssh-copy-id-for-OSX/master/ssh-copy-id.sh -o /usr/local/bin/ssh-copy-id sudo chmod +x /usr/local/bin/ssh-copy-id

Thursday, July 20, 2017

Socat - a Simple Tcp Proxy

In order to setup a simple TCP proxy, I've used the following :

yum install socat

socat TCP4-LISTEN:2003,fork TCP4:app.graphite.lpdomain.com:2003


This listen to port 2003 and send everything to the remote server app.graphite.lpdomain.com , to remote port 2003

I've done that in order to be able to send metric value to a remote graphite server that was not accessible from my server.
In order to send value to graphite , I've used the following :


echo Centralized.service.sandbox.test3   1234  `date +%s --date='30 minutes ago'` | nc -v my-proxy-server 2003


BTW, I was also suggested to use nc command, but it appears that this proxy tool is more primitive and doesn't support multiple connection apparently :

mkfifo backpipe
nc -k -l 2003    <backpipe | nc app.graphite.lpdomain.com 2003  1>backpipe 

Tuesday, November 8, 2016

tcpdump


In order to record the traffic, you can use tcpdump on linux


tcpdump -G 15 -W 1 -i any -nn  -w /tmp/slor-wto176.cap' -t 60


This will record for 15 sec , with rollover file of 1 only (taken from http://stackoverflow.com/questions/25731643/how-to-schedule-tcpdump-to-run-for-a-specfic-time-of-period

We listen to all network card (-i any) and output the file into a file.

Then, you can open the .cap file into WireShark 

For filter, you can use elasticsearch , for ex, or tcp.flags.reset ==1 or tcp.stream eq 28 or ip.dst_host == 10.32.134.203 etc ...


Here's some snapshot of wireshark usage: 


and when clicking on "Follow Stream" : 


Tuesday, July 14, 2015

how to fix the RPM stuck problem

how to fix the RPM stuck problem 
when running rpm -qa |grep something , then it gets stuck forever ...

It's problably due to the a huge number of RPM process ...

I was suggested to do the following: 
  • ps -ef|grep rpm |awk '{print $2}' | xargs kill -9
  • cd /var/lib/rpm/
  • ls
  • rm -f  __*


Other related links: 
http://unix.stackexchange.com/questions/166966/rpm-command-stuck-freeze-when-installing-rpm-file



rpm may be waiting for a lock to be freed.
First, run ps -ef | grep rpm to see if you have any RPM commands running. If you do, kill them using kill -9.
Next, delete any leftover locks rm -rf /var/lib/rpm/__db.0*