trying to find problem in cgi/status.c

John Warburton j.warburton at unsw.edu.au
Thu Mar 3 10:37:50 CET 2005


Hi All

I am running Nagios 2 beta - CVS snapshot Feb 24 19:47 2005 on Solaris 8.

I have a problem where my host detail and status map options in the left 
frame will die with a segmentation fault after displaying some of my 
hosts. The number of hosts depends on the sort options.

Note that the "service detail" option will display *all* hosts and *all* 
services. Weird.

I am guessing I am hitting some sort of problem, where the code expects 
to see something in memory, but it is not there. I think it may be in my 
hosts definition, but I have 25 hosts defined so not sure if I have a 
typo in any of the definitions.

Each entry basically looks like:
define host{
         host_name                       nemesis
         alias                           db server
         address                         1.2.3.4
         check_command                   check-host-alive
         max_check_attempts              5
         contact_groups                  nagios-admins
         notification_interval           30
         notification_period             24x7
         notification_options            d,u,r
         }

Some hosts (not all) have partially filled out hostextinfo entries:
define hostextinfo{
         host_name                       thunderbird
         notes                           IMAP/POP3 Server
         notes_url                       URL
         action_url                      URL
         icon_image                      sun/ppserve450-68sm.jpg
         icon_image_alt                  Sun E450 Server
         }

I can run the status CGI from the command line:
export REMOTE_USER=userid
export REQUEST_METHOD=GET
export QUERY_STRING='hostgroup=all&style=hostdetail&sorttype=2&sortoption=4'

$ pwd
/usr/local/nagios/src/nagios-cvs/cgi

$ /usr/local/bin/gdb  ./status.cgi
(gdb) run
Starting program: /usr/local/nagios/src/nagios-cvs/cgi/status.cgi
Cache-Control: no-store
Pragma: no-cache
Refresh: 90
Last-Modified: Thu, 03 Mar 2005 09:31:51 GMT
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-type: text/html

<html>
<head>
<title>
Current Network Status
.
.
.
.
<TD CLASS='statusEven' nowrap>17d  1h 35m 54s</TD>

Program received signal SIGSEGV, Segmentation fault.
0xff2b3218 in strlen () from /lib/libc.so.1

(gdb) where
#0  0xff2b3218 in strlen () from /lib/libc.so.1
#1  0xff306530 in _doprnt () from /lib/libc.so.1
#2  0xff3081d0 in printf () from /lib/libc.so.1
#3  0x0001a35c in show_host_detail () at status.c:2089

I am now at my limit in C and gdb, so was wondering if anyone had any 
pointers as to how I debug the code to find out what the problem is? ie 
how can I see the contents of the memory, and what the variables are set at?

Thanks

John


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click




More information about the Developers mailing list