Posts Categorized: SAP HANA

compare-icon

Syscompare – a tool for comparing repos across HANA instances

compare-icon.png

A couple of weeks ago I was moving code from 1 hana instance to another trying to keep them in sync. However, I thought there might be a better alternative for comparing the contents of the repos across my systems to ensure that the files matched. After doing some digging and not finding a solution, I decided to write a small tool to do just this, called Syscompare. It is a open source HANA app which uses the new File API and compares the files on each system and displays the differences.

You can read more about the application here, and find the files for the HANA app in Github.

 

Features:

- Compare repos across HANA instances

- Display file differences in the application

- Highlights missing files on each instance

Usage:

- Setup the 2 XSHttpDest files

- Specify the source and target systems (using the xshttpdest file names)

- Specify the repo to compare

Once the processing is complete the app will show a summary of differences:

Screen Shot 2015-06-16 at 10.18.20 PM.png

Screen Shot 2015-06-16 at 10.20.12 PM.png

Screen Shot 2015-06-16 at 10.20.51 PM.png

You can checkout the Github/Source code here: paschmann/Syscompare · GitHub

If you prefer to download the Delivery Unit – please click here and provide your email address (this way I can keep you up to date with changes): metric² | Real-time operational intelligence for SAP HANA

Interested in contributing to the project? Please feel free to fork or submit a pull request.


startup-ideas

Building a Start-up in the SAP HANA space

I have some fond memories of a television series from the BBC called “A Car is Born” a 15 episode show where the presenter, Mark Evans painstakingly builds a AC Cobra replica. The show highlighted his experiences, trials and tribulations of building something from the ground up.

At TechEd 2014 in Las Vegas I gave a presentation on being a part of the SAP HANA startup program, developing a product, and trying to make an impact in the world of SAP HANA. While its been an interesting ride, I really felt that my 45 minutes up at the podium was really not enough to convey the past 2 years of highs, lows, successes and failures. Since that was the case, I thought I would get back to some blogging about my experiences along the road, hoping that I can inspire, dissuade and educate others about my quest, just like the BBC show. If you are a budding entrepreneur, HANA guru or just wanting to gain some life lessons (at someone else cost), I encourage you to read on, and share your experiences through some of your life journeys.


“You should never underestimate enthusiasm”

Over the past 15 odd years of my life I have developed a myriad of applications, some that succeed, and others which failed miserably, but in every case on my path from taking the product from inception to reality, it has always been done with such optimism and enthusiasm that even if the idea was mediocre, in my eyes it was a clear winner. Sometimes this “fog” can get the better of you, but in most cases its the drive which encourages you to work late and over the weekends with the intention to build something which is going to be a winner.

Working on metric² was no different. I recall spending multiple hours at TechEd/Sapphire hearing about HANA and its opportunity to change the world, wondering what the true benefit of HANA really was, and it was just not evident to me. That was until a few things changed my perception, I was working at a customer site which had 23 different systems being consolidated into a single data mart for a single report which was run daily. People worked tirelessly to ensure 23 different ETL jobs were processed timely, correctly and accurately to produce 1 measly report, and it struck me that this would be a great use-case for HANA. I started to understand and realize more and more of the benefits, technologies like AFL, PAL, XS Engine, Columnar store, In-Memory, etc. are all clear winners to simplify IT at the foundational level. Once I understood the opportunities, the enthusiasm kicked in, and drove me to work tirelessly on metric² through challenges, time constraints and personal issues to deliver something which I *knew* was going to be a success. Yes, by this stage the fog had set-in.


“Getting started”

Since I had started work on the metric² product on .NET/MS SQL (and had 1 customer live) it made a lot of sense for me to switch the infrastructure and re-build it on HANA. It took a bit of a learning curve, but since I had developed multiple web applications in the past, it was simple and straight forward to get up and running with XS. I also went through the OpenSAP course (from Thomas Jung) which gave me some great fundamental understanding of the core technologies and some opportunities to take advantage of. With my new found understanding and development skills I started down the road of developing metric². Sketched napkins, rough architecture drawings and random emails littered my desk describing how metric² should work, but an important I never quite decided was, what and who metric² was really for, what was my target audience and who would ultimately be my end users? Unfortunately, looking back, this was one of my biggest failures in the project and still is a challenge today.

In my next post I will chat about my 1 new requirement which everyone should have before they write a single line of code: Defining your value proposition. PS. This is relevant for any form of project (Internal, external, customer etc.)

 

 

 

 


bg_top

metric² for iPhone and SAP HANA

 

metric² for iPhone lets you monitor your SAP HANA instances from your phone showing you alerts, core resources and important metrics. Wherever you are.

As mentioned in my GitHANA article, developing on the metric² open source project has really provided some interesting use cases for me around SAP HANA. While it might not be as critical as ERP, BW or custom solution, the metric² demo system is used fairly regularly by people wanting to test drive the functionality. I recently had some server troubles and my HANA instances was down without me knowing. This promoted me to develop a small mobile app to monitor and ensure that my instance was available and running optimally. This is when metric² for iPhone was conceived and I started developing the free app.

 

 

The app is currently availble for iPhone, and I have a iPad version getting ready to be submitted to the App store. From a technical perspective the app uses a small XS file called mobileapi.xsjs which will need to be put in a package on your XSEngine instance to serve up the data to the app. You can specify how often you would like the data to be refreshed and specify multiple systems which you may need to monitor. (I have included my demo HANA instance as an example within the app so you can try it out.)

http://metric2.com/img/alerts2.png

 

The app is perfect for anyone running a HANA instance, be dev, test or production. It provides a really easy way to view the status of your system from anywhere using your iPhone. The app also downloads updates in the background and will notify you if any high alerts are experienced on the selected system, this is perfect for any sys admin/dba who will be to anticipate critical outages and be ready for the support calls.

A few features of the app

- View CPU, Disk, Memory consumption
- View open alerts
- Insights into your HANA instance quickly and from anywhere
- Add multiple HANA instances for monitoring
- Clean and simple UI for basic admin functions
- Push notifications for high alerts, when the app is in running background

Click here to find the GitHub project (of the mobileapi.xsjs file) and click here to check out the product page. This includes install instructions.

Technical Details

Building a native iOS (read Obj. C or Swift) which is integrated with SAP HANA is not terribly challenging and you really have 2 options for pulling or pushing data. Via a XSJS type file (like this app) or via a xsOData type of interface. Both have their pro’s and con’s but are fundamentally very similar. Below is a snippet of some of the code from my xsjs file and looks/acts very similar to what a regular AJAX call would use from a native XS app.

One of the biggest challenges for production users, like any intranet based resource, will probably be gaining access to the URL (mobileapi.xsjs) from outside the corporate net and will probably require a network admin to grant you access or configure (or reuse) a reverse proxy or firewall.

Screen Shot 2014-08-22 at 1.08.56 PM.png
Screen Shot 2014-08-22 at 1.12.40 PM.png
XCode iOS Pull Data Code
Screen Shot 2014-08-22 at 12.52.08 PM.png
SAP HANA XSJS Code serving data to the iOS app

Git-HANA-Screenshot

Git <> HANA – A free, open-source Github client for SAP HANA

Git-HANA-Screenshot.jpg

Over the last few months, working on the metric² open source project, I have been frequently updating the GitHub repo. As a heavy XS Web IDE user, this entailed exporting or copying the contents of the files from the package into my local GitHub repository for the project and subsequently committing the files from there. Since there is a small disconnect between the source (my HANA packages) and the destination (GitHub) I like to often see what changes which are due to be committed, the differences between the files, or just compare the files between the 2 systems.

Being over dedicated to building solutions to some of my workflow challenges (see here, here and here), I created yet another small HANA native app called Git <> HANA. The application allows you to compare files between your local HANA package and your (or any other) GitHub repo, and it also lets you commit files directly from the UI to GitHub, and vice-versa. If a file does not exists, it will create it for you (on either side). There are a couple other cool features which you can read about below, or watch the little video I created.

If you are a web IDE user it’s quick and convenient to use, and I am convinced it will make your HANA + GitHub integration easier (I am also hoping we will also see more open source native HANA apps on GitHub as a result!!!!)

Features of Git <> HANA

- Compare files between HANA and Github
- Compare inline or side by side
- Commit files from HANA to GitHub
- Commit/activate files from GitHub to HANA
- Repo/branch selection
- Native HANA application
- Easy HANA package installation
- Open source
- handles .xs* (e.g. .xsaccess, .xsapp) files (which your file system probably does not like!)
- Image comparison
- File browsing can be done via the GitHub repo or your HANA package

You can download the app package here (newsletter sign up requested so I can keep you up to date with the app) or check out the source files here.

If you think this would be helpful or would like to see any other features, or would like to contribute to the source … EXCELLENT, please just let me know

Screenshots

  

Use the HANA Package Browser or GitHub repository as a reference.

Push files from HANA to GitHub or from GitHub to your local HANA package.

Compare Files side by side, or inline

Package Install Instructions

- Download the package
- Open Lifecycle manager (http://<HANA_SERVER>:PORT/sap/hana/xs/lm/)
- Click on Import/Export menu
- Click Import from File
- Browse to the downloaded file
- Edit the index.html file and specify your github username/password (or leave it blank and enter these details using the settings)


pastedImage_0

Hacking SAP HANA Web Sockets

Disclaimer: This is not a production or documented feature – its also more of a hijack than a hack 

 

I have been hoping for the inclusion of Websocket support on the HANA DB platform for a while now, and I was a little disappointed it was not packaged in the SPS08 release. My goal when building apps (or products) is to make use of the core platform its running on as much as possible, I firmly believe that when convincing an IT department, or company, to implement a product or app, the first question is: “How much infrastructure does this need?”. This can often be a deal breaker and why I am such a big proponent of the HANA’s DB + XS App Server integration – it consolidates the requirements into a single investment. Having a Websocket technology built directly in XS can be an additional selling point which developers are starting to expect these days.

A little while ago I wrote a blog post on building a dashboard using the awesome Node.js package from Holger Koser, however I have really been wanting to use Websockets in the metric² platform since the get go. Some comments here and here are prime examples of my long lasting hope of seeing the technology being included in the XS Engine platform sooner rather than later. I recently had a little nudge again from John Patterson to dig back into the topic and did manage to hack something together. The most interesting part of this was that once I had it working, I was left wanting just a little more …

Firstly a little bit about Websockets and why I feel they important to the app/web development world …

Real-time: In the age of having blazingly fast DB’s, we need a UI & server side (In our case XSJS files) integration layer which can display the data to user with as little over head as possible. Web Sockets supports this by providing a low-latency, near real-time connection between a client and the server.

Light Weight: Currently we need to do multiple AJAX calls to our backend server (to the XSJS files) to either perform some complex logic or DML against our database. This is slow and also fairly network intensive as each request (and response) requires additional handshakes and the packet size is considerably larger than just the intended content inside the package. In Web sockets, the requests and responses are really just the content themselves.

Duplexity: Web Sockets by nature are Full-duplex, implying that we can send and receive data at the same time for multiple requests.

Persistence: Web sockets provide a “open” connection between the server and client after the initial upgraded HTTP request handshake has been made. This lets us perform multiple server side requests using the same connection. This also lets the server initiate a response without needing a request from the client side.

The importance of these 4 factors to the web development world and to HANA XS specifically is that this is the missing link for us to take Web applications to the next level.

[Cross-domain support is another great feature!] In this example I was able to successfully have the HTML + JS file local to my PC and execute it against my HANA XSWS service (via a public URL).

– 07/25/2014 — Chris Paine made a good point on potential Cross-domain security issues (see below). Keep in mind that these files are secured just like any of the XS content files, e.g. as long as your folder has a authentication requirement it will persist to this XSWS file as well.

So onto the more interesting HANA specific parts …

 

I initially realized that HANA XS was using Web Sockets in SPS06, when for some reason the XS Engine debugger was not loading correctly due to my user missing some permissions. After searching through the XS code I came across the folder where the debugger was saved and it included a interesting file with the suffix of xsws i.e. XSWebService. After doing more digging I found that Websockets were being loaded in the WebDispatcher config file and I was confident I could find a way to start using it for app development.

After spending some time trying to create my own HANA package with these file extension types I realized that the name is somehow being filtered and only this file, and more specifically, in this location can be executed, otherwise the XS Engine passes back a 403 (forbidden) – I was a little disappointed but it didn’t discourage me … and I decided I would simply re-purpose my Debugger.xsws file for my own needs After a quick backup, I was ready to do some coding …

Essentially, a xsws file is just like any xsjs file, with the exception that it has some socket code returning the responses versus your regular xsjs file. You can do things like $.import for additional libraries as well as perform $.sql functions. Here is a small snippet from the code over on Github.

Debugger.xsws

  1. $.ws.onmessage = function (evt){
  2.     handleIncomingRequest(evt);
  3. }
  4. $.ws.onerror = function (evt) {
  5.     $.trace.debug(“error on connection: “ + evt.message);
  6.     throw new Error(evt.message);
  7. }
  8. $.ws.onclose = function (evt) {
  9.     $.trace.debug(“connection closed, disabling debugger”);
  10.     debugObject.enabled = false;
  11.     throw new Error(“Close status “ + evt.code + “:” + evt.reason);
  12. }

 

 

And this is some of our Client side code making calls the xsws service:

App.js

  1. // Create a new WebSocket. This works fine
  2.   var socket = new WebSocket(‘ws://<ENTER YOUR HANA SERVER HERE>/sap/hana/xs/debugger/api/Debugger.xsws’‘xsCrossfire’);
  3.   // Handle any errors that occur.
  4.   socket.onerror = function(error) {
  5.     console.log(‘WebSocket Error: ‘ + error);
  6.   };
  7. // Send the message through the WebSocket.
  8. socket.send(message);

As you can see – the code and requests are very simple and straight forward, in fact to me they are a little easier than jQuery + AJAX.

One caveat I did find was connection persistence in the event you have an error on the server side, the socket connection can break, in this case you would need a error handling state that attempted a reconnect before submitting any new requests.

A quick screenshot of the running test app i developed and how the server is sending persistence frames pings/pongs to validate the open connection along with the client request and server response.

If you are interested in trying this out on your test or dev instance I have posted the code on Github. Follow these simple instructions to get up and running …

1.) Using the Web IDE, open SAP -> HANA -> XS -> Debugger

2.) Make a backup of the Debugger.xsws file or simply comment out the contents.

