[rt-users] Nagios and RT Integration

Kevin Falcone falcone at bestpractical.com
Mon Aug 23 15:40:42 EDT 2010


On Mon, Aug 23, 2010 at 04:50:04PM +0200, Ingo.Itter at ages.de wrote:
>    Hello,
> 
>    i tryed to implement the Hack from Evan into the C Source of then Nagios cmd.c File described
>    in the Thread http://www.gossamer-threads.com/lists/rt/users/45186#45186

Have you seen
http://search.cpan.org/~sunnavy/RT-Extension-Nagios-0.02/

It may be easier to try if you don't have C knowledge.

-kevin

>    I have  only a little knowledge of C , so i became a compiler Error.
> 
>    gcc -g -O2 -DHAVE_CONFIG_H -DNSCGI  -o cmd.cgi cmd.c extcmd_list.o getcgi.o cgiutils.o
>    cgiauth.o macros-cgi.o skiplist.o  objects-cgi.o xobjects-cgi.o statusdata-cgi.o
>    xstatusdata-cgi.o comments-cgi.o downtime-cgi.o
>    cmd.c: In function `make_ticket':
>    cmd.c:325: error: lvalue required as left operand of assignment
>    cmd.c:329: warning: passing argument 1 of `fgets' from incompatible pointer type
>    cmd.c:330: warning: passing argument 1 of `sprintf' from incompatible pointer type
>    cmd.c: In function `request_command_data':
>    cmd.c:1031: warning: passing argument 1 of `sprintf' from incompatible pointer type
>    cmd.c:1032: warning: passing argument 1 of `sprintf' from incompatible pointer type
>    cmd.c:1033: warning: passing argument 2 of `make_ticket' from incompatible pointer type
>    cmd.c:1033: warning: passing argument 3 of `make_ticket' from incompatible pointer type
>    cmd.c:1033: warning: passing argument 4 of `make_ticket' from incompatible pointer type
>    cmd.c:1035: warning: passing argument 1 of `strtok' from incompatible pointer type
>    cmd.c:1035: error: lvalue required as left operand of assignment
>    cmd.c:1036: error: lvalue required as left operand of assignment
>    cmd.c:1037: error: lvalue required as left operand of assignment
>    cmd.c:1038: warning: passing argument 1 of `sprintf' from incompatible pointer type
>    cmd.c:1039: warning: passing argument 1 of `sprintf' from incompatible pointer type
>    cmd.c:1040: warning: passing argument 1 of `snprintf' from incompatible pointer type
>    cmd.c:1044: warning: passing argument 1 of `snprintf' from incompatible pointer type
> 
>    Have anyone a correct cmd.c file for me, or have any suggestions ?
> 
>    Following Lines are added to the cmd.c file :
> 
>     104 int subject(char *);
>     105 int rt_comment(char *);
>     106 int temp_rt_ticket_num(char *);
>     107 int temp_rt_comment(char *);
>     108 int nagios_rt_comment(char *);
>     109 int temp_rt_ticket_num(char *);
>     110 int command_buffer(char *);
>     111 int current_time(char *);
>     112 int ticket_result(char *);
>     113 int result(char *);
> 
>     311 int make_ticket(char * username, char * subject, char * rt_comment, char * ticket_result)
>     312
>     313 {
>     314 char rt_command[300];
>     315 char owner[100];
>     316 FILE * temp_pipe;
>     317 char requestor[40];
>     318 sprintf (requestor, "%s [at] mycompany", owner);
>     319 sprintf (rt_command,"/opt/rt3/bin/rt create -t ticket set status=new subject='%s'
>    owner='%s' queue='Alarms' requestors='%s' adm
>         incc='supervisor [at] mycompany' priority='99'", subject,owner,requestor);
>     320
>     321 /* Create the ticket */
>     322 temp_pipe = popen(rt_command,"r");
>     323 if (!temp_pipe)
>     324 {
>     325 result = "Failed to create Ticket";
>     326 }
>     327 else
>     328 {
>     329 fgets(result, 300, temp_pipe);
>     330 sprintf (result, "%s", result);
>     331 }
>     332 }
> 
>    1027
>    1028 if (do_make_ticket)
>    1029 {
>    1030 /* create a ticket in request tracker */
>    1031 sprintf (subject, "Alarm for %s", host_name);
>    1032 sprintf (rt_comment, "%s", comment_data);
>    1033 make_ticket (current_authdata.username,subject,rt_comment, ticket_result);
>    1034 printf ("<CENTER><B>%s</B></CENTER><BR>\n",ticket_result);
>    1035 temp_rt_ticket_num = strtok (ticket_result," ");
>    1036 temp_rt_ticket_num = strtok (NULL," ");
>    1037 temp_rt_ticket_num = strtok (NULL," ");
>    1038 sprintf (temp_rt_comment," Ticket #%s acknowledged by %s",
>    temp_rt_ticket_num,current_authdata.username);
>    1039 sprintf (nagios_rt_comment, "%s %s", comment_data,temp_rt_comment);
>    1040
>    snprintf(command_buffer,sizeof(command_buffer)-1,"[%lu]ACKNOWLEDGE_HOST_PROBLEM;%s;%d;%d;%d;%s;%s\n",current_time,host_name,(st
> 
>     icky_ack==TRUE)?ACKNOWLEDGEMENT_STICKY:ACKNOWLEDGEMENT_NORMAL,(send_notification==TRUE)?1:0,(persistent_comment==TRUE)?1:0,comm
>         ent_author,nagios_rt_comment);
>    1041 }
>    1042 else
>    1043 {
>    1044
>    snprintf(command_buffer,sizeof(command_buffer)-1,"[%lu]ACKNOWLEDGE_HOST_PROBLEM;%s;%d;%d;%d;%s;%s\n",current_time,host_name,(st
> 
>     icky_ack==TRUE)?ACKNOWLEDGEMENT_STICKY:ACKNOWLEDGEMENT_NORMAL,(send_notification==TRUE)?1:0,(persistent_comment==TRUE)?1:0,comm
>         ent_author,comment_data);
>    1045 }
>    1046 break;
>    1047
> 
>    Thank you
> 
>    Greetings from Germany
>    Ingo von Itter
> 
>    _______________________________________________________________________
>    Gesch*ftsf*hrer: Rolf Herzog, Thomas Benk
>    AGES Maut System GmbH & Co. KG
>    AG D*sseldorf HRA 14045, USt-IdNr.: DE 202525868
>    AGES International GmbH & Co. KG
>    AG D*sseldorf HRA 16636, USt-IdNr.: DE 813749831
>    AGES ETS GmbH
>    AG D*sseldorf HRB 55580, USt-IdNr.: DE 814789134

> 
> RT Training in Washington DC, USA on Oct 25 & 26 2010
> Last one this year -- Learn how to get the most out of RT!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20100823/ff97e32f/attachment.sig>


More information about the rt-users mailing list