Archive for February, 2008

Presenting ring_logger v0.1

Monday, February 25th, 2008

 Ring logger

This weekend, I had an urge to catch up on one of the umpteen projects that I’d like to start, so I attacked a ring logger.

Basically, a ring logger, keeps the log messages in a ring buffer, which can be dumped when interesting circumstances arrise.

The particularité of this one is that it’s pure javascript, and dumps as a ‘POST’ request to a url. This allows for much improved debugging of js-rich web pages, whilst not filling up the web browsers memory with useless logs.

It depends on ToutouJS but doesn’t have a lot of calls, so it should be easilly portable if anyone finds the need.

 Usage

First off, you have to include the relevent files:

<script src="js/toutou/toutou.js" type="text/javascript"></script>
<script src="ring_log.js" type="text/javascript"></script>

Then you just log away (the mores the better):

js.ring_log.log(js.ring_log.DEBUG,'Test','Test message');

Finally, to retrieve your log, ie dump the buffer:

js.ring_log.dump();

Et voila!

For testing purposes, the logger is pre-configured to call a script log.php in the same directory as it is in, and has a buffer size of 10, both parameters changeable in the source. The different parts of the log messages are seperated by a ’splitter’, by default ‘==|==’, this is also configurable.

js.ring_log.requestUri='log.php';
js.ring_log.log_data_size=10;
js.ring_log.splitter='==|==';

And that’s just about it, hope you find it usefull :)

Update: forgot to add the .tgz, oups :$

Zabbix

Thursday, February 7th, 2008

Sometimes things that seem completely harmless just come and hit you over the head…

That’s what happened to me with Zabbix yesterday. I was going through some items and cleaning up, when suddenly, 4 hosts went off-line. Except that they hadn’t.

I couldn’t understand why Zabbix refused to see them (the agents were responding fine).

I finally found out that it was because of the way that Zabbix calculates the ’status’ item, which has a value of 0 if alls well, and 2 if the host is off-line.

Zabbix looks at the first item to be taken of the host, if that item returns an empty string, Zabbix decides that the host is dead and raises the alarm, even if the host has 150 other items all working perfectly. This bizzar to say the least, but workable. If this happens, a quick fix is to deactivate the offending Item, so that the first Item checked returns a value, then the host comes back :)

Any how, I thought I’d just document this in case anyone else starts loosing hair over the issue :)