in reply to Character Length Requirement & String Conversion

When you say "characters" what do you mean? Bytes or unicode code points? Does "Αλφαβετ" count as seven characters or as 14? If we're truly talking about characters, and not just bytes, then defining some sort of base-65536 encoding would probably be feasible, and you might be able to pack 80 or so ASCII characters into a 19 character unicode string. Not an especially attractive solution.

Do you need to be able to reverse the encoding - i.e. expand the encoded string back to the URL? If not, then a digest function such as MD5 should be adequate. Digest::MD5's md5_base64 function is 22 characters. As you are only using it as an identifier, there should be no harm in simply stripping off the final three characters.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
  • Comment on Re: Character Length Requirement & String Conversion

Replies are listed 'Best First'.
Re^2: Character Length Requirement & String Conversion
by bpthatsme (Novice) on Mar 13, 2012 at 01:20 UTC

    Thanks again for the responses.

    Reverse conversion is not a major requirement. We have approximately 20 of these request strings to convert per jmeter test, with approximately 20 tests total.

    The unfortunate scenario is that RRDTool can only use 19 characters for a ds name and our nagios implementation is leaning on RRDTool solely.

    Rather than reinventing the wheel, this is more of a last ditch approach to assigning a static unique identifier to each HTTP request. I will likely add a command line argument to print out the preconverted strings for debugging purposes.

    I suppose it is worth asking if anyone is familiar with a way to assign a unique ID to each request via jmeter, but that really is a rabbithole we probably should avoid... :)

    -BP-

Re^2: Character Length Requirement & String Conversion
by bpthatsme (Novice) on Mar 13, 2012 at 01:25 UTC

    Forgive me, I failed to include that the 19 characters must be alphanumeric.

    -BP-