diff options
author | Ton Voon <tonvoon@users.sourceforge.net> | 2008-04-21 08:38:43 +0000 |
---|---|---|
committer | Ton Voon <tonvoon@users.sourceforge.net> | 2008-04-21 08:38:43 +0000 |
commit | e82d19a892b23abd2f4eef8d4e14d7cba65855e4 (patch) | |
tree | a5f3d95ecb3b41be70c119fcdee5035f2d710fe7 /lib | |
parent | 1a8ce70ed3cca09e78e0b298ace746726d145488 (diff) | |
download | monitoring-plugins-e82d19a892b23abd2f4eef8d4e14d7cba65855e4.tar.gz |
Use utils_cmd to run check_procs' command. Added a
utils_cmd simulation of a filename, for testing purposes
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/branches/new_threshold_syntax@1980 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'lib')
-rw-r--r-- | lib/utils_cmd.c | 18 | ||||
-rw-r--r-- | lib/utils_cmd.h | 1 |
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/utils_cmd.c b/lib/utils_cmd.c index aaf055a9..5ba2f55e 100644 --- a/lib/utils_cmd.c +++ b/lib/utils_cmd.c | |||
@@ -45,6 +45,7 @@ | |||
45 | #include "common.h" | 45 | #include "common.h" |
46 | #include "utils_cmd.h" | 46 | #include "utils_cmd.h" |
47 | #include "utils_base.h" | 47 | #include "utils_base.h" |
48 | #include <fcntl.h> | ||
48 | 49 | ||
49 | #ifdef HAVE_SYS_WAIT_H | 50 | #ifdef HAVE_SYS_WAIT_H |
50 | # include <sys/wait.h> | 51 | # include <sys/wait.h> |
@@ -377,3 +378,20 @@ cmd_run_array (char *const *argv, output * out, output * err, int flags) | |||
377 | 378 | ||
378 | return _cmd_close (fd); | 379 | return _cmd_close (fd); |
379 | } | 380 | } |
381 | |||
382 | int | ||
383 | cmd_file_read ( char *filename, output *out, int flags) | ||
384 | { | ||
385 | int fd; | ||
386 | if(out) | ||
387 | memset (out, 0, sizeof(output)); | ||
388 | |||
389 | if ((fd = open(filename, O_RDONLY)) == -1) { | ||
390 | die( STATE_UNKNOWN, _("Error opening %s: %s"), filename, strerror(errno) ); | ||
391 | } | ||
392 | |||
393 | if(out) | ||
394 | out->lines = _cmd_fetch_output (fd, out, flags); | ||
395 | |||
396 | return 0; | ||
397 | } | ||
diff --git a/lib/utils_cmd.h b/lib/utils_cmd.h index d54b2b4d..8ebb5894 100644 --- a/lib/utils_cmd.h +++ b/lib/utils_cmd.h | |||
@@ -22,6 +22,7 @@ typedef struct output output; | |||
22 | /** prototypes **/ | 22 | /** prototypes **/ |
23 | int cmd_run (const char *, output *, output *, int); | 23 | int cmd_run (const char *, output *, output *, int); |
24 | int cmd_run_array (char *const *, output *, output *, int); | 24 | int cmd_run_array (char *const *, output *, output *, int); |
25 | int cmd_file_read (char *, output *, int); | ||
25 | 26 | ||
26 | /* only multi-threaded plugins need to bother with this */ | 27 | /* only multi-threaded plugins need to bother with this */ |
27 | void cmd_init (void); | 28 | void cmd_init (void); |