Thursday, 5 January 2017

5 things you didn't know about ... Java Database Connectivity



JDBC, or Java™ Database Connectivity, is one of the most frequently used packages in the entire JDK, and yet few Java developers use it to its fullest — or most up-to-date — capacity. Ted Neward offers an introduction to newer JDBC features like ResultSets that automatically scroll and update on the fly, Rowsets that can work with or without an open database connection, and batch updates that can execute multiple SQL statements in one fast trip around the network.


1. Scalar functions

Different RDBMS implementations offer irregular support for SQL and/or value-added features designed to make the developer's life easier. It's well known, for example, that SQL provides a scalar operation, COUNT(), to return the number of rows that meet a particular SQL filter criteria (that is, WHERE predicate). But beyond that, trying to modify values returned by SQL can be tricky — and trying to get the current date and time from the database could drive even the most patient JDBC developer mad (and potentially bald, too).
Toward that end, the JDBC specification provides for a degree of isolation/adaptation against different RDBMS implementations, via scalar functions. The JDBC specification includes a list of supported operations that JDBC drivers should recognize and adapt as necessary to their particular database implementation. Thus, for a database that supported returning the current date and/or time, it could be as simple as Listing 1:
Listing 1. What time is it?

Connection conn = ...; // get it from someplace
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(“{fn CURRENT_DATE()}”);
The full list of scalar functions recognized by the JDBC API is given in the appendix of the JDBC specification (see Resources), but the full list might not be supported by a given driver or database. You can use the DatabaseMetaData object returned from Connection to obtain the functions supported by a given JDBC implementation, as shown in Listing 2:
Listing 2. What can you do for me?

Connection conn = ...; // get it from someplace
DatabaseMetaData dbmd = conn.getMetaData();
The list of scalar functions is a comma-separated String returned from a variety of DatabaseMetaData methods. For example, all the numeric scalars are listed via the getNumericFunctions() call. Do a String.split() on the result and —voilĂ !— instant equals()-testablelist.

2. Scrollable ResultSets

It's a very common procedure in JDBC to create a Connection object (or obtain an existing one) and use it to create a Statement. The Statement, being fed an SQL SELECT, returns a ResultSet. The ResultSet is then fed through a while loop (not unlike an Iterator) until the ResultSet says it's empty, with the body of the loop extracting one column at a time in left-to-right order.
This whole operation is so common that is has become almost sacred: it's done that way simply because that's the way it's done. Alas, it's completely unnecessary.

Introducing the scrollable ResultSet

Many developers are unaware of the fact that JDBC has been considerably enhanced over the years, even though those enhancements are reflected in new version numbers and releases. The first major enhancement, JDBC 2.0, occurred around the time of JDK 1.2. As of this writing, JDBC stands at version 4.0.
One of the interesting (though frequently ignored) enhancements to JDBC 2.0 is the ability to "scroll" through the ResultSet, meaning we can go forward or backward, or even both, as need dictates. Doing so requires a bit of forward-thinking, however — the JDBC call must indicate that it wants a scrollable ResultSet at the time the Statement is created.
If the underlying JDBC driver supports scrolling, a scrollable ResultSet will be returned from that Statement, but it's best to figure out if the driver supports scrollability before asking for it. You can ask about scrolling via the DatabaseMetaData object, which can be obtained from any Connection, as described previously.
Once you have a DatabaseMetaData object, a call to getJDBCMajorVersion() will determine whether the driver supports at least the JDBC 2.0 specification. Of course, a driver could lie about its level of support for a given specification, so to play it particularly safe, call the supportsResultSetType() method with the desired ResultSet type. (It's a constant on the ResultSet class; we'll talk about the values of each in just a second.)
Listing 3. Can you scroll?
int JDBCVersion = dbmd.getJDBCMajorVersion();
boolean srs = dbmd.supportsResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE);
if (JDBCVersion > 2 || srs == true)
{
    // scroll, baby, scroll!
}

Requesting a scrollable ResultSet

