DarkLight.proDarkLight.pro
  • Contact

How to monitor StarWind Virtual SAN status in web browser

February 17, 2016Taras ShvedStorage

StarWind Virtual SAN has a very user-friendly and nice interface which allows IT guys to do most of the operations only in a couple of clicks and provides a one sight overview of all virtual storage related happenings in the environment including pop-up notifications. Accurate and non-intrusive windows-based error reporting makes it quite easy to track any possible issues with the virtual storage subsystem.

StarWind Interface

But what happens if you decide to integrate StarWind Virtual SAN into your existent web-based 24/7 visual monitoring system? Or if you need to grant a read-only monitoring access to other colleagues? How to check quickly the current status of the system remotely from your iPhone, Android smartphone or Smart TV without searching and installing a working RDP application and messing with domain credentials and security?

The answers lie on the surface. A web-based interface would solve all the above-mentioned issues but unfortunately, StarWind Virtual SAN does not have it yet. So today we are going to create our own web-based monitoring console with all the whistles and bells we desire.

Prerequisites

1. Web-server. Apache, IIS or any other PHP-compatible. It does not matter, so you are free to choose the one you are more familiar with.
2. PHP 5.3+ with php_sockets.dll extension installed and enabled.
3. A couple of servers running StarWind Virtual SAN.

Scripting

Yes, you guessed correctly. We will create a PHP script that will get all the possible information from StarWind Virtual SAN instance or instances and pass it into a web browser.

Let’s start with variables that we will need to connect to StarWind host.

1
2
3
4
5
$Server = “192.168.1.100”; //IP of your StarWind Virtual SAN host
$Port = “3261”; //StarWind Virtual SAN default management port
$Login = “root”; //StarWind Virtual SAN default login
$Password = “starwind”; //StarWind Virtual SAN default password
$cfgTimeOut = 10; //Session timeout

The main trick is to initiate a socket connection to the StarWind Virtual SAN management port and try to get some useful data. Since it is basically a kind of telnet protocol we will also call it so:

1
$telnet = @fsockopen($Server, $Port, $errno, $errstr, $cfgTimeOut);

Now we need to log into session with proper credentials:

1
fputs ($telnet, "login $Login $Password\r\n");

And pass a command that lists all the information about current StarWind Virtual SAN host status:

1
fputs ($telnet, "list\r\n");

That’s it. Ready to close the session and grab all the data into array for further usage:

1
fputs ($telnet, "exit\r\n");

Below routine parses received values and splits them to various associated array cells:

1
2
3
4
5
6
7
8
9
10
11
12
13
while (!feof($telnet))
{
    $string = fgets($telnet);
    $explode = explode("=", $string);
    if ($explode[0] == "DeviceName")
    {
        $counter++;
    }
    if (isset($explode[1]))
    {
        $values[$counter][$explode[0]] = str_replace("\"", "", $explode[1]);
    }
}

Now, if we print our $values array we will get something similar to this:

1
Array ( [1] => Array ( [DeviceName] => imagefile4 [DeviceId] => 0x0000000000C9E810 [DeviceType] => Image file [DeviceBusType] => Unknown [SerialId] => 9CF751D5A4DC90EC [Eui64Id] => 9CF751D5A4DC90EC [ScsiInquiry] => STARWIND STARWIND 0001 [DeviceMounted] => no [parent] => HAImage6 [state] => 0 [reservation] => yes [header] => 0 [file] => My Computer\D\DS1\DS1.img [buffering] => no [asyncmode] => yes [SectorSize] => 512 [PhySectorSize] => 4096 [ImageSizeLow] => 1073741824 [ImageSizeHigh] => 11 [readonly] => no [DeviceState] => 1 [CacheMode] => wb [CacheSizeMB] => 512 [CacheBlockExpiryPeriodMS] => 5000 [ScsiLun] => 0 )

As you can see, values are present and readable, so you can start customizing the output the way you like.

Conclusion

We successfully managed to retrieve various information from StarWind Virtual SAN service using direct socket connection. Now we can play with these data, choose only those parameters we are interested in and apply some CSS and markup to transform the visual output according to our wishes. I ended up with this:

StarWind Web Monitor

You can see some useful information about each server, current status of each HA device present and partner network statuses. The most useful information is updating automatically and continuously. This current script with markup and styles can be downloaded here: StarWind Virtual SAN Web Monitor

You will need to change following strings in index.php file:

1
2
3
4
5
$servers = array("192.168.0.101", "192.168.0.102"); // Servers running StarWind Virtual SAN
$port = "3261"; // Port (3261 default)
$login = "root"; // Login
$password = "starwind"; // Password
$refresh = 1000; // Information refresh time

Obviously, the code is crappy since it’s only a quick proof of concept and I am sorry for that. If you are interested in further development of such kind of features or need some help on implementing this in your environment do not hesitate to contact me.

Tags: browser, http, monitor, php, starwind, status, web
Taras Shved
IT specialist with a passion for virtualization.

Related Articles

Using Microsoft DiskSpd to test StarWind Virtual SAN storage performance

December 15, 2015Taras Shved
April 2021
M T W T F S S
« Feb    
 1234
567891011
12131415161718
19202122232425
2627282930  

Categories

  • Performance testing
  • Storage

Tags

browser csvfs diskspd http iscsi microsoft failover cluster monitor ntfs performance php refs smb starwind status storage testing web
© 2015 — 2016 DARKLIGHT.PRO