Prefetch Technologies // Keeping your cache lines cozy

Archive

Posts from 2005

Using awk functions

shellNov 16, 2005 1 min read

I am a huge fan of awk, and find myself constantly using it to parse simple data steams. awk contains numerous string-related functions, which are an invaluable resource for awk script developers. To illustrate some of the cool awk functions, I created a single-line text file with the string "String of string": To get the length of each line in the file text, the length() function can be used: To see if the string "ing" is present in the file text, the index() function can be used: index() will return the location of the first occurrence of "ing," which can then be used to facilitate further string processing. To retrieve a range of characters in a string, a beginning and ending offset can be passed to the awk substr() function: And finally, to tokenize (split a line into word-length pieces) a string, the split() function can be used: I dig awk!

$ read more →

Defragmenting VxFS file systems

storageNov 13, 2005 2 min

I came across Scott Kaiser's defrag.plscript a while back, and have found it useful for determining if the VxFS free extent map is fragmented. The script takes a file system as an option, and prints a one-line string to indicate if the file system should be defragmented: If the script determines that the free extent map (the script doesn't report on directory entry fragmentation) is fragmented, you can perform an online defragmentation by invoking fsadm with the "-e" (reorganize extents) and "-d" (reorganize directory entries) options: I prefer to avoid fragmentation, and try to preallocate all files to avoid this issue (for dynamic applications this isn't always possible). For further information please refer to the fsadm_vxfs(1m) manual page.

$ read more →

Converting an rc script to an SMF manifest

solarisNov 12, 2005 2 min

I use the ORCA utility to graph various system and application metrics, and have recently run into a few problems. The application periodically crashes for no apparaent reason, and I haven't had time to debug the issue (once I get a core file I will figure this out). Since I rely on the graphs to trend server and application capacity, I want to ensure that the application gets restarted each time a failure occurs. Since ORCA is running on a Solaris 10 server, I decided to convert the existing start/stop scripts to Solaris 10 SMF manifests…

$ read more →

Grabbing Apache versions with DTrace

dtraceNov 9, 2005 1 min

While messing around with DTrace, I devised a way to extract the Apache version with a simple DTrace script (this of course can be acquired with telnet and netcat, but it's fun doing things with DTrace): This example utilizes the pid provider to catch returns from ap_get_server_version, and prints the function return value as a string (the return value is a pointer to a global variable named server_version, which contains the token definition from the ServerTokens command). I looooooooooooooves me some DTrace!

$ read more →

Exporting Solaris zone configurations

virtualizationNov 9, 2005 1 min

I have been using Solaris 10 zone technology for the past 4 - 5 months, and just recently came across the zonecfg(am) "export" option. This option allows you to export the configuration from a specific zone, which can be used to recreate zones, or as a template when adding additional zones (with some adjustments of course). The following example prints the zone configuration for a domain called "irc": This is super useful, and can make creating 1000s of zones a snap!

$ read more →