summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_procs.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/plugins/check_procs.c b/plugins/check_procs.c
index 782a9a1..edb33ac 100644
--- a/plugins/check_procs.c
+++ b/plugins/check_procs.c
@@ -79,7 +79,9 @@ char tmp[MAX_INPUT_BUFFER];
79int 79int
80main (int argc, char **argv) 80main (int argc, char **argv)
81{ 81{
82 char input_buffer[MAX_INPUT_BUFFER]; 82 char *input_buffer;
83 char *input_line;
84 char *procprog;
83 85
84 int procuid = 0; 86 int procuid = 0;
85 int procppid = 0; 87 int procppid = 0;
@@ -87,7 +89,6 @@ main (int argc, char **argv)
87 int procrss = 0; 89 int procrss = 0;
88 float procpcpu = 0; 90 float procpcpu = 0;
89 char procstat[8]; 91 char procstat[8];
90 char procprog[MAX_INPUT_BUFFER];
91 char *procargs; 92 char *procargs;
92 char *temp_string; 93 char *temp_string;
93 94
@@ -109,6 +110,9 @@ main (int argc, char **argv)
109 bindtextdomain (PACKAGE, LOCALEDIR); 110 bindtextdomain (PACKAGE, LOCALEDIR);
110 textdomain (PACKAGE); 111 textdomain (PACKAGE);
111 112
113 input_buffer = malloc (MAX_INPUT_BUFFER);
114 procprog = malloc (MAX_INPUT_BUFFER);
115
112 asprintf (&metric_name, "PROCS"); 116 asprintf (&metric_name, "PROCS");
113 metric = METRIC_PROCS; 117 metric = METRIC_PROCS;
114 118
@@ -128,13 +132,25 @@ main (int argc, char **argv)
128 if (child_stderr == NULL) 132 if (child_stderr == NULL)
129 printf (_("Could not open stderr for %s\n"), PS_COMMAND); 133 printf (_("Could not open stderr for %s\n"), PS_COMMAND);
130 134
135 /* flush first line */
131 fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process); 136 fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process);
137 while ( input_buffer[strlen(input_buffer)-1] != '\n' )
138 fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process);
132 139
133 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) { 140 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) {
141 asprintf (&input_line, "%s", input_buffer);
142 while ( input_buffer[strlen(input_buffer)-1] != '\n' ) {
143 fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process);
144 asprintf (&input_line, "%s%s", input_line, input_buffer);
145 }
146
147 if (verbose >= 3)
148 printf ("%s", input_line);
149
134 strcpy (procprog, ""); 150 strcpy (procprog, "");
135 asprintf (&procargs, "%s", ""); 151 asprintf (&procargs, "%s", "");
136 152
137 cols = sscanf (input_buffer, PS_FORMAT, PS_VARLIST); 153 cols = sscanf (input_line, PS_FORMAT, PS_VARLIST);
138 154
139 /* Zombie processes do not give a procprog command */ 155 /* Zombie processes do not give a procprog command */
140 if ( cols == (expected_cols - 1) && strstr(procstat, zombie) ) { 156 if ( cols == (expected_cols - 1) && strstr(procstat, zombie) ) {
@@ -146,7 +162,7 @@ main (int argc, char **argv)
146 } 162 }
147 if ( cols >= expected_cols ) { 163 if ( cols >= expected_cols ) {
148 resultsum = 0; 164 resultsum = 0;
149 asprintf (&procargs, "%s", input_buffer + pos); 165 asprintf (&procargs, "%s", input_line + pos);
150 strip (procargs); 166 strip (procargs);
151 167
152 /* Some ps return full pathname for command. This removes path */ 168 /* Some ps return full pathname for command. This removes path */