Open Source: 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 Nodemaking 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.ioExpress 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://paulaschmann.com/wp-content/uploads/2023/10/hdb.png

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:

PhotoshopHTML 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²</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" class="background"> <div class="centercontainer"> <div class="container shadow"> <div class="containerheader"> <table class="heading"> <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 class="btn btn-link" data-toggle="modal" data-target="#myModal"> <span class="glyphicon glyphicon-cog settingsicon"></span> </button> </h1> </td> </tr> <tr> <td class="h3" style="padding-top: 20px;"> <span class="glyphicon glyphicon-flag icon" style="margin-left: 0px;" /></span><span id="info-alerts">0</span> Alerts <span class="glyphicon glyphicon-repeat icon"></span><span id="info-version">1.0</span> <span class="glyphicon glyphicon-map-marker icon"></span><span id="info-detail">Server Location</span> </td> </tr> </table> </div> <div class="containerbody"> <span class="history">0</span> </div> <div class="containerfooter"> <table class="info"> <tr> <td id="infoUSERS" class="td-info" 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" class="h1">0</span><br /> <span class="h3">Users</span> </td> <td class="td-info"> </td> <td id="infoDISK" class="td-info" onClick="setChart('DISK');"> <span id="info-disk" class="h1">0</span> <sup>GB</sup><br /> <span class="h3">Free Disk</span> </td> <td id="infoMEM" class="td-info" onClick="setChart('MEM');"> <span id="info-mem" class="h1">0</span> <sup>GB</sup><br /> <span class="h3">Free Memory</span> </td> <td id="infoCPU" class="td-info selected" onClick="setChart('CPU');"> <span id="info-cpu" class="h1">0</span> <sup>%</sup><br /> <span class="h3">CPU</span> </td> </tr> </table> </div> <!-- /.containerfooter --> </div> <!-- /.container --> </div> <!-- /.centercontainer --> </div> <!-- /.top --> <!-- Modal --> <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <h4 class="modal-title" id="myModalLabel">Settings</h4> </div> <div class="modal-body"> <form id="modalbox" role="form"> <div class="form-group"> <label for="servername">Name</label> <input type="text" class="form-control" id="servername" placeholder="Enter a reference server name"> </div> <div class="form-group"> <label for="serverdetail">Location</label> <input type="text" class="form-control" id="serverdetail" placeholder="Description, Location or Other Information"> </div> <div class="form-group"> <label for="bg">Background</label><br /> <label class="radio-inline"> <input type="radio" name="bg" value="../img/bg1.jpg" checked> Background 1 </label> <label class="radio-inline"> <input type="radio" name="bg" value="../img/bg2.jpg"> Background 2 </label> <label class="radio-inline"> <input type="radio" name="bg" value="../img/bg3.jpg"> Background 3 </label> <label class="radio-inline"> <input type="radio" name="bg" value="none;"> None </label> </div> <div class="form-group"> <label for="colorscheme">Color Scheme</label><br /> <label class="radio-inline"> <input type="radio" name="colorscheme" value="Dark" checked> Dark </label> <label class="radio-inline"> <input type="radio" name="colorscheme" value="Light"> Light </label> <label class="radio-inline"> <input type="radio" name="colorscheme" value="Fiori"> Fiori </label> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> <button type="button" class="btn btn-primary" id="modalSave" onClick="saveSettings();">Save changes</button> </div> </div><!-- /.modal-content --> </div><!-- /.modal-dialog --> </div><!-- /.modal --> </body> </html> read more

Open Source Project: Metric² for SAP HANA

/wp-content/uploads/2013/11/office13_589243.png

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. read more

Why Demo Jam ROCKS – from a losers perspective ;)

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² read more

2013 SAP Demo Jam Prep

Preparing for SAP Demo Jam at TechEd in Las Vegas was a huge undertaking, I completely underestimated the time and commitment it takes to prep a simple 5 minute demo on the stage in front of 5,000 people. Attached are my notes and details of some of the script around the project and what I was using as a guide.

The store pills should be bigger and center of the screen for everyone to see?

Tell people what you are clicking on?

– Metric squared Twitter Widget: 385571773112012800

Notes

– In Demo – if System crashes … say that I have little kids, any time this happens, mention that it is HANA having a tantrum.

– In Demo – if does not do something … say HANA is a little like my daughter – she doesn’t always listen 😉 read more

Load Testing Metric2 and SAP HANA

[]Charts of performance/errors (bar chart)

