I’ve recently decided to evaluate other shell’s and ran across one that looked interesting: fish.
You can read more about fish: here and here
Based on what I’ve seen I’ve decided to try it out. Before I dive in too deep with fish, does anyone have any opinions, caveats, issues to mention about it?
If I don’t like it I’ll keep trying out zsh but most likely end up back in bash :)
I recently found myself needing to test producing and consuming messages from activemq via stomp. It’s a pretty trivial task thanks to Perl and nagios! Here is a quick script to test the production and consumption of messages and the command you’ll need to put into core.cfg (nagios v2). It’s slim on libs to cut down on excess fat. Enjoy!
Prerequisites..
Class::Accessor (Net::Stomp wants it)
Net::Stomp
$USER3$ = custom location of nagios check scripts..
check_mq = the name of the script.
$ARG1$ = host to check
$ARG1$ = number of messages to produce/consume
$ARG2$ = name of queue to test with
The command for core.cfg:
define command{
command_name check_mq
command_line $USER3$/check_mq $ARG1$ $ARG2$ $ARG3$
}
The code:
#!/usr/bin/perl -w
use strict;
use Net::Stomp;
my $host = $ARGV[0];
my $nummsgs = $ARGV[1];
my $queue = $ARGV[2];
my $stomp = Net::Stomp->new( { hostname => $host, port => '61613' } );
$stomp->connect();
for (my $i=0; $i <$nummsgs; $i++) {
$stomp->send({ destination => "/queue/$queue",
body => "$queue$i",
persistent => 'true'} );
}
$stomp->subscribe({ destination => "/queue/$queue",
'ack' => 'client',
'activemq.prefetchSize' => 1});
my $count = 0;
for (my $i=0; $i <$nummsgs; $i++) {
my $frame = $stomp->receive_frame;
my $body = $frame->body;
if ($body eq "$queue$i") {
$count++;
}
$stomp->ack( { frame => $frame } );
}
$stomp->disconnect();
print "Produced: $nummsgs Consumed $count\n";
if ($count == $nummsgs) {
exit(0);
}
elsif (($count != $nummsgs) && ($count != 0)) {
exit(1);
}
elsif ($count == 0) {
exit(2);
}
Oh so simple..