Nmap Development mailing list archives

[PATCH] Add "days" to uptime stats in XML output


From: Kris Katterjohn <kjak () ispwest com>
Date: Thu, 28 Sep 2006 22:58:33 -0500

The attached patch adds the value of the uptime in days for XML output.

I guess the value in seconds is good for parsers or something, but I
looked at the output in the browser and thought "What does that mean?!"

I have to warn you that I had no idea what I was doing, but everything
works fine :) There's probably a simpler way (maybe using the
XML/XSL/DTD or something), but this worked so I'm just sending this
patch in.

It's a diff against 4.20ALPHA7

Thanks,
Kris Katterjohn
--- x/docs/nmap.dtd     2006-07-04 18:05:03.000000000 -0500
+++ y/docs/nmap.dtd     2006-09-28 22:40:46.000000000 -0500
@@ -235,6 +235,7 @@
 <!ELEMENT uptime       EMPTY >
 <!ATTLIST uptime
                        seconds         %attr_numeric;  #REQUIRED
+                       days            %attr_numeric;  #REQUIRED
                        lastboot        CDATA           #IMPLIED

 
--- x/docs/nmap.xsl     2006-06-24 20:30:48.000000000 -0500
+++ y/docs/nmap.xsl     2006-09-28 22:40:30.000000000 -0500
@@ -599,7 +599,7 @@
 <xsl:template match="uptime">
 <xsl:if test="@seconds != ''"><h3>system uptime</h3></xsl:if>
 <ul>
-<li>uptime: <xsl:value-of select="@seconds" /> sec</li>
+<li>uptime: <xsl:value-of select="@seconds" /> sec (<xsl:value-of select="@days" /> days)</li>
 <li>last reboot: <xsl:value-of select="@lastboot" /></li>
 </ul>
 </xsl:template>

--- x/output.cc 2006-08-31 01:21:50.000000000 -0500
+++ y/output.cc 2006-09-28 22:46:44.000000000 -0500
@@ -1410,7 +1410,7 @@ void printosscanoutput(Target *currenths
        strncpy(tmbuf, ctime(&(currenths->seq.lastboot)), sizeof(tmbuf));
        chomp(tmbuf);
        log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT,"Uptime: %.3f days (since %s)\n", (double) (tv.tv_sec - 
currenths->seq.lastboot) / 86400, tmbuf);
-       log_write(LOG_XML, "<uptime seconds=\"%li\" lastboot=\"%s\" />\n", tv.tv_sec - currenths->seq.lastboot, tmbuf);
+       log_write(LOG_XML, "<uptime seconds=\"%li\" days=\"%.3f\" lastboot=\"%s\" />\n", tv.tv_sec - 
currenths->seq.lastboot, (double) (tv.tv_sec - currenths->seq.lastboot) / 86400, tmbuf);
      }
 
   if (distance!=-1) {

_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org

Current thread: