30 |
|
|
31 |
#include <config.h> |
#include <config.h> |
32 |
|
|
33 |
|
#include <errno.h> |
34 |
|
|
35 |
|
#if defined HAVE_STRING_H |
36 |
|
#include <string.h> |
37 |
|
#endif |
38 |
|
|
39 |
|
#if defined HAVE_SYS_PARAM_H |
40 |
|
#include <sys/param.h> |
41 |
|
#endif |
42 |
|
|
43 |
|
#if defined HAVE_SYS_MOUNT_H |
44 |
|
#include <sys/mount.h> |
45 |
|
#endif |
46 |
|
|
47 |
#include "monitor.h" |
#include "monitor.h" |
48 |
#include "monit_device_sysdep.h" |
#include "monit_device_sysdep.h" |
49 |
|
|
50 |
/** |
/** |
51 |
* Unknown OS special block device dummy mountpoint method. |
* FreeBSD special block device mountpoint method. Filesystem must be mounted. |
52 |
|
* In the case of success, mountpoint is stored in device information |
53 |
|
* structure for later use. |
54 |
* |
* |
55 |
* @param devinfo Information structure |
* @param devinfo Information structure where resulting data will be stored |
56 |
* @param object Identifies block special device |
* @param object Identifies block special device |
57 |
* @return NULL |
* @return NULL in the case of failure otherwise mountpoint |
58 |
*/ |
*/ |
59 |
char *DeviceInfo_MountPoint_sysdep(DeviceInfo_T devinfo, char *object) { |
char *DeviceInfo_MountPoint_sysdep(DeviceInfo_T devinfo, char *object) { |
60 |
|
|
61 |
log("%s: Unsupported mounted filesystem information method", prog); |
struct statfs usage; |
62 |
|
|
63 |
|
ASSERT(devinfo); |
64 |
|
ASSERT(object); |
65 |
|
|
66 |
return NULL; |
if(statfs(object, &usage) != 0) { |
67 |
|
log("%s: Error getting mountpoint for device '%s' -- %s\n", |
68 |
|
prog, object, STRERROR); |
69 |
|
return NULL; |
70 |
|
} |
71 |
|
|
72 |
|
return strncpy(devinfo->mntpath, usage.f_mntonname, sizeof(devinfo->mntpath)); |
73 |
|
|
74 |
} |
} |
75 |
|
|
76 |
|
|
77 |
/** |
/** |
78 |
* Unknown OS filesystem dummy usage statistics. |
* FreeBSD filesystem usage statistics. In the case of success result is stored in |
79 |
|
* given information structure. |
80 |
* |
* |
81 |
* @param devinfo Information structure |
* @param devinfo Information structure where resulting data will be stored |
82 |
* @return FALSE |
* @return TRUE if informations were succesfully read otherwise FALSE |
83 |
*/ |
*/ |
84 |
int DeviceInfo_Usage_sysdep(DeviceInfo_T devinfo) { |
int DeviceInfo_Usage_sysdep(DeviceInfo_T devinfo) { |
85 |
|
|
86 |
log("%s: Unsupported filesystem informations gathering method\n", prog); |
struct statfs usage; |
87 |
|
|
88 |
|
ASSERT(devinfo); |
89 |
|
|
90 |
|
if(statfs(devinfo->mntpath, &usage) != 0) { |
91 |
|
log("%s: Error getting usage statistics for device '%s' -- %s\n", |
92 |
|
prog, devinfo->mntpath, STRERROR); |
93 |
|
return FALSE; |
94 |
|
} |
95 |
|
|
96 |
|
devinfo->f_bsize= usage.f_bsize; |
97 |
|
devinfo->f_blocks= usage.f_blocks; |
98 |
|
devinfo->f_blocksfree= usage.f_bavail; |
99 |
|
devinfo->f_blocksfreetotal= usage.f_bfree; |
100 |
|
devinfo->f_files= usage.f_files; |
101 |
|
devinfo->f_filesfree= usage.f_ffree; |
102 |
|
|
103 |
return FALSE; |
return TRUE; |
104 |
|
|
105 |
} |
} |
106 |
|
|