<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,4 +1,4 @@
-// This file is part of ScopePort (Linux client).
+ // This file is part of ScopePort (Linux client).
 //
 // Copyright 2007, 2008 Lennart Koopmann
 //
@@ -197,6 +197,8 @@ int main(void) {
 	parameters.push_back(&quot;tz3&quot;);
 	parameters.push_back(&quot;tz4&quot;);
 	parameters.push_back(&quot;tz5&quot;);
+	parameters.push_back(&quot;usedropr&quot;);
+	parameters.push_back(&quot;droprbin&quot;);
 
 	ifstream configstream(CONFIGFILE);
 	string configline;
@@ -234,7 +236,10 @@ int main(void) {
 	char* server;
 	int port = 0;
 	string pass;
+	string droprbin;
 	int loglevel = 0;
+
+	// Host ID.
 	string hostid;
 	if(!config[3].empty()){
 		hostid = config[3];
@@ -242,6 +247,7 @@ int main(void) {
 		cout &lt;&lt; &quot;Error. Host ID not set?&quot; &lt;&lt; endl;
 		return 0;
 	}
+
 	// Convert server string to (non-const) char*
 	if(!config[0].empty()){
 		server = const_cast&lt;char*&gt;(config[0].c_str());
@@ -249,6 +255,7 @@ int main(void) {
 		cout &lt;&lt; &quot;Error. Server not set?&quot; &lt;&lt; endl;
 		return 0;
 	}
+
 	// Convert strings to int.
 	istringstream isst;
 	if(!config[1].empty()){
@@ -257,6 +264,7 @@ int main(void) {
 		cout &lt;&lt; &quot;Error. Port not set?&quot; &lt;&lt; endl;
 		return 0;
 	}
+
 	if(!config[2].empty()){
 		pass = config[2];
 	}else{
@@ -276,7 +284,7 @@ int main(void) {
 	// Should we use profile data?
 	isst.clear();
 	bool useprofiledata;
-	if(config[5] == &quot;0&quot; &amp;&amp; !config[5].empty()){
+	if(config[5] == &quot;0&quot;){
 		useprofiledata = 0;
 	}else{
 		useprofiledata = 1;
@@ -284,7 +292,7 @@ int main(void) {
 
 	// Should we collect information about the load average?
 	bool useLoadAvg;
-	if(config[6] == &quot;0&quot; &amp;&amp; !config[6].empty()){
+	if(config[6] == &quot;0&quot;){
 		useLoadAvg = 0;
 	}else{
 		useLoadAvg = 1;
@@ -292,7 +300,7 @@ int main(void) {
 
 	// Should we collect information about running tasks?
 	bool useTasksRun;
-	if(config[7] == &quot;0&quot; &amp;&amp; !config[7].empty()){
+	if(config[7] == &quot;0&quot;){
 		useTasksRun = 0;
 	}else{
 		useTasksRun = 1;
@@ -300,7 +308,7 @@ int main(void) {
 
 	// Should we collect information about total number of tasks?
 	bool useTasksSum;
-	if(config[8] == &quot;0&quot; &amp;&amp; !config[8].empty()){
+	if(config[8] == &quot;0&quot;){
 		useTasksSum = 0;
 	}else{
 		useTasksSum = 1;
@@ -308,7 +316,7 @@ int main(void) {
 
 	// Should we collect information about NIC statistics?
 	bool useNetstats;
-	if(config[9] == &quot;0&quot; &amp;&amp; !config[9].empty()){
+	if(config[9] == &quot;0&quot;){
 		useNetstats = 0;
 	}else{
 		useNetstats = 1;
@@ -316,7 +324,7 @@ int main(void) {
 
 	// Should we collect information about opened files?
 	bool useOpenFiles;
-	if(config[10] == &quot;0&quot; &amp;&amp; !config[10].empty()){
+	if(config[10] == &quot;0&quot;){
 		useOpenFiles = 0;
 	}else{
 		useOpenFiles = 1;
@@ -324,7 +332,7 @@ int main(void) {
 
 	// Should we collect information about free memory?
 	bool useFreeMem;
-	if(config[11] == &quot;0&quot; &amp;&amp; !config[11].empty()){
+	if(config[11] == &quot;0&quot;){
 		useFreeMem = 0;
 	}else{
 		useFreeMem = 1;
@@ -332,7 +340,7 @@ int main(void) {
 
 	// Should we collect information about free swap space?
 	bool useFreeSwap;
-	if(config[12] == &quot;0&quot; &amp;&amp; !config[12].empty()){
+	if(config[12] == &quot;0&quot;){
 		useFreeSwap = 0;
 	}else{
 		useFreeSwap = 1;
@@ -340,7 +348,7 @@ int main(void) {
 
 	// Should we collect information about free inodes?
 	bool useFreeInodes;
-	if(config[13] == &quot;0&quot; &amp;&amp; !config[13].empty()){
+	if(config[13] == &quot;0&quot;){
 		useFreeInodes = 0;
 	}else{
 		useFreeInodes = 1;
@@ -433,6 +441,21 @@ int main(void) {
 		}
 	}
 
+  // Should we collect dropr counts?
+	bool useDropr;
+	if(config[20] == &quot;0&quot;){
+		useDropr = 0;
+	}else{
+		useDropr = 1;
+	}
+
+	// Path to dropr binary.
+	if(!config[21].empty()){
+		droprbin = config[21];
+	}else{
+		droprbin = &quot;&quot;;
+	}
+	
 	// Finished parsing of config file.
 	Log log(loglevel, LOGFILE);
 
@@ -623,6 +646,14 @@ int main(void) {
 			// TZ5 was set to &quot;none&quot; or empty. Send &quot;-0-&quot;.
 			sensorSend::sendSensorData(hostid, port, server, pass, &quot;19&quot;,&quot;-0-&quot;);
 		}
+	
+    // Dropr.
+    if(useDropr){
+      // Dropr messages in queue.
+      sensorSend::sendSensorData(hostid, port, server, pass, &quot;20&quot;, sensorTalk::getDroprCount(droprbin, 0));
+      // Dropr messages sent.
+      sensorSend::sendSensorData(hostid, port, server, pass, &quot;21&quot;, sensorTalk::getDroprCount(droprbin, 1));
+    }
 
 		sensorSend::sendSensorData(hostid, port, server, pass, &quot;999&quot;, &quot;&quot;);
 </diff>
      <filename>src/core.cc</filename>
    </modified>
    <modified>
      <diff>@@ -17,23 +17,24 @@
 
 #include &quot;internal.h&quot;
 #include &quot;sensorTalk.h&quot;
+#include &quot;Log.h&quot;
 
 /*
  * 1: Load1
  * 2: Load5
  * 3: Load15
  * 4: Tasks running
- * 5: Tasks sum 
+ * 5: Tasks sum
  */
 
-string sensorTalk::getLoadAndTasks(int type){
-	
+string sensorTalk::getLoadAndTasks(unsigned int type){
+
 	string load1;
 	string load5;
 	string load15;
 	string tasksrun;
 	string taskssum;
-	
+
 	int i = 0;
 	ifstream avgoutput(&quot;/proc/loadavg&quot;);
 	if(!avgoutput.fail()){
@@ -72,7 +73,7 @@ string sensorTalk::getLoadAndTasks(int type){
 			}
 			i++;
 		}
-		
+
 		switch(type){
 			case 1:
 				if(!load1.empty())
@@ -95,55 +96,55 @@ string sensorTalk::getLoadAndTasks(int type){
 					return taskssum;
 				break;
 		}
-		
+
 	}
 	return &quot;-0-&quot;;
 }
 
-string sensorTalk::getNet(int type){
+string sensorTalk::getNet(unsigned int type){
 	stringstream returnage;
 	string netdev;
 	int i = 0;
 	int j = 0;
 	string token;
 	ifstream output(&quot;/proc/net/dev&quot;);
-	// See if nothing went wrong while opening the file.  
+	// See if nothing went wrong while opening the file.
 	if(!output.fail()){
 		unsigned long recvBytes = 0;
 		unsigned long sentBytes = 0;
 		while(getline(output, netdev)){
-			// We dont want the head lines.  
+			// We dont want the head lines.
 			if(i &gt; 1){
 				istringstream iss(netdev);
 				while(getline(iss, token, ':')){
-					// Start with the device name.  
+					// Start with the device name.
 					if(j == 0) returnage &lt;&lt; noSpaces(token) &lt;&lt; &quot;:&quot;;
 					if(j == 1){
 						int k = 0;
 						istringstream iss(token);
 						while(getline(iss, token, ' ')){
 							if(noSpaces(token) != &quot;err&quot;){
-								// Received bytes.  
+								// Received bytes.
 								if(k == 0){
 									recvBytes += atol(token.c_str());
 									returnage &lt;&lt; noSpaces(token) &lt;&lt; &quot;.&quot;;
 								}
-								// Received packets.  
+								// Received packets.
 								if(k == 1) returnage &lt;&lt; noSpaces(token) &lt;&lt; &quot;.&quot;;
-								// Errors (Recv).  
+								// Errors (Recv).
 								if(k == 2) returnage &lt;&lt; noSpaces(token) &lt;&lt; &quot;.&quot;;
-								// Dropped (Recv).  
+								// Dropped (Recv).
 								if(k == 3) returnage &lt;&lt; noSpaces(token) &lt;&lt; &quot;.&quot;;
-								// Sent bytes.  
+								// Sent bytes.
 								if(k == 8){
 									sentBytes += atol(token.c_str());
 									returnage &lt;&lt; noSpaces(token) &lt;&lt; &quot;.&quot;;
 								}
-								// Sent packets.  
+								// Sent packets.
 								if(k == 9) returnage &lt;&lt; noSpaces(token) &lt;&lt; &quot;.&quot;;
-								// Errors (Transm.)  
+								// Errors (Transm.)
 								if(k == 10) returnage &lt;&lt; noSpaces(token) &lt;&lt; &quot;.&quot;;
-								// Dropped (Transm.)  
+								// Dropped (Transm.)
 								if(k == 11) returnage &lt;&lt; noSpaces(token) &lt;&lt; &quot;|&quot;;
 								k++;
 							}
@@ -163,8 +164,8 @@ string sensorTalk::getNet(int type){
 		if(type == 2) return sRecvBytes.str();
 		return returnage.str();
 	}
-	
-	return &quot;-0-&quot;;	
+
+	return &quot;-0-&quot;;
 }
 
 string sensorTalk::getOpenFiles(){
@@ -179,24 +180,24 @@ string sensorTalk::getOpenFiles(){
 			return file;
 		}
 	}
-	return &quot;-0-&quot;;	
+	return &quot;-0-&quot;;
 }
 
-/* 
+/*
  * Type:
  *  1 = Free memory
  *  2 = Free swap
- */ 
- 
-string sensorTalk::getMemInfo(int type){
+ */
+
+string sensorTalk::getMemInfo(unsigned int type){
 	ifstream testoutput(&quot;/proc/meminfo&quot;);
 	string meminfo;
 	string result;
 	int i = 0;
-	// Try if we can open the file.  
+	// Try if we can open the file.
 	if(getline(testoutput,meminfo)){
 		ifstream output(&quot;/proc/meminfo&quot;);
-		// Get output.  
+		// Get output.
 		while(getline(output,meminfo)){
 			if(type == 1 &amp;&amp; meminfo.find(&quot;MemFree&quot;,0) != string::npos){
 				result = meminfo;
@@ -208,8 +209,8 @@ string sensorTalk::getMemInfo(int type){
 			}
 			i++;
 		}
-		
-		// Split output to relevant parts.  
+
+		// Split output to relevant parts.
 		i = 0;
 		string token;
 		istringstream iss(result);
@@ -221,10 +222,10 @@ string sensorTalk::getMemInfo(int type){
 
 		output.close();
 
-		// Return.  
+		// Return.
 		return result;
 	}
-	// Could not open meminfo file.  
+	// Could not open meminfo file.
 	testoutput.close();
 	return &quot;-0-&quot;;
 }
@@ -243,10 +244,10 @@ string sensorTalk::getFreeInodes(){
 			i++;
 		}
 	}
-	return &quot;-0-&quot;;	
+	return &quot;-0-&quot;;
 }
 
-string sensorTalk::getDiskStats26(int type){
+string sensorTalk::getDiskStats26(unsigned int type){
 	string disks;
 	unsigned long writes = 0;
 	unsigned long reads = 0;
@@ -255,9 +256,9 @@ string sensorTalk::getDiskStats26(int type){
 		string disk;
 		while(getline(output, disk)){
 			if(disk.length() &gt; 8){
-				if(disk.at(8) == '0' &amp;&amp; 
+				if(disk.at(8) == '0' &amp;&amp;
 					disk.find(&quot;ram&quot;,0) == string::npos){
-					// We have a hard disk here.  
+					// We have a hard disk here.
 					string token;
 					istringstream iss(disk.substr(10));
 					int i = 0;
@@ -274,7 +275,7 @@ string sensorTalk::getDiskStats26(int type){
 					}
 				}
 			}else{
-				// Disk line too short.  
+				// Disk line too short.
 				return 0;
 			}
 		}
@@ -286,7 +287,7 @@ string sensorTalk::getDiskStats26(int type){
 		if(type == 1) return swrites.str();
 		output.close();
 	}
-	return &quot;-0-&quot;;	
+	return &quot;-0-&quot;;
 }
 
 string sensorTalk::getACPITemp(string TZ){
@@ -305,23 +306,72 @@ string sensorTalk::getACPITemp(string TZ){
 		istringstream iss(tempstring);
 		while(getline(iss, temp, ':')){
 			if(i == 1){
-				// Remove the trailing temperature unit sign.  
+				// Remove the trailing temperature unit sign.
 				switch(noSpaces(temp).length()){
 					case 2:
-						// Remove 2nd char.  
+						// Remove 2nd char.
 						return noSpaces(temp).erase(1);
 					case 3:
-						// Remove 3rd char.  
+						// Remove 3rd char.
 						return noSpaces(temp).erase(2);
 					case 4:
-						// Remove 4th char.  
+						// Remove 4th char.
 						return noSpaces(temp).erase(3);
 					default:
-						return &quot;-0-&quot;;	
+						return &quot;-0-&quot;;
 				}
 			}
 			i++;
 		}
 	}
-	return &quot;-0-&quot;;	
+	return &quot;-0-&quot;;
+}
+
+string sensorTalk::getDroprCount(string binary, unsigned int type){
+	// Return if no binary path has been given.
+	if(binary.empty())
+		return &quot;-0-&quot;;
+
+	string count;
+	string command;
+  string tmpfile;
+
+  // Check if we need to add a trailing slash.
+  if(binary.at(binary.length()-1) != '/')
+    binary += &quot;/&quot;;
+
+	// Build the command.
+	switch(type){
+		case 0:
+      tmpfile = &quot;/tmp/scopeport-dropr-queue&quot;;
+			command = &quot;cd &quot; + noSpaces(binary) + &quot; &amp;&amp; ./dropcmd count_queue &gt; &quot; + tmpfile;
+			break;
+		case 1:
+      tmpfile = &quot;/tmp/scopeport-dropr-sent&quot;;
+			command = &quot;cd &quot; + noSpaces(binary) + &quot; &amp;&amp; ./dropcmd count_sent &gt; &quot; + tmpfile;
+			break;
+		default:
+			return &quot;-0-&quot;;
+	}
+
+  // Execute the command.
+  if(system(command.c_str()) &lt; 0)
+    return &quot;-0-&quot;;
+
+  // The counts are not stored in the tmp files.
+
+	// Get the output.
+	ifstream output(tmpfile.c_str());
+	if(!output.fail()){
+		getline(output, count);
+		output.close();
+	}else{
+    return &quot;-0-&quot;;
+  }
+
+  // TODO: Check this and log in case of error. Needs new log class first.
+  remove(tmpfile.c_str());
+
+  return count;
+
 }</diff>
      <filename>src/sensorTalk.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -20,14 +20,19 @@
 
 class sensorTalk {
 	public:
-		static string getLoadAndTasks(int type);
-		static string getNet(int type);
+		static string getLoadAndTasks(unsigned int type);
+		static string getNet(unsigned int type);
 		static string getSwaps();
 		static string getOpenFiles();
-		static string getMemInfo(int type);
+		static string getMemInfo(unsigned int type);
 		static string getFreeInodes();
-		static string getDiskStats26(int type);
+		static string getDiskStats26(unsigned int type);
 		static string getACPITemp(string TZ);
+
+		// Application based sensors.
+
+		// Dropr.
+		static string getDroprCount(string binary, unsigned int type);
 };
 
 #endif /*SENSORTALK_H_*/</diff>
      <filename>src/sensorTalk.h</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>97e40af51058d5ba9d74a3641c88f927be79b2e4</id>
    </parent>
  </parents>
  <author>
    <name>Lennart</name>
    <email>lennart@scopeport.org</email>
  </author>
  <url>http://github.com/lennartkoopmann/scopeport-client-linux/commit/e4dd76399ece4bf449ce9aadc0e449c7715e262b</url>
  <id>e4dd76399ece4bf449ce9aadc0e449c7715e262b</id>
  <committed-date>2009-01-07T09:02:32-08:00</committed-date>
  <authored-date>2009-01-07T09:02:32-08:00</authored-date>
  <message>Added support for dropr</message>
  <tree>3885a09e3e2046e9417ad418851b0625e41979fa</tree>
  <committer>
    <name>Lennart</name>
    <email>lennart@scopeport.org</email>
  </committer>
</commit>
