Newsletters



Sawmill Newsletter

January 17, 2012



Welcome to the Sawmill Newsletter!

You're receiving this newsletter because during the downloading or purchase of Sawmill, you checked the box to join our mailing list. If you wish to be removed from this list, please send an email, with the subject line of "UNSUBSCRIBE" to newsletter@sawmill.net (please include the entire message, as the identifying information is at the bottom).


News


Sawmill 8.5.5 is now available. This is the latest minor upgrade to Sawmill, improving reporting performance, adding some minor functionality, and fixing a few bugs. It is a free upgrade for Sawmill 8.5 users, and also a free upgrade for Sawmill 8.0/8.1 users (though your profiles and databases will need to be converted). You can download Sawmill 8.5.5 from http://sawmill.net/download.html . Please send your feedback about your experiences with Sawmill.

Sawmill 7 users can upgrade to Sawmill 8 for half of the license price; or if you have Premium Support, the upgrade is free. Major features of Sawmill 8 include support for Oracle and Microsoft SQL Server databases, a completely redesigned web interface, better multi-processor and multi-core support, and role-based authentication control.

This issue of the Sawmill Newsletter gives an example of generating daily scheduled reports to timestamped directories, so each new report doesn't overwrite the report from the day before.


Get The Most Out Of Sawmill With Professional Services

Looking to get more out of your statistics from Sawmill? Running short on time, but need the information now to make critical business decisions? Our Professional Service Experts are available for just this situation and many others. We will assist in the initial installation of Sawmill using best practices; work with you to integrate and configure Sawmill to generate reports in the shortest possible time. We will tailor Sawmill to your environment, create a customized solution, be sensitive to your requirements and stay focused on what your business needs are. We will show you areas of Sawmill you may not even be aware of, demonstrating many streamlined methods to get you the information more quickly. Often you'll find that Sawmill's deep analysis can even provide you with information you've been after but never knew how to reach, or possibly never realized was readily available in reports. Sawmill is an extremely powerful tool for your business, and most users only exercise a fraction of this power. That's where our experts really can make the difference. Our Sawmill experts have many years of experience with Sawmill and with a large cross section of devices and business sectors. Our promise is to very quickly come up with a cost effective solution that fits your business, and greatly expand your ROI with only a few hours of fee based Sawmill Professional Services. For more information, a quote, or to speak directly with a Professional services expert contact consulting@flowerfire.com.



Tips & Techniques: Generating Scheduled Reports To Timestamped Directories


The Sawmill Scheduler allows a variety of actions to be executed periodically, including database updates, and scheduled reports. (8.5.5 also adds an option to run an arbitrary command line from the Scheduler). A typical installation has a nightly database update of all changing profiles (profiles which have new log data generated each day), sometimes followed by a report generation. Reports can be emailed, or they can be generated to disk.

When reports are generated periodically to disk, the Schedule asks for a particular pathname to which the report should be written. If only yesterday's report is needed, that works fine, and each report overwrites the previous day's report. But to generate a series of historical reports to disk, they need to be rotated, or each written to a different location. Fortunately, Sawmill's Scheduler makes this possible, through the use of embedded Salang in the directory name.

Salang, the Sawmill language, is a full-featured scripting language which is used throughout Sawmill, for log filters, database filters, log format plug-ins, custom actions, snapons, and more (the entire web interface to Sawmill is written in Salang). In certain cases, Salang code can be embedded in a parameter value using the tokens {= and =}; it will be automatically evaluated, and the result inserted back into the position of the bracketed range. For instance, a value of "Hello {=1+1=} U" will be converted to "Hello 2 U", as the Salang expression 1+1 is evaluated to 2. One place this is supported, is in the "Output directory" option of the Scheduler page for "Generate report files." A Salang expression embedded in the filename can be used to create a different directory each day.

To create a schedule which generates timestamped reports, start in the Scheduler and click New Schedule. Enter a name like "Timestamped Daily Single-Page Summary" in the Name field, and click the pencil icon ([No action defined]) to define an action. Choose as the Action "Generate report files," the Profile, and the Report you want to generate (in this case, Single-page Summary). Then enter the expression in the Output directory. The screen shot below doesn't show the whole expression, but it's:

  {='/d/Sawmill Reports/' . replace_all(substr(epoc_to_local_date_time(now()), 0, 11), '/', '')=}

Here's what it looks like on the screen:




We'll examine the mechanics of that expression below. For now, click OK, choose a scheduled time, Save Changes, and you're done. Every night, it will generate reports to a directory with a name like:

  /d/Sawmill Reports/17Jan2012

You can test it right now, if you like, by clicking Run Now.

On Windows, there's one wrinkle: because backslashes are used as dividers in Windows, and also as escape characters in Salang, you need you use two backslashes any time you want a directory divider, like this:

  {='C:\\Sawmill Reports\\' . replace_all(substr(epoc_to_date_time(now()), 0, 11), '/', '')=}

which will give you reports in a directory with a name like:

  C:\\Sawmill Reports\\17Jan2012


Breaking Down The Expression

The complicated part of this process is the expression, so let's take a minute to look at how it works, working outward in layers from now().

1. "now()" returns the current time in EPOC format (seconds since January 1, 1970, UTC).
2. Working outward, "epoc_to_local_date_time(now())" returns the local time on the Sawmill server (not UTC) as a string, something like "17/Jan/2012 12:34:56".
3. Working outward, "substr(epoc_to_local_date_time(now()), 0, 11)" returns the first 11 characters of that, which will be "17/Jan/2012".
4. Working outward, "replace_all(substr(epoc_to_local_date_time(now()), 0, 11), '/', '')" removes all /s (replacing them with empty strings), yielding "17Jan2012". This isn't necessary on Windows, but on other platforms, those /s will become directory dividers, which you probably don't want.
5. Finally, "'/d/Sawmill Reports/' . replace_all(substr(epoc_to_local_date_time(now()), 0, 11), '/', '')" concatenates "/d/Sawmill Reports/" to the value computed, yielding the final pathname, "/d/Sawmill Reports/17Jan2012".


Advanced Applications


Since the code in the {==} section is Salang, it can do anything Salang can do, which is pretty much anything any programming language can do. Salang can call other programs, create and call subroutines, read information from files, make network connections (functionality for HTTP, HTTPS, and LDAP, in particular, are included in Sawmill's Salang libraries), etc. So the directory could name could be computed in any way, e.g., looking it up the profile name in a database server via an HTTP request, computing an LDAP DN from that, looking up the group with a query to an LDAP server, and using the group name in the directory name. The most common situation is just to embed a timestamp, but more advanced calculations are possible.

Also, the Subject of an emailed report can contain Salang in a {==} section, to timestamp the emailed report, or to include other information (date range of database, etc.).


Professional Services

This newsletter describes the use of Salang to generate scheduled reports to timestamped directories. If you need a different timestamp format than the one shown above, or a more advanced computed directory name, our Sawmill Experts can help. Contact consulting@sawmill.net for more information.



[Article revision v1.0]
[ClientID: 451828]