Add "df" display to give information about filesystems, available diskspace
and used disk capacity, similar to df(1): Filesystem Avail Capacity /0% /10% /20% /30% /40% /50% /60% /70% /80% /90% /100% / 359M |XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX /tmp 180M | /home 146G |XXXXXXXXXXXXXXXX
This commit is contained in:
parent
e6e79dacef
commit
756c7041c0
|
@ -1,4 +1,4 @@
|
|||
LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.425 $>
|
||||
LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.426 $>
|
||||
|
||||
|
||||
[Note: This file does not mention every change made to the NetBSD source tree.
|
||||
|
@ -216,3 +216,7 @@ Changes from NetBSD 2.0 to NetBSD 3.0:
|
|||
ipf(8): updated to version 4.1.5. [martti 20050208]
|
||||
ipsec(4): Add support for IPsec NAT-T [manu 20050212]
|
||||
ssh: Imported OpenSSH 3.9 [christos 20050213]
|
||||
systat(1): Add "df" display to give information about filesystems,
|
||||
available diskspace and used disk capacity, similar to df(1).
|
||||
[hubertf 20050216]
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile,v 1.28 2005/01/10 02:58:59 lukem Exp $
|
||||
# $NetBSD: Makefile,v 1.29 2005/02/16 03:45:41 hubertf Exp $
|
||||
# @(#)Makefile 8.1 (Berkeley) 6/6/93
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
@ -10,9 +10,9 @@ PROG= systat
|
|||
CPPFLAGS+=-I${NETBSDSRCDIR}/usr.bin/vmstat -DSUPPORT_UTMP -DSUPPORT_UTMPX \
|
||||
-I${NETBSDSRCDIR}/usr.bin/who
|
||||
CWARNFLAGS+= -Wno-format-y2k
|
||||
SRCS= bufcache.c cmds.c cmdtab.c disks.c dkstats.c fetch.c globalcmds.c \
|
||||
icmp.c iostat.c ip.c keyboard.c main.c mbufs.c netcmds.c netstat.c \
|
||||
pigs.c ps.c swap.c tcp.c vmstat.c utmpentry.c
|
||||
SRCS= bufcache.c cmds.c cmdtab.c disks.c df.c dkstats.c fetch.c \
|
||||
globalcmds.c icmp.c iostat.c ip.c keyboard.c main.c mbufs.c \
|
||||
netcmds.c netstat.c pigs.c ps.c swap.c tcp.c vmstat.c utmpentry.c
|
||||
DPADD= ${LIBCURSES} ${LIBM} ${LIBKVM}
|
||||
LDADD= -lutil -lcurses -lm -lkvm
|
||||
BINGRP= kmem
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: cmdtab.c,v 1.19 2003/09/12 17:32:29 mycroft Exp $ */
|
||||
/* $NetBSD: cmdtab.c,v 1.20 2005/02/16 03:45:41 hubertf Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1980, 1992, 1993
|
||||
|
@ -34,7 +34,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)cmdtab.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
__RCSID("$NetBSD: cmdtab.c,v 1.19 2003/09/12 17:32:29 mycroft Exp $");
|
||||
__RCSID("$NetBSD: cmdtab.c,v 1.20 2005/02/16 03:45:41 hubertf Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include "systat.h"
|
||||
|
@ -55,6 +55,12 @@ struct command global_commands[] = {
|
|||
{ 0 }
|
||||
};
|
||||
|
||||
struct command df_commands[] = {
|
||||
{ "all", df_all, "show all filesystems"},
|
||||
{ "some", df_some, "show only some filesystems"},
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
struct command icmp_commands[] = {
|
||||
{ "boot", icmp_boot, "show total stats since boot"},
|
||||
{ "run", icmp_run, "show running total stats"},
|
||||
|
@ -150,6 +156,9 @@ struct mode modes[] = {
|
|||
{ "bufcache", showbufcache, fetchbufcache, labelbufcache,
|
||||
initbufcache, openbufcache, closebufcache, 0,
|
||||
CF_LOADAV },
|
||||
{ "df", showdf, fetchdf, labeldf,
|
||||
initdf, opendf, closedf, df_commands,
|
||||
CF_LOADAV },
|
||||
{ "inet.icmp", showicmp, fetchicmp, labelicmp,
|
||||
initicmp, openicmp, closeicmp, icmp_commands,
|
||||
CF_LOADAV },
|
||||
|
|
|
@ -0,0 +1,176 @@
|
|||
/* $NetBSD: df.c,v 1.1 2005/02/16 03:45:41 hubertf Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1980, 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
* Copyright (c) 2005
|
||||
* Hubert Feyrer <hubert@feyrer.de>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: df.c,v 1.1 2005/02/16 03:45:41 hubertf Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mount.h>
|
||||
|
||||
#include <curses.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <util.h>
|
||||
|
||||
#include "extern.h"
|
||||
#include "systat.h"
|
||||
|
||||
static int nfss;
|
||||
static struct statvfs *fss;
|
||||
static char *nodisplay[] = {"procfs", "kernfs", "null", NULL };
|
||||
static int displayall=0;
|
||||
|
||||
|
||||
WINDOW *
|
||||
opendf(void)
|
||||
{
|
||||
return (subwin(stdscr, -1, 0, 5, 0));
|
||||
}
|
||||
|
||||
void
|
||||
closedf(WINDOW *w)
|
||||
{
|
||||
if (w == NULL)
|
||||
return;
|
||||
wclear(w);
|
||||
wrefresh(w);
|
||||
delwin(w);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
showdf(void)
|
||||
{
|
||||
int i, j, skip;
|
||||
char s[MNAMELEN];
|
||||
char s2[MNAMELEN];
|
||||
float pct;
|
||||
int64_t used, bsize, bavail, availblks;
|
||||
int y;
|
||||
|
||||
y=2; /* at what line to start displaying */
|
||||
for (i=0; i<nfss; i++) {
|
||||
skip = 0;
|
||||
for(j=0; nodisplay[j] != NULL; j++) {
|
||||
if (strcmp(nodisplay[j],
|
||||
fss[i].f_fstypename) == 0) {
|
||||
skip=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (displayall || !skip) {
|
||||
wmove(wnd, y, 0);
|
||||
wclrtoeol(wnd);
|
||||
|
||||
snprintf(s, sizeof(s), "%s", fss[i].f_mntonname);
|
||||
mvwaddstr(wnd, y, 0, s);
|
||||
|
||||
used = fss[i].f_blocks - fss[i].f_bfree;
|
||||
bavail = fss[i].f_bavail;
|
||||
availblks = bavail + used;
|
||||
bsize = fss[i].f_frsize;
|
||||
|
||||
if (availblks == 0) {
|
||||
pct = 1.0; /* full pseudo-disk */
|
||||
} else {
|
||||
pct = (1.0 * used) / availblks;
|
||||
}
|
||||
|
||||
#define FREELEN 7
|
||||
humanize_number(s2, FREELEN, bavail*bsize,
|
||||
" |", HN_AUTOSCALE,
|
||||
HN_B | HN_NOSPACE | HN_DECIMAL);
|
||||
snprintf(s, sizeof(s), "%*s", FREELEN, s2);
|
||||
mvwaddstr(wnd, y, 25-FREELEN, s);
|
||||
#undef FREELEN
|
||||
|
||||
mvwhline(wnd, y, 25, 'X', (int)(51*pct));
|
||||
|
||||
y++;
|
||||
}
|
||||
}
|
||||
wmove(wnd, y, 0);
|
||||
wclrtobot(wnd);
|
||||
}
|
||||
|
||||
int
|
||||
initdf(void)
|
||||
{
|
||||
nfss = getmntinfo(&fss, MNT_NOWAIT);
|
||||
if (nfss == 0) {
|
||||
error("init: getmntinfo error");
|
||||
return(0);
|
||||
}
|
||||
|
||||
mvwaddstr(wnd, 0, 0, "Disk free %age:");
|
||||
return(1);
|
||||
}
|
||||
|
||||
void
|
||||
fetchdf(void)
|
||||
{
|
||||
nfss = getmntinfo(&fss, MNT_NOWAIT);
|
||||
if (nfss == 0) {
|
||||
error("fetch: getmntinfo error");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
labeldf(void)
|
||||
{
|
||||
wmove(wnd, 0, 0);
|
||||
wclrtoeol(wnd);
|
||||
mvwaddstr(wnd, 0, 0, "Filesystem");
|
||||
mvwaddstr(wnd, 0, 18, "Avail");
|
||||
mvwaddstr(wnd, 0, 26, "Capacity");
|
||||
mvwaddstr(wnd, 1, 25, "/0% /10% /20% /30% /40% /50% /60% /70% /80% /90% /100%");
|
||||
}
|
||||
|
||||
void
|
||||
df_all(char *args)
|
||||
{
|
||||
displayall=1;
|
||||
}
|
||||
|
||||
void
|
||||
df_some(char *args)
|
||||
{
|
||||
displayall=0;
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: extern.h,v 1.34 2004/03/27 00:53:59 martin Exp $ */
|
||||
/* $NetBSD: extern.h,v 1.35 2005/02/16 03:45:41 hubertf Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
|
@ -72,6 +72,7 @@ int checkhost6(struct in6pcb *);
|
|||
int checkport6(struct in6pcb *);
|
||||
#endif
|
||||
void closebufcache(WINDOW *);
|
||||
void closedf(WINDOW *);
|
||||
void closeicmp(WINDOW *);
|
||||
void closeiostat(WINDOW *);
|
||||
void closeip(WINDOW *);
|
||||
|
@ -82,6 +83,8 @@ void closepigs(WINDOW *);
|
|||
void closeswap(WINDOW *);
|
||||
void closetcp(WINDOW *);
|
||||
void command(char *);
|
||||
void df_all(char *);
|
||||
void df_some(char *);
|
||||
void die(int);
|
||||
void disks_add(char *);
|
||||
void disks_remove(char *);
|
||||
|
@ -90,6 +93,7 @@ void display(int);
|
|||
void error(const char *, ...)
|
||||
__attribute__((__format__(__printf__, 1, 2)));
|
||||
void fetchbufcache(void);
|
||||
void fetchdf(void);
|
||||
void fetchicmp(void);
|
||||
void fetchiostat(void);
|
||||
void fetchip(void);
|
||||
|
@ -110,6 +114,7 @@ void icmp_run(char *);
|
|||
void icmp_time(char *);
|
||||
void icmp_zero(char *);
|
||||
int initbufcache(void);
|
||||
int initdf(void);
|
||||
int initicmp(void);
|
||||
int initiostat(void);
|
||||
int initip(void);
|
||||
|
@ -131,6 +136,7 @@ void ip_zero(char *);
|
|||
void keyboard(void) __attribute__((__noreturn__));
|
||||
ssize_t kvm_ckread(const void *, void *, size_t, const char *);
|
||||
void labelbufcache(void);
|
||||
void labeldf(void);
|
||||
void labelicmp(void);
|
||||
void labeliostat(void);
|
||||
void labelip(void);
|
||||
|
@ -154,6 +160,7 @@ void netstat_tcp(char *);
|
|||
void netstat_udp(char *);
|
||||
void nlisterr(struct nlist []) __attribute__((__noreturn__));
|
||||
WINDOW *openbufcache(void);
|
||||
WINDOW *opendf(void);
|
||||
WINDOW *openicmp(void);
|
||||
WINDOW *openiostat(void);
|
||||
WINDOW *openip(void);
|
||||
|
@ -166,6 +173,7 @@ WINDOW *opentcp(void);
|
|||
void ps_user(char *);
|
||||
void redraw(int);
|
||||
void showbufcache(void);
|
||||
void showdf(void);
|
||||
void showicmp(void);
|
||||
void showiostat(void);
|
||||
void showip(void);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: systat.1,v 1.33 2003/09/15 13:17:24 wiz Exp $
|
||||
.\" $NetBSD: systat.1,v 1.34 2005/02/16 03:45:41 hubertf Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1985, 1990, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
|
@ -29,7 +29,7 @@
|
|||
.\"
|
||||
.\" @(#)systat.1 8.2 (Berkeley) 12/30/93
|
||||
.\"
|
||||
.Dd September 12, 2003
|
||||
.Dd February 16, 2005
|
||||
.Dt SYSTAT 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
@ -63,7 +63,11 @@ By default
|
|||
.Nm
|
||||
displays the processes getting the largest percentage of the processor
|
||||
in the lower window.
|
||||
Other displays show more detailed process information, swap space usage, disk
|
||||
Other displays show more detailed process information,
|
||||
swap space usage,
|
||||
disk usage statistics (a la
|
||||
.Xr df 1 ) ,
|
||||
disk
|
||||
.Tn I/O
|
||||
statistics (a la
|
||||
.Xr iostat 8 ) ,
|
||||
|
@ -110,6 +114,7 @@ The
|
|||
argument expects to be one of:
|
||||
.Ic all ,
|
||||
.Ic bufcache ,
|
||||
.Ic df ,
|
||||
.Ic inet.icmp ,
|
||||
.Ic inet.ip ,
|
||||
.Ic inet.tcp ,
|
||||
|
@ -208,6 +213,22 @@ Display, in the lower window, statistics about the file system buffers.
|
|||
Statistics for each file system that has active buffers include the number
|
||||
of buffers for that file system, the number of active kilobytes in those
|
||||
buffers and the total size of the buffers for that file system.
|
||||
.It Ic df
|
||||
Lists disk usage statistics for all filesystems,
|
||||
including the available free space as well as a bar
|
||||
graph indicating the used capacity.
|
||||
.Pp
|
||||
The following commands are specific to the
|
||||
.Ic df
|
||||
display:
|
||||
.Pp
|
||||
.Bl -tag -width Fl -compact
|
||||
.It Cm all
|
||||
Displays information for all filesystems, including
|
||||
kernfs, procfs and null-mounts.
|
||||
.It Cm some
|
||||
Suppress information about procfs, kernfs and null-mounts (default).
|
||||
.El
|
||||
.It Ic inet.icmp
|
||||
Display ICMP statistics.
|
||||
.It Ic inet.ip
|
||||
|
@ -517,12 +538,13 @@ Much of the information that
|
|||
uses is obtained from
|
||||
.Cm struct vmmeter cnt .
|
||||
.Sh SEE ALSO
|
||||
.Xr df 1 ,
|
||||
.Xr iostat 8 ,
|
||||
.Xr netstat 1 ,
|
||||
.Xr ps 1 ,
|
||||
.Xr pstat 8 ,
|
||||
.Xr top 1 ,
|
||||
.Xr vmstat 1 ,
|
||||
.Xr iostat 8 ,
|
||||
.Xr pstat 8
|
||||
.Xr vmstat 1
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
|
|
Loading…
Reference in New Issue