Assuming your driver says yes (if it doesn't, you need a new driver or database), you can request a scrollable ResultSet by passing two parameters to the Connection.createStatement() call, shown in Listing 4:
Listing 4. I want to scroll!
Statement stmt = con.createStatement(
                       ResultSet.TYPE_SCROLL_INSENSITIVE, 
                       ResultSet.CONCUR_READ_ONLY);
ResultSet scrollingRS = stmt.executeQuery("SELECT * FROM whatever");
You have to be particularly careful when calling createStatement() because its first and second parameters are both ints. (Curse the fact that we didn't get enumerated types until Java 5!) Any int value (including the wrong constant value) will work with createStatement().
The first parameter, indicating the "scrollability" desired in the ResultSet, can be one of three accepted values:
  • ResultSet.TYPE_FORWARD_ONLY: This is the default, firehose-style cursor that we know and love.
  • ResultSet.TYPE_SCROLL_INSENSITIVE: This ResultSet enables backward iteration as well as forward, but if the data in the database changes, the ResultSet won't reflect it. This scrollable ResultSet is probably the most commonly desired type.
  • ResultSet.TYPE_SCROLL_SENSITIVE: The ResultSet created will not only allow for bidirectional iteration, but will also give a "live" view of the data in the database as it changes.
The second parameter is discussed in the next tip, so hang on.

Directional scrolling

Once you've obtained a ResultSet from the Statement, scrolling backward through it is just a matter of calling previous(), which goes backward a row instead of forward, as next() would. Or you could call first() to go back to the beginning of the ResultSet, or call last()to go to the end of the ResultSet, or ... well, you get the idea.
The relative() and absolute() methods can also be helpful: the first moves the specified number of rows (forward if the value is positive, backward if the value is negative), and the latter moves to the specified row in the ResultSet regardless of where the cursor is. Of course, the current row number is available via getRow().
If you plan on doing a lot of scrolling in a particular direction, you can help the ResultSet by specifying that direction, by callingsetFetchDirection(). (A ResultSet will work regardless of its scrolling direction but knowing beforehand allows it to optimize its data retrieval.)

3. Updateable ResultSets

JDBC doesn't just support bidirectional ResultSets, it also supports in-place updates to ResultSets. This means that rather than create a new SQL statement to change the values currently stored in the database, you can just modify the value held inside the ResultSet, and it will be automatically sent to the database for that column of that row.
Asking for an updateable ResultSet is similar to the process involved in asking for a scrollable ResultSet. In fact, it's where you'll use the second parameter to createStatement(). Instead of specifying ResultSet.CONCUR_READ_ONLY for the second parameter, send ResultSet.CONCUR_UPDATEABLE, as shown in Listing 5:
Listing 5. I'd like an updateable ResultSet, please
Statement stmt = con.createStatement(
                       ResultSet.TYPE_SCROLL_INSENSITIVE, 
                       ResultSet.CONCUR_UPDATABLE);
ResultSet scrollingRS = stmt.executeQuery("SELECT * FROM whatever");
Assuming your driver supports updateable cursors (that's another feature of the JDBC 2.0 specification, which most "real-world" databases will support), you can update any given value in a ResultSet by navigating to that row and calling one of the update...() methods on it (shown in Listing 6). Like the get...() methods on ResultSetupdate...() is overloaded for the actual column type in the ResultSet. So to change the floating-point column named "PRICE", call updateFloat("PRICE"). Doing so only updates the value in the ResultSet, however. To push the value to the database backing it, call updateRow(). If the user changes his or her mind about changing the price, a call to cancelRowUpdates() will kill all pending updates.
Listing 6. A better way
Statement stmt = con.createStatement(
                       ResultSet.TYPE_SCROLL_INSENSITIVE, 
                       ResultSet.CONCUR_UPDATABLE);
ResultSet scrollingRS = 
    stmt.executeQuery("SELECT * FROM lineitem WHERE id=1");
scrollingRS.first();
scrollingRS.udpateFloat("PRICE", 121.45f);
// ...
if (userSaidOK)
    scrollingRS.updateRow();
else
    scrollingRS.cancelRowUpdates();
JDBC 2.0 supports more than just updates. If the user wants to add a completely new row, rather than create a new Statement and execute an INSERT, just call moveToInsertRow(), call update...() for each column, then call insertRow() to complete the work. If a column value isn't specified, it's assumed to be an SQL NULL (which might trigger an SQLException if the database schema doesn't allow NULLs for that column).
Naturally, if the ResultSet supports updating a row, it must also support deleting one, via deleteRow().
Oh, and before I forget, all of this scrollability and updateability applies equally to PreparedStatement (by passing those parameters to the prepareStatement() method), which is infinitely preferable to a regular Statement due to the constant danger of SQL injection attacks.

4. Rowsets

If all this functionality has been in JDBC for the better part of a decade, why are most developers still stuck on forward-scrolling ResultSets and disconnected access?
The main culprit is scalability. Keeping database connections to a minimum is key to supporting the massive numbers of users that the Internet can bring to a company's web site. Because scrolling and/or updating ResultSets usually requires an open network connection, many developers will not (or cannot) use them.
Fortunately, JDBC 3.0 introduced an alternative that lets you do many of the same things you would with a ResultSet, without necessarily needing to keep the database connection open.
In concept, a Rowset is essentially a ResultSet, but one which allows for either a connected or disconnected model. All you need to do is create a Rowset, point it at a ResultSet, and when it's done populating itself, use it as you would a ResultSet, shown in Listing 7:
Listing 7. Rowset replaces ResultSet
Statement stmt = con.createStatement(
                       ResultSet.TYPE_SCROLL_INSENSITIVE, 
                       ResultSet.CONCUR_UPDATABLE);
ResultSet scrollingRS = stmt.executeQuery("SELECT * FROM whatever");
if (wantsConnected)
    JdbcRowSet rs = new JdbcRowSet(scrollingRS); // connected
else
   CachedRowSetImpl crs = new CachedRowSetImpl();  // disconnected
   cachedRowSet.populate(scrollingRS);
JDBC comes with five "implementations" (meaning extended interfaces) of the Rowset interface. JdbcRowSet is a connected Rowsetimplementation; the remaining four are disconnected:
  • CachedRowSet is just a disconnected Rowset.

  • WebRowSet is a subclass of CachedRowSet that knows how to transform its results to XML and back again
  • .
  • JoinRowSet is a WebRowSet that also knows how to form the equivalent of an SQL JOIN without having to connect back to the database
  • .
  • FilteredRowSet is a WebRowSet that also knows how to further filter the data handed back without having to connect back to the database.

Rowsets are full JavaBeans, meaning they support listener-style events, so any modifications to the Rowset can be caught, examined, and acted upon, if desired. In fact, Rowset can even manage the complete act against the database if it has its UsernamePasswordURL, and DatasourceName properties set (which means it will create a connection using DriverManager.getConnection()) or its Datasourceproperty set (which was probably obtained via JNDI). You would then specify the SQL to execute in the Command property, call execute(), and start working with the results — no further work required.
Rowset implementations are generally provided by the JDBC driver, so the actual name and/or package will depend on what JDBC driver you use. Rowset implementations have been a part of the standard distribution since Java 5, so you should be able to just create a ...RowsetImpl()and go. (In the unlikely event that your driver doesn't provide one, Sun offers a reference implementation; see Resources for the link.)

5. Batch updates

Despite their usefulness, Rowsets sometimes just don't meet all your needs, and you may need to fall back to writing straight SQL statements. In those situations, particularly when you're facing a slew of work, you might appreciate the ability to do batch updates, executing more than one SQL statement against the database as part of one network round-trip.
To determine whether the JDBC driver supports batch updates, a quick call to the DatabaseMetaData.supportsBatchUpdates() yields a boolean telling the story. Assuming batch updates are supported (indicated by anything non-SELECT), queue one up and release it in a blast, like in Listing 8:
Listing 8. Let the database have it!
conn.setAutoCommit(false);

PreparedStatement pstmt = conn.prepareStatement("INSERT INTO lineitems VALUES(?,?,?,?)");
pstmt.setInt(1, 1);
pstmt.setString(2, "52919-49278");
pstmt.setFloat(3, 49.99);
pstmt.setBoolean(4, true);
pstmt.addBatch();

// rinse, lather, repeat

int[] updateCount = pstmt.executeBatch();
conn.commit();
conn.setAutoCommit(true);
The call to setAutoCommit() is necessary because by default, the driver will try to commit every statement that it is fed. Other than that, the rest of the code is pretty straightforward: do the usual SQL thing with the Statement or PreparedStatement, but instead of calling execute(), invoke executeBatch(), which queues the call instead of sending it right away.
When the whole mess of statements is ready to go, fire them all at the database with executeBatch(), which returns an array of integer values, each of which holds the same result as if executeUpdate() had been used.
In the event that a statement in the batch fails, if the driver doesn't support batch updates, or if a statement in the batch returns a ResultSet, the driver will throw a BatchUpdateException. In some cases, the driver may have tried to continue executing statements after an exception was thrown. The JDBC specification doesn't mandate particular behavior, so you are advised to experiment with your driver beforehand, so that you know exactly how it behaves. (But of course you'll be running unit tests, so you'll discover the error long before it becomes a problem, right?)
source:ibm.com

4 Ways To Make Linux Compatible With Even More Software



1 – Use Adobe Air Apps

Adobe Air,  if you’re not aware, is a software platform that runs on Linux, Mac and Windows. There are hundreds of free Linux compatible software applications over at the Adobe Air Marketplace that do everything from giving you newspaper-like access to the New York Times to viewing your Google Analytics Data.

Getting Adobe Air working on Linux is surprisingly easy. You’ll find a Linux-based installer over at get.adobe.com, or you can simply attempt to install any Adobe Air application and Air will install automatically.

Some MakeUseOf posts covering cool Adobe Air apps:
– 3 Really Cool Adobe AIR Apps for Movies and Music
– 8 Adobe AIR Apps that DON’T Suck
– 4 Adobe AIR ToDo List Apps For Managing Your Tasks



2 – Get Java Going

Linux compatible software
Java is the original cross-platform programming language. To this day many programmers use Java to create programs that work equally well on Linux, Mac and Windows. We’ve covered many Java apps, the most recent being “Pauker – An Easy-To-Use Freeware Java Flash Card Program” which Varun wrote all about.
Java’s probably in the repositories of your Linux distribution already. If you’re on Ubuntu you’ll find that Java is instaled when you install the “ubuntu-restricted-extras” package discussed in Varun’s article “10 Applications You Must Install On Ubuntu Lucid Lynx”

3 – Wine For Windows Apps

linux compatible

There are millions of Windows appications out there, and the Wine project gives Linux access to many of them. Wine attempts to provide a compatibility layer between the Linux operating system and Windows programs. It’s far from perfect, but it’s worth a shot. Check out “Run Windows Applications on Linux (or Mac) with WINE”  to learn all about making use of wine.

Wondering if a certain program is compatible with Wine? Check out the database over at WineHQ.
Wine is availible in the package manager of pretty much every Linux distribution in existence, so check yours.

4 – DOSbox for Old DOS Games

linux compatible

Simon recently pointed out 4 sites where you can download old games for free. If these old games were meant to run in DOS you can run them in Ubuntu; all you need is DOSbox. This DOS emulator can run most any DOS program you can throw at it, but it’s really tailor-made for games.

DOSbox is included in the package manager of most fine Linux distributions, so look for it and set it up. You can learn all about using DOSbox in Shaminder’s article about using DOSbox on Windows XP. Yes, the article is about Windows XP, but the principle is basically the same.
If you’re really geeky you could even setup DOSbox to run Windows 3.1. I did using this guide just for so I could play Chip’s Challenge the way God intended: in Windows 3.1.


source: makeuseof.com

Wednesday, 4 January 2017

The Best Linux Distros for First Time Switchers from Windows and Mac


Linux has an intimidating image, making it seem like it would be difficult to start using it. But the switch from Windows and Mac is actually pretty easy, if you can ease yourself into it.

If you’re a Windows user, you have probably slowly evolved from Windows 95 to XP to Windows 7 and now you are getting ready for Windows 10. This gradual progression has helped you deal with changes in how Windows is now, and is a major reason that you may think you should stick to Windows. However, if you’re switching to Linux, do yourself a favour and make it gradual, rather than a dramatic shift.


Linux doesn’t have a single look and feel, as there are several operating systems based on Linux; these are called distributions (distro). The jury is out on which is the best Linux distro, but that’s just a technical comparison. The best distro for you is what matters, and when you are switching, that is usually the distro most akin to which OS you are coming from.

The Best Distro to Switch to from Windows XP

The-best-linux-distros-for-beginners-linux-mint-switch-from-windows-xp

If you are still on Windows XP, it’s probably best to switch to Linux since Microsoft no longer supports updates for XP. And Linux Mint is probably the best way to go. Some reckon it’s the Ubuntu killer!

The familiar desktop environment, the fact that your minimise-maximize-close buttons are in the same place as Windows, and several other such small tweaks make Mint an easy shift for first-time Linux users coming from XP.

The Best Distro to Switch to from Windows Vista

The-best-linux-distros-for-beginners-linux-kubuntu-switch-from-windows-vista

Vista had most of the same elements as XP—the taskbar, the start menu, the file explorer and more generally remained the same, except for cosmetic upgrades. You could safely use Linux Mint if you’re upgrading from Vista, but you might also want to try Kubuntu.

It is based on Ubuntu, one of the most popular distros. However, the desktop environment uses KDE, which looks and operates differently from Debian or Unity (used by Ubuntu). In fact, you can easily try the gorgeous KDE 5 desktop. Jargon aside, what you need to know is this: Kubuntu is the closest you’ll come to Vista in terms of look and feel, especially if you apply one of the darker themes.

The Best Distro to Switch to from Windows 8 or Touchscreen Laptops

The-best-linux-distros-for-beginners-ubuntu-switch-from-windows-8-touchscreen

Microsoft made Windows 8 so that it could be used with laptops that have a touchscreen or 2-in-1 hybrid devices. If you’re using one such device, then you want a Linux distro that will work with touchscreen input. Look no further than Ubuntu.

Of all the Linux distros, Ubuntu is the most flawless for touchscreen usage, thanks to its large icons and well-spaced buttons—you won’t be tapping things mistakenly. This is mainly because of the Unity interface, made to be used with both tablets and in a desktop environment. Plus, Ubuntu’s on-screen keyboard is far better than what you get on other distros (although it’s still not as good as  Windows 8, let alone iOS or Android).
source:makeuseof.com


How to Easily Upgrade Ubuntu’s Linux Kernel With Ukuu

What Is a Kernel?

The kernel is basically an important piece of software found in every operating system. It acts as a mediator between the software you run every day (e.g. web browsers), and the hardware that it’s running on. Essentially, without a kernel, other programs cannot function since they can’t access your computer’s resources.
For example, open up your task manager. All of your processes take up some amount of your computer’s memory. It is the operating system’s kernel that is quietly allocating this memory to your programs.
Different operating systems have different kernels. For Linux users, this means using operating systems built upon the Linux kernel. Other examples include the NT kernel (Windows) and the XNU kernel (Mac).

Why Should I Upgrade My Kernel?

Since the kernel is essentially the go-between for your programs and the hardware it’s running on, updates can provide a myriad of benefits. Two examples of these include better support for your computer system, and improved performance.

art of the Linux kernel is devoted solely to controlling things like your graphics card and CPU in the form of device drivers. These drivers inside the kernel tend to be limited to a particular range of hardware. With newer and newer technologies coming out, drivers need to be constantly added and updated to match them. If you’re using a partially unsupported computer, upgrading the kernel may help it become more compatible.
Along with this, system performance can go hand-in-hand with better drivers. Your graphics performance in particular get almost constant improvements per release. Just don’t expect miracles!
Unfortunately, the process of upgrading a kernel by hand can be a little tedious, and that’s where Ukuu comes in.

What Is Ukuu?

Ukuu (short for Ubuntu Kernel Update Utility) makes updating your Ubuntu kernel much easier to perform. It downloads newer kernels from the internet, and changes your system to let it use them. All you really have to do is choose which kernel you’d like and reboot into it.
ubuntu kernels
Traditionally, updating your kernel means installing a new copy of Ubuntu over your old Linux box. If you repeat your installation experience a couple of times, you’ll see how it can eat up some time. Ukuu makes this process as easy as installing a program from the Ubuntu Software Center.

Getting Ukuu

Enter these commands in the terminal to install Ukuu:
sudo apt-add-repository -y ppa:teejee2008/ppa
You can’t get Ukuu by default from the list of software that Ubuntu provides. As such, using the above command, we point our package manager to the desired repository. Adding such locations lets us install software that Ubuntu doesn’t have by default (such as Ukuu).
apt add repository
sudo apt-get update
Package managers (such as APT), work by retrieving a list of all the software that they can install. The second command ensures that this list is up to date. Put shortly, if you don’t enter this command, you won’t be able to find Ukuu!
apt get update
sudo apt-get install ukuu
The above command actually downloads and installs the program. Alternatively, you could open the Ubuntu Software Center, and install Ukuu from there. After all that, launch the program using the command below.

Read More: click Here


UVify’s plucky little Draco drone hits speeds up to 100 miles an hour


For all the grandiosity of its ancient Grecian name, the Draco is a fairly unassuming thing. It’s surprisingly small and unimposing in fact — and if it weren’t for those four rotors, it would fit comfortably in the palm of your hand.
But UVify’s little drone has tremendous zip when pushed. In fact, the little quadcopter can hit a top speed of 100 miles an hour – which handily blows more mainstream photography drones out of the water.

The startup gave us a sneak peek of the product just ahead of CES’s kickoff this week, happily putting it through its paces, with sweeping 360 barrel rolls and some impressive quick drops/recoveries.
img_1673
The product represents an emergent market for the technology – drone racers looking for a product that’s ready to fly, right off the shelf. And indeed, the company’s offering up a full package, including the drone, controller, FPV visor and even some tools all bundled in a backpack, akin to what DJI and GoPro have put together for their respective folding drones.
Of course, traditionally a least, there’s been a sizable overlap between those who are interested in drone racing and those who want to build and customize their devices themselves. UVify is banking on the rapid expansion of racing leagues creating a demand for a device that just works.
img_1712
That said, the Draco does have something of a modular design, so users can swap in parts to upgrade, or in case of collision. The drone’s battery, perhaps unsurprisingly, will only last ten minutes on a charge – and that number drops down to two, if you’re operating it at top speeds. Thankfully, it’s fully swappable, so flyers can push it a bit longer.
Draco is currently up for pre-order, starting at $499 for just the drone. It’s set to start shipping “as soon as” next quarter.
Read more:Click Here

Sunday, 1 January 2017

Server management tips: Linux's advantages and avoiding common mistakes




What server management capabilities are unique to Linux, if any?
 Linux presents a number of options on the management front. You can manage a Linux server with an in-band management agent. You can use SSH (Secure Shell), telnet, serial console and connect with PPP (Point-to-Point protocol) through a console server, etc. You can use KVM, remote X, and VNC (virtual network computing). Unix also provides a powerful scripting environment for automating common IT tasks. Many of these options are extremely difficult or impossible to accomplish with a Windows server.
One of the biggest advantages of using Linux is the freedom to customize it to the needs of enterprise data center. IT can easily write scripts to automate their IT processes, which can be completely catered to individual enterprise data center requirements. By moving outside the scope of their traditional Windows-based environment and trying out something new, IT managers have a great deal to gain in efficiency.
What are the most common mistakes IT managers make when managing Linux-based servers?
One of the biggest mistakes IT managers can make is not using the pre-integrated agentless capabilities that standards like IPMI and SMASH provide. In fact, the Aberdeen Group, an industry research firm, stated that IPMI has become a checklist requirement for IT when evaluating infrastructure needs.
IPMI was created by the IPMI Forum back in 1998. It's an industry-wide management initiative that today has more than 180 vendors that work together to continually update and implement this open hardware management standard for servers and other systems such as storage, network and telecommunications equipment. An important characteristic of IPMI is that it is an open and flexible standard that can be supported across tower, pedestal, rack and blade servers -- irrespective of the hardware vendor or Linux build used. And by being pre-integrated within the server, it does not demand any extra management agent purchases - an approach frequently described as agentless.
In emergency and/or ad-hoc situations, administrators often need to interactively manage various servers using specific commands. The challenge however is that different vendors use different commands to do the same thing. Enter SMASH. Defined by the DMTF (Distributed Management Task Force), the SMASH working group released its first specification last year – the SMASH Command Line Protocol (CLP). SMASH CLP addresses IT administrator needs for a universal command line - enabling systems offered by different vendors to be managed with the same commands and scripts.
It's helpful to think of IPMI and SMASH as collaborating with each other. Even though IPMI offers a standardized message interface for developers and vendors inside the server, the server's command line interface often varies from vendor to vendor. Think of SMASH then as the scriptable command line interface (CLI) available out of the box, accessing the IPMI hardware management features in the box.
Could you give examples of how IPMI and SMASH help in the real IT world?
There are three likely scenarios: a large cluster, a branch office, and a mixed rack of 1U servers with blades.
In clusters, how do you diagnose and power cycle the various servers within the cluster when the operating system has hung? By configuring IPMI thresholds within the servers, potential heat and power issues can be recorded and alerted to management consoles, ahead of meltdowns, providing time to fix the problem. Alternatively, power cycling can be achieved by executing the "Power Cycle" SMASH script against the IPMI firmware in the servers using a telnet or SSH2 session.
In a branch office, without local expertise or even personnel to keep an eye on systems, how do you fill the gap? By placing an appliance out at the branch, you can aggregate alerts and secure access to a single point. If an appliance supports SMASH, scripts can be run centrally, irrespective of the model or vendor of those branch servers. Opening a Telnet/SSH2 session to the SMASH appliance enables a health check to be run by pulling IPMI information. Additionally, an 'Inventory Scan' can be run using a SMASH script to identify whether changes have been made out in the field. •
In mixed racks, IPMI and SMASH don't care whether they are being applied to a blade, a motherboard, a plug-in card, or the blade's chassis manager. To the administrator and his scripts, it all looks the same. So what happens when the rack experiences an event? A Stream Console over LAN SMASH script opens multiple operating system console sessions and records what the operating system consoles were doing right before the failure.
What are the most common challenges in managing Linux servers remotely?
The most common challenge is the same for managing any server, whether Linux, Unix or Windows, remotely, which is having a secure way to connect and control even when the server isn't operational. That's why it is important to build an out-of-band management strategy into your server management strategy. You can't assume that the operating systems (OS) will always perform as expected, so unless you build a system that allows you to remotely reload an OS, reboot or power cycle in a secure fashion, you are not spending time or money wisely.
What server management best practices have you seen succeed most often in your work with IT organizations?
 During your data center's design phase, design an out-of-band management strategy, not just an in-band strategy.
Free up valuable time by getting rid of mundane tasks that can be automated.
Consider virtualization: If you haven't yet, you should be, because power and cooling issues and increased costs are not going away, and virtualization is a good method for helping to solve those issues. Virtualization isn't going to go away either, so over time, more tools for leveraging virtualization will be developed. Now is a good time to begin exploring virtualization in a test environment to determine if and how it can be rolled into your data center strategy.
source: searchenterpriselinux.techtarget.com/