Aint Your Ruby
Author: John on November 18, 2014
When meeting new people in the programming community, we frequently share what we do in our day jobs. By day I primarily use Perl, though I have been slowly building up an arsenal of Ruby and Ruby on Rails applications. But before learning Matz's Ruby, I learned a different flavor of Ruby. And this 'aint your ruby.'
When I first transitioned to the team I am on now, my primary duties were to provide tier three support of specialized networking equipment. Our team can be split into two roles: Tech Support/Project Management and Automation/Programming. Over time, I migrated over to the Automation side. We use Perl for our tool server scripts and Ruby to get things started. Off to the internet I went to learn Ruby, only to quickly find that our Ruby was not the Ruby I found online.
The Ruby we use at work stands for: Rules yoU Build Yourself. I believe the foundation or underlaying language is Java.
In a nutshell, our networking equipment sends events/traps to a trap collector. That collector then does some processing on the event and forwards to our Ruby system. We then perform certain actions using our Ruby based on the received alarms/events. Below is a small example of code of 'our' Ruby:
// Ping failed to LoopBack interface. IP=
// Able to extract an IP Address
rule DI0780_0020
{
packet = DI0780;
when
{
?a: ModemsAlarm(isTypeNull() != 0;
isStringMatch(?a.getObject(), "^[a-z][a-z][a-z0-9][a-z][a-z][0-9][0-9]+(kvm|mve|rrs[0-9][0-9][a-z][a-z][a-z]*)") == False;
isStringMatch(?a.getService(), "ALPHA|BETA") !=0;
isNameMatch("Ping +failed +to +LoopBack .*IP=") != 0);
}
then
{
modify ?a
{
setType("DI0780_CiscoInterfaceDown");
setContainer("IP",?a.getToken("IP= *([0-9]+.[0-9]+.[0-9]+.[0-9]+)",?a.getAlarmText()));
setContainer("ROUTER_IFNAME","Loopback");
setContainer("DEVICE_NAME",?a.getToken("([a-z0-9]+).els-an.att.net",?a.getSource()));
setContainer("EVENT_CORELATION_NAME",?a.buildString2("%1 %2",?a.getContainer("DEVICE_NAME"),?a.getContainer("IP")));
putRubyLog2("DI0780_0020", ?a.buildString1("Received a Generic Ping fail to Loopback alarm, %1", ?a.getName()));
}
}
};
Pretty wild stuff, eh? This is just a short snippet - there is a lot more going on in our 'library' of packets and rules.
Learn Something New Every Day
Last Edited by: John on November 11, 2015