Back to index

nagios-plugins  1.4.16
Classes | Functions
utils_disk.h File Reference
#include "mountlist.h"
#include "utils_base.h"
#include "regex.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  name_list
struct  parameter_list

Functions

void np_add_name (struct name_list **list, const char *name)
int np_find_name (struct name_list *list, const char *name)
int np_seen_name (struct name_list *list, const char *name)
struct parameter_listnp_add_parameter (struct parameter_list **list, const char *name)
struct parameter_listnp_find_parameter (struct parameter_list *list, const char *name)
struct parameter_listnp_del_parameter (struct parameter_list *item, struct parameter_list *prev)
int search_parameter_list (struct parameter_list *list, const char *name)
void np_set_best_match (struct parameter_list *desired, struct mount_entry *mount_list, int exact)
int np_regex_match_mount_entry (struct mount_entry *me, regex_t *re)

Class Documentation

struct name_list

Definition at line 7 of file utils_disk.h.

Collaboration diagram for name_list:
Class Members
char * name
struct name_list * next
struct parameter_list

Definition at line 13 of file utils_disk.h.

Collaboration diagram for parameter_list:
Class Members
uintmax_t available
uintmax_t available_to_root
struct mount_entry * best_match
double dfree_inodes_percent
double dfree_pct
double dfree_units
double dtotal_units
double dused_inodes_percent
double dused_pct
double dused_units
thresholds * freeinodes_percent
thresholds * freespace_bytes
thresholds * freespace_percent
thresholds * freespace_units
char * group
uintmax_t inodes_free
uintmax_t inodes_total
char * name
struct parameter_list * name_next
uintmax_t total
uintmax_t used
thresholds * usedinodes_percent
thresholds * usedspace_bytes
thresholds * usedspace_percent
thresholds * usedspace_units

Function Documentation

void np_add_name ( struct name_list **  list,
const char *  name 
)

Definition at line 33 of file utils_disk.c.

{
  struct name_list *new_entry;
  new_entry = (struct name_list *) malloc (sizeof *new_entry);
  new_entry->name = (char *) name;
  new_entry->next = *list;
  *list = new_entry;
}

Here is the caller graph for this function:

struct parameter_list* np_add_parameter ( struct parameter_list **  list,
const char *  name 
) [read]

Definition at line 44 of file utils_disk.c.

{
  struct parameter_list *current = *list;
  struct parameter_list *new_path;
  new_path = (struct parameter_list *) malloc (sizeof *new_path);
  new_path->name = (char *) name;
  new_path->best_match = NULL;
  new_path->name_next = NULL;
  new_path->freespace_bytes = NULL;
  new_path->freespace_units = NULL;
  new_path->freespace_percent = NULL;
  new_path->usedspace_bytes = NULL;
  new_path->usedspace_units = NULL;
  new_path->usedspace_percent = NULL;
  new_path->usedinodes_percent = NULL;
  new_path->freeinodes_percent = NULL;
  new_path->group = NULL;
  new_path->dfree_pct = -1;
  new_path->dused_pct = -1; 
  new_path->total = 0;
  new_path->available = 0;
  new_path->available_to_root = 0;
  new_path->used = 0;
  new_path->dused_units = 0;
  new_path->dfree_units = 0;
  new_path->dtotal_units = 0;
  new_path->inodes_total = 0;
  new_path->inodes_free = 0;
  new_path->dused_inodes_percent = 0;
  new_path->dfree_inodes_percent = 0;

  if (current == NULL) {
    *list = new_path;
  } else {
    while (current->name_next) {
      current = current->name_next;
    }
    current->name_next = new_path;
  }
  return new_path;
}

Here is the caller graph for this function:

struct parameter_list* np_del_parameter ( struct parameter_list item,
struct parameter_list prev 
) [read]

Definition at line 88 of file utils_disk.c.

{
  struct parameter_list *next;

  if (item->name_next)
    next = item->name_next;
  else
    next = NULL;

  free(item);
  if (prev)
    prev->name_next = next;

  return next;
}

Here is the caller graph for this function:

int np_find_name ( struct name_list list,
const char *  name 
)

Definition at line 160 of file utils_disk.c.

{
  const struct name_list *n;

  if (list == NULL || name == NULL) {
    return FALSE;
  }
  for (n = list; n; n = n->next) {
    if (!strcmp(name, n->name)) {
      return TRUE;
    }
  }
  return FALSE;
}

Here is the caller graph for this function:

struct parameter_list* np_find_parameter ( struct parameter_list list,
const char *  name 
) [read]

Definition at line 107 of file utils_disk.c.

{
  struct parameter_list *temp_list;
  for (temp_list = list; temp_list; temp_list = temp_list->name_next) {
    if (! strcmp(temp_list->name, name))
        return temp_list;
  }

  return NULL;
}

Here is the caller graph for this function:

int np_regex_match_mount_entry ( struct mount_entry me,
regex_t *  re 
)

Definition at line 188 of file utils_disk.c.

{
  if (regexec(re, me->me_devname, (size_t) 0, NULL, 0) == 0 ||
      regexec(re, me->me_mountdir, (size_t) 0, NULL, 0) == 0 ) {
    return TRUE;
  } else {
    return FALSE;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int np_seen_name ( struct name_list list,
const char *  name 
)

Definition at line 176 of file utils_disk.c.

{
  const struct name_list *s;
  for (s = list; s; s=s->next) {
    if (!strcmp(s->name, name)) {
      return TRUE;
    }
  }
  return FALSE;
}

Here is the caller graph for this function:

void np_set_best_match ( struct parameter_list desired,
struct mount_entry mount_list,
int  exact 
)

Definition at line 119 of file utils_disk.c.

{
  struct parameter_list *d;
  for (d = desired; d; d= d->name_next) {
    if (! d->best_match) {
      struct mount_entry *me;
      size_t name_len = strlen(d->name);
      size_t best_match_len = 0;
      struct mount_entry *best_match = NULL;

      /* set best match if path name exactly matches a mounted device name */
      for (me = mount_list; me; me = me->me_next) {
        if (strcmp(me->me_devname, d->name)==0)
          best_match = me;
      }

      /* set best match by directory name if no match was found by devname */
      if (! best_match) {
        for (me = mount_list; me; me = me->me_next) {
          size_t len = strlen (me->me_mountdir);
          if ((exact == FALSE && (best_match_len <= len && len <= name_len &&
             (len == 1 || strncmp (me->me_mountdir, d->name, len) == 0)))
             || (exact == TRUE && strcmp(me->me_mountdir, d->name)==0))
          {
            best_match = me;
            best_match_len = len;
          }
        }
      }

      if (best_match) {
        d->best_match = best_match;
      } else {
        d->best_match = NULL;      /* Not sure why this is needed as it should be null on initialisation */
      }
    }
  }
}

Here is the caller graph for this function:

int search_parameter_list ( struct parameter_list list,
const char *  name 
)