pmm  1.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Functions
pmm_cond.c File Reference

Functions to test system conditions. More...

#include <stdlib.h>
#include <stdio.h>
#include <utmp.h>
#include <paths.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/param.h>
#include "pmm_model.h"
#include "pmm_cond.h"

Go to the source code of this file.

Functions

int ttystat (char *line, int sz)
int num_users ()
int cond_users ()
int cond_idle ()
int check_conds (struct pmm_routine *r)

Detailed Description

Functions to test system conditions.

this file contains the code for testing system conditions which may limit or permit the construction of models by the pmm daemon

Definition in file pmm_cond.c.

Function Documentation

int check_conds ( struct pmm_routine r)

check if conditions for execution of a routine are satisfied and set executable parameter of routine accordingly

Parameters
rpointer to the routine
Returns
0 if routine is not execuable based on conditions, 1 if it is

Definition at line 170 of file pmm_cond.c.

int cond_idle ( )

test system for idleness

true if 5 minute load is below 0.1

return 0 if not idle, 1 if idle

Definition at line 143 of file pmm_cond.c.

int cond_users ( )

Definition at line 128 of file pmm_cond.c.

int num_users ( )

counts the number of users logged into a system by reading utmp returns the number of users logged in.

code comes from FreeBSD /usr/src/usr.bin/w/w.c

Returns
number of users logged in

Definition at line 90 of file pmm_cond.c.

int ttystat ( char *  line,
int  sz 
)

checks that the tty a user is logged into (as per utmp) exists in /dev

This indicates whether a user has an interactive session or not

code comes from FreeBSD /usr/src/usr.bin/w/w.c

Parameters
linepointer to line of the utmp file
szsize of the line
Returns
1 if user has a tty, 0 if user does not.

Definition at line 62 of file pmm_cond.c.