summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f0b61a7)
raw | patch | inline | side by side (parent: f0b61a7)
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Fri, 20 Feb 2004 05:04:32 +0000 (05:04 +0000) | ||
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Fri, 20 Feb 2004 05:04:32 +0000 (05:04 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@815 f882894a-f735-0410-b71e-b25c423dba1c
plugins/check_procs.c | patch | blob | history |
diff --git a/plugins/check_procs.c b/plugins/check_procs.c
index 782a9a11bdcc16a426e31da85688030412b0c108..edb33acaa05ab857b307c05783eb11d35e7ca928 100644 (file)
--- a/plugins/check_procs.c
+++ b/plugins/check_procs.c
int
main (int argc, char **argv)
{
- char input_buffer[MAX_INPUT_BUFFER];
+ char *input_buffer;
+ char *input_line;
+ char *procprog;
int procuid = 0;
int procppid = 0;
int procrss = 0;
float procpcpu = 0;
char procstat[8];
- char procprog[MAX_INPUT_BUFFER];
char *procargs;
char *temp_string;
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ input_buffer = malloc (MAX_INPUT_BUFFER);
+ procprog = malloc (MAX_INPUT_BUFFER);
+
asprintf (&metric_name, "PROCS");
metric = METRIC_PROCS;
if (child_stderr == NULL)
printf (_("Could not open stderr for %s\n"), PS_COMMAND);
+ /* flush first line */
fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process);
+ while ( input_buffer[strlen(input_buffer)-1] != '\n' )
+ fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process);
while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) {
+ asprintf (&input_line, "%s", input_buffer);
+ while ( input_buffer[strlen(input_buffer)-1] != '\n' ) {
+ fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process);
+ asprintf (&input_line, "%s%s", input_line, input_buffer);
+ }
+
+ if (verbose >= 3)
+ printf ("%s", input_line);
+
strcpy (procprog, "");
asprintf (&procargs, "%s", "");
- cols = sscanf (input_buffer, PS_FORMAT, PS_VARLIST);
+ cols = sscanf (input_line, PS_FORMAT, PS_VARLIST);
/* Zombie processes do not give a procprog command */
if ( cols == (expected_cols - 1) && strstr(procstat, zombie) ) {
}
if ( cols >= expected_cols ) {
resultsum = 0;
- asprintf (&procargs, "%s", input_buffer + pos);
+ asprintf (&procargs, "%s", input_line + pos);
strip (procargs);
/* Some ps return full pathname for command. This removes path */