codejanitor

OCS Mac Agent 4.4 Released

Dec. 20th, 2007

There’s been some delay in getting this out the door, but hopefully the wait is worth it since we have a whole batch of improvements (nearly all of which come from John Schubert). So, what’s new in version 4.4 for OCS Inventory:

  • Support for 10.5
  • Fixed bug where not having Serial ATA or IDE drives caused the script to die
  • Better support for printers
  • Hostname can now be set using the hostname or the scutil tool. hostname is the default, but scutil uses the results from the dhcp server which can be better. Which tool is used can be set via the new GETNAME parameter in the ocsinv.conf file
  • Two new command line options: -n to force a hostname and -g to force either scutil or hostname to be used
  • Support for multiple video cards
  • Better detection of whether or not the script is being run by root
  • More intelligent way of waiting for the network card to come up before running.

Download it here

If you want to recreate the package yourself (i.e. so you can customize the host file) you can download the source, which can be opened in Package Maker, here

Questions? Check out the forum dedicated to OCS agents here

Filed under: Jason @ 12:47 pm

OCS Mac Agent 4.3 Released

Nov. 5th, 2007

It’s been awhile, but I’ve finally managed to get the next release of OCS Mac agent out the door. This release owes all its improvements to patches sent in by users — so thank you to all who contributed! What’s new in version 4.3 for OCS Inventory:

  • Better handling of foreign characters. By running the output through utf8_decode foreign characters in the descriptions of the inventory are better handled (Nicolas).
  • The hostname command now works even if you have fink installed (Tim).
  • SATA drives are correctly handled (Josh).
  • The output of the MONITORS section now gives more descriptive (Mark).
  • Pragma header is fixed which ensures that inventory results are not cached (Nicolas).

Download it here

If you want to recreate the package yourself (i.e. so you can customize the host file) you can download the source, which can be opened in Package Maker, here

Questions? Check out the forum dedicated to OCS agents here

Filed under: Jason @ 6:23 pm

Levenshtein Distance as a MySQL Stored Function

Feb. 10th, 2007

For a recent project I needed to dig into “fuzzy matching” to try and find duplicate names and addresses in a MySQL table. I decided using the Levenshtein Distance would be very useful for what I needed. I thought I was home free when I came across a Levenshtein U.D.F. (User Defined Function). However, my excitement was short lived when I discovered my MySQL database was going to be on a Windows server and that compiling U.D.F’s on Windows is quite the process. So, I decided to implement the Levenshtein algorithm using just SQL as a stored function. Obviously, it won’t be near so fast as the U.D.F. but it’s sure a lot easier to install on multiple Windows machines.

There are a few Levenshtein implementations for SQL out there, but I decided to use one I found written for SQL server. I chose it mostly because it uses a binary variable for creating the matrix instead of a temporary table (which, I think, would be quite a bit slower). Anyhow, I fixed a few bugs it had and spent too many hours figuring out how to convert it, but it’s done and it works (at least for all the tests I’ve thrown at it). The code for those interested:

CREATE FUNCTION LEVENSHTEIN (s1 VARCHAR(255), s2 VARCHAR(255))
  RETURNS INT
    DETERMINISTIC
      BEGIN
        DECLARE s1_len, s2_len, i, j, c, c_temp, cost INT;
        DECLARE s1_char CHAR;
        DECLARE cv0, cv1 VARBINARY(256);
        SET s1_len = CHAR_LENGTH(s1), s2_len = CHAR_LENGTH(s2), cv1 = 0x00, j = 1, i = 1, c = 0;
        IF s1 = s2 THEN
          RETURN 0;
        ELSEIF s1_len = 0 THEN
          RETURN s2_len;
        ELSEIF s2_len = 0 THEN
          RETURN s1_len;
        ELSE
          WHILE j <= s2_len DO
            SET cv1 = CONCAT(cv1, UNHEX(HEX(j))), j = j + 1;
          END WHILE;
          WHILE i <= s1_len DO
            SET s1_char = SUBSTRING(s1, i, 1), c = i, cv0 = UNHEX(HEX(i)), j = 1;
            WHILE j <= s2_len DO
                SET c = c + 1;
                IF s1_char = SUBSTRING(s2, j, 1) THEN SET cost = 0; ELSE SET cost = 1; END IF;
                SET c_temp = CONV(HEX(SUBSTRING(cv1, j, 1)), 16, 10) + cost;
                IF c > c_temp THEN SET c = c_temp; END IF;
                SET c_temp = CONV(HEX(SUBSTRING(cv1, j+1, 1)), 16, 10) + 1;
                IF c > c_temp THEN SET c = c_temp; END IF;
                SET cv0 = CONCAT(cv0, UNHEX(HEX(c))), j = j + 1;
            END WHILE;
            SET cv1 = cv0, i = i + 1;
          END WHILE;
        END IF;
        RETURN c;
      END

