[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [hobbit] Integrating Hobbit with Ticketing system(s) / Feature Request
- To: hobbit (at) hswn.dk
- Subject: Re: [hobbit] Integrating Hobbit with Ticketing system(s) / Feature Request
- From: Henrik Stoerner <henrik (at) hswn.dk>
- Date: Mon, 14 Jan 2008 22:14:33 +0100
- References: <478B9654.2030801 (at) cisco.com>
- User-agent: Mutt/1.5.15+20070412 (2007-04-11)
On Mon, Jan 14, 2008 at 10:05:24AM -0700, Charles Jones wrote:
> However, in going over the code in my head (I havn't written it yet), I see
> a problem. I believe that Hobbit is different from BB in that recovery
> pages are not sent with an ID (and I think if you forced it with a script
> the ID is "-1") which makes it impossible to relate them to the origional
> alert. Is there any simple way that we could have access to this ID
> number, or does Hobbit simply not track it?
Hobbit doesn't track it. The core Hobbit services only knows about hosts
and services - alert handling is a separate utility, and is done
entirely within the hobbitd_alert module. And there is no interface into
the innards of hobbitd_alert.
I can see that some way of identifying an alert - both initially, when the
alert is repeated, and when the issue ends - could be useful, especially
for the task you've taken to integrate it with ticketing systems. The
only unique identity of an event is the combination of
hostname+testname+eventstarttime - this is also persistent throughout
the life of an incident.
So how about stuffing all of this into an MD5 hash value, and use that
as the event ID ?
Patch attached ... applies against the current snapshot, but it can
easily be retrofitted onto the 4.2.0 code.
Regards,
Henrik
--- hobbitd/do_alert.c 2008/01/11 13:11:07 1.101
+++ hobbitd/do_alert.c 2008/01/14 20:58:34
@@ -50,6 +50,32 @@
int include_configid = 0; /* Whether to include the configuration file linenumber in alerts */
int testonly = 0; /* Test mode, dont actually send out alerts */
+/*
+ * This generates a unique ID for an event.
+ * The ID is an MD5 hash of the hostname, testname and the
+ * event start-time.
+ */
+static char *make_alertid(char *hostname, char *testname, time_t eventstart)
+{
+ static char result[33];
+ unsigned char id[16];
+ char *key;
+ void *md5handle;
+ int i, j;
+
+ key = (char *)malloc(strlen(hostname)+strlen(testname)+15);
+ sprintf(key, "%s|%s|%d", hostname, testname, (int)eventstart);
+
+ md5handle = (void *)malloc(myMD5_Size());
+ myMD5_Init(md5handle);
+ myMD5_Update(md5handle, key, strlen(key));
+ myMD5_Final(id, md5handle);
+
+ for (i=0, j=0; (i < 16); i++, j+=2) sprintf(result+j, "%02x", id[i]);
+ result[32] = '\0';
+ return result;
+}
+
static int servicecode(char *testname)
{
/*
@@ -426,6 +452,7 @@
char *p;
int ip1=0, ip2=0, ip3=0, ip4=0;
char *bbalphamsg, *ackcode, *rcpt, *bbhostname, *bbhostsvc, *bbhostsvccommas, *bbnumeric, *machip, *bbsvcname, *bbsvcnum, *bbcolorlevel, *recovered, *downsecs, *eventtstamp, *downsecsmsg, *cfidtxt;
+ char *alertid, *alertidenv;
int msglen;
cfidtxt = (char *)malloc(strlen("CFID=") + 10);
@@ -509,6 +536,11 @@
}
putenv(downsecsmsg);
+ alertid = make_alertid(alert->hostname, alert->testname, alert->eventstart);
+ alertidenv = (char *)malloc(strlen("ALERTID=") + strlen(alertid) + 10);
+ sprintf(alertidenv, "ALERTID=%s", alertid);
+ putenv(alertidenv);
+
hinfo = hostinfo(alert->hostname);
if (hinfo) {
enum bbh_item_t walk;