Category Archives: Computers

Microsoft Azure – Redis

Microsoft have implemented the open-sourced Redis key-cache and store in Azure.

Similar to have there are “Basic” and “Standard” levels of Virtual Machines, with associated redundancy, with Redis there are the same options available:

  • Basic – Single node
  • Standard – 2 node (in a primary/secondary setup), with built in replication and automatic failover

Redis Cache Azure Portal

Basic is ideal for development and non business critical (no SLA), whereas Standard is best for business critical systems (with a 99.9% SLA – 1 minute downtime per day)

Cache sizes range from 250mb through to 53GB. Prices range from £11 a month (250mb on Basic) to a huge £995 a month (53GB on Standard).

I’ve been using Redis on Azure for a good month or two now (started when it was in Preview before general release availability), speeds and reliability is impressive, with all requests taking less than 10ms. (only exception being GET * which returns all keys and takes about 50ms).

Redsmin

There are only a few changes which I would like to see:

  • Ability to manage via current management portal (only available on beta portal)
  • Ability to upgrade/downgrade packages on the fly (need to delete and recreate from scratch)
  • Improved statistics (although I currently use Redsmin)
  • Improved SLA for standard package

I thought about writing a guide, but Microsoft have a very good guide on their website about how to setup and use their Redis cache here: How to use Redis Cache in Azure

Server 2012 UNC Network Share One Way 0x80004005

Recently I’ve had a strange issue with Microsoft Azure. For some reason on some of the Virtual Machines could not access UNC network shares, throwing a 0x80004005 error. However strangely, worked the other way. The virtual machines run Server 2012 Datacentre edition.

For example:

From Machine A
Ping Machine B – Success
Access Network Share on Machine B – Success

From Machine B
Ping Machine A – Success
Access Network Share on Machine A – Fail

The following did not help with resolving the issue:

  • Removal and rejoin domain (rejoin failed)
  • Check Firewall Settings
  • Disable IP6
  • Delete network adapters

Following some work by Azure’s support team, it was identified that the issue is a bug in windows due to the way Azure handles the automatic scaling.

The automatic scaling feature in Microsoft Azure automatically boots and shuts down machines dependant on load on the cloud service. This allows cloud services and associated websites to benefit from extra processing power and memory when load is higher than expected.

Every time the virtual machine assigns the windows image to a new host machine, a new virtual network adapter is created, and various entries are added to the registry. SMB then picks up the details from the registry to resolve the UNC path on the network. Once a specific number is reached, SMB then fails to redirect the paths to the right address, causing this error.

Microsoft do not have a permanent fix, however the following script clears out the junk in the registry and leaves only the valid entries behind. Running this script fixed the issue after a reboot of the machine.

KB-269155

WordPress 4.0.1 Security Update

Today WordPress has released a security update, fixing several security holes plus 23 bugs.

These include:

  • Three cross-site scripting issues that a contributor or author could use to compromise a site.
  • A cross-site request forgery that could be used to trick a user into changing their password.
  • An issue that could lead to a denial of service when passwords are checked.
  • Additional protections for server-side request forgery attacks when WordPress makes HTTP requests.
  • An extremely unlikely hash collision could allow a user’s account to be compromised, that also required that they haven’t logged in since 2008.
  • WordPress now invalidates the links in a password reset email if the user remembers their password, logs in, and changes their email address.

It’s important to check your installs and install the latest update and install if required. Luckily most WordPress installs will automatically update using the built in auto-update script. Unfortunately the host I use does not support this (nor the automatic install via the dashboard), so I need to manually download the file, unzip and upload via FTP. A bit of a pain, but necessary.

For full details, view on the official website – WordPress 4.0.1

Or jump straight in – Download Latest Version of WordPress

.NET Framework and Visual Studio

Microsoft’s recent announcement regarding the .NET Framework is quite an interesting one, especially for those who are interested in the open source community.

The idea of making the CLR cross platform across Linux and Mac (on top of Windows of course) will make it easier for developers and users alike and remove the need for projects such as WINE.

Within the announcement there was a new version of Visual Studio 2013 called “Community”, aimed at those who are not producing enterprise grade software. Looking at the feature set, it’s comparable to the “Express” versions of earlier releases.
image

Additionally preview editions of Visual Studio 2015 was released. The new feature of being able to develop for Windows, Android and IOS from one development environment looks quite interesting.

Exciting times ahead

Further Information

Microsoft Dynamics Nav 2015

Microsoft has now released Microsoft Dynamics Nav 2015 earlier on this month. There’s a handful of new features above and beyond the features added in 2013. The tablet client looks pretty cool, removing the need to use the web client whilst out in the field. It’s optimised for touch use and available for all platforms:

If you have a valid subscription, it’s available for download on CustomerSource – Microsoft Dynamics Nav 2015 Download. You do need to get an upgraded licence to run 2015. This can be downloaded from CustomerSource (Microsoft are automatically upgrading Customer licences, or via your partner.)

Live Chat