2 Weeks ago I was getting for ready for TechEd Demojam and since my demo was going to involve the audience actually using the a website being served up by the XS engine, I started having some concerns about how much load it could handle. I spent some time digging through the documentation as well as reaching out to guys like Thomas Jung for any advice I could get. As always, it was an interesting experiment and thought it would be great to share some of the experiences I had, and hopefully you can share some ideas or feedback from your point of view. 

So, just add some context – the website the audience was going to interact with at Demojam was extremely simple, a single page, 2 buttons, when a user clicked on one of the buttons, I was making a call to a XSJS file, doing a table insert and returning a confirmation, (and in the demo some counts). Pretty simple and straight forward. read more

Open Source Project: HANA Talk – A Simple HANA XS helper

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

<script type="text/javascript">
var resp = hana.executeScalar('SELECT 1 FROM DUMMY');
console.log(resp); //Outputs 1
</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.

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).

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

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

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

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

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.

document.getElementById("resp3").innerHTML = hana.executeRecordSetObj("SELECT TOP 5 * FROM M_HOST_INFORMATION"); read more

A peek inside xSync and the HANA XS Engine

/wp-content/uploads/2013/06/icon_128x128_231789.png

On saturday I published a blog about a small app I wrote called xSync – basically a XS Engine app for Mac developers where you can sync a local development folder with your HANA repository. This is for rapid development and to encourage the “bring your own IDE” approach to application development on HANA. Here is a look behind the scenes on how the app works and some of the challenges of the project.

Image.png

As mentioned in my previous blog – I started using the IDE Lightweight editor after doing the upgrade of my AWS HANA box last weekend. I enjoyed the experience but after working with it for nearly a full day was wanting a little more. Syntax highlighting, easy commenting, easy indentation, CSS autocomplete and hints, etc. etc. so I started doing some peaking around the editor itself and came to find the editor is something called ACE, a pretty nice little open source IDE (written in JS). This got me thinking … maybe I could insert text directly into the Lightweight IDE browser text box, and submit the form as a save …. hmmm …. not a terrible idea …. just need to scrape the page, find the elements and submit the form via some injected JS. Pretty simple …  I did some digging and found the HTML objects I needed by using Firebug when a lightbulb went off … instead of populating the form via a HTML page, why not rather check the HTTP methods it is calling when doing the actual save, since there must be some integration with HANA directly … which is when I came across the mother load … a small file called reposervice.xsjs 🙂 It seemed that every time I was saving or modifying my objects through the IDE, it was calling this file. After checking out the parameters it was `, it was very clear that the methods and text were easy to simulate. I fired up REST Client and within a couple minutes the concept was POC’ed. Pass your file contents as your body with a path param and a POST and you were off to the races 🙂 

Screen Shot 2013-06-09 at 4.39.png

Using Firefox Rest Client to monitor system calls showed each save, create, delete operation was using a small file called reposervice.xsjs, which references the libraries needed for the repository modifications. read more

xSync – Making HANA XS development easier

Update: March 7th 2014

– Added support for SAP HANA SPS07 
– Ability to ignore local deletes, which would leave the files on the server 
– Shortcut link opens the Web Editor, and another to open IDE in your browser 

– Stability and speed improvements 
– Corrected multiple minor bugs  

————————————————————————————————————————————————

A couple of weeks ago, I started playing with HANA development after going through a couple of the opensapcourses. One of my biggest surprises was that HANA Studio was windows only. As a Web/Mobile/App developer spending majority of my time on the Mac platform, having to get my Dell out was a walk down memory lane, and caused me to not spend as much time working on the projects as I would have liked. Since Rev 52 of HANA included a XS Engine Lite IDE, a useful web based IDE for your XSJS/SAPUI5 development. I was been looking forward to getting it installed on my AWS machine and giving it a test drive. Last weekend Juergen Schmerderposted a updated really easy to follow and simple guide of going through the process and within a hour, I was up and running on the newest available rev. read more

Simple Sample: Writing an entry to SAP Netweaver Gateway using JSON

Skill Level: Beginner

Time Needed: 20 minutes

I recently assisted someone on the forums when they were having trouble creating records in their SAP ECC instance while using Gateway. I thought I would share some very simple code showing what it takes to write an entry into a service via JSON from iOS (Objective C). The reason the title of the document is “Simple Sample” – there are no frills. Whenever I develop a new app, I start small, get the basic functionality working, and proof out the process before getting too creative.

*** If you do not have your own gateway server, you might be able to connect this to the SAP Gateway System which can be found hereCreate an account and utilize this service *** DISCLAIMER: Untested as the signup form does not work 🙁  read more