Nagios CGI File is not working as Expected after the Upgrade

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Teja
Posts: 53
Joined: Tue Jun 13, 2017 8:13 am

Re: Nagios CGI File is not working as Expected after the Upg

Post by Teja »

Hi tgriep,
We use the XML data to check the Status of the hosts (Like to brief :- It shows for how long the host was up and when it when down).So,If you can share the related XML plugin it could be real help for me and i have gone through the link which you have posted and i wasn't able to find any of that kind. Thanks Much!!
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Nagios CGI File is not working as Expected after the Upg

Post by mcapra »

The only Nagios maintained "thing" (that I am aware of) that produces XML as part of the response body is NRDP, which definitely doesn't re-write the behaviors of CGIs. That page (/cgi-bin/status.cgi) should be producing structured HTML by default. Something like this:

Code: Select all

<html>
   <head>
      <link rel="shortcut icon" href="/nagios/images/favicon.ico" type="image/ico">
      <title>
         Current Network Status
      </title>
      <link rel='stylesheet' type='text/css' href='/nagios/stylesheets/common.css' />
      <link rel='stylesheet' type='text/css' href='/nagios/stylesheets/status.css' />
      <LINK REL='stylesheet' TYPE='text/css' HREF='/nagios/stylesheets/nag_funcs.css'>
      <script type='text/javascript' src='/nagios/js/jquery-1.7.1.min.js'></script>
      <script type='text/javascript' src='/nagios/js/nag_funcs.js'></script>
      <script type='text/javascript'>
         var vbox, vBoxId='status00', vboxText = '<a href=https://www.nagios.com/tours target=_blank>Click here to watch the entire Nagios Core 4 Tour!</a>';
         $(document).ready(function() {
         $('#top_page_numbers').append($('#bottom_page_numbers').html() );
         var user = 'nagiosadmin';
         vBoxId += ';' + user;vbox = new vidbox({pos:'lr',vidurl:'https://www.youtube.com/embed/ahDIJcbSEFM',text:vboxText,vidid:vBoxId});
         });
         function set_limit(url) { 
         this.location = url+'&limit='+$('#limit').val();
           }
      </script>
   </head>
   <body class='status'>
      <!-- Produced by Nagios (https://www.nagios.org).  Copyright (c) 1999-2007 Ethan Galstad. -->
      <table class='headertable'>
         <tr>
            <td align=left valign=top width=33%>
               <TABLE CLASS='infoBox' BORDER=1 CELLSPACING=0 CELLPADDING=0>
                  <TR>
                     <TD CLASS='infoBox'>
                        <DIV CLASS='infoBoxTitle'>Current Network Status</DIV>
                        Last Updated: Thu Jul 20 09:59:13 CDT 2017<BR>
                        Updated every 90 seconds<br>
                        Nagios® Core™ 4.3.2 - <A HREF='https://www.nagios.org' TARGET='_new' CLASS='homepageURL'>www.nagios.org</A><BR>
                        Logged in as <i>nagiosadmin</i><BR>
                     </TD>
                  </TR>
               </TABLE>
               <table class='linkBox'>
                  <tr>
                     <td class='linkBox'>
                        <a href='history.cgi?host=esprod00'>View History For This Host</a><br>
                        <a href='notifications.cgi?host=esprod00'>View Notifications For This Host</a>
                        <br /><a href='status.cgi?host=all'>View Service Status Detail For All Hosts</a>
                     </td>
                  </tr>
               </table>
            </td>
            <td align=center valign=top width=33%>
               <div class='hostTotals'>Host Status Totals</div>
               <table border=0 cellspacing=0 cellpadding=0>
                  <tr>
                     <td>
                        <table class='hostTotals'>
                           <tr>
                              <th class='hostTotals'><a class='hostTotals' href='status.cgi?host=esprod00&hoststatustypes=2'>Up</a></th>
                              <th class='hostTotals'><a class='hostTotals' href='status.cgi?host=esprod00&hoststatustypes=4'>Down</a></th>
                              <th class='hostTotals'><a class='hostTotals' href='status.cgi?host=esprod00&hoststatustypes=8'>Unreachable</a></th>
                              <th class='hostTotals'><a class='hostTotals' href='status.cgi?host=esprod00&hoststatustypes=1'>Pending</a></th>
                           </tr>
                           <tr>
                              <td class='hostTotals'>0</td>
                              <td class='hostTotalsDOWN'>1</td>
                              <td class='hostTotals'>0</td>
                              <td class='hostTotals'>0</td>
                           </tr>
                        </table>
                     </td>
                  </tr>
                  <tr>
                     <td align='center'>
                        <table class='hostTotals'>
                           <tr>
                              <th class='hostTotals'><a class='hostTotals' href='status.cgi?host=esprod00&hoststatustypes=12'><em>All Problems</em></a></th>
                              <th class='hostTotals'><a class='hostTotals' href='status.cgi?host=esprod00'><em>All Types</em></a></th>
                           </tr>
                           <tr>
                              <td class='hostTotalsPROBLEMS'>1</td>
                              <td class='hostTotals'>1</td>
                           </tr>
                        </table>
                     </td>
                  </tr>
               </table>
               </div>
            </td>
            <td align=center valign=top width=33%>
               <div class='serviceTotals'>Service Status Totals</div>
               <table border='0' cellspacing='0' cellpadding='0'>
                  <tr>
                     <td>
                        <table class='serviceTotals'>
                           <tr>
                              <th class='serviceTotals'><a class='serviceTotals' href='status.cgi?host=esprod00&servicestatustypes=2&hoststatustypes=15'>Ok</a></th>
                              <th class='serviceTotals'><a class='serviceTotals' href='status.cgi?host=esprod00&servicestatustypes=4&hoststatustypes=15'>Warning</a></th>
                              <th class='serviceTotals'><a class='serviceTotals' href='status.cgi?host=esprod00&servicestatustypes=8&hoststatustypes=15'>Unknown</a></th>
                              <th class='serviceTotals'><a class='serviceTotals' href='status.cgi?host=esprod00&servicestatustypes=16&hoststatustypes=15'>Critical</a></th>
                              <th class='serviceTotals'><a class='serviceTotals' href='status.cgi?host=esprod00&servicestatustypes=1&hoststatustypes=15'>Pending</a></th>
                           </tr>
                           <tr>
                              <td class='serviceTotalsOK'>4</td>
                              <td class='serviceTotals'>0</td>
                              <td class='serviceTotals'>0</td>
                              <td class='serviceTotalsCRITICAL'>1</td>
                              <td class='serviceTotals'>0</td>
                           </tr>
                        </table>
                     </td>
                  </tr>
                  <tr>
                     <td align='center'>
                        <table class='serviceTotals'>
                           <tr>
                              <th class='serviceTotals'><a class='serviceTotals' href='status.cgi?host=esprod00&servicestatustypes=28&hoststatustypes=15'><em>All Problems</em></a></th>
                              <th class='serviceTotals'><a class='serviceTotals' href='status.cgi?host=esprod00&hoststatustypes=15'><em>All Types</em></a></th>
                           </tr>
                           <tr>
                              <td class='serviceTotalsPROBLEMS'>1</td>
                              <td class='serviceTotals'>5</td>
                           </tr>
                        </table>
                     </td>
                  </tr>
               </table>
               </div>
            </td>
            <td align=right valign=bottom></td>
         </tr>
      </table>
      <table class='pageTitle' border='0' width='100%'>
         <tr>
            <td valign=top align=left width=33%></td>
            <td valign=top align=center width=33%>
               <div align='center' class='statusTitle'>Service Status Details For Host 'esprod00'</div>
               <br>
            </td>
            <td valign=top align=right width=33%></td>
         </tr>
      </table>
      <div id='pagelimit'>
         <div id='result_limit'>
            <label for='limit'>Limit Results: </label>
            <select onchange='set_limit("status.cgi?host=esprod00")' name='limit' id='limit'>
               <option  value='50'>50</option>
               <option selected='selected' value='100'>100</option>
               <option  value='250'>250</option>
               <option  value='1000'>1000</option>
               <option  value='0'>All</option>
            </select>
         </div>
         <div id='top_page_numbers'></div>
      </div>
      <table border=0 width=100% class='status'>
         <tr>
            <th class='status'>Host <a href='status.cgi?host=esprod00&sorttype=1&sortoption=1'><IMG SRC='/nagios/images/up.gif' border=0 ALT='Sort by host name (ascending)' TITLE='Sort by host name (ascending)'></a><a href='status.cgi?host=esprod00&sorttype=2&sortoption=1'><IMG SRC='/nagios/images/down.gif' border=0 ALT='Sort by host name (descending)' TITLE='Sort by host name (descending)'></a></th>
            <th class='status'>Service <a href='status.cgi?host=esprod00&sorttype=1&sortoption=2'><IMG SRC='/nagios/images/up.gif' border=0 ALT='Sort by service name (ascending)' TITLE='Sort by service name (ascending)'></a><a href='status.cgi?host=esprod00&sorttype=2&sortoption=2'><IMG SRC='/nagios/images/down.gif' border=0 ALT='Sort by service name (descending)' TITLE='Sort by service name (descending)'></a></th>
            <th class='status'>Status <a href='status.cgi?host=esprod00&sorttype=1&sortoption=3'><IMG SRC='/nagios/images/up.gif' border=0 ALT='Sort by service status (ascending)' TITLE='Sort by service status (ascending)'></a><a href='status.cgi?host=esprod00&sorttype=2&sortoption=3'><IMG SRC='/nagios/images/down.gif' border=0 ALT='Sort by service status (descending)' TITLE='Sort by service status (descending)'></a></th>
            <th class='status'>Last Check <a href='status.cgi?host=esprod00&sorttype=1&sortoption=4'><IMG SRC='/nagios/images/up.gif' border=0 ALT='Sort by last check time (ascending)' TITLE='Sort by last check time (ascending)'></a><a href='status.cgi?host=esprod00&sorttype=2&sortoption=4'><IMG SRC='/nagios/images/down.gif' border=0 ALT='Sort by last check time (descending)' TITLE='Sort by last check time (descending)'></a></th>
            <th class='status'>Duration <a href='status.cgi?host=esprod00&sorttype=1&sortoption=6'><IMG SRC='/nagios/images/up.gif' border=0 ALT='Sort by state duration (ascending)' TITLE='Sort by state duration (ascending)'></a><a href='status.cgi?host=esprod00&sorttype=2&sortoption=6'><IMG SRC='/nagios/images/down.gif' border=0 ALT='Sort by state duration time (descending)' TITLE='Sort by state duration time (descending)'></a></th>
            <th class='status'>Attempt <a href='status.cgi?host=esprod00&sorttype=1&sortoption=5'><IMG SRC='/nagios/images/up.gif' border=0 ALT='Sort by current attempt (ascending)' TITLE='Sort by current attempt (ascending)'></a><a href='status.cgi?host=esprod00&sorttype=2&sortoption=5'><IMG SRC='/nagios/images/down.gif' border=0 ALT='Sort by current attempt (descending)' TITLE='Sort by current attempt (descending)'></a></th>
            <th class='status'>Status Information</th>
         </tr>
         <tr>
            <td class='statusHOSTDOWN'>
               <table border=0 width='100%' cellpadding=0 cellspacing=0>
                  <tr>
                     <td align='left'>
                        <table border=0 cellpadding=0 cellspacing=0>
                           <tr>
                              <td align=left valign=center class='statusHOSTDOWN'><a href='extinfo.cgi?type=1&host=esprod00' title='esprod00'>esprod00</a></td>
                           </tr>
                        </table>
                     </td>
                     <td align=right valign=center>
                        <table border=0 cellpadding=0 cellspacing=0>
                           <tr>
                              <td align='right'></td>
                           </tr>
                        </table>
                     </td>
                  </tr>
               </table>
            </td>
            <td class='statusEven'>
               <table border=0 WIDTH='100%' cellspacing=0 cellpadding=0>
                  <tr>
                     <td align='left'>
                        <table border=0 cellspacing=0 cellpadding=0>
                           <tr>
                              <td align='left' valign=center class='statusEven'><a href='extinfo.cgi?type=2&host=esprod00&service=CPU+Usage'>CPU Usage</a></td>
                           </tr>
                        </table>
                     </td>
                     <td ALIGN=RIGHT class='statusEven'>
                        <table border=0 cellspacing=0 cellpadding=0>
                           <tr></tr>
                        </table>
                     </td>
                  </tr>
               </table>
            </td>
            <td class='statusOK'>OK</td>
            <td class='statusEven' nowrap>07-19-2017 15:42:36</td>
            <td class='statusEven' nowrap> 1d  0h 15m 37s</td>
            <td class='statusEven'>1/5</td>
            <td class='statusEven' valign='center'>OK - CPU Usage is 21% </td>
         </tr>
         <tr>
            <td></td>
            <td class='statusOdd'>
               <table border=0 WIDTH='100%' cellspacing=0 cellpadding=0>
                  <tr>
                     <td align='left'>
                        <table border=0 cellspacing=0 cellpadding=0>
                           <tr>
                              <td align='left' valign=center class='statusOdd'><a href='extinfo.cgi?type=2&host=esprod00&service=Cluster+Status'>Cluster Status</a></td>
                           </tr>
                        </table>
                     </td>
                     <td ALIGN=RIGHT class='statusOdd'>
                        <table border=0 cellspacing=0 cellpadding=0>
                           <tr></tr>
                        </table>
                     </td>
                  </tr>
               </table>
            </td>
            <td class='statusOK'>OK</td>
            <td class='statusOdd' nowrap>07-19-2017 15:42:44</td>
            <td class='statusOdd' nowrap> 1d  0h 15m 30s</td>
            <td class='statusOdd'>1/5</td>
            <td class='statusOdd' valign='center'>OK - Cluster Status is Green </td>
         </tr>
         <tr>
            <td></td>
            <td class='statusEven'>
               <table border=0 WIDTH='100%' cellspacing=0 cellpadding=0>
                  <tr>
                     <td align='left'>
                        <table border=0 cellspacing=0 cellpadding=0>
                           <tr>
                              <td align='left' valign=center class='statusEven'><a href='extinfo.cgi?type=2&host=esprod00&service=Heap+Usage'>Heap Usage</a></td>
                           </tr>
                        </table>
                     </td>
                     <td ALIGN=RIGHT class='statusEven'>
                        <table border=0 cellspacing=0 cellpadding=0>
                           <tr></tr>
                        </table>
                     </td>
                  </tr>
               </table>
            </td>
            <td class='statusOK'>OK</td>
            <td class='statusEven' nowrap>07-19-2017 15:43:07</td>
            <td class='statusEven' nowrap> 1d  0h 15m  6s</td>
            <td class='statusEven'>1/5</td>
            <td class='statusEven' valign='center'>OK - Heap Usage is 74% </td>
         </tr>
         <tr>
            <td></td>
            <td class='statusOdd'>
               <table border=0 WIDTH='100%' cellspacing=0 cellpadding=0>
                  <tr>
                     <td align='left'>
                        <table border=0 cellspacing=0 cellpadding=0>
                           <tr>
                              <td align='left' valign=center class='statusOdd'><a href='extinfo.cgi?type=2&host=esprod00&service=Memory+Usage'>Memory Usage</a></td>
                           </tr>
                        </table>
                     </td>
                     <td ALIGN=RIGHT class='statusOdd'>
                        <table border=0 cellspacing=0 cellpadding=0>
                           <tr></tr>
                        </table>
                     </td>
                  </tr>
               </table>
            </td>
            <td class='statusOK'>OK</td>
            <td class='statusOdd' nowrap>07-19-2017 15:43:28</td>
            <td class='statusOdd' nowrap> 1d  0h 14m 45s</td>
            <td class='statusOdd'>1/5</td>
            <td class='statusOdd' valign='center'>OK - Memory usage is 53% </td>
         </tr>
         <tr>
            <td></td>
            <td class='statusBGCRITICAL'>
               <table border=0 WIDTH='100%' cellspacing=0 cellpadding=0>
                  <tr>
                     <td align='left'>
                        <table border=0 cellspacing=0 cellpadding=0>
                           <tr>
                              <td align='left' valign=center class='statusBGCRITICAL'><a href='extinfo.cgi?type=2&host=esprod00&service=Ping'>Ping</a></td>
                           </tr>
                        </table>
                     </td>
                     <td ALIGN=RIGHT class='statusBGCRITICAL'>
                        <table border=0 cellspacing=0 cellpadding=0>
                           <tr></tr>
                        </table>
                     </td>
                  </tr>
               </table>
            </td>
            <td class='statusCRITICAL'>CRITICAL</td>
            <td class='statusBGCRITICAL' nowrap>07-20-2017 09:58:53</td>
            <td class='statusBGCRITICAL' nowrap> 0d  0h  0m 20s</td>
            <td class='statusBGCRITICAL'>1/5</td>
            <td class='statusBGCRITICAL' valign='center'>CRITICAL - Plugin timed out </td>
         </tr>
      </table>
      <br />
      <div class='itemTotalsTitle'>Results 1 - 5 of 5 Matching Services</div>
      </div>
      <!-- Produced by Nagios (https://www.nagios.org).  Copyright (c) 1999-2007 Ethan Galstad. -->
   </body>
</html>
I doubt anyone here knows what was installed on your system by the contents of a single page alone.
Former Nagios employee
https://www.mcapra.com/
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Nagios CGI File is not working as Expected after the Upg

Post by tmcdonald »

Thanks for the assist, @mcapra!
Former Nagios employee
Teja
Posts: 53
Joined: Tue Jun 13, 2017 8:13 am

Re: Nagios CGI File is not working as Expected after the Upg

Post by Teja »

Hi mcapra,
Thanks for your reply.I have one doubt here will his script provide output in XML format? Or do i need to make any changes in the Server. Could you please assist me in how and where should i place this script? Can i directly place in
"/usr/local/nagios/sbin" Path.

Thanks again!!!
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Nagios CGI File is not working as Expected after the Upg

Post by mcapra »

I'm uhh...confused? The HTML I shared is what was drawn by the regular old status.cgi page that I shared for demonstrative purposes. That's not some script you can chuck into a C file and compile to get your desired results.

Here's the C behind status.cgi. That's what would need to be modified/re-compiled if you really want status.cgi to produce XML.
https://github.com/NagiosEnterprises/na ... i/status.c

I'm certain it's doable, but I can't offer any guidance on that topic.
Former Nagios employee
https://www.mcapra.com/
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Nagios CGI File is not working as Expected after the Upg

Post by dwhitfield »

What is the output of the three following commands:

Code: Select all

ls -la /usr/local/nagios/sbin
ls -la /usr/local/nagios/libexec
ls -la /usr/local/nagios
Please put the output in a code block. The "Code" button is the fifth from the left on the post input screen (between Quote and List).

That may give us a clue as to what is going on. It'd also be great to get that nagios.cfg file. If you can PM it instead of posting it directly, that would work. If you need to scrub any sensitive data, feel free.

UPDATE: nagios.cfg received and shared with techs
Teja
Posts: 53
Joined: Tue Jun 13, 2017 8:13 am

Re: Nagios CGI File is not working as Expected after the Upg

Post by Teja »

Thanks All!!
Last edited by Teja on Tue Aug 01, 2017 4:24 am, edited 1 time in total.
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Nagios CGI File is not working as Expected after the Upg

Post by dwhitfield »

Do you have a snapshot of your old system? If we could take a look at some of the software installed previously, we could try to help recreate it, but I don't think we are going to be able to figure it out under the current system.

Did you look at http://labs.nagios.com/2014/06/19/explo ... -7-part-1/ , as suggested?
Teja
Posts: 53
Joined: Tue Jun 13, 2017 8:13 am

Re: Nagios CGI File is not working as Expected after the Upg

Post by Teja »

Thanks Everyone who assisted me in this issue,I have cleared it!!
bolson

Re: Nagios CGI File is not working as Expected after the Upg

Post by bolson »

Closing topic as resolved.

Thank you for using the Nagios Support Forum.
Locked