Code

check_procs captures stderr and adds to plugin output. This is
[nagiosplug.git] / lib / utils_cmd.c
index aaf055a9f0a86c228fe00daf85e2035b08f6d778..5ba2f55e56a2300fabe4941899e1ea6e1f46ec9c 100644 (file)
@@ -45,6 +45,7 @@
 #include "common.h"
 #include "utils_cmd.h"
 #include "utils_base.h"
+#include <fcntl.h>
 
 #ifdef HAVE_SYS_WAIT_H
 # include <sys/wait.h>
@@ -377,3 +378,20 @@ cmd_run_array (char *const *argv, output * out, output * err, int flags)
 
        return _cmd_close (fd);
 }
+
+int
+cmd_file_read ( char *filename, output *out, int flags)
+{
+       int fd;
+       if(out)
+               memset (out, 0, sizeof(output));
+
+       if ((fd = open(filename, O_RDONLY)) == -1) {
+               die( STATE_UNKNOWN, _("Error opening %s: %s"), filename, strerror(errno) );
+       }
+       
+       if(out)
+               out->lines = _cmd_fetch_output (fd, out, flags);
+
+       return 0;
+}