/[monit]/monit/device/sysdep_HPUX.c
ViewVC logotype

Diff of /monit/device/sysdep_HPUX.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by martinp, Sun Jul 6 18:29:38 2003 UTC revision 1.2 by martinp, Sun Jul 6 22:57:01 2003 UTC
# Line 30  Line 30 
30    
31  #include <config.h>  #include <config.h>
32    
33    #include <stdio.h>
34    #include <errno.h>
35    
36    #ifdef HAVE_SYS_VFS_H
37    # include <sys/vfs.h>
38    #endif
39    
40    #ifdef HAVE_MNTENT_H
41    #include <mntent.h>
42    #endif
43    
44  #include "monitor.h"  #include "monitor.h"
45  #include "monit_device_sysdep.h"  #include "monit_device_sysdep.h"
46    
47    
48  /**  /**
49   * Unknown OS special block device dummy mountpoint method.   * HPUX special block device mountpoint method. Filesystem must be mounted.
50     * In the case of success, mountpoint is stored in device information
51     * structure for later use.
52   *   *
53   * @param devinfo Information structure   * @param devinfo Information structure where resulting data will be stored
54   * @param object  Identifies block special device   * @param object  Identifies block special device
55   * @return        NULL   * @return        NULL in the case of failure otherwise mountpoint
56   */   */
57  char *DeviceInfo_MountPoint_sysdep(DeviceInfo_T devinfo, char *object) {  char *DeviceInfo_MountPoint_sysdep(DeviceInfo_T devinfo, char *object) {
58    
59    log("%s: Unsupported mounted filesystem information method", prog);    struct mntent *mnt;
60      FILE          *mntfd;
61    
62      ASSERT(devinfo);
63      ASSERT(object);
64    
65    
66      if((mntfd= setmntent("/etc/mnttab", "r")) == NULL) {
67        log("%s: Cannot open /etc/mnttab file", prog);
68        return NULL;
69      }
70    
71      /* First match is significant */
72      while((mnt= getmntent(mntfd)) != NULL) {
73    
74        if(IS(object, mnt->mnt_fsname)) {
75    
76          endmntent(mntfd);
77          return strncpy(devinfo->mntpath, mnt->mnt_dir, sizeof(devinfo->mntpath));
78    
79        }
80    
81      }
82    
83      endmntent(mntfd);
84    
85    return NULL;    return NULL;
86    
# Line 50  char *DeviceInfo_MountPoint_sysdep(Devic Line 88  char *DeviceInfo_MountPoint_sysdep(Devic
88    
89    
90  /**  /**
91   * Unknown OS filesystem dummy usage statistics.   * HPUX filesystem usage statistics. In the case of success result is stored in
92     * given information structure.
93   *   *
94   * @param devinfo Information structure   * @param devinfo Information structure where resulting data will be stored
95   * @return        FALSE   * @return        TRUE if informations were succesfully read otherwise FALSE
96   */   */
97  int DeviceInfo_Usage_sysdep(DeviceInfo_T devinfo) {  int DeviceInfo_Usage_sysdep(DeviceInfo_T devinfo) {
98    
99    log("%s: Unsupported filesystem informations gathering method\n", prog);    struct statfs usage;
100    
101      ASSERT(devinfo);
102    
103      if(statfsdev(devinfo->mntpath, &usage) != 0) {
104        log("%s: Error getting usage statistics for device '%s' -- %s\n",
105            prog, devinfo->mntpath, STRERROR);
106        return FALSE;
107      }
108    
109      devinfo->f_bsize=           usage.f_bsize;
110      devinfo->f_blocks=          usage.f_blocks;
111      devinfo->f_blocksfree=      usage.f_bavail;
112      devinfo->f_blocksfreetotal= usage.f_bfree;
113      devinfo->f_files=           usage.f_files;
114      devinfo->f_filesfree=       usage.f_ffree;
115    
116    return FALSE;    return TRUE;
117    
118  }  }
119    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26