3.) Paste the code into the file from Github

4.) Create the Websocket.html file and paste the contents of the Github file

4.) Create the app.js file and paste the contents of the Github file

5.) Open the Websocket.html file and enter any SQL statement

(Be sure you have the debugger security role)

As you can see from the files, the required methods for web sockets are really at a minimum and barely get in your way at all.

Conclusion

At the start of the article I mentioned I was left wanting a little more … this was mainly because since I have been wanting Web Sockets for such a long time, I realized that using it , alone its not really enough. In order for us to really take XS Engine to the next level, we also need to consider a “Publish/Subscribe” feature and a server side timer feature.

The Pub-Sub approach would essentially allow us to push data from the server side, on a specific occurrence of an event, much like a DB trigger. If a new row gets inserted, push the new inserted record to the registered subscriber.

The server side timer feature would allow us to create a server side timer (similar to a xsjob) which would persist and execute the server side function every x secs/mins/hours.

Overall I am pretty impressed with the opportunities Web sockets will bring to the XS Engine. I am hoping they will be included in the next release.


office14

metric² v2.0 release

After releasing metric² at TechEd Las Vegas last year it has had well over a hundred downloads, and has a couple loyal followers always offering advice and feedback (which I am truly thankful for). Last week we released version 2.0 of the free and open source app and subsequently put it onto GitHub under the MIT license which you can find here.

The biggest changes of the new version of metric² include:

  • A new UI (Twitter bootstrap based)
  • The ability for users to create their own account
  • A few new metrics
  • No longer uses SAPUI5 (a blog post in itself!)
  • The biggest change was the front-end/UI and the code has been refactored and split up into multiple library files (XSJSLib) and is simplified for easier reading.

You can download the source code over at Github or you can download the HANA Delivery unit file (tgz) here.

The primary goal of the app is, and always has been to try and visualize your big data. Along with providing a self service tool to monitor and provide insights on the data you have in, and around your HANA system, while using it to the fullest.

Short Survey

I am in the process of trying to understand where to take the app in terms of use and direction and if you are interested in helping guide the discussion, if you have downloaded, used or seen the app I would greatly appreciate if you took 1 minute to complete a short 5 question, multiple choice survey here.

(Read further below for Future updates and the mobile app) ,,,

Below are a few screenshots of the new version (2.0):

Screen Shot 2014-07-06 at 9.11.31 PM.png Screenshot2.png

Mobile App

If you are a HANA admin, or are simply managing your own dev instance for learning HANA, a new iOS app called metric2 – Admin will be in the app store within the next month, it will be a free app with some pretty basic core metrics centered around HANA performance/availability. Below are a few screenshots of the upcoming mobile app:

Screen Shot 2014-07-15 at 3.37.38 PM.png

Next Release

A couple of new features for the upcoming release (v2.1) are centered around some new metrics, including support for iBeacon devices (upload a map, designate regions and you can monitor and track from the live dashboards). Another metric in the process of being developed is around quickly and easily showing twitter sentiment using your HANA instance. Using HANA Live views will also be included as a data source option for the metrics allowing you to make use of the predefined SAP designed views. From a code perspective I am in the process of pulling out widgets to be independent, upgradable and customizable without touching the core code.

As usual if you are using the app in your environment I am always looking for ways to improve it and the feedback provided so far is invaluable. Feel free to leave a comment or reach out to me at paschmann@metric2.com


pastedImage_15

Node.js dashboard for SAP HANA

This is what we will be developing in this blog …

