Posted in February 20, 2012 ¬ 1:16 pmh.Colin Millar
We were finding that one of the Ubuntu Linux 10.04LTS VMs on one of our VMware ESXi 4 hosts was locking up completely on an almost regular basis after about between 24 and 48 hours, with no obvious cause. We couldn’t see any errors logged anywhere, but did manage to catch this error message: “BUG: soft lockup – CPU#0 stuck for XXXs! [apache:processID]“.
We think we’ve found the root cause of this which is that Ubuntu’s ACPI support is a bit flaky, at least when running in a VM on ESXi 4. So, to fix it (fingers crossed, it looks like it’s fixed), we did the following to disable ACPI support:
- Log in via terminal to the Ubuntu server in question
- Execute the following command:
sudo vi /etc/default/grub
- Find the line which contains the GRUB_CMDLINE_LINUX_DEFAULT entry – mine had a value of “quiet” only in it.
- Add
"pci=noacpi acpi=off noapic" to this line so that it looks like this: GRUB_CMDLINE_LINUX_DEFAULT="quiet pci=noacpi acpi=off noapic"
- Save the changes to the file
- Execute the following command:
sudo update-grub
- Restart the server with:
sudo shutdown now -r
Hope this works for you as well as it works for me.
Posted in February 12, 2011 ¬ 2:49 pmh.Colin Millar
Windows Server 2008 R2 running on VMware ESXi is quick, until you decide to use vSphere’s Console view to try and do something, at which point it’s utterly, painfully, slow over a WAN. Remote Desktop works just fine, but you don’t always want that to be opened up from just anywhere.
Anyway, here’s how to cure it (no idea why the VMware Tools don’t do this automatically):
- Make sure that VMware Tools are installed and up to date
- Click Start -> Right-click Computer -> Click Manage
- Select Diagnostics -> Device Manager and expand “Display Adapters”. If it says “Standard VGA Graphics Adapter” then that’s why it’s incredibly slow. You need to manually update this to the VMware display driver…
- Right-click “Standard VGA Graphics Adapter” and select “Update Driver Software…”
- Select “Browse my computer for driver software”, and select “C:\Program Files\Common Files\VMware\Drivers\wddm_video”. Click OK.
- Click Next
- Click Close.
- Reboot whem prompted.
And voila! You should now get MUCH better performance from the vSphere client console view.
More info available here: Troubleshooting SVGA drivers installed with VMware Tools on Windows 7 and Windows 2008 R2 running on ESX 4.0.
Posted in December 3, 2010 ¬ 11:40 amh.Colin Millar
When trying to import a CSV file into a database using the “Import Data” SSIS option in SQL Server Management Studio I kept getting this error:
“Text was truncated or one or more characters had no match in the target code page.”
This was driving me nuts – such a simple thing to do and the tool failed each time. Turns out that, for whatever reason, and despite the data import wizard realising the target table has enough room in the columns, that you have to click on the Advanced tab and say what the size of the destination table columns are going to be (this is before you have selected the destination of course).

Once you’ve done this the import should now work perfectly.
You would have thought by now that Microsoft would have made this a bit more intelligent by now…
Posted in November 30, 2010 ¬ 9:44 amh.Colin Millar
To encrypt, open a command prompt and type this:
c:\windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -pef "appSettings" "c:\inetpub\wwwroot\FOLDER_CONTAINING_WEB.CONFIG"
and to reverse this, type this:
c:\windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -pdf "appSettings" "c:\inetpub\wwwroot\FOLDER_CONTAINING_WEB.CONFIG"
The key things to remember when typing this out are…
- Remember to include the “appSettings” bit.
- Remember to reference only the FOLDER containing the web.config tool – don’t reference the web.config file itself or you’ll get an error!
Posted in August 26, 2010 ¬ 9:45 amh.Colin Millar
The following table provides rough calculations of point sizes to “em”s to font percentage sizes.
Pixels EMs Percent Points
6px 0.462em 46.2% 5pt
7px 0.538em 53.8% 5pt
8px 0.615em 61.5% 6pt
9px 0.692em 69.2% 7pt
10px 0.769em 77% 8pt
11px 0.846em 85% 8pt
12px 0.923em 93% 9pt
13px 1em 100% 10pt
14px 1.077em 108% 11pt
15px 1.154em 116% 11pt
16px 1.231em 123.1% 12pt
17px 1.308em 131% 13pt
18px 1.385em 138.5% 14pt
19px 1.462em 146.5% 14pt
20px 1.538em 153.9% 15pt
21px 1.615em 161.6% 16pt
22px 1.692em 167% 17pt
23px 1.769em 174% 17pt
24px 1.846em 182% 18pt
Posted in April 22, 2010 ¬ 3:32 pmh.Colin Millar
For one of our new web hosting clients, I had to create several hundred local Windows accounts on a server (wouldn’t recommend it normally, but that’s how they worked). This is the VBScript that I wrote to take a CSV file of users, and create all of the users, adding them to a specific local user group:
Instructions
- Create a CSV file with each line in the form username,password,Full Name
- Change the variables at the start of the script (first three lines) as appropriate
- Run the script with cscript.exe scriptname.vbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
| Const ComputerName = "My Server Name" ' Change this to whatever your computer name is
Const GroupName = "My User Group" ' Change this to whatever group you want to add users to
Const CsvFilename = "c:\temp\userlist.csv" ' Change this to wherever you store your user list
Const ForReading = 1
Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000
Const ADS_UF_PASSWD_CANT_CHANGE = &H0040
' Open CSV File and Call CreateUser for each line in file
sub CreateUsers
set objfs = CreateObject("Scripting.FileSystemObject")
set fs = objfs.OpenTextFile(CsvFilename, ForReading)
Do while NOT fs.AtEndOfStream
arrStr = split(fs.ReadLine,",")
If arrStr(0) <> "" Then
strUsername = arrStr(0)
strPassword = arrStr(1)
strName = arrStr(2)
CreateUser strUsername, strPassword, strName
End If
Loop
fs.Close
end sub
' Create User, Set flags and add to Group
sub CreateUser(strUser, strPass, strName)
Set colAccounts = GetObject("WinNT://" & ComputerName & "")
Set objUser = colAccounts.Create("user", strUser)
objUser.Put "FullName", strName
' objUser.Put "PasswordExpired", CLng(1) ' Force user to change password at first login
objUser.SetPassword strPass
objUser.SetInfo
objUserFlags = objUser.Get("UserFlags")
objPasswordExpirationFlag = objUserFlags OR ADS_UF_DONT_EXPIRE_PASSWD OR ADS_UF_PASSWD_CANT_CHANGE ' Comment out this line and the next line if using the PasswordExpired option above
objUser.Put "userFlags", objPasswordExpirationFlag
objUser.SetInfo
Set objGroup = GetObject("WinNT://" & ComputerName & “/” & GroupName)
objGroup.Add(objUser.ADsPath)
wscript.echo("Created user '" & strUser & "' with password '" & strPass & "'")
end sub
'Go forth and create!
CreateUsers |
Posted in March 11, 2010 ¬ 3:25 pmh.Colin Millar
Needed this for a survey where users were able to enter a number or the string “na”. Regular expression is as follows:
To allow “NA” or Positive Whole number: ^(na|NA|Na)$|^\d+$
To allow “NA” or optional Positive Fractional Number: ^(na|NA|Na)$|^\d+(\.\d+)?$
Posted in January 31, 2010 ¬ 1:13 amh.Colin Millar
Retrieve data from a SQL Server database which looks up information based on cells in an Excel spreadsheet is very useful, and can be done fairly simply:
1. Open your Excel spreadsheet (instructions based on Excel 2007)
2. Hit Alt-F11 to open up a Visual Basic script window.
3. Select menu item Insert -> Module and click on the newly created “Module1″ module.
4. Select menu item Tools -> References and add a reference to “Microsoft ActiveX Data Objects 2.8 Library” (or a previous version which should be OK too).
5. Add in code like the following:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| Function GetSupplierId(cell As Range)
Dim supplierName As String
supplierName = cell.Text
Dim conn As New ADODB.Connection
Dim rs As ADODB.Recordset
conn.Open ("Provider=sqloledb;Data Source=MyDatabaseServer;Initial Catalog=MyDatabaseName;Integrated Security=SSPI")
Set rs = conn.Execute("select SupplierId from Supplier where SupName = '" & Replace(supplierName, "'", "''") & "'")
GetSupplierId = rs.Fields(0).Value
rs.Close
conn.Close
Set conn = Nothing
Set rs = Nothing
End Function |
Obviously your function will differ to this function, but the basics are the same – take input from a cell in the Excel spreadsheet, use this as part of a SQL query, and return the results to Excel from SQL Server.
Now close the Visual Basic window, and you can now use your custom function as you would any other function. In the example above, you could use an Excel function of “=GetSupplierId(D7)” to take the value stored in cell D7 (e.g. “Acme Corp”), lookup this supplier name in SQL Server, and return the Supplier ID (e.g. “ACM-01″).
Posted in December 4, 2009 ¬ 11:16 amh.Colin Millar
Symptoms: searches in WSS 3 produce no results.
Whilst there are a number of reasons that these errors could occur, one of the reasons may be that the default zone (which must be Windows authenticated) may be hidden from the search crawler due to the Windows Loopback Check security feature. Disable the Loopback check security feature and content will suddenly become searchable again.
Errors:
- The start address cannot be crawled
- and The update cannot be started because the content sources cannot be accessed. Fix the errors and try the update again.
Both of these errors will be fixed by disabling this loopback check.
Posted in October 26, 2009 ¬ 11:21 amh.Colin Millar
Here is a quick example of how to create a GZipped Tar file using only C#. This tutorial utilises the excellent SharpZipLib library to create the tar and gzip it:
-
First, you need to download the SharpZipLib library provides the ability to create Tar files.
- Then you need to add a reference to the ICSharpCode.SharpZipLib.dll
- Then you need to add a using clause to include the GZip and Tar namespaces:
1
2
3
| using System.IO;
using ICSharpCode.SharpZipLib.Tar;
using ICSharpCode.SharpZipLib.GZip; |
Finally, you can call the following “CreateTar” method (from a button click or whatever event should trigger the creation of your new tar file) to generate your gzipped, tar file using only C# code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
| /// <summary>
/// Creates a GZipped Tar file from a source directory
/// </summary>
/// <param name="outputTarFilename">Output .tar.gz file</param>
/// <param name="sourceDirectory">Input directory containing files to be added to GZipped tar archive</param>
private void CreateTar(string outputTarFilename, string sourceDirectory)
{
using (FileStream fs = new FileStream(outputTarFilename, FileMode.Create, FileAccess.Write, FileShare.None))
using (Stream gzipStream = new GZipOutputStream(fs))
using (TarArchive tarArchive = TarArchive.CreateOutputTarArchive(gzipStream))
{
AddDirectoryFilesToTar(tarArchive, sourceDirectory, true);
}
}
/// <summary>
/// Recursively adds folders and files to archive
/// </summary>
/// <param name="tarArchive"></param>
/// <param name="sourceDirectory"></param>
/// <param name="recurse"></param>
private void AddDirectoryFilesToTar(TarArchive tarArchive, string sourceDirectory, bool recurse)
{
// Recursively add sub-folders
if (recurse)
{
string[] directories = Directory.GetDirectories(sourceDirectory);
foreach (string directory in directories)
AddDirectoryFilesToTar(tarArchive, directory, recurse);
}
// Add files
string[] filenames = Directory.GetFiles(sourceDirectory);
foreach (string filename in filenames)
{
TarEntry tarEntry = TarEntry.CreateEntryFromFile(filename);
tarArchive.WriteEntry(tarEntry, true);
}
} |
Voila – a gzipped, tar file!