mirror of
https://github.com/monitoring-plugins/monitoring-plugins.git
synced 2026-05-28 04:35:40 -04:00
start support for gettimeofday and tv_usec
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@116 f882894a-f735-0410-b71e-b25c423dba1c
This commit is contained in:
parent
509f71f79e
commit
6cbf1dd4a3
2 changed files with 39 additions and 7 deletions
|
|
@ -316,6 +316,19 @@ is_option (char *str)
|
|||
|
||||
|
||||
|
||||
double
|
||||
delta_time (struct timeval *tv)
|
||||
{
|
||||
struct timeval *pt;
|
||||
struct timezone *tz;
|
||||
|
||||
gettimeofday (pt, tz);
|
||||
|
||||
return (pt->tv_sec - tv->tv_sec + (pt->tv_usec - tv->tv_usec) / 1000000);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
strip (char *buffer)
|
||||
|
|
|
|||
|
|
@ -45,13 +45,31 @@ int is_percentage (char *);
|
|||
|
||||
int is_option (char *);
|
||||
|
||||
/* generalized timer that will do milliseconds if available */
|
||||
#ifndef HAVE_GETTIMEOFDAY
|
||||
struct timeval {
|
||||
long tv_sec; /* seconds */
|
||||
long tv_usec; /* microseconds */
|
||||
};
|
||||
|
||||
struct timezone {
|
||||
int tz_minuteswest; /* minutes W of Greenwich */
|
||||
int tz_dsttime; /* type of dst correction */
|
||||
};
|
||||
|
||||
#define gettimeofday (tvp,tz) {\
|
||||
tvp->tv_usec=0;\
|
||||
tvp->tv_sec=(long)time();\
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Handle strings safely */
|
||||
|
||||
void strip (char *buffer);
|
||||
char *strscpy (char *dest, char *src);
|
||||
char *strscat (char *dest, char *src);
|
||||
char *strnl (char *str);
|
||||
char *ssprintf (char *str, const char *fmt, ...);
|
||||
char *ssprintf (char *str, const char *fmt, ...); /* deprecate for asprintf */
|
||||
char *strpcpy (char *dest, const char *src, const char *str);
|
||||
char *strpcat (char *dest, const char *src, const char *str);
|
||||
|
||||
|
|
@ -61,15 +79,15 @@ int max_state(int, int);
|
|||
#define max(a,b) ((a)>(b))?(a):(b)
|
||||
|
||||
#define usage(msg) {\
|
||||
printf(msg);\
|
||||
print_usage();\
|
||||
exit(STATE_UNKNOWN);\
|
||||
printf(msg);\
|
||||
print_usage();\
|
||||
exit(STATE_UNKNOWN);\
|
||||
}
|
||||
|
||||
#define usage2(msg,arg) {\
|
||||
printf("%s: %s - %s\n",PROGNAME,msg,arg);\
|
||||
print_usage();\
|
||||
exit(STATE_UNKNOWN);\
|
||||
printf("%s: %s - %s\n",PROGNAME,msg,arg);\
|
||||
print_usage();\
|
||||
exit(STATE_UNKNOWN);\
|
||||
}
|
||||
|
||||
#define state_text(a) \
|
||||
|
|
@ -94,3 +112,4 @@ exit(STATE_UNKNOWN);\
|
|||
{"warning",required_argument,0,'w'},\
|
||||
{"hostname",required_argument,0,'H'},\
|
||||
{"file",required_argument,0,'F'}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue