PDA

View Full Version : Threads counted as processes


skogan
28-11-2007, 06:37
The following is a patch of a problem where Zabbix agent counts threads as processes on systems running kernel 2.4 (RedHat EL3, for example). This happens because on these systems threads appear as directories under /proc (just like processes) the only difference being a leading "."


1.4.2.orig/src/libs/zbxsysinfo/linux/proc.c 2007-08-20 19:22:23.000000000 +0000
+++ zabbix-1.4.2/src/libs/zbxsysinfo/linux/proc.c 2007-11-22 20:50:14.000000000 +0000
@@ -151,6 +151,12 @@
continue;
}

+ /* Ignore threads -- by Stanislav Kogan, TELUS */
+ if(entries->d_name[0]=='.')
+ {
+ continue;
+ }
+
if(stat(filename,&buf)==0)
{
if(NULL == ( f = fopen(filename,"r") ))
@@ -431,6 +437,12 @@
{
continue;
}
+
+ /* Ignore threads -- by Stanislav Kogan, TELUS */
+ if(entries->d_name[0]=='.')
+ {
+ continue;
+ }

strscpy(filename,"/proc/");
zbx_strlcat(filename,entries->d_name,MAX_STRING_LEN);

skogan
28-10-2008, 17:21
This bug is still there in 1.6! I guess for some people it's hard to imagine that anybody uses any other flavor of Linux besides Ubuntu :(