Over the past few years Node.js has really caught my attention. The simplicity of Javascript with server side processing, Non-blocking-IO, Event Driven, and simple integration always intrigued me as a great combination for enterprise applications. (Somehow it sounds similar to HANA XS Engine)
A couple months ago I ran into a similar problem to Jon-Paul Boyd (HANA Forum Post) in which I wanted to use XS Engine for websocket/persistant connections to my HANA Instance, but due to the support not being included in SPS6, I decided to look elsewhere, and ended up using Node.js to fulfill this requirement.In the past, while developing HANA/Node apps, I resorted to creating a XSJS App which really just acted as a middleware layer to push and pull data from my HANA DB, until recently I noticed a great blog post from Ingo Sauerzapf which piqued my interest. The blog mentioned that Holger Koser had created a HANA DB Client for Node making life extremely easy to connect to HANA directly from Node. I thought it would be good share the small project I developed using Node.js and this new client with the community in the hopes that others will share their experiences with the technology.This blog is not necessarily an introduction to Node.js development as there are some nice tutorials and examples out there from Tobias Hoffman and Alessandro Spadoni. The blog is intended to cover a small app developed in Node.js and shows the development process behind it, taking it from conception through to reality. I encourage you to download a few of these components, and also the example out. This app, similar to another app I developed called Metric² (which you can read about here), it is a web based widget showing some friendly KPI’s on the performance of your HANA Instance. The app gets streaming data from our HANA backend displaying this in a friendly, simple dashboard. The dashboard is designed to be shown on a large format monitor in a Ops or IT center and can also very easily be modified to show any KPI’s relevant to your business or needs.

Requirements:

SAP HANA Instance (e.g. AWS Developer Image)

Node.js installed (this does not need to be on the HANA box but same network with access to the HANA port – normally 30015).

Node Dependencies

We will also use a couple of helpful dependencies from the node community including Socket.io, Express and obviously hdb. Installing these packages is as simple as running “npm install hdb”. Once you have the dependencies installed we can start creating our app.

https://nodei.co/npm/hdb.png?compact=true

App Design

For me, I always start mocking up in my favorite Image IDE (Photoshop), I used this image as inspiration for my app. I liked the simplicity, clean layout with focus on the numbers at the bottom. In our case, we will add a small chart in the center, giving us a basic visual representation of the numbers being displayed:

 

Photoshop HTML Mockup
Download the PSD

App Development

Index.html

In this case I decided to use Twitter Bootstrap to help with some of the layout/formatting of the page as well as some mundane tasks like Modal popups. From a coding perspective I started out developing the Single paged “index.html” file, doing my best to stick with my mockup which I previously created. I was sure to “id” all of my elements on this page as we will be updating these values from our node.js backend. This aspect of node development is strictly “traditional” web based development. No need to work with Node or any server for that matter. Once you have your page rendering the way you want, we can move on.

<html>

<head>

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

<meta charset="UTF-8"/>

<meta name="viewport" content="width=device-width, maximum-scale=1.0" />

<title>Metric&#178;</title>

<!-- jQuery -->

<script src="https://code.jquery.com/jquery.js"></script>

<!-- Socket.IO -->

<script src='/socket.io/socket.io.js'></script>

<!-- Peity - a lightweight sparkline package for jQuery -->

<script src='js/jquery.peity.min.js'></script>

<!-- Client side code needed -->

<script src='js/client.js'></script>

<!-- Bootstrap CSS -->

<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css">

<!-- Latest compiled and minified JavaScript -->

<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.min.js"></script>

<!-- CSS -->

<link rel="stylesheet" href="css/style.css">

</head>

<body>

<div id="top">

<div>

<div>

<div>

<table>

<tr>

<td rowspan="2" style="text-align: center; width: 10%;" >

<img id="statusicon" src="img/OKIcon.png"/>

</td>

<td style="vertical-align: top;">

<h1><span id="info-name">SAP HANA Instance</span>

<button data-toggle="modal" data-target="#myModal">

<span></span>

</button>

</h1>

</td>

</tr>

<tr>

<td style="padding-top: 20px;">

<span style="margin-left: 0px;" /></span><span id="info-alerts">0</span> Alerts

<span></span><span id="info-version">1.0</span>

<span></span><span id="info-detail">Server Location</span>

</td>

</tr>

</table>

</div>

<div>

<span>0</span>

</div>

<div>

<table>

<tr>

<td id="infoUSERS" onClick="setChart('USERS');">

<!-- The ID of each of our <SPAN> tags is important for updating the data being returned from the server -->

<span id="info-users">0</span><br />

<span>Users</span>

</td>

<td> </td>

<td id="infoDISK" onClick="setChart('DISK');">

<span id="info-disk">0</span> <sup>GB</sup><br />

<span>Free Disk</span>

</td>

<td id="infoMEM" onClick="setChart('MEM');">

<span id="info-mem">0</span> <sup>GB</sup><br />

<span>Free Memory</span>

</td>

<td id="infoCPU" onClick="setChart('CPU');">

<span id="info-cpu">0</span> <sup>%</sup><br />

<span>CPU</span>

</td>

</tr>

</table>

</div> <!-- /.containerfooter -->

</div> <!-- /.container -->

</div> <!-- /.centercontainer -->

</div> <!-- /.top -->

<!-- Modal -->

<div id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

<div>

<div>

<div>

<button type="button" data-dismiss="modal" aria-hidden="true">&times;</button>

<h4 id="myModalLabel">Settings</h4>

</div>

<div>

<form id="modalbox" role="form">

<div>

<label for="servername">Name</label>

<input type="text" id="servername" placeholder="Enter a reference server name">

</div>

<div>

<label for="serverdetail">Location</label>

<input type="text" id="serverdetail" placeholder="Description, Location or Other Information">

</div>

<div>

<label for="bg">Background</label><br />

<label>

<input type="radio" name="bg" value="../img/bg1.jpg" checked> Background 1

</label>

<label>

<input type="radio" name="bg" value="../img/bg2.jpg"> Background 2

</label>

<label>

<input type="radio" name="bg" value="../img/bg3.jpg"> Background 3

</label>

<label>

<input type="radio" name="bg" value="none;"> None

</label>

</div>

<div>

<label for="colorscheme">Color Scheme</label><br />

<label>

<input type="radio" name="colorscheme" value="Dark" checked> Dark

</label>

<label>

<input type="radio" name="colorscheme" value="Light"> Light

</label>

<label>

<input type="radio" name="colorscheme" value="Fiori"> Fiori

</label>

</div>

<div>

<button type="button" data-dismiss="modal">Close</button>

<button type="button" id="modalSave" onClick="saveSettings();">Save changes</button>

</div>

</div><!-- /.modal-content -->

</div><!-- /.modal-dialog -->

</div><!-- /.modal -->

</body>

</html>

App.js

Next we develop the app.js file which is the brains of our operation. This file is firstly going to act as our web server for our web site, and secondly provide the data from our HANA server to the web page, pushing the data via web sockets.

Below is the app.js code, here you can see how we process each request based on the type and subsequently respond with the requested data. You can also see how simple it is to call the HANA DB and respond with the results.

 

var express = require('express'),

http = require('http'),

hdb = require('hdb');

try {

var app = express();

var server = http.createServer(app);

server.listen(3000);

var io = require('socket.io').listen(server);

app.use(express.static(__dirname + '/'));

// development only

if ('development' == app.get('env')) {

app.use(express.errorHandler());

}

var client = hdb.createClient({

host     : 'Your HANA IP Address or DNS Name',

port     : 30015,

user     : 'username',

password : 'password'

});

client.connect(function (err) {

if (err) {

console.error('Connect Error:', err);

} else {

console.log('Connected to server');

}

});

process.on('uncaughtException', function (err) {

console.log('Caught exception: ' + err);

});

strContent = '';

io.sockets.on('connection', function (socket) {

socket.on('request', function (data) {

// Handle Service Requests

switch (data.service) {

case 'CPU':

client.exec("SELECT ABS(SUM(PROCESS_CPU)) as CPU from SYS.M_SERVICE_STATISTICS", function(err, rows) {

if (err) {

console.error('Error:', err);

} else {

socket.emit('response', {service: 'CPU', response: rows[0].CPU});

}

});

break;

case 'MEM':

client.exec("select TO_VARCHAR(ROUND((FREE_PHYSICAL_MEMORY) /1024/1024/1024, 2)) AS FREEMEM

from PUBLIC.M_HOST_RESOURCE_UTILIZATION", function(err, rows) {

if (err) {

console.error('Error:', err);

} else {

socket.emit('response', {service: data.service, response: rows[0].FREEMEM});

}

});

break;

case 'INFO':

client.exec("SELECT VALUE FROM SYS.M_SYSTEM_OVERVIEW WHERE NAME = 'Version'", function(err, rows) {

if (err) {

console.error('Error:', err);

} else {

socket.emit('response', {service: data.service, response: rows[0].VALUE});

}

});

break;

case 'DISK':

client.exec("select TO_VARCHAR((ROUND(d.total_size/1024/1024/1024, 2) - ROUND(d.used_size/1024/1024/1024,2))) as FREESPACE

from ( ( m_volumes as v1 join M_VOLUME_SIZES as v2 on v1.volume_id = v2.volume_id ) right outer join m_disks as d on d.disk_id = v2.disk_id )

where d.usage_type = 'DATA' group by v1.host, d.usage_type, d.total_size,    d.device_id, d.path, d.used_size", function(err, rows) {

if (err) {

console.error('Error:', err);

} else {

socket.emit('response', {service: data.service, response: rows[0].FREESPACE});

}

});

break;

case 'USERS':

client.exec("SELECT COUNT(CONNECTION_ID) as STATUS FROM SYS.M_CONNECTIONS

WHERE CONNECTION_STATUS = 'RUNNING'", function(err, rows) {

if (err) {

console.error('Error:', err);

} else {

socket.emit('response', {service: data.service, response: rows[0].STATUS});

}

});

break;

case 'ALERTS':

client.exec("SELECT COUNT(ALERT_DETAILS) as ALERTCOUNT FROM _SYS_STATISTICS.STATISTICS_CURRENT_ALERTS", function(err, rows) {

if (err) {

console.error('Error:', err);

} else {

socket.emit('response', {service: data.service, response: rows[0].ALERTCOUNT});

}

});

break;

}

});

});

} catch(err) {

console.log(err);

}

 

The App does have a couple of different themes which will hopefully make it fit with your office decor

Below you can see a couple of images of the app running and showing the output. You can obviously very easily modify the code to show anything relevant to your business case as well. The Node-hdb package for node.js really makes developing HANA connected Node apps a breeze! Thanks Holger!

Fiori Styled
Light Theme
Image5.png
Dark Theme
Image6.png
As usual – please feel free to comment on your experience with Node.js and if you feel like this type of technology is a good fit in the enterprise? Do you have any suggestions on what I could have done differently?You can download the app here: Metric² for Node
Credits: The Bokeh backgrounds are from devientArt

Image1

Metric² for SAP HANA

Metric² is a web based, realtime dashboarding platform for SAP HANA, on SAP HANA.I recently gave a demo of the app at Demojam in Las Vegas (You can read my blog post about the event here). Metric² is a free app/download and this blog gives some insight into how it works, and how you can download and install it in your own HANA system:

Overview

Metric² is made up of 3 key areas:

Dashboards: Metric² can have multiple dashboards. Dashboards are designed as blank canvases, are quite flexible, and can contain widgets which are added can be simply dragged and dropped into their needed locations and also sized accordingly.

Widgets: Dashboards can have multiple widgets displayed. There are a variety of widgets including a range of predefined datasources (CPU, Memory, Disk etc.) but also include custom widgets (SQL, JSON, Yahoo) which can display a myriad of information to your team.

Alerts: Certain widgets can have alerts “attached” to them, when the value meets the conditions, the alert is logged and displayed.

  1. Why realtime? The intent is to be proactive about your systems or applications health, having the Metric² dashboards up on a large format monitor ensures that everyone is well aware of how your system is performing, and more importantly, when it is not.
  2. Why Web Based? While I personally prefer Native/Traditional/Window types apps, having Metric² run as a web app (using SAPUI5) means it can be used and displayed on a variety of devices and formats.
  3. Why do you call it a platform? Its more than just a bunch of metrics, everything is customizable, you can create your own widgets, your own dashboards and alerts, it also acts as a large data warehouse for any of the data you are monitoring/tracking, taking it past being an app, to a small platform which you can build, and extend upon.