To note:

  • Maximum length of input strings is 255 characters. I’m sure you could edit the function to support more if needed.
  • I’ve tested it with international characters on a utf8_bin column and it seemed to work, but I’ve not tested that capability exstensively.
  • I’ve only tested it on MySQL 5.0+. No idea how it will work on versions less than that.

And as a bonus I also created a helper function that returns the ratio (as a percentage) of different : same characters which can be more helpful than just a straight edit distance (idea from here).

CREATE FUNCTION LEVENSHTEIN_RATIO (s1 VARCHAR(255), s2 VARCHAR(255))
  RETURNS INT
    DETERMINISTIC
      BEGIN
        DECLARE s1_len, s2_len, max_len INT;
        SET s1_len = LENGTH(s1), s2_len = LENGTH(s2);
        IF s1_len > s2_len THEN SET max_len = s1_len; ELSE SET max_len = s2_len; END IF;
        RETURN ROUND((1 - LEVENSHTEIN(s1, s2) / max_len) * 100);
      END

If anyone finds a bug or way to improve the functions I’d be happy to know!

Filed under: Jason @ 7:09 pm

OCS Mac Agent 4.2 Released

Sep. 1st, 2006

The fastest new release ever! Shortly after releasing 4.1 I got an email from a user with some good improvements. Thus, we have OCS Mac agent for OCS Inventory, version 4.2. This release adds the following features:

  • The script can now take an input file manually. Normally the agent uses System Profiler to generate an XML file with system info. Sometimes, however, a mac will refuse to generate the file or it will be corrupt. If that’s the case you can manually generate it from the command line and feed it the file with the -i switch.
  • No more PEAR dependencies! The script still uses PEAR libraries, but they are all included in the script. This solves the problem where some machines (for no apparent reason) came without PEAR installed.

Download it here

If you want to recreate the package yourself (i.e. so you can customize the host file) you can download the source, which can be opened in Package Maker, here

Questions? Check out the forum dedicated to OCS agents here

Filed under: Jason @ 2:27 pm

OCS Mac Agent 4.1 Released

Aug. 31st, 2006

Bug fix time. A new version of OCS Mac agent for OCS Inventory has been released, version 4.1. This is a bug fix release that makes OCS Mac Agent compatible with OCS Inventory RC3+.

Download it here

If you want to recreate the package yourself (i.e. so you can customize the host file) you can download the source, which can be opened in Package Maker, here

Questions?  Check out the forum dedicated to OCS agents here.

Filed under: Jason @ 12:39 pm

GUI Goodness! Version 3.4 of FastFrame & Apps Released

Jun. 23rd, 2006

The FastFrame team is proud to announce the release “GUI Goodness,” version 3.2 of FastFrame and its applications.

It’s certainly been awhile (over 8 months!) since the last release, but we’ve been hard at work fixing bugs and improving the user interface to make mayday, checkout, and other FastFrame applications easier and faster to use. A lot of the improvements came through adding AJAX and other javascript functionality to the main pages used by the different applications, which means less page loads and a smoother interface. However, these improvements did come at a small cost, older web browsers are no longer supported. You must have Safari 1.2+, Firefox 1+, IE6+, or Opera 8+ to use FastFrame now. If your user base is using older browsers you’ll need to upgrade them.

Please note: There is database incompatibility between 3.2 and 3.4. By running updatedb_32_to_34.php in the FastFrame/scripts/ directory you can upgrade your database without losing any data. See the upgrade docs for more information on upgrading.

Highlights of this release include:

FastFrame

  • IE loads faster because transparent PNG icons are no longer used
  • Support for AJAX

Mayday!

  • Comments can be added, deleted, and edited inline.
  • Multiple attachments can be added to a ticket at one time.
  • Comments can be added, deleted, and edited inline.
  • Comments are collapsed by default (gmail style!)
  • Assigning a mayday and changing priority can now be done from the summary page without a page reload.
  • The email interface is much more robust (people who are CC’d are added to the watchlist, emails that are sent high priority are marked as such in the mayday)

Checkout

  • Deleted reservations and completed loans can now be searched and displayed.
  • Added the ability to download borrower info in CSV format.
  • Shoppers can now see their demos and reddots via the My Profile page

Those are only the highlights, so head over to the download area to get them. Or, as always, you can check out the demo to give it a test run.

Filed under: Jason @ 11:03 am

AJAX, Safari, and Returning an HTTP Error Code

Mar. 30th, 2006

For my AJAX apps I decided to return a 500 error code if there was some sort of problem on the server side (e.g. user doesn’t have permissions, database error, etc.). That way my onFailure code will be called by prototype and the page will reset itself and let the user know what the problem was. In PHP it just requires a header(’HTTP/1.0 500 We Have a Problem Houston’); Even better is that, because the 500 status code is just a header, I can also pass back XML (i.e. with multiple error messages) if I want.

However, I ran into a problem when debugging this in Safari today. Even though I sent back the 500 status code the onSuccess function was being called in Safari. Alerting the request.status and request.getAllResponseHeaders() gave me “undefined.” After a bit of hunting I figured out that it only happend when my PHP script outputted nothing. The solution? Just have PHP print something (a space suffices) before exiting.

Filed under: Jason @ 6:15 pm

AJAX Timeouts with Prototype

Mar. 23rd, 2006

I’ve been implementing some AJAX goodness in Mayday and other FastFrame apps lately. In my reading of the various pitfalls of AJAX one that popped up repeatedly was how to handle gracefully a network outage or the webserver going down. For example, Gmail’s chat handles it nicely. When I turn off my airport connection Gmail chat lets me know that it can’t contact the server and maybe my connection is down. Much better than an endlessly spinning hour glass, or worse, not letting the user know their action was never completed.

Anyhow, after some research I found an excellent post over at the AJAX blog on a general solution to the problem of aborting an AJAX request after a specified amount of time. After a bit of munging I got it to work nicely with prototype, the javascript library of my choice (You may want to check out this Prototype reference if you don’t know how to use it). Here’s the code, commented to explain what’s going on:


function callInProgress (xmlhttp) {
switch (xmlhttp.readyState) {
case 1: case 2: case 3:
return true;
break;
// Case 4 and 0
default:
return false;
break;
}
}
function showFailureMessage() {
alert('uh oh, it looks like the network is down. Try again shortly');
}
// Register global responders that will occur on all AJAX requests
Ajax.Responders.register({
onCreate: function(request) {
request['timeoutId'] = window.setTimeout(
function() {
// If we have hit the timeout and the AJAX request is active, abort it and let the user know
if (callInProgress(request.transport)) {
request.transport.abort();
showFailureMessage();
// Run the onFailure method if we set one up when creating the AJAX object
if (request.options['onFailure']) {
request.options['onFailure'](request.transport, request.json);
}
}
},
5000 // Five seconds
);
},
onComplete: function(request) {
// Clear the timeout, the request completed ok
window.clearTimeout(request['timeoutId']);
}
});

Filed under: Jason @ 3:36 pm

OCS Mac Agent 4.0 Released

Feb. 16th, 2006

A new version of OCS Mac agent for OCS Inventory has been released. This is a complete rewrite of the agent so that it works with the new OCSInventory-NG. If you are still using OCS Inventory 3.0 you will need to use the old Mac agent.

  • This new version is written in PHP which comes with all OSX machines. You don’t need to install any additional software.
  • It only works with OSX 10.3+
  • To install, just download the DMG file and install the package. If your OCS communication server is named ocsinventory-ng it will work out of the box. If it is named something different you will need to edit the server in /etc/ocsinventory-client/ocsinv.conf
  • If you upload the agent to your OCS communication server then the script will upgrade itself whenever a new version is released.

Download it here

If you want to recreate the package yourself (i.e. so you can customize the host file) you can download the source, which can be opened in Package Maker, here

Filed under: Jason @ 12:44 pm

OCS Mac Agent 3.1 Released

Nov. 23rd, 2005

This version fixes the following:

  • The samba drive is no longer mounted which fixes a bug where the mounted drive would sometimes show up on the user’s desktop and they would have access to it.
  • The domain is detected correctly for Tiger machines.

Download it here

If you want to recreate the package yourself (i.e. so you can customize the samba username and password) you can download the source, which can be opened in Package Maker, here

Filed under: Jason @ 12:52 pm