Posts

Lambda function to tag all available snapshots

Following Lambda function will add a defined tag(s) to all available EBS snapshots. Lambda function should be associated with an IAM Role with necessary permissions. E.g with EC2FullAccess permissions. from __future__ import print_function import json import boto3 import logging #setup simple logging for INFO logger = logging.getLogger() logger.setLevel(logging.ERROR) #define the connection region ec2 = boto3.resource('ec2', region_name="eu-west-2") ec = boto3.client('ec2', 'eu-west-2') snapshots = ec.describe_snapshots(MaxResults=1000,OwnerIds=['put account id here'])['Snapshots'] #Set this to True if you don't want the function to perform any actions debugMode = False def lambda_handler(event, context): for snapshot in snapshots: print('Sanpshot id '+snapshot['SnapshotId']) snapshotx = ec2.Snapshot(snapshot['SnapshotId']) snapshotx.create_tags(Tags=[{'Key': 'T

Hostname and mail configurations in Linux

By default mail command will set the from address as $user@$hostname in Linux. If you want to change this behavior using the configuration file (/etc/mail.rc ) this is how it can be done. Set the entire from address like below. Add this to the configuration file. set from="from address" If you need to change the hostname part only, add this. set hostname="hostname"

Getting abbreviated name with daylight saving of a timezone in Java 8

Recently I wanted to get the timezone abbreviation of a timezone as a string. There are many tutorials which cover that. But in all those, timezone is given in one of the following formats. "America/Los-Angeles" or "PT". But I needed to get the abbreviation with the daylight saving such as "PST" or "PDT". Finally, I was able to get it using the following method. ZonedDateTime currentTime; boolean isDayLightSavingEnabled =currentTime.getZone().getRules().isDaylightSavings(currentTime.toInstant()); TimeZone timeZone = TimeZone.getTimeZone(currentTime.getZone()); String timeZoneName = timeZone.getDisplayName(isDayLightSavingEnabled, TimeZone.SHORT); System.out.println( timeZoneName); Output will be PST

Fix issues in upgrading Ubuntu 14.04 to 16.04

When I upgraded my Ubuntu 14.04 PC to 16.04 it restarted and terminal screen was loaded without any GUI. I fixed this by doing following steps. First login with by entering login name(this is your username) and password Run sudo apt-get update If above step fails run the command which is given in the error. Usually this is something related to dpkg. Run sudo apt-get upgrade -f If confirmations occurs while upgrading accept all After upgrading is done restart the computer. If it still goes to terminal run sudo do-release-upgrade

Accessing all highcharts in a page at once

Recently I needed to call a reflow method of all hi-charts in the page for a particular event. I used following method for that. function redrawHighcharts() {     for (var i = 0; i < Highcharts.charts.length; i++) {         Highcharts.charts[i].reflow();     } }

Fixing Unicode issues in Pentaho CDA

Recently I encountered problem when sending a query parameter with unicode text to Pentaho CDA. For these type of queries CDA returns an empty result set although there are matching items. After some research I fixed this issue by adding an additional parameter to the JDBC connection url. Now JDBC connection is like below. <DataSources>         <Connection id="1" type="sql.jdbc">             <Driver>com.mysql.jdbc.Driver</Driver>             <Url>jdbc:mysql://host:3306/DB?useUnicode=true&amp;characterEncoding=UTF-8</Url>             <User>user</User>             <Pass>pass</Pass>         </Connection>  </DataSources>

Creating a Pentaho BI server cluster

Image
Note - This is applicable to Pentaho BI server community edition 5.x only. Pentaho BI server provides a large set of features which are essential for  BI applications. To use this in production we might need to create a CDA cluster to maintain high availability as well as load balancing. To create a cluster we need to configure BI server instances to use a common data source to store configurations. I configured the following setup for this. Follow these steps to create the cluster. Install MySQL servers and setup master master replication. Make sure you have installed Oracle Java 7 in all nodes. Using other java versions will cause runtime errors. Follow  this  document to to install a CDA instance. Make sure to follow the document named "Install with Your Own BA Repository" and follow the configurations related to MySQL.  Start the server and install all the components needed. Modify the cluster documentation as mentioned in this document.  https://help.pent