205 |
|
diskio_stat_t *diskio_stat_ptr; |
206 |
|
network_stat_t *network_stat_ptr; |
207 |
|
disk_stat_t *disk_stat_ptr; |
208 |
+ |
/* Size before it will start overwriting "uptime" */ |
209 |
+ |
char hostname[15]; |
210 |
+ |
char *ptr; |
211 |
|
|
212 |
|
move(0,12); |
213 |
< |
printw("%s", stats.general_stats->hostname); |
213 |
> |
strncpy(hostname, stats.general_stats->hostname, sizeof(hostname)); |
214 |
> |
ptr=strchr(hostname, '.'); |
215 |
> |
/* Some hosts give back a FQDN for hostname. To avoid this, we'll |
216 |
> |
* just blank out everything after the first "." |
217 |
> |
*/ |
218 |
> |
if (ptr != NULL){ |
219 |
> |
*ptr = '\0'; |
220 |
> |
} |
221 |
> |
printw("%s", hostname); |
222 |
|
move(0,36); |
223 |
|
printw("%s", hr_uptime(stats.general_stats->uptime)); |
224 |
|
epoc_time=time(NULL); |
258 |
|
printw("%5d", stats.user_stats->num_entries); |
259 |
|
|
260 |
|
/* Mem */ |
250 |
– |
|
261 |
|
move(6, 12); |
262 |
|
printw("%7s", size_conv(stats.mem_stats->total)); |
263 |
|
move(7, 12); |
325 |
|
network_stat_ptr++; |
326 |
|
} |
327 |
|
|
328 |
+ |
/* Disk */ |
329 |
|
disk_stat_ptr = stats.disk_stats; |
330 |
|
for(counter=0;counter<stats.disk_entries;counter++){ |
331 |
|
move(13+stats.network_entries+counter, 42); |
333 |
|
move(13+stats.network_entries+counter, 62); |
334 |
|
printw("%7s", size_conv(disk_stat_ptr->avail)); |
335 |
|
move(13+stats.network_entries+counter, 73); |
336 |
< |
printw("%5.2f%%", 100.00 * ((float)disk_stat_ptr->used / (float)disk_stat_ptr->size)); |
336 |
> |
printw("%5.2f%%", 100.00 * ((float) (disk_stat_ptr->size - disk_stat_ptr->avail) / (float) disk_stat_ptr->size)); |
337 |
|
disk_stat_ptr++; |
338 |
|
} |
339 |
|
|
364 |
|
} |
365 |
|
|
366 |
|
void version_num(char *progname){ |
367 |
< |
fprintf(stderr, "%s version %s\n", PACKAGE_VERSION); |
367 |
> |
fprintf(stderr, "%s version %s\n", progname, PACKAGE_VERSION); |
368 |
|
fprintf(stderr, "\nReport bugs to <%s>.\n", PACKAGE_BUGREPORT); |
369 |
|
exit(1); |
370 |
|
} |
372 |
|
void usage(char *progname){ |
373 |
|
fprintf(stderr, "Usage: %s [-d delay] [-v] [-h]\n\n", progname); |
374 |
|
fprintf(stderr, " -d Sets the update time in seconds\n"); |
375 |
< |
fprintf(stderr, " -v Prints version number\n"); |
375 |
> |
fprintf(stderr, " -v Prints version number\n"); |
376 |
|
fprintf(stderr, " -h Displays this help information.\n"); |
377 |
|
fprintf(stderr, "\nReport bugs to <%s>.\n", PACKAGE_BUGREPORT); |
378 |
|
exit(1); |
396 |
|
|
397 |
|
int delay=2; |
398 |
|
|
399 |
< |
while ((c = getopt(argc, argv, "d:")) != EOF){ |
399 |
> |
while ((c = getopt(argc, argv, "vhd:")) != EOF){ |
400 |
|
switch (c){ |
401 |
|
case 'd': |
402 |
|
delay = atoi(optarg); |