Live chat is all the rage now with websites. These allow you to instantly chat live with a real human being via the website. Being an IT Geek (or Professional as we like to be called), I could write one, but with the prices so low, I don’t really see the reason to. As they say, why invent the wheel?

To install, simply copy and paste the supplied code into your website and your pretty much up and running. The user interface allows the chat to be themed to match your website.

I’ve tried a few, and settled on Website Alive. Not only is it one of the cheaper options out there, it also allows you to view users live as they are on your site, giving you key information on what pages they are currently viewing, how many pages they have visited etc. Although it’s not as detailed as the de-facto standard – Google Analytics, it does allow you to push prompts to those users to start a chat session. Personally I find these quite annoying, but I guess in some industries a friendly prompt which is not too overwhelming can increase sales.

Before diving in and paying, I’d definitely recommend signing up for a free trial of the software you wish to use and see if there is benefit before you start coughing up any money.

Selective Reindexing of Indexes in SQL Server

I’ve wrote many scripts over the years to selectively reindex indexes and update statistics on Microsoft SQL Server. However more recently I’ve been using Hallengren’s SQL reindex script as it’s very powerful and pretty easy to use and schedule via SQL Agent.

Hallengren’s SQL Reindex Script

I currently use the following script run daily as it reorganises indexes with fragmentation of between 5% and 20%, and performs an online rebuild if over 20%. Fragmentation under 5% is ignored (it’s not worth doing anything with these). It also updates statistics on records which have been modified.

EXECUTE dbo.IndexOptimize @Databases = 'USER_DATABASES',
@FragmentationLow = NULL,
@FragmentationMedium = 'INDEX_REORGANIZE,INDEX_REBUILD_ONLINE,INDEX_REBUILD_OFFLINE',
@FragmentationHigh = 'INDEX_REBUILD_ONLINE,INDEX_REBUILD_OFFLINE',
@FragmentationLevel1 = 5,
@FragmentationLevel2 = 20,
@SortInTempdb = 'Y',
@MaxDOP = 0,
@UpdateStatistics = 'ALL',
@OnlyModifiedStatistics = 'Y'

Monitoring Azure SQL Database CPU Usage

Sometimes there is a need to monitor Microsoft’s Azure SQL database usage, but your after the raw figures rather than an impressive looking graph.

Running the following SQL against the master database will give you the recent information:

DECLARE @DatabaseName nvarchar(50);
SET @DatabaseName = 'databasename';

SELECT getdate() AS [Current Server Time];

SELECT start_time AS [Start of Period],
end_time AS [End of Period],
active_session_count AS [Sessions At End of Period],
avg_cpu_percent AS [Average CPU Usage %],
avg_physical_data_read_percent AS [Average Log Reads %],
avg_log_write_percent AS [Average Log Writes %]
FROM sys.resource_stats

WHERE start_time > DATEADD(minute, -240, GETDATE()) AND database_name = @DatabaseName
Order By start_time DESC;

Here’s an example of the results:
Azure SQL Database Processor Usage

Remote Vulnerability in BASH

There’s been a report of a new code injection attack in Linux, using environment variables. In order to test to see if your system is vulnerable, run the following code from SSH:

env x='() { :;}; echo vulnerable' bash -c "echo this is a test"

If your OK, you should get something like this:
env x='() { :;}; echo vulnerable' bash -c "echo this is a test"
bash: warning: x: ignoring function definition attempt
bash: error importing function definition for `x'
this is a test

If not, you will get something like this:
env x='() { :;}; echo vulnerable' bash -c "echo this is a test"
vulnerable
this is a test

BASH Screenshot

If vulnerable, it’s recommended to patch the BASH installation.

Further Information

Common SQL Queries

Frequently I use SQL with the work I do with Orbis Taskcentre.

There’s some queries which I use quite a lot and have to always look up on the internet or work out how to do, so to save time, here’s my list:

Date Part of Date Time
DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE()))

First Day of This Month
DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()), 0)

First Day of Last Month
DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()) - 1, 0)

First Day of Next Month
DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()) + 1, 0)

Last Day of Current Month
DATEADD(DAY, -(DAY(DATEADD(MONTH, 1, GETDATE()))),DATEADD(MONTH, 1, GETDATE()))

Last Day of Last Month
DATEADD(DAY, -(DAY(GETDATE())), GETDATE())

Last Day of Next Month
DATEADD(DAY, -(DAY(DATEADD(MONTH,0,GETDATE()))),DATEADD(MONTH, 2, GETDATE()))

Select Text Before Space
This also checks to see if a space exists, if there’s no space it returns the full text in order to prevent an error
LEFT(@Column, CASE WHEN charindex(' ', @Column) = 0 THEN LEN(@Column) ELSE charindex(' ', @Column) - 1 END)

Count Workdays Between Two Dates
(DATEDIFF(dd, @StartDate, @EndDate) + 1)-(DATEDIFF(wk, @StartDate, @EndDate) * 2)-(CASE WHEN DATENAME(dw, @StartDate) = 'Sunday' THEN 1 ELSE 0 END)-(CASE WHEN DATENAME(dw, @EndDate) = 'Saturday' THEN 1 ELSE 0 END)