Saturday, March 24, 2018

Copy specific files from within nested folders

I had a situation where I needed to save all log files that were present in nested sub-folders and copy them over to another folder for analysis.
There are many ways to do this - but here is the simplest that I could figure out using rsync:
rsync -aihv --include='*/' --include='*.log*' --exclude='*' /source_folder/to/search/in/  /destination_folder/to/copy/to/

Important thing to note here is the order of include and exclude flags passed to rsync command - it is sensitive to the order in which these flags are provided.
First include flag '*/' makes rsync look into subfolders and the second flag selects all files of the format '*.log*'.
The next exclude flag excludes any file not selected as yet and then copies them over to the destination folder.
You can provide more include flags before the exclude flag to select multiple types of files as per your requirement.

Rename multiple files in one command

If you want to rename multiple files, the trusty old Unix "mv" command can't help as it can rename only one file at a time.
This requires us to bring out something different from our Unix arsenal - the "rename" command!
Use the rename command in conjunction with find to rename multiple files:
find /source_folder/to/search/in/ -name 'myapp*.log.201*' -exec rename -v .log. .oldlog. {} \; >> /temp/rename.log

Here we are searching for files named 'myapp*.log.201*' and renaming them to 'myapp*.oldlog.201*'
In case you need to do this on multiple servers, use the for loops trick!

Running same set of commands on multiple servers using for loop

Developers as usual are very lazy and so instead of going to each server to grep for an error string in the log file and creating a report, here is a simple way to collect all the necessary log lines.
Create a file containing a list of server names on which we want to check the logs - one on each line and then run this for loop if using bash:

for s1 in $(cat servers_list.txt); do
  ssh -q ${s1} "grep 'search_string' /search/folder/*/*.log* | sed 's/^/${s1} => /'" >> /tmp/search.log
  # Other commands here if required
done

If you are using csh, then the for loop syntax is slightly different:

foreach s1 in (cat servers_list.txt)
  ssh -q ${s1} "grep 'search_string' /search/folder/*/*.log* | sed 's/^/${s1} => /'" >> /tmp/search.log
  # Other commands here if required
end

The code is simple - for each server, ssh to that server and run the grep command to find out the log lines having the specific string. The bigger trick here is to use sed to pre-pend server name to the grepped log line to make the report useful. This should return a file with lines in the format:

server_name => [log line grepped from the log file]

Tuesday, February 6, 2018

Obi keeps ringing - Calls from weird numbers - Ghost calls

Some time back my Obi Google Voice phone kept ringing constantly and the caller ids were weird numbers. Strangely, Google Voice had no history of any such calls that I could mark as spam and rebooting the Obi device would help.

Researching this problem showed that it could be SIP scanning by bots that probe standard SIP ports causing the phone to ring and caller id to show strange numbers like 1000, 1001, 0000, 123456, etc.

A simple solution to this problem is to change the value of X_InboundCallRoute.
Use Obi Expert > Voice Services > SPx Service > X_InboundCallRoute to:
{>('GV12345678901'):ph}
where GV12345678901 is your Simonics SIP Login Prefix and SPx is the service on which GV is configured

There are other possible solutions as well, but I found this solution to be the simplest - but still for sake of completeness, you can check out the other possible solutions at ObiTalk forum post and Simonics forum post.

Obi100 and Obi110 Google Voice with Simonics Gateway

Obi100 and Obi 110 devices worked great with Google Voice but Obihai declared these devices to be end of life in August 2016. So a recent Google change made these devices to stop working with GV.
To solve this, you could either buy a newer Obi 200 series device or use a paid GV gateway setup by simonics.

Here are the instructions for using simonics GV gateway from the ObiTalk forum post:

1:  Assumptions:  you have an OBi 100 or 110, running the final build 2886 firmware.  You have a working inbound Google Voice telephone number assigned to your Google account.  You've paid the fee to use the gateway, and you are on the gateway setup page.

2:  Go to your OBiTALK web dashboard:  https://www.obitalk.com/obinet/pg/obhdev.  Click the OBi device.  Find the Service Provider (SP1 or SP2) that was setup to use Google Voice.  Delete the SPx configuration by clicking the trash can icon.

3:  After waiting a few minutes for the OBi's configuration to be remotely deleted, again click on the SP1 or SP2 you want to use.  On the next page, scroll down to the bottom and select "OBiTALK Compatible Service Providers".  On the next page, scroll down and click "Generic Service Provider" and click "Next".

4:  On the next page, fill in your GVGW server name, SIP user ID and SIP password, and click "Save".

5:  Wait for the portal to remotely configure your OBi.  It will reboot once or twice (power LED will blink on then off).  Give it plenty of time to finish.

6:  Refresh the OBiTALK dashboard in your browser, and click the SPx.  You should now see that it is registered to the gatway.  You're done!

Wednesday, January 31, 2018

Use CSipSimple instead of ObiTalk ObiOn App on Android

Android app for ObiTalk - ObiOn stopped working some time back so here is my solution for using CSipSimple instead.
It requires you to sign-up for a free IP Freedom account at Callcentric and a bit of setup.

  1. Create an IP Freedom account 12341234567 at Callcentric here
  2. Create a sub-account 12341234567101 (extension 101)
  3. On your Android phone download and install CSipSimple from the Play Store
  4. Add credentials for extension 101 from step 2 in CSipSimple setting
  5. Login to your account on the ObiTalk Portal (https://www.obitalk.com/obinet/)
  6. Setup SP2 (Callcentric) with the credentials from step 1 in the ObiTalk portal
  7. Login to the management screen of your Obi on your  network using the IP Address
  8. Under Voice Services > SP2 Service - set up this rule instead of the default:
    X_InboundCallRoute= {101>12341234567:aa},{ph}

That's it! To call into your Obi's AA, dial 100 (100 is the default extension for your main Callcentric account) from CSipSimple app on your phone.
Note that this is valid for Obi100 and Obi110 for sure but may also work for other Obi models.
And don't forget to replace the 12341234567 with the Callcentric number you receive after signing up!

Thanks to the multiple posters on the ObiTalk forums for all the above info that I have condensed into a set of simple easy to follow steps that work.

LinkWithin

Related Posts Plugin for WordPress, Blogger...