Fixed mbtask disk and loadavg status
This commit is contained in:
parent
8e1a1569b0
commit
8fa71f10a1
@ -4464,6 +4464,9 @@ v0.33.19 26-Oct-2001
|
||||
used by ppp scripts to see if there is work and when there is
|
||||
no more work to do. Not important for permament connected
|
||||
systems.
|
||||
Made the FreeBSD and NetBSD disk status calls reliable now
|
||||
that I know how to really get the mounted filesystems.
|
||||
The system load value is implemented on FreeBSD and NetBSD.
|
||||
|
||||
mbmon:
|
||||
Changed the lastcaller screen to display the External Door
|
||||
|
@ -88,7 +88,7 @@ char ttyfn[PATH_MAX]; /* TTY file name */
|
||||
int ping_isocket; /* Ping socket */
|
||||
int icmp_errs = 0; /* ICMP error counter */
|
||||
int internet = FALSE; /* Internet is down */
|
||||
float Load; /* System Load */
|
||||
double Load; /* System Load */
|
||||
int Processing; /* Is system running */
|
||||
int ZMH = FALSE; /* Zone Mail Hour */
|
||||
int UPSalarm = FALSE; /* UPS alarm status */
|
||||
@ -1169,12 +1169,14 @@ void scheduler(void)
|
||||
static char doing[32], buf[2048];
|
||||
time_t now;
|
||||
struct tm *tm, *utm;
|
||||
#if !defined(__FreeBSD__) && !defined(__NetBSD__)
|
||||
FILE *fp;
|
||||
float lavg1, lavg2, lavg3;
|
||||
#endif
|
||||
struct pollfd pfd;
|
||||
struct in_addr paddr;
|
||||
int call_work;
|
||||
static int call_entry = MAXTASKS;
|
||||
double loadavg[3];
|
||||
|
||||
InitFidonet();
|
||||
|
||||
@ -1275,23 +1277,31 @@ void scheduler(void)
|
||||
/*
|
||||
* Check the systems load average. FIXME: doesn't work in FreeBSD !!!
|
||||
*/
|
||||
Load = 0.0;
|
||||
loadavg[0] = loadavg[1] = loadavg[2] = 0.0;
|
||||
#if defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
if (getloadavg(loadavg, 3) == 3) {
|
||||
Load = loadavg[0];
|
||||
}
|
||||
#else
|
||||
if ((fp = fopen((char *)"/proc/loadavg", "r"))) {
|
||||
if (fscanf(fp, "%f %f %f", &lavg1, &lavg2, &lavg3) == 3) {
|
||||
Load = lavg1;
|
||||
if (lavg1 >= TCFG.maxload) {
|
||||
if (!LOADhi) {
|
||||
tasklog('!', "System load too high: %2.2f (%2.2f)", lavg1, TCFG.maxload);
|
||||
LOADhi = TRUE;
|
||||
}
|
||||
} else {
|
||||
if (LOADhi) {
|
||||
tasklog('!', "System load normal: %2.2f (%2.2f)", lavg1, TCFG.maxload);
|
||||
LOADhi = FALSE;
|
||||
}
|
||||
}
|
||||
if (fscanf(fp, "%f %f %f", &loadavg[0], &loadavg[1], &loadavg[2]) == 3) {
|
||||
Load = loadavg[0];
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
#endif
|
||||
if (Load >= TCFG.maxload) {
|
||||
if (!LOADhi) {
|
||||
tasklog('!', "System load too high: %2.2f (%2.2f)", Load, TCFG.maxload);
|
||||
LOADhi = TRUE;
|
||||
}
|
||||
} else {
|
||||
if (LOADhi) {
|
||||
tasklog('!', "System load normal: %2.2f (%2.2f)", Load, TCFG.maxload);
|
||||
LOADhi = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Report to the system monitor.
|
||||
@ -1306,7 +1316,7 @@ void scheduler(void)
|
||||
else if (Processing)
|
||||
sprintf(doing, "Waiting (%d)", oldmin);
|
||||
else
|
||||
sprintf(doing, "Overload %2.2f", lavg1);
|
||||
sprintf(doing, "Overload %2.2f", Load);
|
||||
|
||||
sprintf(reginfo[0].doing, "%s", doing);
|
||||
reginfo[0].lastcon = time(NULL);
|
||||
|
@ -41,21 +41,27 @@
|
||||
*/
|
||||
char *get_diskstat()
|
||||
{
|
||||
char *mtab, *dev, *fs, *type, *tmp = NULL;
|
||||
FILE *fp;
|
||||
int i = 0;
|
||||
static char buf[SS_BUFSIZE];
|
||||
struct statfs sfs;
|
||||
char *tmp = NULL;
|
||||
char tt[80];
|
||||
struct statfs sfs;
|
||||
unsigned long temp;
|
||||
#if defined(__linux__)
|
||||
char *mtab, *dev, *fs, *type;
|
||||
FILE *fp;
|
||||
int i = 0;
|
||||
#elif defined(__FreeBSD__) || (__NetBSD__)
|
||||
struct statfs *mntbuf;
|
||||
long mntsize;
|
||||
int i, j = 0;
|
||||
#endif
|
||||
|
||||
buf[0] = '\0';
|
||||
|
||||
#if defined (__linux__)
|
||||
|
||||
mtab = calloc(PATH_MAX, sizeof(char));
|
||||
#ifdef __linux__
|
||||
if ((fp = fopen((char *)"/etc/mtab", "r")) == 0) {
|
||||
#elif __FreeBSD__ || __NetBSD__
|
||||
if ((fp = fopen((char *)"/etc/fstab", "r")) == 0) {
|
||||
#endif
|
||||
sprintf(buf, "100:0;");
|
||||
return buf;
|
||||
}
|
||||
@ -90,6 +96,39 @@ char *get_diskstat()
|
||||
else
|
||||
sprintf(buf, "100:%d%s;", i, tmp);
|
||||
|
||||
#elif defined(__FreeBSD__) || (__NetBSD__)
|
||||
|
||||
mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
|
||||
|
||||
for (i = 0; i < mntsize; i++) {
|
||||
if ((strncmp(mntbuf[i].f_fstypename, (char *)"kernfs", 6)) && (statfs(mntbuf[i].f_mntonname, &sfs) == 0)) {
|
||||
if (tmp == NULL)
|
||||
tmp = xstrcpy((char *)",");
|
||||
else
|
||||
tmp = xstrcat(tmp, (char *)",");
|
||||
tt[0] = '\0';
|
||||
temp = (unsigned long)(sfs.f_bsize / 512L);
|
||||
sprintf(tt, "%lu %lu %s %s",
|
||||
(unsigned long)(sfs.f_blocks * temp) / 2048L,
|
||||
(unsigned long)(sfs.f_bavail * temp) / 2048L,
|
||||
mntbuf[i].f_mntonname, mntbuf[i].f_fstypename);
|
||||
tmp = xstrcat(tmp, tt);
|
||||
j++;
|
||||
if (j == 10)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (strlen(tmp) > (SS_BUFSIZE - 8))
|
||||
sprintf(buf, "100:0;");
|
||||
else
|
||||
sprintf(buf, "100:%d%s;", j, tmp);
|
||||
#else
|
||||
/*
|
||||
* Not supported, so return nothing usefull.
|
||||
*/
|
||||
sprintf(buf, "100:0;");
|
||||
#endif
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ typedef struct {
|
||||
|
||||
static char stat_fn[PATH_MAX]; /* Statusfile name */
|
||||
static status_r status; /* Status data */
|
||||
extern float Load; /* System Load */
|
||||
extern double Load; /* System Load */
|
||||
extern int Processing; /* Is system running */
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user