16 #include <sys/types.h>
25 #include <sys/resource.h>
35 nagios_metadata_name(
const char *plugin)
43 GList *plugin_list = NULL;
49 for (GList *gIter = plugin_list; gIter != NULL; gIter = gIter->next) {
51 const char *plugin = gIter->data;
52 char *metadata = nagios_metadata_name(plugin);
54 if (stat(metadata, &st) == 0) {
55 result = g_list_append(result, strdup(plugin));
59 g_list_free_full(plugin_list, free);
75 if (stat(buf, &st) == 0) {
87 FILE *file_strm = NULL;
88 int start = 0, length = 0, read_len = 0;
89 char *metadata_file = nagios_metadata_name(type);
91 file_strm = fopen(metadata_file,
"r");
92 if (file_strm == NULL) {
93 crm_err(
"Metadata file %s does not exist", metadata_file);
99 start = ftell(file_strm);
100 fseek(file_strm, 0L, SEEK_END);
101 length = ftell(file_strm);
102 fseek(file_strm, 0L, start);
108 crm_info(
"%s was not valid", metadata_file);
114 crm_trace(
"Reading %d bytes from file", length);
115 *output = calloc(1, (length + 1));
116 read_len = fread(*output, 1, length, file_strm);
117 if (read_len != length) {
118 crm_err(
"Calculated and read bytes differ: %d vs. %d",
int services__get_nagios_metadata(const char *type, char **output)
GList * services_os_get_directory_list(const char *root, gboolean files, gboolean executable)
enum crm_ais_msg_types type
Wrappers for and extensions to glib mainloop.
#define crm_trace(fmt, args...)
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
gboolean services__nagios_agent_exists(const char *name)
#define NAGIOS_PLUGIN_DIR
#define crm_err(fmt, args...)
GList * services__list_nagios_agents(void)
#define crm_info(fmt, args...)
#define NAGIOS_METADATA_DIR