1 |
< |
/* |
1 |
> |
/* |
2 |
|
* i-scream central monitoring system |
3 |
|
* http://www.i-scream.org |
4 |
< |
* Copyright (C) 2000-2003 i-scream |
4 |
> |
* Copyright (C) 2000-2004 i-scream |
5 |
|
* |
6 |
< |
* This program is free software; you can redistribute it and/or |
7 |
< |
* modify it under the terms of the GNU General Public License |
8 |
< |
* as published by the Free Software Foundation; either version 2 |
9 |
< |
* of the License, or (at your option) any later version. |
6 |
> |
* This library is free software; you can redistribute it and/or |
7 |
> |
* modify it under the terms of the GNU Lesser General Public |
8 |
> |
* License as published by the Free Software Foundation; either |
9 |
> |
* version 2.1 of the License, or (at your option) any later version. |
10 |
|
* |
11 |
< |
* This program is distributed in the hope that it will be useful, |
11 |
> |
* This library is distributed in the hope that it will be useful, |
12 |
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
< |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
< |
* GNU General Public License for more details. |
13 |
> |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 |
> |
* Lesser General Public License for more details. |
15 |
|
* |
16 |
< |
* You should have received a copy of the GNU General Public License |
17 |
< |
* along with this program; if not, write to the Free Software |
18 |
< |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
16 |
> |
* You should have received a copy of the GNU Lesser General Public |
17 |
> |
* License along with this library; if not, write to the Free Software |
18 |
> |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
19 |
> |
* 02111-1307 USA |
20 |
> |
* |
21 |
> |
* $Id$ |
22 |
|
*/ |
23 |
|
|
24 |
|
#ifdef HAVE_CONFIG_H |
101 |
|
} |
102 |
|
} |
103 |
|
|
104 |
+ |
int is_valid_fs_type(const char *type) { |
105 |
+ |
const char *types[] = VALID_FS_TYPES; |
106 |
+ |
int i; |
107 |
+ |
|
108 |
+ |
for (i = 0; i < (sizeof types / sizeof *types); i++) { |
109 |
+ |
if (strcmp(types[i], type) == 0) { |
110 |
+ |
return 1; |
111 |
+ |
} |
112 |
+ |
} |
113 |
+ |
return 0; |
114 |
+ |
} |
115 |
+ |
|
116 |
|
disk_stat_t *get_disk_stats(int *entries){ |
117 |
|
|
118 |
|
static disk_stat_t *disk_stats; |
119 |
|
static int watermark=-1; |
120 |
|
|
121 |
< |
char *fs_types[] = VALID_FS_TYPES; |
107 |
< |
int x, valid_type; |
121 |
> |
int valid_type; |
122 |
|
int num_disks=0; |
123 |
|
#if defined(LINUX) || defined (SOLARIS) || defined(CYGWIN) |
124 |
|
FILE *f; |
153 |
|
return NULL; |
154 |
|
} |
155 |
|
for(;nummnt--; mp++){ |
156 |
< |
valid_type=0; |
143 |
< |
for(x=0;x<((sizeof(fs_types))/(sizeof(char*)));x++){ |
144 |
< |
if(strcmp(mp->f_fstypename, fs_types[x]) ==0){ |
145 |
< |
valid_type=1; |
146 |
< |
break; |
147 |
< |
} |
148 |
< |
} |
156 |
> |
valid_type = is_valid_fs_type(mp->f_fstypename); |
157 |
|
#endif |
158 |
|
|
159 |
|
#if defined(LINUX) || defined(CYGWIN) |
166 |
|
continue; |
167 |
|
} |
168 |
|
|
169 |
< |
valid_type=0; |
162 |
< |
for(x=0;x<((sizeof(fs_types))/(sizeof(char*)));x++){ |
163 |
< |
if(strcmp(mp->mnt_type, fs_types[x]) ==0){ |
164 |
< |
valid_type=1; |
165 |
< |
break; |
166 |
< |
} |
167 |
< |
} |
169 |
> |
valid_type = is_valid_fs_type(mp->mnt_type); |
170 |
|
#endif |
171 |
|
|
172 |
|
#ifdef SOLARIS |
177 |
|
if ((statvfs(mp.mnt_mountp, &fs)) !=0){ |
178 |
|
continue; |
179 |
|
} |
180 |
< |
valid_type=0; |
179 |
< |
for(x=0;x<((sizeof(fs_types))/(sizeof(char*)));x++){ |
180 |
< |
if(strcmp(mp.mnt_fstype, fs_types[x]) ==0){ |
181 |
< |
valid_type=1; |
182 |
< |
break; |
183 |
< |
} |
184 |
< |
} |
180 |
> |
valid_type = is_valid_fs_type(mp.mnt_fstype); |
181 |
|
#endif |
182 |
|
|
183 |
|
if(valid_type){ |
506 |
|
|
507 |
|
if(diskio_stats_ptr->disk_name!=NULL) free(diskio_stats_ptr->disk_name); |
508 |
|
|
509 |
< |
diskio_stats_ptr->disk_name=strdup(ksp->ks_name); |
509 |
> |
diskio_stats_ptr->disk_name=strdup((char *) get_svr_from_bsd(ksp->ks_name)); |
510 |
|
diskio_stats_ptr->systime=time(NULL); |
511 |
|
num_diskio++; |
512 |
|
} |
579 |
|
n++; |
580 |
|
} |
581 |
|
|
582 |
+ |
fclose(f); |
583 |
+ |
f = NULL; |
584 |
+ |
|
585 |
|
if (!has_pp_stats) { |
586 |
< |
/* This is an older kernel without stats in /proc/partitions. |
587 |
< |
Read what we can from /proc/stat instead. */ |
586 |
> |
/* This is an older kernel where /proc/partitions doesn't |
587 |
> |
contain stats. Read what we can from /proc/stat instead, and |
588 |
> |
fill in the appropriate bits of the list allocated above. */ |
589 |
|
|
590 |
|
f = fopen("/proc/stat", "r"); |
591 |
|
if (f == NULL) goto out; |
652 |
|
num_diskio = n; |
653 |
|
out: |
654 |
|
if (f != NULL) fclose(f); |
655 |
+ |
#endif |
656 |
|
|
657 |
+ |
#ifdef CYGWIN |
658 |
+ |
return NULL; |
659 |
|
#endif |
660 |
+ |
|
661 |
|
*entries=num_diskio; |
662 |
|
|
663 |
|
return diskio_stats; |
697 |
|
} |
698 |
|
|
699 |
|
diskio_stats_ptr=get_diskio_stats(&disks); |
700 |
+ |
if (diskio_stats_ptr == NULL) { |
701 |
+ |
return NULL; |
702 |
+ |
} |
703 |
|
diskio_stats_diff_ptr=diskio_stats_diff; |
704 |
|
|
705 |
|
for(x=0;x<sizeof_diskio_stats_diff;x++){ |