]> granicus.if.org Git - pdns/commitdiff
implement 'rec_control get uptime' (suggested by Niels Bakker), implement --version...
authorBert Hubert <bert.hubert@netherlabs.nl>
Wed, 27 Dec 2006 23:00:18 +0000 (23:00 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Wed, 27 Dec 2006 23:00:18 +0000 (23:00 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@935 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/docs/pdns.sgml
pdns/pdns_recursor.cc
pdns/rec_channel_rec.cc
pdns/syncres.hh

index def48d8ec79d1eaead1f6360c3aad5f5b7c4a5c3..841953fca8994ce76547e07680160d829a0ca3a1 100644 (file)
          <itemizedlist>
            <listitem>
              <para>
-               Reported version can be changed, or removed - see the "version-string" setting.
+               Reported version can be changed, or removed - see the "version-string" setting. 
              </para>
            </listitem>
            <listitem>
@@ -6999,6 +6999,14 @@ local0.err                        /var/log/pdns.err
              </para>
            </listitem>
          </varlistentry>
+         <varlistentry>
+           <term>version</term>
+           <listitem>
+             <para>
+               Print version of this binary. Useful for checking which version of the PowerDNS recursor is installed on a system. Available since 3.1.5.
+             </para>
+           </listitem>
+         </varlistentry>
          <varlistentry>
            <term>version-string</term>
            <listitem>
@@ -7253,7 +7261,8 @@ throttle-entries    shows the number of entries in the throttle map
 unauthorized-tcp    number of TCP questions denied because of allow-from restrictions
 unauthorized-udp    number of UDP questions denied because of allow-from restrictions
 unexpected-packets  number of answers from remote servers that were unexpected (might point to spoofing)
-user-msec            number of CPU milliseconds spent in 'user' mode
+uptime              number of seconds process has been running (since 3.1.5)
+user-msec           number of CPU milliseconds spent in 'user' mode
          </screen>
        In the <filename>rrd/</filename> subdirectory a number of rrdtool scripts is provided to make nice
        graphs of all these numbers.
index 41020654cf665652f7542f1b0538bdd4ba73690d..7a542f9a787c2ef867dee6487da0dc256d0f53ae 100644 (file)
@@ -1740,6 +1740,7 @@ void doWindowsServiceArguments(RecursorService& recursor)
 
 int main(int argc, char **argv) 
 {
+  g_stats.startupTime=time(0);
   reportBasicTypes();
 
   int ret = EXIT_SUCCESS;
@@ -1806,6 +1807,7 @@ int main(int argc, char **argv)
     ::arg().setSwitch( "ignore-rd-bit", "Assume each packet requires recursion, for compatability" )= "off"; 
 
     ::arg().setCmd("help","Provide a helpful message");
+    ::arg().setCmd("version","Print version string ("VERSION")");
     ::arg().setCmd("config","Output blank configuration");
     L.toConsole(Logger::Info);
     ::arg().laxParse(argc,argv); // do a lax parse
@@ -1825,6 +1827,10 @@ int main(int argc, char **argv)
       cerr<<::arg().helpstring(::arg()["help"])<<endl;
       exit(99);
     }
+    if(::arg().mustDo("version")) {
+      cerr<<"version: "VERSION<<endl;
+      exit(99);
+    }
 
     if(::arg().mustDo("config")) {
       cout<<::arg().configstring()<<endl;
index 51439381acf694ab949b45a49e72ceefb9b99339..72024ef449f49ec92f88e699c4786ee3a1568360 100644 (file)
@@ -134,6 +134,11 @@ static uint64_t getUserTimeMsec()
 }
 #endif
 
+static uint64_t calculateUptime()
+{
+  return time(0) - g_stats.startupTime;
+}
+
 static string doCurrentQueries()
 {
   ostringstream ostr;
@@ -213,6 +218,8 @@ RecursorControlParser::RecursorControlParser()
   addGetStat("unreachables", &SyncRes::s_unreachables);
   addGetStat("chain-resends", &g_stats.chainResends);
 
+  addGetStat("uptime", calculateUptime);
+
 #ifndef WIN32
   //  addGetStat("query-rate", getQueryRate);
   addGetStat("user-msec", getUserTimeMsec);
index 9ad97c381924fb414bf8f07a40c9543afd4df38b..e10d455d80db7b3dc9302b1e3e643fe028362086 100644 (file)
@@ -479,7 +479,7 @@ struct RecursorStats
   uint64_t nsSetInvalidations;
   uint64_t shunted;
   uint64_t noShuntCNAME, noShuntExpired, noShuntSize, noShuntNoMatch, noShuntWrongType, noShuntWrongQuestion;
-
+  time_t startupTime;
 
   typedef vector<ComboAddress> remotes_t;
   remotes_t remotes;