Image1.png

Architecture:

This was an interesting dilemma for me, I wanted to keep the app as simple as possible by not requiring that admins install *any* additional components (thus deemed as a “Native” XS HANA app). It has a DB schema which Metric² needs to have present, and subsequently a set of files which get installed in the content repository via a package.

This lead to an interesting challenge, because the XS Engine did not support web sockets for “true” realtime app runtime, the app uses timers and HTTP polling to fetch the data from the backend system (read xsjs file). This is less than perfect. I have high hopes that SPS7 will include WebSocket support and we can start writing true realtime web apps directly on XS Engine. Another alternative is the recent availability of Node.js library for HANA, while its awesome, still requires additional components outside of the core HANA platform.

Image2.png

Design:

The app is based on a “Fiori” themed SAP UI5 foundation. I also used a variety of JQuery add-on’s to help (read: not reinvent the wheel) with the display of  the data. I also used the standard D3 visualization library of UI5 along with a helper class called NVD3 which is very useful in simplifying the D3 charting experience.

Image3.pngWhats Missing:

- Currently the app does not support multiple users.

- Browser support … currently its developed for Firefox only, but does not look too bad on Safari or Chrome (CSS Changes needed).

- The polling aspect, because the data is being fetched from your XSJS file and returned to the main page, I am constantly having to eval the returned code to update the chart widgets. Eval is Evil

- Widget history: Because widgets are being polled, if the screen is not open, it will not capture any historical data. Not very useful for troubleshooting.

Whats Next:

I am currently working on porting the app to support the realtime abilities. Planning on a new theme (not so much Fiori like) to make it a little more differentiated. Also planning on adding a few more predefined widgets (suggestions welcomed!!!).

Download:

Here

Install Guide:

  1. Import the Metric² Package to the content repository in XS Engine (This can be done via Web or Studio)
    1. Open http://YOURIP:8000/sap/hana/xs/ide/
    2. Click on the Delivery Unit Menu and then Import Delivery Unit From File System
    3. Select the downloaded/unzipped file (REPO_20131109-203950826-HDB–METRIC2.tgz)
  2. Run the Install script (InstallScript.sql) for the DB which is included in the download – This can be done in either HANA Studio or the Web IDE
  3. Optional: Run the Overview dashboard script (Overview Dashboard.sql) from here to give you a sample dashboard  – This can be done in either HANA Studio or the IDE
  4. Open your browser to http://YOURIP:8000/lilabs/metric2/Index.html

- Optional: Predictive Analytics: You may need to enable PAL on your server in order to use the libraries and forecasting feature under some of the widgets.

Known Issues:

- The ping response widget is not functional currently

- The Total CPU reported on the “System overview” widget should be converted to a legitimate percentage (0 – 100%) as SLES displays a summed percentage of all the CPU’s.

- The Map of the US Widget – coordinates are not accurate, they need an offset due to the images size and padding within the widget

- The dashboard itself is not fully responsive, when displaying on an iPad the view is often too small to display all the widgets

- There is no mail server functionality built into XS Engine, so alerts are only displayed on the monitor and in the notifications area on the right of the screen.

You can submit an issue log on my website making it easier to track, share, resolve: http://blog.li-labs.com/issue-log/

Disclaimer:

Vishal Sikka made a humorous reference at the Las Vegas Keynote to a certain “Pre-release” Beta product, so I am going to do the same This version of Metric² is a “Prerelease” beta please use and test it thoroughly in your development environment.

Stay up to date:

Please head over to http://www.metric2.com and signup for the newsletter, this way I can stay in touch with people interested in learning more.

License:

This software is provided as is, and with no warranty. You may copy, modify and share the code for personal purposes. You may not sell or include, any parts, or as a whole, the software. Please share the download via the URL provided – Thanks.

Favor:

If you install Metric² and build an interesting dashboard, please tweet or share it in the comments. Also if you find any errors or issues on the installation process, please let me know and I will gladly update this guide. Thanks


pastedImage_24

Why Demo Jam ROCKS

It was Tuesday night sometime back in 2009 at my first TechEd where I was sitting in the audience and really wishing I was standing up on stage, presenting something inspiring and innovative which would encourage the votes of the demanding audience of Demojam. Well, it took 4 years to creep over personal hurdles, family time and to gain an ounce of courage which persuaded me to post an entry in 2013, this blog gives some insight into what I did, what I would have done differently, and also why Demojam really needs people like YOU!A couple of months ago (May through July) I went through the openSAP HANA course and was really impressed, not only by the DB, but more the HANA XS Engine as an Web/App server. Being a “learn by doing” kinda person I struggled to get the most out of the course content since it really didn’t apply to anything I was currently working on, until I realized the opportunity… As I described in my demojam presentation, I drank the HANA coolaid Personally, it was not so much of the big data aspect that intrigued me, but rather this concept of the DB and the app server really being a single entity from a platform, as well as infrastructure perspective. Simple. I spent a couple weeks learning a lot more, since I had something to apply it against and started developing an app called Metric²(pronounced squared).Image.png“I realized that while there are a lot of applications which are using HANA, there were very few for HANA.”My goal with Metric² was to build a web based realtime platform for showing how your HANA instance was performing, and subsequently, how your business was actually benefiting from having this type system and helping your business run better. The concept was to try and correlate performance with user impact.

OK , get to the demo jam part …

Around the end of August, Metric² was doing what I had intended and I decided to submit the app for Demojam, although, my original anticipation was to build something far more purpose built and “crowd” pleasing. However, I was really hoping that the free perspective, something useful – realtime dashboards – and a good use case – audience involvement – would hopefully win the votes and hearts of a couple techies in crowd. I created a submission video and a couple days after submissions closed, I got a welcoming, but equally nerve wracking acceptance email. Graham Robinson was actually the one who sparked the idea of a Demojam submission with his comment on a small Mac app I developed for HANA called xSync. I both cursed and thanked him for about 2 months straight when I was wondering what I had gotten myself into

After getting accepted, I had a couple interesting challenges, my 1st priority and goal was to deliver the app at Teched, which meant between the acceptance email (around the 20th of September) and October 20th (TechEd) I needed a fully function product. I also needed to put together, and have a solid presentation nailed down. I subsequently neglected the last point and as always, focused more on adding features and functionality to the app. I had conceptual ideas about what I was going to present, and set out to do something a little different by getting the audience involved by using the actual system I built to show its purpose and functionality, but also to make them feel a part of the demo.

Shortly after being accepted you also have the opportunity to have a online session with Tobias Queck and Sebastian Steinhauer, 2 really great guys and coaches who listen to your demojam pitch and provide some really solid feedback on what their thoughts and suggestions are. After speaking with them, it really calmed my nerves and gave me a certain reassurance that I was going to be OK. A great and well needed confidence boost, especially for a first timer.

Well the 30 days between the above mentioned dates just flew by, and before I knew it, it was TechEd time. The first two days of TechEd for me, included the awesome Innojam event – I thoroughly enjoyed myself, but ended up spending considerably more time helping out than I anticipated and did not get as much coding done as possible. Yes, I was still writing code 2 days before the presentation. Adding features, optimizing things and getting the website finished. Innojam wrapped up on Monday evening, I skipped the keynote to do additional coding and practicing my pitch, the Tuesday of the event unfortunately came pretty quickly and my nerves were starting to get the better of me. I was super stressed to go up on stage, especially knowing it was going to be tough to beat the other participants. I was optimistic and pressed on … on Tuesday the demojam rehearsals start around midday. You get to run through your presentation twice, with others watching and the stage/event crew helping you out with monitor setup, displays, etc. You get to meet the funny and friendly Ian Kimbell, and also Tobias and Sebastian who coach you through your pitch once again, providing some really helpful feedback.  This really helps ensuring that your demo goes  smoothly.

A word of praise – The events team are amazing people, they will literally do anything to make are you are comfortable and happy and EVERYTHING you need to be successful. I do not have enough praise for them. They really go above and beyond, and this image should give you an idea of just how far they go.

photo.JPG

Jen Abrahamson (part of the talented events team) gave me this shirt just before the event!

While going through my 1st rehearsal I was so nervous I left out close to 40% of the pitch/demo and still had 2 minutes on the clock, at that stage, i realized I needed more practice and I spent the rest of the afternoon going through my talk over and over again to engrain it as best I could. In between that – as you can guess, I was also doing last minute code changes making some small modifications. Having the audience involved proved to add its own set of challenges, since I didnt have a full time HANA system and using the developer image on AWS, it was far from a very powerful machine, I spent quite a lot of time running load tests, but was never 100% sure who and how users were going to influence the performance and subsequently the outcome of the demo … major stress factor.

Around 8pm the event started and I got my time on stage, I went through my presentation and felt it really went pretty well. It was reasonably well received, with the exception of me forgetting to mention that the app has support for gestures using the Leap Motion. During the demo I walked over to the large monitor to show this functionality, it did not work – making me look like i was swatting or catching flies Boo.


“Tell people what you are doing and why, that way when it does not work, people at least understand what you were attempting to do….”

With around 2 minutes left I asked the audience to open up the demo website on their mobile device and they got to pick which pill they wanted to purchase from my online store (running on HANA) which was being monitored by Metric². Up on the screen you could see the orders being completed in realtime and how the system was reacting to the new load. In the end around 700 orders were completed which was great, and to me, is what made the demo a success.

Link to my Demojam presentation

I was subsequently voted off the stage in round 1, I walked off the stage pretty disappointed … all I could think about was what I would need to do to win it next year. Its official, I am hooked. I now understand why John Astill has done this for so many years over and over again.

In the end, I *really* want to win. I already have around 5 ideas about what I could potentially do next year and I really hope i get the chance to redeem myself and write a sequel to this blog post, but from a winners perspective

Thinking of submitting an entry? Here are a couple tips which I learned:

  • Think small – my challenge was that I developed a full featured app, with loads of features. This is challenging at best just to demo in 6 mins, never mind apply a crowd friendly use case.
  • Your presentation is 50% of your demo – Have a creative and complimentary presentation and you can succeed very easily. (The running demo of John and Greg is a great example of a creative presentation).
  • Creative use of a technology, far outweighs technology being used for creativity. I.e. Don’t just use HANA for the sake of it
  • Come to TechEd prepared, have your 6 min pitch nailed down. I didn’t and it was far more stressful than I had hoped.
  • Even if its the same, make it look different: On Tuesday morning Vishal Sikka and Sam Yen gave some great introductions to the SAP UI5/Fiori programming paradigm. Guess what, my app had a very similar look and feel. When they were going through their presentations I was literally sinking in my seat … I was actually considering changing my color scheme and if I had just a couple hours more, I probably would have. Point is, even if your demo is a UI5 app, don’t make it look like UI5 app.
  • The devil is NOT in the details, its in the use case. Its far more important to have a sound, solid and relevant use case, than a phone number having the correct input format of (111) – 111 – 1111.
  • Tell people what you are doing – (Sebastian suggested this) – it is helpful and adds context to your presentation. Its also often hard to see what your mouse is clicking on, or what watch button you are pressing.
  • Your jokes are not as funny as you think they are – I threw a couple small jokes in and all I heard was crickets chirping, nothing breaks moral more One of Ian’s tips are not to start with a joke, and I fully agree.

The Demojam event needs some changes …

I noticed a couple of tweets a couple of days ago about changing rules, and doing things differently, having now participated in an event, here is are my feedback/comments to the demo jam organizers:

  • We need more demo jammers, way more. if it means we need to reduce the 6 minutes to 4, so be it. The event starts pretty late which also may limit the amount of Demojam presentations, the SCN event is also prior which takes up quite some time while being a big advocate for this, it might be best to restructure the timetable a little?
  • I would like to see a couple different categories. It would be great to have a “open source” category and a “regular” category. Any others you can suggest?
  • I think there should be more prizes for different criteria or per category, this could or could not be known prior to the event. At Innojam LV, there were multiple winners and this really encourages more entries across multiple disciplines.
  • I would like to see SAP employees back in, even alone. Maybe a category for best SAP employee demo? They have developed some great tech in the past, I understand it could be a slight advantage due to technology accessibility, early access, and a couple of other aspects but I also believe the audience wants to see how internal SAP employees are innovating in their respective areas. I know there was a huge thread back in 2011 from Demojam winner Matt Harding about this topic, and this is just my opinion
  • Limit previous winners? No way, I applaud jammers who can win multiple times, it encourages all other jammers to build something more creative, more innovative and deliver a great presentation.
  • Please change the voting – the “Clapometer”? I would prefer to see a slightly more transparent process … winners could be based on amount of tweets? Voting page from a mobile app? Even a panel like X Factor handing out tasteless feedback would be pretty cool and a bit more enjoyable.

In the end ….

Demojam ROCKS, I am truly grateful for an opportunity to participate. It was a great feeling to have completed a life long dream of mine. I got 6 minutes of fame up on the same stage as the greats of Vishal Sikka and Hasso Platner. Here’s the best part – YOU can too. All of us have done something outstanding, something creative and something I/WE/YOU/SCN/Attendees want to hear about. I encourage you to create or share a concept, a dream or just a downright outrageous idea for next years demo jam, and hopefully join me in showing your peers, friends and family that you are a dedicated and a creative innovator of awesome enterprise technology.

Metric² Update

For those of you who would like to download/check out Metric² – its coming! I had a huge amount of great feedback at TechEd and I am in the process of making some of the suggested changes to make it a little better before throwing it into the wild. (I developed the entire app on the concept of polling due to the XS Engine limitation of not supporting Web Sockets in SPS6 = not perfect.) You can stay up to date using the website here: http://www.metric2.com


pastedImage_1

HANA Talk – A Simple helper class for SAP HANA Development

HANA Talk is a small Javascript class which help facilitate the communication between your front end html/js files and HANA database when using SAP
HANA XS Engine. This is intended to help people who are just starting out development on XS Engine and would like a easy place to get  their feet wet without having to go through too much trial and error. This is also a great starting point for people involved in events like InnoJam, Hackathons, etc. when POC’s and demos need to developed quickly, but not necessarily perfectly *cough* or securely *cough*

By providing this tutorial and the HANA Talk download, my hope is that it will encourage more people to consider using XS Engine as a app platform to drive their front end web apps and subsequently, encourage the use and innovation around HANA in general. Anne Hardy had a comment in her blog post regarding the Developer Advisory Board which was along the lines of “Developers want to get it in 5mins max; they want to build real stuff in less than an hour”.

I frequently get discouraged by the amount of learning and effort always needed to learn new technologies and products which companies “get into bed with”. Nearly every one of the apps I develop start out in a POC type phase, where my imagination and reality clash and inevitably produce the equivalent of a 3yr old’s self portrait, often resembling “Unconventional”. While going through these exercises I often wish it was simple to get somethings done, and understanding the cost and willing to accept the trade offs. This is why I developed HANA Talk – to make those unconventional portraits, easier to deliver

OK – so what does it do?

By adding a HANA Talk js and xsjs file to your project, you can simply write SQL statements in your HTML file and have the results returned synchronously.

e.g.  Index.html

  1. <script type=”text/javascript”>
  2. var resp = hana.executeScalar(‘SELECT 1 FROM DUMMY’);
  3. console.log(resp); //Outputs 1
  4. </script>

Super simple and easy. See below for further details.

Prerequisites

1. Download/fork these 2 files – client.js & server.xsjs from Github and add them to your package. The filenames/structure can be changed if you are feeling adventurous. In your HTML file, you will need to reference client.js, this is as simple as adding a tag to you header. For reference, if you are not using SAP UI5 or jQuery – you will need to add this to your HTML header as well.

A Basic Example

2. In your javascript code, instantiate a new HanaTalk object. We will use this to “pass” our SQL commands to our HANA DB.

  1. var hana = new HanaTalk(‘SYS’); //The ‘SYS’ reference is in relation to the Schema. It can be specified here or within your TSQL Statement

3. Call your HanaTalk object with the operation type and SQL you would like execute (see below for additional operations).

  1. var result = hana.executeRecordSet(“SELECT 1 FROM DUMMY”);

4. We can populate that response into our html (DOM)

  1. document.getElementById(“SomeElementID”).innerHTML = result;

A few more examples

a.) Insert/Update/Delete a record – use .executeChange, this will execute your code and respond with the records which have been updated

  1. document.getElementById(“resp4″).innerHTML = /*hana.executeChange(“UPDATE/INSERT/DELETE …. “) + */ ‘ Record Changed’;

b.) Return a Table – using .executeRecordSet will return a html formatted table, displaying the select’s record set

  1. document.getElementById(“resp2″).innerHTML = hana.executeRecordSet(“SELECT TOP 5 * FROM M_HOST_INFORMATION”);

c.) Return a Object – .executeRecordSetObj allows us to loop through records, and have quite a lot of control of the display of each record and its column name.

  1. document.getElementById(“resp3″).innerHTML = hana.executeRecordSetObj(“SELECT TOP 5 * FROM M_HOST_INFORMATION”);

Here are the results of the calls above:

As you can see, making these types of calls is fairly simple and since your files reside directly on the DB app server, responsiveness is not too bad. So what’s so bad about this method?

Security: Because you are passing your SQL text directly from your browser to the backend server, you open yourself up to all kinds of SQL Injection hacks. Technically, we are not parsing URL arguments/parameters into the server side DB request but rather entire statements. In order for us to hack this, we could simply change the URL request to include some devious SQL.

Speed: For simplicity and to avoid AJAX Callbacks, the execution is performed Synchronously (i.e. We wait for the server to completely respond before we continue processing). The good: Code is “inline” and easy to manipulate the response/results from the server. The Bad: if we do a Select * on a massive (read billion) row table, the entire window is locked/hung until it either times out or completes. Not a particularly nice behaving UI.

The usual disclaimer: As mentioned, the intent of this post/download is to encourage simplicity, this comes at a cost, both performance and security are less than perfect – in this case, we will do our best to mitigate some of these. In fact, I expect a snarling comment from Thomas Jung, like a high school math teacher, disappointed that one of his protege openSAP students would even suggest these obscenities

I encourage you to test this out and provide some feedback or makes some changes and share this with the community.