2001-08-17 05:46:24 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
2001-12-23 21:05:40 +00:00
|
|
|
* $Id$
|
2001-08-17 05:46:24 +00:00
|
|
|
* Purpose ...............: Keep track of server status
|
|
|
|
*
|
|
|
|
*****************************************************************************
|
2007-04-30 19:04:15 +00:00
|
|
|
* Copyright (C) 1997-2007
|
2001-08-17 05:46:24 +00:00
|
|
|
*
|
|
|
|
* Michiel Broek FIDO: 2:280/2802
|
|
|
|
* Beekmansbos 10
|
|
|
|
* 1971 BV IJmuiden
|
|
|
|
* the Netherlands
|
|
|
|
*
|
|
|
|
* This file is part of MBSE BBS.
|
|
|
|
*
|
|
|
|
* This BBS is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
* later version.
|
|
|
|
*
|
|
|
|
* MB BBS is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with MB BBS; see the file COPYING. If not, write to the Free
|
|
|
|
* Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2002-06-30 13:20:57 +00:00
|
|
|
#include "../config.h"
|
2004-02-21 17:22:00 +00:00
|
|
|
#include "../lib/mbselib.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "taskstat.h"
|
2001-12-29 12:59:40 +00:00
|
|
|
#include "callstat.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "outstat.h"
|
2005-05-01 09:18:17 +00:00
|
|
|
#include "taskibc.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "taskutil.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Semafores
|
|
|
|
*/
|
|
|
|
int s_scanout = FALSE;
|
|
|
|
int s_mailout = FALSE;
|
|
|
|
int s_mailin = FALSE;
|
|
|
|
int s_reqindex = FALSE;
|
|
|
|
int s_index = FALSE;
|
|
|
|
int s_msglink = FALSE;
|
|
|
|
int s_newnews = FALSE;
|
|
|
|
int s_bbsopen = FALSE;
|
2002-02-02 15:15:34 +00:00
|
|
|
int s_do_inet = FALSE;
|
2003-02-12 20:20:59 +00:00
|
|
|
int tosswait = TOSSWAIT_TIME;
|
2001-08-17 05:46:24 +00:00
|
|
|
extern int UPSalarm;
|
2004-09-19 14:08:01 +00:00
|
|
|
extern int UPSdown;
|
2001-12-23 21:05:40 +00:00
|
|
|
extern int ptimer;
|
2002-02-24 13:52:13 +00:00
|
|
|
extern int rescan;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
extern struct taskrec TCFG;
|
|
|
|
extern int internet;
|
|
|
|
extern int ZMH;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
2005-10-11 20:49:41 +00:00
|
|
|
int tot_clt; /* Total client connects */
|
|
|
|
int peak_clt; /* Peak simultaneous tot_cltes */
|
|
|
|
int s_error; /* Syntax errors from clients */
|
|
|
|
int c_error; /* Comms errors from clients */
|
2001-08-17 05:46:24 +00:00
|
|
|
} cl_stat;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
2005-10-11 20:49:41 +00:00
|
|
|
int start; /* Start date/time */
|
|
|
|
int laststart; /* Last start date/time */
|
|
|
|
int daily; /* Last daily update */
|
|
|
|
int startups; /* Total starts */
|
|
|
|
int clients; /* Connected clients */
|
2001-08-17 05:46:24 +00:00
|
|
|
cl_stat total; /* Total statistics */
|
|
|
|
cl_stat today; /* Todays statistics */
|
|
|
|
unsigned open : 1; /* Is BBS open */
|
2005-10-11 20:49:41 +00:00
|
|
|
unsigned int sequence; /* Sequencer counter */
|
2007-04-30 15:08:05 +00:00
|
|
|
|
|
|
|
unsigned int mkbrcvd; /* MIB mailer Kbytes received */
|
|
|
|
unsigned int mkbsent; /* MIB mailer Kbytes sent */
|
|
|
|
unsigned int msessin; /* MIB mailer inbound sessions */
|
|
|
|
unsigned int msessout; /* MIB mailer outbound sessions */
|
|
|
|
unsigned int msesssecure; /* MIB mailer secure sessions */
|
|
|
|
unsigned int msessunsec; /* MIB mailer unsecure sessions */
|
|
|
|
unsigned int msessbad; /* MIB mailer bad sessions */
|
2007-04-30 19:04:15 +00:00
|
|
|
unsigned int mftsc; /* MIB mailer FTSC sessions */
|
|
|
|
unsigned int myoohoo; /* MIB mailer YooHoo sessions */
|
|
|
|
unsigned int memsi; /* MIB mailer EMSI sessions */
|
|
|
|
unsigned int mbinkp; /* MIB mailer Binkp sessions */
|
2007-04-30 15:08:05 +00:00
|
|
|
unsigned int mfreqs; /* MIB mailer file requests */
|
|
|
|
|
|
|
|
unsigned int tmsgsin; /* MIB tosser messages in */
|
|
|
|
unsigned int tmsgsout; /* MIB tosser messages out */
|
|
|
|
unsigned int tmsgsbad; /* MIB tosser messages bad */
|
|
|
|
unsigned int tmsgsdupe; /* MIB tosser messages dupe */
|
|
|
|
|
|
|
|
unsigned int tnetin; /* MIB tosser netmail in */
|
|
|
|
unsigned int tnetout; /* MIB tosser netmail out */
|
|
|
|
unsigned int tnetbad; /* MIB tosser netmail bad */
|
|
|
|
|
|
|
|
unsigned int temailin; /* MIB tosser email in */
|
|
|
|
unsigned int temailout; /* MIB tosser email out */
|
|
|
|
unsigned int temailbad; /* MIB tosser email bad */
|
|
|
|
|
|
|
|
unsigned int techoin; /* MIB tosser echomail in */
|
|
|
|
unsigned int techoout; /* MIB tosser echomail out */
|
|
|
|
unsigned int techobad; /* MIB tosser echomail bad */
|
|
|
|
unsigned int techodupe; /* MIB tosser echomail dupe */
|
|
|
|
|
|
|
|
unsigned int tnewsin; /* MIB tosser news in */
|
|
|
|
unsigned int tnewsout; /* MIB tosser news out */
|
|
|
|
unsigned int tnewsbad; /* MIB tosser news bad */
|
|
|
|
unsigned int tnewsdupe; /* MIB tosser news dupe */
|
|
|
|
|
|
|
|
unsigned int tfilesin; /* MIB tosser files in */
|
|
|
|
unsigned int tfilesout; /* MIB tosser files out */
|
|
|
|
unsigned int tfilesbad; /* MIB tosser bad files */
|
|
|
|
unsigned int tfilesdupe; /* MIB tosser dupe files */
|
|
|
|
|
|
|
|
unsigned int tfilesmagic; /* MIB tosser files magics */
|
|
|
|
unsigned int tfileshatched; /* MIB tosser files hatched */
|
2007-04-30 19:54:57 +00:00
|
|
|
|
|
|
|
unsigned int bsessions; /* MIB BBS sessions */
|
|
|
|
unsigned int bminutes; /* MIB BBS minutes used */
|
|
|
|
unsigned int bposted; /* MIB BBS msgs posted */
|
|
|
|
unsigned int buploads; /* MIB BBS file uploads */
|
|
|
|
unsigned int bkbupload; /* MIB BBS kbytes uploaded */
|
|
|
|
unsigned int bdownloads; /* MIB BBS file downloads */
|
|
|
|
unsigned int bkbdownload; /* MIB BBS kbytes downloaded */
|
|
|
|
unsigned int bchats; /* MIB BBS chatsessions */
|
|
|
|
unsigned int bchatminutes; /* MIB BBS chat minutes */
|
2001-08-17 05:46:24 +00:00
|
|
|
} status_r;
|
|
|
|
|
|
|
|
|
|
|
|
static char stat_fn[PATH_MAX]; /* Statusfile name */
|
|
|
|
static status_r status; /* Status data */
|
2002-02-04 20:37:01 +00:00
|
|
|
extern double Load; /* System Load */
|
2001-08-17 05:46:24 +00:00
|
|
|
extern int Processing; /* Is system running */
|
|
|
|
|
2005-05-01 09:18:17 +00:00
|
|
|
|
2001-08-17 05:46:24 +00:00
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
*
|
|
|
|
* Initialize the statusfile, create it if necesary.
|
|
|
|
*/
|
|
|
|
void status_init()
|
|
|
|
{
|
2004-12-29 13:06:09 +00:00
|
|
|
size_t cnt;
|
|
|
|
int stat_fd;
|
|
|
|
|
2005-08-29 21:03:28 +00:00
|
|
|
snprintf(stat_fn, PATH_MAX, "%s/var/status.mbsed", getenv("MBSE_ROOT"));
|
2004-12-29 13:06:09 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* First check if this is the very first time we start the show.
|
|
|
|
* If so, we generate an empty status file with only the start
|
|
|
|
* date in it.
|
|
|
|
*/
|
2007-04-30 15:08:05 +00:00
|
|
|
memset((char *)&status, 0, sizeof(status_r));
|
2004-12-29 13:06:09 +00:00
|
|
|
stat_fd = open(stat_fn, O_RDWR);
|
|
|
|
if (stat_fd == -1) {
|
2005-10-16 12:22:30 +00:00
|
|
|
status.start = (int)time(NULL);
|
|
|
|
status.daily = (int)time(NULL);
|
2005-10-11 20:49:41 +00:00
|
|
|
status.sequence = (unsigned int)time(NULL);
|
2004-12-29 13:06:09 +00:00
|
|
|
stat_fd = open(stat_fn, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
|
2001-08-17 05:46:24 +00:00
|
|
|
cnt = write(stat_fd, &status, sizeof(status_r));
|
2004-12-29 13:06:09 +00:00
|
|
|
Syslog('+', "New statusfile created");
|
|
|
|
lseek(stat_fd, 0, SEEK_SET);
|
|
|
|
}
|
|
|
|
|
|
|
|
cnt = read(stat_fd, &status, sizeof(status_r));
|
2007-04-30 15:37:47 +00:00
|
|
|
if ((cnt != sizeof(status_r)) && (cnt < 50)) {
|
2004-12-29 13:06:09 +00:00
|
|
|
printf("Error reading status file\n");
|
|
|
|
exit(MBERR_INIT_ERROR);
|
|
|
|
}
|
|
|
|
status.startups++;
|
2005-10-16 12:22:30 +00:00
|
|
|
status.laststart = (int)time(NULL);
|
2004-12-29 13:06:09 +00:00
|
|
|
status.clients = 1; /* We are a client ourself */
|
|
|
|
s_bbsopen = status.open;
|
|
|
|
lseek(stat_fd, 0, SEEK_SET);
|
|
|
|
cnt = write(stat_fd, &status, sizeof(status_r));
|
|
|
|
if (cnt != sizeof(status_r)) {
|
|
|
|
Syslog('?', "$Error rewrite status file\n");
|
|
|
|
exit(MBERR_INIT_ERROR);
|
|
|
|
}
|
|
|
|
close(stat_fd);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Writeback the updated status record.
|
|
|
|
*/
|
|
|
|
void status_write(void);
|
|
|
|
void status_write(void)
|
|
|
|
{
|
2003-01-27 21:55:42 +00:00
|
|
|
int d, stat_fd, yday;
|
2004-12-29 12:39:47 +00:00
|
|
|
struct tm ttm;
|
2003-01-27 21:55:42 +00:00
|
|
|
time_t temp;
|
|
|
|
|
|
|
|
temp = time(NULL);
|
2004-12-29 12:39:47 +00:00
|
|
|
localtime_r(&temp, &ttm);
|
|
|
|
yday = ttm.tm_yday;
|
2005-10-16 12:22:30 +00:00
|
|
|
temp = (time_t)status.daily;
|
2004-12-29 12:39:47 +00:00
|
|
|
localtime_r(&temp, &ttm);
|
2003-01-27 21:55:42 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If we passed to the next day, zero the today counters
|
|
|
|
*/
|
2004-12-29 12:39:47 +00:00
|
|
|
if (yday != ttm.tm_yday) {
|
2003-01-27 21:55:42 +00:00
|
|
|
Syslog('+', "Last days statistics:");
|
|
|
|
Syslog('+', "Total clients : %lu", status.today.tot_clt);
|
|
|
|
Syslog('+', "Peak clients : %lu", status.today.peak_clt);
|
|
|
|
Syslog('+', "Syntax errors : %lu", status.today.s_error);
|
|
|
|
Syslog('+', "Comms errors : %lu", status.today.c_error);
|
|
|
|
|
|
|
|
memset((char *)&status.today, 0, sizeof(cl_stat));
|
|
|
|
status.daily = time(NULL);
|
|
|
|
Syslog('+', "Zeroed todays status counters");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((stat_fd = open(stat_fn, O_RDWR)) == -1) {
|
|
|
|
Syslog('?', "$Error open statusfile %s", stat_fn);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((d = lseek(stat_fd, 0, SEEK_SET)) != 0) {
|
|
|
|
Syslog('?', "$Error seeking in statusfile");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
d = write(stat_fd, &status, sizeof(status_r));
|
|
|
|
if (d != sizeof(status_r))
|
|
|
|
Syslog('?', "$Error writing statusfile, only %d bytes", d);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* CLose the statusfile
|
|
|
|
*/
|
|
|
|
if (close(stat_fd) != 0)
|
|
|
|
Syslog('?', "$Error closing statusfile");
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* Various actions on the statusfile.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check for Zone Mail Hour, return TRUE if it is.
|
|
|
|
*/
|
|
|
|
int get_zmh()
|
|
|
|
{
|
2005-10-16 12:22:30 +00:00
|
|
|
struct tm l_date;
|
|
|
|
char sstime[6];
|
|
|
|
time_t Now;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-12-29 13:06:09 +00:00
|
|
|
Now = time(NULL);
|
|
|
|
gmtime_r(&Now, &l_date);
|
2005-08-29 21:03:28 +00:00
|
|
|
snprintf(sstime, 6, "%02d:%02d", l_date.tm_hour, l_date.tm_min);
|
2004-12-29 13:06:09 +00:00
|
|
|
|
|
|
|
if ((strncmp(sstime, TCFG.zmh_start, 5) >= 0) && (strncmp(sstime, TCFG.zmh_end, 5) < 0)) {
|
|
|
|
if (!ZMH) {
|
|
|
|
CreateSema((char *)"zmh");
|
|
|
|
Syslog('!', "Start of Zone Mail Hour");
|
|
|
|
ZMH = TRUE;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (ZMH) {
|
|
|
|
RemoveSema((char *)"zmh");
|
|
|
|
Syslog('!', "End of Zone Mail Hour");
|
|
|
|
ZMH = FALSE;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-12-29 13:06:09 +00:00
|
|
|
}
|
|
|
|
return ZMH;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void stat_inc_clients()
|
|
|
|
{
|
2004-12-29 13:06:09 +00:00
|
|
|
status.clients++;
|
|
|
|
status.total.tot_clt++;
|
|
|
|
status.today.tot_clt++;
|
|
|
|
if (status.clients >= status.total.peak_clt)
|
|
|
|
status.total.peak_clt = status.clients;
|
|
|
|
if (status.clients >= status.today.peak_clt)
|
|
|
|
status.today.peak_clt = status.clients;
|
|
|
|
|
|
|
|
status_write();
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void stat_dec_clients()
|
|
|
|
{
|
2004-12-29 13:06:09 +00:00
|
|
|
status.clients--;
|
|
|
|
status_write();
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void stat_set_open(int op)
|
|
|
|
{
|
2004-12-29 13:06:09 +00:00
|
|
|
if (op) {
|
|
|
|
if (!s_bbsopen) {
|
|
|
|
Syslog('!', "The bbs is open");
|
|
|
|
sem_set((char *)"scanout", TRUE);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-12-29 13:06:09 +00:00
|
|
|
} else {
|
|
|
|
if (s_bbsopen) {
|
|
|
|
Syslog('!', "The bbs is closed");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
s_bbsopen = status.open = op;
|
|
|
|
status_write();
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void stat_inc_serr()
|
|
|
|
{
|
2004-12-29 13:06:09 +00:00
|
|
|
status.total.s_error++;
|
|
|
|
status.today.s_error++;
|
|
|
|
status_write();
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void stat_inc_cerr()
|
|
|
|
{
|
2004-12-29 13:06:09 +00:00
|
|
|
status.total.c_error++;
|
|
|
|
status.today.c_error++;
|
|
|
|
status_write();
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-01-30 22:27:02 +00:00
|
|
|
void stat_status_r(char *buf)
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2006-05-25 16:37:52 +00:00
|
|
|
int i, srvcnt = 0, chncnt = 0, usrcnt = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < MAXIBC_SRV; i++)
|
|
|
|
if (strlen(srv_list[i].server))
|
|
|
|
srvcnt++;
|
|
|
|
for (i = 0; i < MAXIBC_CHN; i++)
|
|
|
|
if (strlen(chn_list[i].server))
|
|
|
|
chncnt++;
|
|
|
|
for (i = 0; i < MAXIBC_USR; i++)
|
|
|
|
if (strlen(usr_list[i].server))
|
|
|
|
usrcnt++;
|
2006-01-30 22:27:02 +00:00
|
|
|
snprintf(buf, SS_BUFSIZE, "100:23,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%2.2f,%u,%d,%d,%d;",
|
2005-10-16 12:22:30 +00:00
|
|
|
status.start, status.laststart, status.daily,
|
2004-12-29 13:06:09 +00:00
|
|
|
status.startups, status.clients,
|
|
|
|
status.total.tot_clt, status.total.peak_clt,
|
|
|
|
status.total.s_error, status.total.c_error,
|
|
|
|
status.today.tot_clt, status.today.peak_clt,
|
|
|
|
status.today.s_error, status.today.c_error,
|
2005-05-01 09:18:17 +00:00
|
|
|
status.open, get_zmh(), internet, s_do_inet, Processing, Load, status.sequence,
|
|
|
|
srvcnt, chncnt, usrcnt);
|
2006-01-30 22:27:02 +00:00
|
|
|
return;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return open status:
|
|
|
|
* 0 = open.
|
|
|
|
* 1 = closed.
|
|
|
|
* 2 = Zone Mail Hour.
|
|
|
|
*/
|
|
|
|
int stat_bbs_stat()
|
|
|
|
{
|
2004-12-29 13:06:09 +00:00
|
|
|
if (!status.open)
|
|
|
|
return 1;
|
|
|
|
if (get_zmh())
|
|
|
|
return 2;
|
|
|
|
return 0;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get next sequence number
|
|
|
|
*/
|
2006-01-30 22:27:02 +00:00
|
|
|
void getseq_r(char *buf)
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2004-12-29 13:06:09 +00:00
|
|
|
status.sequence++;
|
|
|
|
status_write();
|
2005-10-11 20:49:41 +00:00
|
|
|
snprintf(buf, 80, "100:1,%u;", status.sequence);
|
2006-01-30 22:27:02 +00:00
|
|
|
return;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-10-11 20:49:41 +00:00
|
|
|
unsigned int gettoken(void)
|
2005-04-17 10:32:41 +00:00
|
|
|
{
|
|
|
|
status.sequence++;
|
|
|
|
status_write();
|
|
|
|
return status.sequence;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-08-17 05:46:24 +00:00
|
|
|
int sem_set(char *sem, int value)
|
|
|
|
{
|
2003-02-12 20:20:59 +00:00
|
|
|
if (!strcmp(sem, "scanout")) {
|
|
|
|
s_scanout = value;
|
|
|
|
if (value)
|
|
|
|
rescan = TRUE;
|
|
|
|
} else if (!strcmp(sem, "mailout")) {
|
|
|
|
s_mailout = value;
|
|
|
|
} else if (!strcmp(sem, "mailin")) {
|
|
|
|
s_mailin = value;
|
|
|
|
if (value)
|
|
|
|
tosswait = TOSSWAIT_TIME;
|
|
|
|
} else if (!strcmp(sem, "mbindex")) {
|
|
|
|
s_index = value;
|
|
|
|
} else if (!strcmp(sem, "newnews")) {
|
|
|
|
s_newnews = value;
|
|
|
|
} else if (!strcmp(sem, "msglink")) {
|
|
|
|
s_msglink = value;
|
|
|
|
} else if (!strcmp(sem, "reqindex")) {
|
|
|
|
s_reqindex = value;
|
|
|
|
} else if (!strcmp(sem, "do_inet")) {
|
|
|
|
s_do_inet = value;
|
|
|
|
} else {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
ptimer = PAUSETIME;
|
|
|
|
return TRUE;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-01-30 22:27:02 +00:00
|
|
|
void sem_status_r(char *data, char *buf)
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2003-08-03 15:58:26 +00:00
|
|
|
char *cnt, *sem;
|
|
|
|
int value;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-08-29 21:03:28 +00:00
|
|
|
snprintf(buf, 40, "200:1,16;");
|
2003-08-03 15:58:26 +00:00
|
|
|
cnt = strtok(data, ",");
|
|
|
|
sem = strtok(NULL, ";");
|
|
|
|
|
|
|
|
if (!strcmp(sem, "scanout")) {
|
|
|
|
value = s_scanout;
|
|
|
|
} else if (!strcmp(sem, "mailout")) {
|
|
|
|
value = s_mailout;
|
|
|
|
} else if (!strcmp(sem, "mailin")) {
|
|
|
|
value = s_mailin;
|
|
|
|
} else if (!strcmp(sem, "mbindex")) {
|
|
|
|
value = s_index;
|
|
|
|
} else if (!strcmp(sem, "newnews")) {
|
|
|
|
value = s_newnews;
|
|
|
|
} else if (!strcmp(sem, "msglink")) {
|
|
|
|
value = s_msglink;
|
|
|
|
} else if (!strcmp(sem, "reqindex")) {
|
|
|
|
value = s_reqindex;
|
|
|
|
} else if (!strcmp(sem, "upsalarm")) {
|
|
|
|
value = UPSalarm;
|
2004-09-19 14:08:01 +00:00
|
|
|
} else if (!strcmp(sem, "upsdown")) {
|
|
|
|
value = UPSdown;
|
2003-08-03 15:58:26 +00:00
|
|
|
} else if (!strcmp(sem, "do_inet")) {
|
|
|
|
value = s_do_inet;
|
|
|
|
} else {
|
|
|
|
Syslog('s', "sem_status(%s) buf=%s", sem, buf);
|
2006-01-30 22:27:02 +00:00
|
|
|
return;
|
2003-08-03 15:58:26 +00:00
|
|
|
}
|
|
|
|
|
2005-08-29 21:03:28 +00:00
|
|
|
snprintf(buf, 40, "100:1,%s;", value ? "1":"0");
|
2006-01-30 22:27:02 +00:00
|
|
|
return;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-01-30 22:27:02 +00:00
|
|
|
void sem_create_r(char *data, char *buf)
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2006-05-22 12:09:15 +00:00
|
|
|
char *sem;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2006-05-22 12:09:15 +00:00
|
|
|
strtok(data, ",");
|
|
|
|
sem = xstrcpy(strtok(NULL, ";"));
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-08-03 15:58:26 +00:00
|
|
|
if (sem_set(sem, TRUE))
|
2005-08-29 21:03:28 +00:00
|
|
|
snprintf(buf, 40, "100:0;");
|
2006-01-30 22:27:02 +00:00
|
|
|
else
|
|
|
|
snprintf(buf, 40, "200:1,16;");
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2006-05-22 12:09:15 +00:00
|
|
|
free(sem);
|
2006-01-30 22:27:02 +00:00
|
|
|
return;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-01-30 22:27:02 +00:00
|
|
|
void sem_remove_r(char *data, char *buf)
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2006-05-22 12:09:15 +00:00
|
|
|
char *sem;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2006-05-22 12:09:15 +00:00
|
|
|
strtok(data, ",");
|
|
|
|
sem = xstrcpy(strtok(NULL, ";"));
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-08-03 15:58:26 +00:00
|
|
|
if (sem_set(sem, FALSE))
|
2005-08-29 21:03:28 +00:00
|
|
|
snprintf(buf, 40, "100:0;");
|
2006-01-30 22:27:02 +00:00
|
|
|
else
|
|
|
|
snprintf(buf, 40, "200:1,16;");
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2006-05-22 12:09:15 +00:00
|
|
|
free(sem);
|
2006-01-30 22:27:02 +00:00
|
|
|
return;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-30 15:08:05 +00:00
|
|
|
|
|
|
|
void mib_set_mailer(char *data)
|
|
|
|
{
|
2007-04-30 19:04:15 +00:00
|
|
|
unsigned int kbrcvd, kbsent, direction, state, type, freqs;
|
2007-04-30 15:08:05 +00:00
|
|
|
|
|
|
|
Syslog('m', "MIB set mailer %s", data);
|
|
|
|
strtok(data, ",");
|
|
|
|
kbrcvd = atoi(strtok(NULL, ","));
|
|
|
|
kbsent = atoi(strtok(NULL, ","));
|
|
|
|
direction = atoi(strtok(NULL, ","));
|
|
|
|
state = atoi(strtok(NULL, ","));
|
2007-04-30 19:04:15 +00:00
|
|
|
type = atoi(strtok(NULL, ","));
|
2007-04-30 15:08:05 +00:00
|
|
|
freqs = atoi(strtok(NULL, ";"));
|
|
|
|
|
|
|
|
status.mkbrcvd += kbrcvd;
|
|
|
|
status.mkbsent += kbsent;
|
|
|
|
if (direction)
|
|
|
|
status.msessout++;
|
|
|
|
else
|
|
|
|
status.msessin++;
|
|
|
|
switch (state) {
|
|
|
|
case 0: status.msesssecure++; break;
|
|
|
|
case 1: status.msessunsec++; break;
|
|
|
|
case 2: status.msessbad++; break;
|
|
|
|
}
|
2007-04-30 19:04:15 +00:00
|
|
|
switch (type) {
|
|
|
|
case 1: status.mftsc++; break;
|
|
|
|
case 2: status.myoohoo++; break;
|
|
|
|
case 3: status.memsi++; break;
|
|
|
|
case 4: status.mbinkp++; break;
|
|
|
|
}
|
2007-04-30 15:08:05 +00:00
|
|
|
status.mfreqs += freqs;
|
2007-04-30 19:04:15 +00:00
|
|
|
Syslog('m', "MIB mailer: rcvd=%d sent=%d in=%d out=%d sec=%d unsec=%d bad=%d ftsc=%d yoohoo=%d emsi=%d binkp=%d freq=%d",
|
|
|
|
status.mkbrcvd, status.mkbsent, status.msessin,
|
|
|
|
status.msessout, status.msesssecure, status.msessunsec, status.msessbad,
|
|
|
|
status.mftsc, status.myoohoo, status.memsi, status.mbinkp, status.mfreqs);
|
2007-04-30 15:08:05 +00:00
|
|
|
|
|
|
|
status_write();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void mib_set_netmail(char *data)
|
|
|
|
{
|
|
|
|
unsigned int in, out, bad;
|
|
|
|
|
|
|
|
Syslog('m', "MIB set netmail %s", data);
|
|
|
|
strtok(data, ",");
|
|
|
|
in = atoi(strtok(NULL, ","));
|
|
|
|
out = atoi(strtok(NULL, ","));
|
|
|
|
bad = atoi(strtok(NULL, ";"));
|
|
|
|
|
|
|
|
status.tmsgsin += in;
|
|
|
|
status.tnetin += in;
|
|
|
|
status.tmsgsout += out;
|
|
|
|
status.tnetout += out;
|
|
|
|
status.tmsgsbad += bad;
|
|
|
|
status.tnetbad += bad;
|
2007-04-30 19:04:15 +00:00
|
|
|
Syslog('m', "MIB netmail: in=%d out=%d bad=%d in=%d out=%d bad=%d", status.tmsgsin, status.tmsgsout, status.tmsgsbad,
|
2007-04-30 15:08:05 +00:00
|
|
|
status.tnetin, status.tnetout, status.tnetbad);
|
|
|
|
|
|
|
|
status_write();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void mib_set_email(char *data)
|
|
|
|
{
|
|
|
|
unsigned int in, out, bad;
|
|
|
|
|
|
|
|
Syslog('m', "MIB set email %s", data);
|
|
|
|
strtok(data, ",");
|
|
|
|
in = atoi(strtok(NULL, ","));
|
|
|
|
out = atoi(strtok(NULL, ","));
|
|
|
|
bad = atoi(strtok(NULL, ";"));
|
|
|
|
|
|
|
|
status.tmsgsin += in;
|
|
|
|
status.temailin += in;
|
|
|
|
status.tmsgsout += out;
|
|
|
|
status.temailout += out;
|
|
|
|
status.tmsgsbad += bad;
|
|
|
|
status.temailbad += bad;
|
|
|
|
|
2007-04-30 19:04:15 +00:00
|
|
|
Syslog('m', "MIB netmail: in=%d out=%d bad=%d in=%d out=%d bad=%d", status.tmsgsin, status.tmsgsout, status.tmsgsbad,
|
2007-04-30 15:08:05 +00:00
|
|
|
status.temailin, status.temailout, status.temailbad);
|
|
|
|
|
|
|
|
status_write();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void mib_set_news(char *data)
|
|
|
|
{
|
|
|
|
unsigned int in, out, bad, dupe;
|
|
|
|
|
|
|
|
Syslog('m', "MIB set news %s", data);
|
|
|
|
strtok(data, ",");
|
|
|
|
in = atoi(strtok(NULL, ","));
|
|
|
|
out = atoi(strtok(NULL, ","));
|
|
|
|
bad = atoi(strtok(NULL, ","));
|
|
|
|
dupe = atoi(strtok(NULL, ";"));
|
|
|
|
|
|
|
|
|
|
|
|
status.tmsgsin += in;
|
|
|
|
status.tnewsin += in;
|
|
|
|
status.tmsgsout += out;
|
|
|
|
status.tnewsout += out;
|
|
|
|
status.tmsgsbad += bad;
|
|
|
|
status.tnewsbad += bad;
|
|
|
|
status.tmsgsdupe += dupe;
|
|
|
|
status.tnewsdupe += dupe;
|
|
|
|
|
2007-04-30 19:04:15 +00:00
|
|
|
Syslog('m', "MIB news: in=%d out=%d bad=%d dupe=%d in=%d out=%d bad=%d dupe=%d",
|
|
|
|
status.tmsgsin, status.tmsgsout, status.tmsgsbad, status.tmsgsdupe,
|
2007-04-30 15:08:05 +00:00
|
|
|
status.tnewsin, status.tnewsout, status.tnewsbad, status.tnewsdupe);
|
|
|
|
|
|
|
|
status_write();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void mib_set_echo(char *data)
|
|
|
|
{
|
|
|
|
unsigned int in, out, bad, dupe;
|
|
|
|
|
|
|
|
Syslog('m', "MIB set echo %s", data);
|
|
|
|
strtok(data, ",");
|
|
|
|
in = atoi(strtok(NULL, ","));
|
|
|
|
out = atoi(strtok(NULL, ","));
|
|
|
|
bad = atoi(strtok(NULL, ","));
|
|
|
|
dupe = atoi(strtok(NULL, ";"));
|
|
|
|
|
|
|
|
status.tmsgsin += in;
|
|
|
|
status.techoin += in;
|
|
|
|
status.tmsgsout += out;
|
|
|
|
status.techoout += out;
|
|
|
|
status.tmsgsbad += bad;
|
|
|
|
status.techobad += bad;
|
|
|
|
status.tmsgsdupe += dupe;
|
|
|
|
status.techodupe += dupe;
|
|
|
|
|
2007-04-30 19:04:15 +00:00
|
|
|
Syslog('m', "MIB echo: in=%d out=%d bad=%d dupe=%d in=%d out=%d bad=%d dupe=%d",
|
|
|
|
status.tmsgsin, status.tmsgsout, status.tmsgsbad, status.tmsgsdupe,
|
2007-04-30 15:08:05 +00:00
|
|
|
status.techoin, status.techoout, status.techobad, status.techodupe);
|
|
|
|
|
|
|
|
status_write();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void mib_set_files(char *data)
|
|
|
|
{
|
|
|
|
unsigned int in, out, bad, dupe, magics, hatched;
|
|
|
|
|
|
|
|
Syslog('m', "MIB set files %s", data);
|
|
|
|
strtok(data, ",");
|
|
|
|
in = atoi(strtok(NULL, ","));
|
|
|
|
out = atoi(strtok(NULL, ","));
|
|
|
|
bad = atoi(strtok(NULL, ","));
|
|
|
|
dupe = atoi(strtok(NULL, ","));
|
|
|
|
magics = atoi(strtok(NULL, ","));
|
|
|
|
hatched = atoi(strtok(NULL, ";"));
|
|
|
|
|
|
|
|
status.tfilesin += in;
|
|
|
|
status.tfilesout += out;
|
|
|
|
status.tfilesbad += bad;
|
|
|
|
status.tfilesdupe += dupe;
|
|
|
|
status.tfilesmagic += magics;
|
|
|
|
status.tfileshatched += hatched;
|
|
|
|
|
2007-04-30 19:04:15 +00:00
|
|
|
Syslog('m', "MIB files: in=%d out=%d bad=%d dupe=%d magic=%d hatch=%d",
|
|
|
|
status.tfilesin, status.tfilesout, status.tfilesbad, status.tfilesdupe,
|
2007-04-30 15:08:05 +00:00
|
|
|
status.tfilesmagic, status.tfileshatched);
|
|
|
|
|
|
|
|
status_write();
|
|
|
|
}
|
|
|
|
|
|
|
|
|