xymon

Check-in [6a6a3f1e51]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Multiple patches from jcleaver: - network tests resulting in odd connect()-errors now include the test definiti$ - r6905 from trunk: fix RRD update of xymongen status (blanks must be removed) - sendmsg() debug code had syntax error - stackio: Must initialise eolchar - xymond: Timers for statistics update and purple-check changed from hardcoded $ - Clients now use "xymon --version" as the default for client-version data - xymoncmd: Use $HOSTNAME as the hostname, if defined, before running "uname". $ - xymoncmd: Fix buffer overflow in defining SERVEROSTYPE environment variable. - xymonnet and xymongen can now run via CRONDATE definitions. - xymonlaunch: Search for tasks.cfg in /etc, /etc/xymon, /etc/xymon-client and $ - xymond_client: Permit data from unknown client types, but parse only the "mes$ - Linux client: Send error-output from netstat/ifconfig to /dev/null - loadhosts: Handle "vpage", "vsubpage" and "vsubparent" correctly. - loadhosts: Increase default hosts.cfg filebuffer size to 20 kB - xymond: Send "drop" and other admin-commands to the client-change and user-ch$ - xymond_channel: Make the timeout for a worker to handle a message configurabl$ - xymond_channel: Don't commit genocide on xymonlaunch when shutting down in ne$ - xymond_rrd: Add --no-rrd option to let all graph data flow to an external pro$ - Linux client: Format ps output to align columns better. - Add SHELL variable to xymonserver.cfg, and use it when we need to run an exte$ - "msgs" status: Change text from "System logs" to "Log files" - "xymongen" and "xymond" status: Standardize format of first status line. git-svn-id: http://svn.code.sf.net/p/xymon/code/trunk@7205 44351d6e-118b-4698-b696-ce33095ecaa4
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | master
Files: files | file ages | folders
SHA3-256: 6a6a3f1e513776171e0bb3704c6dcc434438fd9d70b1a75f39e80b21fe8624f2
User & Date: storner@users.sf.net 2013-07-23 12:23:51
Context
2013-07-23
13:48
From 4.3.12 (r7206): Patches from jcleaver: - xymond: Add --lqueue=N option to specify TCP listen queue size - xymonmenu.cfg: Add "hover" workaround for iPad (and other touch-devices) - xymond_rrd: Parse data in "clear" status messages git-svn-id: http://svn.code.sf.net/p/xymon/code/trunk@7207 44351d6e-118b-4698-b696-ce33095ecaa4 check-in: e672e658cb user: storner@users.sf.net tags: trunk, master
12:23
Multiple patches from jcleaver: - network tests resulting in odd connect()-errors now include the test definiti$ - r6905 from trunk: fix RRD update of xymongen status (blanks must be removed) - sendmsg() debug code had syntax error - stackio: Must initialise eolchar - xymond: Timers for statistics update and purple-check changed from hardcoded $ - Clients now use "xymon --version" as the default for client-version data - xymoncmd: Use $HOSTNAME as the hostname, if defined, before running "uname". $ - xymoncmd: Fix buffer overflow in defining SERVEROSTYPE environment variable. - xymonnet and xymongen can now run via CRONDATE definitions. - xymonlaunch: Search for tasks.cfg in /etc, /etc/xymon, /etc/xymon-client and $ - xymond_client: Permit data from unknown client types, but parse only the "mes$ - Linux client: Send error-output from netstat/ifconfig to /dev/null - loadhosts: Handle "vpage", "vsubpage" and "vsubparent" correctly. - loadhosts: Increase default hosts.cfg filebuffer size to 20 kB - xymond: Send "drop" and other admin-commands to the client-change and user-ch$ - xymond_channel: Make the timeout for a worker to handle a message configurabl$ - xymond_channel: Don't commit genocide on xymonlaunch when shutting down in ne$ - xymond_rrd: Add --no-rrd option to let all graph data flow to an external pro$ - Linux client: Format ps output to align columns better. - Add SHELL variable to xymonserver.cfg, and use it when we need to run an exte$ - "msgs" status: Change text from "System logs" to "Log files" - "xymongen" and "xymond" status: Standardize format of first status line. git-svn-id: http://svn.code.sf.net/p/xymon/code/trunk@7205 44351d6e-118b-4698-b696-ce33095ecaa4 check-in: 6a6a3f1e51 user: storner@users.sf.net tags: trunk, master
05:33
r7202 from 4.3.12: stackio: Permit both blank and tabs after 'include' or 'directory' git-svn-id: http://svn.code.sf.net/p/xymon/code/trunk@7203 44351d6e-118b-4698-b696-ce33095ecaa4 check-in: 2a09ca38ae user: storner@users.sf.net tags: trunk, master
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to client/xymonclient-linux.sh.

57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
s/[ 	]*\n[ 	]*/ /
}' -e "s&^rootfs&${ROOTFS}&"
echo "[mount]"
mount
echo "[free]"
free
echo "[ifconfig]"
/sbin/ifconfig
echo "[route]"
netstat -rn
echo "[netstat]"
netstat -s
echo "[ports]"
# Bug in RedHat's netstat spews annoying error messages. 
netstat -ant 2>/dev/null
echo "[ifstat]"
/sbin/ifconfig
# Report mdstat data if it exists
if test -r /proc/mdstat; then echo "[mdstat]"; cat /proc/mdstat; fi
echo "[ps]"
ps -Aww -o pid,ppid,user,start,state,pri,pcpu,time,pmem,rsz,vsz,cmd

# $TOP must be set, the install utility should do that for us if it exists.
if test "$TOP" != ""
then
    if test -x "$TOP"
    then
        echo "[top]"







|








|



|







57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
s/[ 	]*\n[ 	]*/ /
}' -e "s&^rootfs&${ROOTFS}&"
echo "[mount]"
mount
echo "[free]"
free
echo "[ifconfig]"
/sbin/ifconfig 2>/dev/null
echo "[route]"
netstat -rn
echo "[netstat]"
netstat -s
echo "[ports]"
# Bug in RedHat's netstat spews annoying error messages. 
netstat -ant 2>/dev/null
echo "[ifstat]"
/sbin/ifconfig 2>/dev/null
# Report mdstat data if it exists
if test -r /proc/mdstat; then echo "[mdstat]"; cat /proc/mdstat; fi
echo "[ps]"
ps -Aww -o pid,ppid,user,start,state,pri,pcpu,time:12,pmem,rsz:10,vsz:10,cmd

# $TOP must be set, the install utility should do that for us if it exists.
if test "$TOP" != ""
then
    if test -x "$TOP"
    then
        echo "[top]"

Changes to client/xymonclient.cfg.DIST.

1
2
3
4
5
6
7

8
9
10
11
12
13
14
# Environment settings for the Xymon client.

XYMSRV="@XYMONHOSTIP@"          # IP address of the Xymon server
XYMSERVERS=""                   # IP of multiple Xymon servers. XYMSRV must be "0.0.0.0".
CONFIGCLASS="$SERVEROSTYPE"     # Default configuration class for logfiles

PATH="/bin:/usr/bin:/sbin:/usr/sbin:/etc"  # PATH setting for the client scripts.


# You normally dont need to modify anything below here
XYMONDPORT="1984"                   # Portnumber where xymond listens
XYMONHOME="$XYMONCLIENTHOME"       # Directory for the Xymon client files
XYMON="$XYMONHOME/bin/xymon"          # The Xymon client "xymon" utility
XYMONTMP="$XYMONHOME/tmp"             # Where we may store temporary files.
XYMONCLIENTLOGS="$XYMONHOME/logs"     # Where we store the client logfiles







>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Environment settings for the Xymon client.

XYMSRV="@XYMONHOSTIP@"          # IP address of the Xymon server
XYMSERVERS=""                   # IP of multiple Xymon servers. XYMSRV must be "0.0.0.0".
CONFIGCLASS="$SERVEROSTYPE"     # Default configuration class for logfiles

PATH="/bin:/usr/bin:/sbin:/usr/sbin:/etc"  # PATH setting for the client scripts.
SHELL="/bin/sh"				# Shell to use when forking programs

# You normally dont need to modify anything below here
XYMONDPORT="1984"                   # Portnumber where xymond listens
XYMONHOME="$XYMONCLIENTHOME"       # Directory for the Xymon client files
XYMON="$XYMONHOME/bin/xymon"          # The Xymon client "xymon" utility
XYMONTMP="$XYMONHOME/tmp"             # Where we may store temporary files.
XYMONCLIENTLOGS="$XYMONHOME/logs"     # Where we store the client logfiles

Changes to client/xymonclient.sh.

39
40
41
42
43
44
45



46
47
48
49
50
51
52
export LOGFETCHCFG LOGFETCHSTATUS

rm -f $MSGTMPFILE
touch $MSGTMPFILE


CLIENTVERSION="`$XYMONHOME/bin/clientupdate --level`"




if test "$LOCALMODE" = "yes"; then
	echo "@@client#1|0|127.0.0.1|$MACHINEDOTS|$SERVEROSTYPE" >> $MSGTMPFILE
fi

echo "client $MACHINE.$SERVEROSTYPE $CONFIGCLASS"  >>  $MSGTMPFILE
$XYMONHOME/bin/$XYMONOSSCRIPT >> $MSGTMPFILE







>
>
>







39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
export LOGFETCHCFG LOGFETCHSTATUS

rm -f $MSGTMPFILE
touch $MSGTMPFILE


CLIENTVERSION="`$XYMONHOME/bin/clientupdate --level`"
if test -z "$CLIENTVERSION"; then
	CLIENTVERSION="`$XYMON --version`"
fi

if test "$LOCALMODE" = "yes"; then
	echo "@@client#1|0|127.0.0.1|$MACHINEDOTS|$SERVEROSTYPE" >> $MSGTMPFILE
fi

echo "client $MACHINE.$SERVEROSTYPE $CONFIGCLASS"  >>  $MSGTMPFILE
$XYMONHOME/bin/$XYMONOSSCRIPT >> $MSGTMPFILE

Changes to common/xymoncmd.c.

29
30
31
32
33
34
35


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

53
54
55
56
57
58
59
60
61
62
63
64
65
{
	FILE *fd;
	char buf[1024];
	char *evar;
	char *homedir, *p;

	if (getenv("MACHINEDOTS") == NULL) {


		fd = popen("uname -n", "r");
		if (fd && fgets(buf, sizeof(buf), fd)) {
			p = strchr(buf, '\n'); if (p) *p = '\0';
			pclose(fd);
		}
		else strcpy(buf, "localhost");

		evar = (char *)malloc(strlen(buf) + 13);
		sprintf(evar, "MACHINEDOTS=%s", buf);
		putenv(evar);
	}

	xgetenv("MACHINE");

	if (getenv("SERVEROSTYPE") == NULL) {
		fd = popen("uname -s", "r");
		if (fd && fgets(buf, sizeof(buf), fd)) {

			pclose(fd);
		}
		else strcpy(buf, "unix");
		for (p=buf; (*p); p++) *p = (char) tolower((int)*p);

		evar = (char *)malloc(strlen(buf) + 10);
		sprintf(evar, "SERVEROSTYPE=%s", buf);
		putenv(evar);
	}

	if (getenv("XYMONCLIENTHOME") == NULL) {
		homedir = strdup(envfn);
		p = strrchr(homedir, '/');







>
>






|










>





|







29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{
	FILE *fd;
	char buf[1024];
	char *evar;
	char *homedir, *p;

	if (getenv("MACHINEDOTS") == NULL) {
	    if (getenv("HOSTNAME") != NULL) sprintf(buf, "%s", xgetenv("HOSTNAME"));
	    else {
		fd = popen("uname -n", "r");
		if (fd && fgets(buf, sizeof(buf), fd)) {
			p = strchr(buf, '\n'); if (p) *p = '\0';
			pclose(fd);
		}
		else strcpy(buf, "localhost");
	    }
		evar = (char *)malloc(strlen(buf) + 13);
		sprintf(evar, "MACHINEDOTS=%s", buf);
		putenv(evar);
	}

	xgetenv("MACHINE");

	if (getenv("SERVEROSTYPE") == NULL) {
		fd = popen("uname -s", "r");
		if (fd && fgets(buf, sizeof(buf), fd)) {
			p = strchr(buf, '\n'); if (p) *p = '\0';
			pclose(fd);
		}
		else strcpy(buf, "unix");
		for (p=buf; (*p); p++) *p = (char) tolower((int)*p);

		evar = (char *)malloc(strlen(buf) + 14);
		sprintf(evar, "SERVEROSTYPE=%s", buf);
		putenv(evar);
	}

	if (getenv("XYMONCLIENTHOME") == NULL) {
		homedir = strdup(envfn);
		p = strrchr(homedir, '/');

Changes to common/xymonlaunch.8.

26
27
28
29
30
31
32
33


34
35
36
37
38
39
40
overridden by the ENVFILE option in 
.I tasks.cfg(5)

.IP "--config=FILENAME"
This option defines the file that xymonlaunch scans for tasks it
must launch. A description of this file is in 
.I tasks.cfg(5)
The default tasklist is /etc/tasks.cfg



.IP "--log=FILENAME"
Defines the logfile where xymonlaunch logs information about
failures to launch tasks and other data about the operation of
xymonlaunch. Logs from individual tasks are defined in the tasks.cfg
file. By default this is logged to stdout.








|
>
>







26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
overridden by the ENVFILE option in 
.I tasks.cfg(5)

.IP "--config=FILENAME"
This option defines the file that xymonlaunch scans for tasks it
must launch. A description of this file is in 
.I tasks.cfg(5)
If not specified, files at /etc/tasks.cfg, /etc/xymon/tasks.cfg,
and /etc/xymon-client/clientlaunch.cfg are searched for, as
well as ~/server/etc/tasks.cfg.

.IP "--log=FILENAME"
Defines the logfile where xymonlaunch logs information about
failures to launch tasks and other data about the operation of
xymonlaunch. Logs from individual tasks are defined in the tasks.cfg
file. By default this is logged to stdout.

Changes to common/xymonlaunch.c.

483
484
485
486
487
488
489


490
491
492
493
494
495
496
497
...
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542














































543
544
545
546
547
548
549
int main(int argc, char *argv[])
{
	tasklist_t *twalk, *dwalk;
	grouplist_t *gwalk;
	int argi;
	int daemonize = 1;
	int verbose = 0;


	char *config = "/etc/tasks.cfg";
	pid_t cpid;
	int status;
	struct sigaction sa;

	libxymon_init(argv[0]);
	for (argi=1; (argi < argc); argi++) {
		if (strcmp(argv[argi], "--no-daemon") == 0) {
................................................................................
			verbose = 1;
		}
		else if (argnmatch(argv[argi], "--config=")) {
			char *p = strchr(argv[argi], '=');
			config = strdup(expand_env(p+1));
		}
		else if (strcmp(argv[argi], "--dump") == 0) {
			/* Dump configuration */
			forcereload=1;
			load_config(config);
			forcereload=0;
			for (gwalk = grouphead; (gwalk); gwalk = gwalk->next) {
				if (gwalk->maxuse > 1) printf("GROUP %s %d\n", gwalk->groupname, gwalk->maxuse);
			}
			printf("\n");
			for (twalk = taskhead; (twalk); twalk = twalk->next) {
				printf("[%s]\n", twalk->key);
				printf("\tCMD %s\n", twalk->cmd);
				if (twalk->disabled)     printf("\tDISABLED\n");
				if (twalk->group)        printf("\tGROUP %s\n", twalk->group->groupname);
				if (twalk->depends)      printf("\tNEEDS %s\n", twalk->depends->key);
				if (twalk->interval > 0) printf("\tINTERVAL %d\n", twalk->interval);
				if (twalk->cronstr)      printf("\tCRONDATE %s\n", twalk->cronstr);
				if (twalk->maxruntime)   printf("\tMAXTIME %d\n", twalk->maxruntime);
				if (twalk->logfile)      printf("\tLOGFILE %s\n", twalk->logfile);
				if (twalk->envfile)      printf("\tENVFILE %s\n", twalk->envfile);
				if (twalk->envarea)      printf("\tENVAREA %s\n", twalk->envarea);
				if (twalk->onhostptn)    printf("\tONHOST %s\n", twalk->onhostptn);
				printf("\n");
			}
			fflush(stdout);
			return 0;
		}
		else if (standardoption(argv[argi])) {
			if (showhelp) return 0;
		}
		else {
			fprintf(stderr,"%s: Unsupported argument: %s\n",argv[0],argv[argi]);
			fflush(stderr);
			return 1;
		}
	}















































	/* Go daemon */
	if (daemonize) {
		pid_t childpid;

		/* Become a daemon */
		childpid = fork();







>
>
|







 







|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
...
503
504
505
506
507
508
509
510
























511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
int main(int argc, char *argv[])
{
	tasklist_t *twalk, *dwalk;
	grouplist_t *gwalk;
	int argi;
	int daemonize = 1;
	int verbose = 0;
	int dumpconfig = 0;
	struct stat st;
	char *config = NULL;
	pid_t cpid;
	int status;
	struct sigaction sa;

	libxymon_init(argv[0]);
	for (argi=1; (argi < argc); argi++) {
		if (strcmp(argv[argi], "--no-daemon") == 0) {
................................................................................
			verbose = 1;
		}
		else if (argnmatch(argv[argi], "--config=")) {
			char *p = strchr(argv[argi], '=');
			config = strdup(expand_env(p+1));
		}
		else if (strcmp(argv[argi], "--dump") == 0) {
			dumpconfig = 1;
























		}
		else if (standardoption(argv[argi])) {
			if (showhelp) return 0;
		}
		else {
			fprintf(stderr,"%s: Unsupported argument: %s\n",argv[0],argv[argi]);
			fflush(stderr);
			return 1;
		}
	}

	/* Find config */
	if (!config) {
		if (stat("/etc/tasks.cfg", &st) != -1) config = strdup("/etc/tasks.cfg");
		else if (stat("/etc/xymon/tasks.cfg", &st) != -1) config = strdup("/etc/xymon/tasks.cfg");
		else if (stat("/etc/xymon-client/clientlaunch.cfg", &st) != -1) config = strdup("/etc/xymon-client/clientlaunch.cfg");
		else if (xgetenv("XYMONHOME")) {
			char *pf = NULL;
			sprintf(pf, "%s/etc/tasks.cfg", xgetenv("XYMONHOME"));
			if (pf && stat(pf, &st) != -1) config = strdup(pf);
		}
		if (config) dbgprintf("Using config file: %s\n", config);
	}
	if (!config || stat(config, &st) == -1) {
		fprintf(stderr,"%s: Error reading config file %s\n", argv[0], config);
		fflush(stderr);
		return 1;
	}

	/* Dump configuration */
	if (dumpconfig) {
		forcereload=1;
		load_config(config);
		forcereload=0;
		for (gwalk = grouphead; (gwalk); gwalk = gwalk->next) {
			if (gwalk->maxuse > 1) printf("GROUP %s %d\n", gwalk->groupname, gwalk->maxuse);
		}
		printf("\n");
		for (twalk = taskhead; (twalk); twalk = twalk->next) {
			printf("[%s]\n", twalk->key);
			printf("\tCMD %s\n", twalk->cmd);
			if (twalk->disabled)     printf("\tDISABLED\n");
			if (twalk->group)        printf("\tGROUP %s\n", twalk->group->groupname);
			if (twalk->depends)      printf("\tNEEDS %s\n", twalk->depends->key);
			if (twalk->interval > 0) printf("\tINTERVAL %d\n", twalk->interval);
			if (twalk->cronstr)      printf("\tCRONDATE %s\n", twalk->cronstr);
			if (twalk->maxruntime)   printf("\tMAXTIME %d\n", twalk->maxruntime);
			if (twalk->logfile)      printf("\tLOGFILE %s\n", twalk->logfile);
			if (twalk->envfile)      printf("\tENVFILE %s\n", twalk->envfile);
			if (twalk->envarea)      printf("\tENVAREA %s\n", twalk->envarea);
			if (twalk->onhostptn)    printf("\tONHOST %s\n", twalk->onhostptn);
			printf("\n");
		}
		fflush(stdout);
		return 0;
	}

	/* Go daemon */
	if (daemonize) {
		pid_t childpid;

		/* Become a daemon */
		childpid = fork();

Changes to lib/loadhosts_file.c.

67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
...
177
178
179
180
181
182
183



184
185
186
187
188
189
190

	if (!contentbuffer) contentbuffer = newstrbuffer(0);
	clearstrbuffer(contentbuffer);

	hosts = stackfopen(hostsfn, "r", &hostfiles);
	if (hosts == NULL) return -1;

	inbuf = newstrbuffer(0);
	while (stackfgets(inbuf, extrainclude)) {
		sanitize_input(inbuf, 0, 0);
		addtostrbuffer(contentbuffer, inbuf);
		addtobuffer(contentbuffer, "\n");
	}

	stackfclose(hosts);
................................................................................
			while ((ineol > inbol) && (isspace(*ineol) || (*ineol == '\n'))) ineol--;
			if (*ineol != '\n') ineol++;

			insavchar = *ineol;
			*ineol = '\0';
		}




		if (strncmp(inbol, "page", 4) == 0) {
			pagelist_t *newp;
			char *name, *title;

			pageidx = groupid = 0;
			if (dgname) xfree(dgname); dgname = NULL;
			if (get_page_name_title(inbol, "page", &name, &title) == 0) {







|







 







>
>
>







67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
...
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193

	if (!contentbuffer) contentbuffer = newstrbuffer(0);
	clearstrbuffer(contentbuffer);

	hosts = stackfopen(hostsfn, "r", &hostfiles);
	if (hosts == NULL) return -1;

	inbuf = newstrbuffer(20480);
	while (stackfgets(inbuf, extrainclude)) {
		sanitize_input(inbuf, 0, 0);
		addtostrbuffer(contentbuffer, inbuf);
		addtobuffer(contentbuffer, "\n");
	}

	stackfclose(hosts);
................................................................................
			while ((ineol > inbol) && (isspace(*ineol) || (*ineol == '\n'))) ineol--;
			if (*ineol != '\n') ineol++;

			insavchar = *ineol;
			*ineol = '\0';
		}

		/* Strip out initial "v" for vpage/vsubpage/vsubparent -- we don't care about the difference here */
		if ((strncmp(inbol, "vpage", 5) == 0) || (strncmp(inbol, "vsubpage", 8) == 0) || (strncmp(inbol, "vsubparent", 10) == 0)) inbol++;

		if (strncmp(inbol, "page", 4) == 0) {
			pagelist_t *newp;
			char *name, *title;

			pageidx = groupid = 0;
			if (dgname) xfree(dgname); dgname = NULL;
			if (get_page_name_title(inbol, "page", &name, &title) == 0) {

Changes to lib/readmib.h.

64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
};

typedef struct mibidx_t {
	char marker;				/* Marker character for key OID */
	enum mibidxtype_t idxtype;		/* How to interpret the key */
	char *keyoid;				/* Key OID */
	void *rootoid;				/* Binary representation of keyoid */
	unsigned int rootoidlen;		/* Length of binary keyoid */
	struct mibidx_t *next;
} mibidx_t;

typedef struct mibdef_t {
	enum { 
		MIB_STATUS_NOTLOADED, 		/* Not loaded */
		MIB_STATUS_LOADED, 		/* Loaded OK, can be used */







|







64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
};

typedef struct mibidx_t {
	char marker;				/* Marker character for key OID */
	enum mibidxtype_t idxtype;		/* How to interpret the key */
	char *keyoid;				/* Key OID */
	void *rootoid;				/* Binary representation of keyoid */
	size_t rootoidlen;			/* Length of binary keyoid */
	struct mibidx_t *next;
} mibidx_t;

typedef struct mibdef_t {
	enum { 
		MIB_STATUS_NOTLOADED, 		/* Not loaded */
		MIB_STATUS_LOADED, 		/* Loaded OK, can be used */

Changes to lib/run.c.

64
65
66
67
68
69
70




71

72
73
74
75
76
77
78
		close(pfd[0]);
		if (pfd[1] != STDOUT_FILENO) {
			dup2(pfd[1], STDOUT_FILENO);
			dup2(pfd[1], STDERR_FILENO);
			close(pfd[1]);
		}





		execl("/bin/sh", "sh", "-c", cmd, NULL);

		exit(127);
	}
	else {
		/* The parent runs here */
		int done = 0, didterm = 0, n;
		struct timespec tmo, timestamp, cutoff;








>
>
>
>
|
>







64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
		close(pfd[0]);
		if (pfd[1] != STDOUT_FILENO) {
			dup2(pfd[1], STDOUT_FILENO);
			dup2(pfd[1], STDERR_FILENO);
			close(pfd[1]);
		}

		if (strchr(cmd, ' ') == NULL) execlp(cmd, cmd, NULL);
		else {
			char *shell = getenv("SHELL");
			if (!shell) shell = "/bin/sh";
			execl(shell, "sh", "-c", cmd, NULL);
		}
		exit(127);
	}
	else {
		/* The parent runs here */
		int done = 0, didterm = 0, n;
		struct timespec tmo, timestamp, cutoff;

Changes to lib/stackio.c.

417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
...
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
	result = unlimfgets(buffer, fdhead->fd);

	if (result) {
		char *bufpastwhitespace = STRBUF(buffer) + strspn(STRBUF(buffer), " \t");

		if ( (strncmp(bufpastwhitespace, "include ", 8) == 0) || (strncmp(bufpastwhitespace, "include\t", 8) == 0) ||
		     (extraincl && (strncmp(bufpastwhitespace, extraincl, strlen(extraincl)) == 0)) ) {
			char *newfn, *eol, eolchar;

			eol = bufpastwhitespace + strcspn(bufpastwhitespace, "\r\n"); if (eol) { eolchar = *eol; *eol = '\0'; }
			newfn = bufpastwhitespace + strcspn(bufpastwhitespace, " \t");
			newfn += strspn(newfn, " \t");
			while (*newfn && isspace(*(newfn + strlen(newfn) - 1))) *(newfn + strlen(newfn) -1) = '\0';

			if (*newfn && (stackfopen(newfn, "r", (void **)fdhead->listhead) != NULL))
................................................................................
				errprintf("WARNING: Cannot open include file '%s', line was:%s\n", 
					  newfn, STRBUF(buffer));
				if (eol) *eol = eolchar;
				return result;
			}
		}
		else if ((strncmp(bufpastwhitespace, "directory ", 10) == 0) || (strncmp(bufpastwhitespace, "directory\t", 10) == 0)) {
			char *dirfn, *eol, eolchar;

			eol = bufpastwhitespace + strcspn(bufpastwhitespace, "\r\n"); if (eol) { eolchar = *eol; *eol = '\0'; }
			dirfn = bufpastwhitespace + 9;
			dirfn += strspn(dirfn, " \t");
			while (*dirfn && isspace(*(dirfn + strlen(dirfn) - 1))) *(dirfn + strlen(dirfn) -1) = '\0';

			if (*dirfn) addtofnlist(dirfn, (void **)fdhead->listhead);







|







 







|







417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
...
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
	result = unlimfgets(buffer, fdhead->fd);

	if (result) {
		char *bufpastwhitespace = STRBUF(buffer) + strspn(STRBUF(buffer), " \t");

		if ( (strncmp(bufpastwhitespace, "include ", 8) == 0) || (strncmp(bufpastwhitespace, "include\t", 8) == 0) ||
		     (extraincl && (strncmp(bufpastwhitespace, extraincl, strlen(extraincl)) == 0)) ) {
			char *newfn, *eol, eolchar = '\0';

			eol = bufpastwhitespace + strcspn(bufpastwhitespace, "\r\n"); if (eol) { eolchar = *eol; *eol = '\0'; }
			newfn = bufpastwhitespace + strcspn(bufpastwhitespace, " \t");
			newfn += strspn(newfn, " \t");
			while (*newfn && isspace(*(newfn + strlen(newfn) - 1))) *(newfn + strlen(newfn) -1) = '\0';

			if (*newfn && (stackfopen(newfn, "r", (void **)fdhead->listhead) != NULL))
................................................................................
				errprintf("WARNING: Cannot open include file '%s', line was:%s\n", 
					  newfn, STRBUF(buffer));
				if (eol) *eol = eolchar;
				return result;
			}
		}
		else if ((strncmp(bufpastwhitespace, "directory ", 10) == 0) || (strncmp(bufpastwhitespace, "directory\t", 10) == 0)) {
			char *dirfn, *eol, eolchar = '\0';

			eol = bufpastwhitespace + strcspn(bufpastwhitespace, "\r\n"); if (eol) { eolchar = *eol; *eol = '\0'; }
			dirfn = bufpastwhitespace + 9;
			dirfn += strspn(dirfn, " \t");
			while (*dirfn && isspace(*(dirfn + strlen(dirfn) - 1))) *(dirfn + strlen(dirfn) -1) = '\0';

			if (*dirfn) addtofnlist(dirfn, (void **)fdhead->listhead);

Added xymond/client/generic.c.











































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*----------------------------------------------------------------------------*/
/* Xymon message daemon.                                                      */
/*                                                                            */
/* Client backend module for generic unknown client                           */
/*                                                                            */
/* Copyright (C) 2005-2011 Henrik Storner <henrik@hswn.dk>                    */
/*                                                                            */
/* This program is released under the GNU General Public License (GPL),       */
/* version 2. See the file "COPYING" for details.                             */
/*                                                                            */
/*----------------------------------------------------------------------------*/

static char generic_rcsid[] = "$Id: generic.c 7059 2012-07-14 15:18:14Z storner $";

void handle_generic_client(char *hostname, char *clienttype, enum ostype_t os, 
			 void *hinfo, char *sender, time_t timestamp,
			 char *clientdata)
{
	char *timestr;
	char *msgsstr;

	char fromline[1024];

	sprintf(fromline, "\nStatus message received from %s\n", sender);

	splitmsg(clientdata);

	timestr = getdata("date");
	msgsstr = getdata("msgs");

	msgs_report(hostname, clienttype, os, hinfo, fromline, timestr, msgsstr);
	file_report(hostname, clienttype, os, hinfo, fromline, timestr);
	linecount_report(hostname, clienttype, os, hinfo, fromline, timestr);

	splitmsg_done();
}

Changes to xymond/do_rrd.c.

35
36
37
38
39
40
41

42
43
44
45
46
47
48
...
454
455
456
457
458
459
460



461
462
463
464
465
466
467
#define NAME_MAX 255	/* Solaris doesn't define NAME_MAX, but ufs limit is 255 */
#endif

extern int seq;	/* from xymond_rrd.c */

char *rrddir = NULL;
int use_rrd_cache = 1;         /* Use the cache by default */


static int  processorfd = 0;
static FILE *processorstream = NULL;

static char *exthandler = NULL;
static char **extids = NULL;

................................................................................
		if (n >= 0) fflush(processorstream);

		if (n == -1) {
			errprintf("Ext-processor write failed: %s\n", strerror(errno));
			shutdown_extprocessor();
		}
	}




	/* 
	 * We cannot just cache data every time because then after CACHESZ updates
	 * of each RRD, we will flush all of the data at once (all of the caches 
	 * fill at the same speed); this would result in huge load-spikes every 
	 * rrdinterval*CACHESZ seconds.
	 *







>







 







>
>
>







35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
...
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
#define NAME_MAX 255	/* Solaris doesn't define NAME_MAX, but ufs limit is 255 */
#endif

extern int seq;	/* from xymond_rrd.c */

char *rrddir = NULL;
int use_rrd_cache = 1;         /* Use the cache by default */
int no_rrd = 0;                /* Write to rrd by default */

static int  processorfd = 0;
static FILE *processorstream = NULL;

static char *exthandler = NULL;
static char **extids = NULL;

................................................................................
		if (n >= 0) fflush(processorstream);

		if (n == -1) {
			errprintf("Ext-processor write failed: %s\n", strerror(errno));
			shutdown_extprocessor();
		}
	}

	/* Are we actually handling the writing of RRD files? */
	if (no_rrd) return 0;

	/* 
	 * We cannot just cache data every time because then after CACHESZ updates
	 * of each RRD, we will flush all of the data at once (all of the caches 
	 * fill at the same speed); this would result in huge load-spikes every 
	 * rrdinterval*CACHESZ seconds.
	 *

Changes to xymond/do_rrd.h.

14
15
16
17
18
19
20

21
22
23
24
25
26
27
28
29
30
#include <time.h>

#include "libxymon.h"

extern char *rrddir;
extern char *trackmax;
extern int use_rrd_cache;

extern void setup_exthandler(char *handlerpath, char *ids);
extern void update_rrd(char *hostname, char *testname, char *restofmsg, time_t tstamp, char *sender, xymonrrd_t *ldef, char *classname, char *pagepaths);
extern void rrdcacheflushall(void);
extern void rrdcacheflushhost(char *hostname);
extern void setup_extprocessor(char *cmd);
extern void shutdown_extprocessor(void);


#endif








>










14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <time.h>

#include "libxymon.h"

extern char *rrddir;
extern char *trackmax;
extern int use_rrd_cache;
extern int no_rrd;
extern void setup_exthandler(char *handlerpath, char *ids);
extern void update_rrd(char *hostname, char *testname, char *restofmsg, time_t tstamp, char *sender, xymonrrd_t *ldef, char *classname, char *pagepaths);
extern void rrdcacheflushall(void);
extern void rrdcacheflushhost(char *hostname);
extern void setup_extprocessor(char *cmd);
extern void shutdown_extprocessor(void);


#endif

Changes to xymond/etcfiles/xymonserver.cfg.DIST.

17
18
19
20
21
22
23

24
25
26
27
28
29
30
# XYMONNETWORK="foo"				# The network location, makes xymonnet test only hosts with NET:foo
						# You only need to set this if you have multiple network test servers with
						# a shared hosts.cfg file.

# Make sure the path includes the directories where you have fping, mail and (optionally) ntpdate installed,
# as well as the XYMONHOME/bin directory where all of the Xymon programs reside.
PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin:@XYMONHOME@/bin"


# Some systems need extra settings e.g. to locate run-time libraries.
# You can add these extra settings here:
@RUNTIMEDEFS@

# Default settings for "delayred" and "delayyellow" parameters in hosts.cfg
DELAYRED=""			# Format: status:delay[,status:delay - e.g. "cpu:15,disk:30"







>







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# XYMONNETWORK="foo"				# The network location, makes xymonnet test only hosts with NET:foo
						# You only need to set this if you have multiple network test servers with
						# a shared hosts.cfg file.

# Make sure the path includes the directories where you have fping, mail and (optionally) ntpdate installed,
# as well as the XYMONHOME/bin directory where all of the Xymon programs reside.
PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin:@XYMONHOME@/bin"
SHELL="/bin/sh"					# Shell to use when forking programs

# Some systems need extra settings e.g. to locate run-time libraries.
# You can add these extra settings here:
@RUNTIMEDEFS@

# Default settings for "delayred" and "delayyellow" parameters in hosts.cfg
DELAYRED=""			# Format: status:delay[,status:delay - e.g. "cpu:15,disk:30"

Changes to xymond/xymond.c.

70
71
72
73
74
75
76









77
78
79
80
81
82
83
...
366
367
368
369
370
371
372


373
374
375
376
377
378
379
380
381
....
2287
2288
2289
2290
2291
2292
2293


2294
2295
2296
2297
2298
2299
2300
....
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266

/* How much the input buffer grows per re-allocation */
#define XYMON_INBUF_INCREMENT (32*1024)

/* How long to keep an ack after the status has recovered */
#define ACKCLEARDELAY 720 /* 12 minutes */










/* How long are sub-client messages valid */
#define MAX_SUBCLIENT_LIFETIME 960	/* 15 minutes + a bit */

#define DEFAULT_FLAPCOUNT 5
int flapcount = DEFAULT_FLAPCOUNT;
int flapthreshold = (DEFAULT_FLAPCOUNT+1)*5*60;	/* Seconds - if more than flapcount changes during this period, it's flapping */

................................................................................
		clearstrbuffer(statsbuf);
	}

	strftime(bootuptxt, sizeof(bootuptxt), "%d-%b-%Y %T", localtime(&boottstamp));
	sprintf(uptimetxt, "%d days, %02d:%02d:%02d", 
		(int)(uptime / 86400), (int)(uptime % 86400)/3600, (int)(uptime % 3600)/60, (int)(uptime % 60));



	sprintf(msgline, "status %s.xymond %s\nStatistics for Xymon daemon\nVersion: %s\nUp since %s (%s)\n\n",
		xgetenv("MACHINE"), colorname(errbuf ? COL_YELLOW : COL_GREEN), VERSION, bootuptxt, uptimetxt);
	addtobuffer(statsbuf, msgline);
	sprintf(msgline, "Incoming messages      : %10ld\n", msgs_total);
	addtobuffer(statsbuf, msgline);
	i = 0;
	while (xymond_stats[i].cmd) {
		sprintf(msgline, "- %-20s : %10ld\n", xymond_stats[i].cmd, xymond_stats[i].count);
		addtobuffer(statsbuf, msgline);
................................................................................
			posttochannel(statuschn, marker, NULL, sender, NULL, NULL, msgbuf);
			posttochannel(stachgchn, marker, NULL, sender, NULL, NULL, msgbuf);
			posttochannel(pagechn, marker, NULL, sender, NULL, NULL, msgbuf);
			posttochannel(datachn, marker, NULL, sender, NULL, NULL, msgbuf);
			posttochannel(noteschn, marker, NULL, sender, NULL, NULL, msgbuf);
			posttochannel(enadischn, marker, NULL, sender, NULL, NULL, msgbuf);
			posttochannel(clientchn, marker, NULL, sender, NULL, NULL, msgbuf);


		}

		xfree(msgbuf);
	}


	/*
................................................................................

				posttoall("reload");
			}

			load_clientconfig();
		}

		if (do_purples && (now > nextpurpleupdate)) {
			nextpurpleupdate = getcurrenttime(NULL) + 60;
			check_purple_status();
		}

		if ((last_stats_time + 300) <= now) {
			char *buf;
			xymond_hostlist_t *h;
			testinfo_t *t;
			xymond_log_t *log;
			int color;

			buf = generate_stats();







>
>
>
>
>
>
>
>
>







 







>
>
|
|







 







>
>







 







|
|



|







70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
...
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
....
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
....
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279

/* How much the input buffer grows per re-allocation */
#define XYMON_INBUF_INCREMENT (32*1024)

/* How long to keep an ack after the status has recovered */
#define ACKCLEARDELAY 720 /* 12 minutes */

/* How long messages are good for (by default) before going purple - minutes */
#define DEFAULT_VALIDITY 30

#define DEFAULT_PURPLE_INTERVAL 60
int purplecheckinterval = DEFAULT_PURPLE_INTERVAL; /* Seconds - check for purples every 60s */

#define DEFAULT_STATS_INTERVAL (5*60)
int statsinterval = DEFAULT_STATS_INTERVAL;	/* Seconds - report xymond status every 5m */

/* How long are sub-client messages valid */
#define MAX_SUBCLIENT_LIFETIME 960	/* 15 minutes + a bit */

#define DEFAULT_FLAPCOUNT 5
int flapcount = DEFAULT_FLAPCOUNT;
int flapthreshold = (DEFAULT_FLAPCOUNT+1)*5*60;	/* Seconds - if more than flapcount changes during this period, it's flapping */

................................................................................
		clearstrbuffer(statsbuf);
	}

	strftime(bootuptxt, sizeof(bootuptxt), "%d-%b-%Y %T", localtime(&boottstamp));
	sprintf(uptimetxt, "%d days, %02d:%02d:%02d", 
		(int)(uptime / 86400), (int)(uptime % 86400)/3600, (int)(uptime % 3600)/60, (int)(uptime % 60));

	init_timestamp();

	sprintf(msgline, "status+11 %s.xymond %s %s - xymon daemon up: %s\nStatistics for Xymon daemon\nVersion: %s\nUp since %s (%s)\n\n",
		xgetenv("MACHINE"), colorname(errbuf ? COL_YELLOW : COL_GREEN), timestamp, uptimetxt, VERSION, bootuptxt, uptimetxt);
	addtobuffer(statsbuf, msgline);
	sprintf(msgline, "Incoming messages      : %10ld\n", msgs_total);
	addtobuffer(statsbuf, msgline);
	i = 0;
	while (xymond_stats[i].cmd) {
		sprintf(msgline, "- %-20s : %10ld\n", xymond_stats[i].cmd, xymond_stats[i].count);
		addtobuffer(statsbuf, msgline);
................................................................................
			posttochannel(statuschn, marker, NULL, sender, NULL, NULL, msgbuf);
			posttochannel(stachgchn, marker, NULL, sender, NULL, NULL, msgbuf);
			posttochannel(pagechn, marker, NULL, sender, NULL, NULL, msgbuf);
			posttochannel(datachn, marker, NULL, sender, NULL, NULL, msgbuf);
			posttochannel(noteschn, marker, NULL, sender, NULL, NULL, msgbuf);
			posttochannel(enadischn, marker, NULL, sender, NULL, NULL, msgbuf);
			posttochannel(clientchn, marker, NULL, sender, NULL, NULL, msgbuf);
			posttochannel(clichgchn, marker, NULL, sender, NULL, NULL, msgbuf);
			posttochannel(userchn, marker, NULL, sender, NULL, NULL, msgbuf);
		}

		xfree(msgbuf);
	}


	/*
................................................................................

				posttoall("reload");
			}

			load_clientconfig();
		}

		if (do_purples && (now >= nextpurpleupdate)) {
			nextpurpleupdate = getcurrenttime(NULL) + purplecheckinterval;
			check_purple_status();
		}

		if ((last_stats_time + statsinterval) <= now) {
			char *buf;
			xymond_hostlist_t *h;
			testinfo_t *t;
			xymond_log_t *log;
			int color;

			buf = generate_stats();

Changes to xymond/xymond_channel.8.

48
49
50
51
52
53
54





55
56
57
58
59
60
61
worker modules and during testing, to limit the amount of data that the module
must process.
.br
Note that messages for "logrotate", "shutdown", "drophost", "renamehost",
"droptest" and "renametest" are always forwarded by xymond_channel, whether
they match the filter or not.






.IP "--daemon"
xymond_channel is normally started by 
.I xymonlaunch(8)
as a task defined in the
.I tasks.cfg(5)
file. If you are not using xymonlaunch, then starting xymond_channel with this
option causes it to run as a stand-alone background task.







>
>
>
>
>







48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
worker modules and during testing, to limit the amount of data that the module
must process.
.br
Note that messages for "logrotate", "shutdown", "drophost", "renamehost",
"droptest" and "renametest" are always forwarded by xymond_channel, whether
they match the filter or not.

.IP "--msgtimeout=TIMEOUT"
Modify the default timeout (30 seconds) for the worker module to handle a message.
If a message is not handled within this time, it is considered lost. You normally
do not have to modify this unless you have an extremely busy server.

.IP "--daemon"
xymond_channel is normally started by 
.I xymonlaunch(8)
as a task defined in the
.I tasks.cfg(5)
file. If you are not using xymonlaunch, then starting xymond_channel with this
option causes it to run as a stand-alone background task.

Changes to xymond/xymond_channel.c.

39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
..
85
86
87
88
89
90
91

92
93
94
95
96
97
98
...
448
449
450
451
452
453
454




455
456
457
458
459
460
461
...
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
#include "libxymon.h"

#include "xymond_ipc.h"

#include <signal.h>


#define MSGTIMEOUT 30	/* Seconds */


/* Our in-memory queue of messages received from xymond via IPC. One queue per peer. */
typedef struct xymon_msg_t {
	time_t tstamp;  /* When did the message arrive */
	char *buf;	/* The message data */
	char *bufp;	/* Next char to send */
	int buflen;	/* How many bytes left to send */
................................................................................
char *logfn = NULL;
int locatorbased = 0;
enum locator_servicetype_t locatorservice = ST_MAX;

static int running = 1;
static int gotalarm = 0;
static int pendingcount = 0;


/*
 * chksumsize is the space left in front of the message buffer, to
 * allow room for a message digest checksum to be added to the
 * message. Since we use an MD5 hash, this will be 32 bytes 
 * plus a one-char marker.
 */
................................................................................
			debug = 1;
		}
		else if (argnmatch(argv[argi], "--channel=")) {
			char *cn = strchr(argv[argi], '=') + 1;

			for (cnid = C_STATUS; (channelnames[cnid] && strcmp(channelnames[cnid], cn)); cnid++) ;
			if (channelnames[cnid] == NULL) cnid = -1;




		}
		else if (argnmatch(argv[argi], "--daemon")) {
			daemonize = 1;
		}
		else if (argnmatch(argv[argi], "--no-daemon")) {
			daemonize = 0;
		}
................................................................................
		 * In practice, however, the queue will be empty most
		 * of the time because we'll just shove the data to the
		 * worker child.
		 */
		for (handle = xtreeFirst(peers); (handle != xtreeEnd(peers)); handle = xtreeNext(peers, handle)) {
			int canwrite = 1, hasfailed = 0;
			xymon_peer_t *pwalk;
			time_t msgtimeout = gettimer() - MSGTIMEOUT;
			int flushcount = 0;

			pwalk = (xymon_peer_t *) xtreeData(peers, handle);
			if (pwalk->msghead == NULL) continue; /* Ignore peers with nothing queued */

			switch (pwalk->peerstatus) {
			  case P_UP:







<
<







 







>







 







>
>
>
>







 







|







39
40
41
42
43
44
45


46
47
48
49
50
51
52
..
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
...
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
...
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
#include "libxymon.h"

#include "xymond_ipc.h"

#include <signal.h>





/* Our in-memory queue of messages received from xymond via IPC. One queue per peer. */
typedef struct xymon_msg_t {
	time_t tstamp;  /* When did the message arrive */
	char *buf;	/* The message data */
	char *bufp;	/* Next char to send */
	int buflen;	/* How many bytes left to send */
................................................................................
char *logfn = NULL;
int locatorbased = 0;
enum locator_servicetype_t locatorservice = ST_MAX;

static int running = 1;
static int gotalarm = 0;
static int pendingcount = 0;
static int messagetimeout = 30;

/*
 * chksumsize is the space left in front of the message buffer, to
 * allow room for a message digest checksum to be added to the
 * message. Since we use an MD5 hash, this will be 32 bytes 
 * plus a one-char marker.
 */
................................................................................
			debug = 1;
		}
		else if (argnmatch(argv[argi], "--channel=")) {
			char *cn = strchr(argv[argi], '=') + 1;

			for (cnid = C_STATUS; (channelnames[cnid] && strcmp(channelnames[cnid], cn)); cnid++) ;
			if (channelnames[cnid] == NULL) cnid = -1;
		}
		else if (argnmatch(argv[argi], "--msgtimeout")) {
			char *p = strchr(argv[argi], '=');
			messagetimeout = atoi(p+1);
		}
		else if (argnmatch(argv[argi], "--daemon")) {
			daemonize = 1;
		}
		else if (argnmatch(argv[argi], "--no-daemon")) {
			daemonize = 0;
		}
................................................................................
		 * In practice, however, the queue will be empty most
		 * of the time because we'll just shove the data to the
		 * worker child.
		 */
		for (handle = xtreeFirst(peers); (handle != xtreeEnd(peers)); handle = xtreeNext(peers, handle)) {
			int canwrite = 1, hasfailed = 0;
			xymon_peer_t *pwalk;
			time_t msgtimeout = gettimer() - messagetimeout;
			int flushcount = 0;

			pwalk = (xymon_peer_t *) xtreeData(peers, handle);
			if (pwalk->msghead == NULL) continue; /* Ignore peers with nothing queued */

			switch (pwalk->peerstatus) {
			  case P_UP:

Changes to xymond/xymond_client.8.

55
56
57
58
59
60
61





62
63
64
65
66
67
68

.IP "--config=FILENAME"
Sets the filename for the 
.I analysis.cfg
file. The default value is "etc/analysis.cfg" below the Xymon
server directory.






.IP "--dump-config"
Dumps the configuration after parsing it. May be useful to track
down problems with configuration file errors.

.IP "--test"
Starts an interactive session where you can test the analysis.cfg
configuration.







>
>
>
>
>







55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73

.IP "--config=FILENAME"
Sets the filename for the 
.I analysis.cfg
file. The default value is "etc/analysis.cfg" below the Xymon
server directory.

.IP "--unknownclientosok"
Expect and attempt to parse clients with unknown CLIENTOS types.
Useful if you're submitting custom host responses with file or msgs
data that you'd like to parse.

.IP "--dump-config"
Dumps the configuration after parsing it. May be useful to track
down problems with configuration file errors.

.IP "--test"
Starts an interactive session where you can test the analysis.cfg
configuration.

Changes to xymond/xymond_client.c.

36
37
38
39
40
41
42

43
44
45
46
47
48
49
....
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
....
1616
1617
1618
1619
1620
1621
1622

1623
1624
1625
1626
1627
1628
1629
....
1915
1916
1917
1918
1919
1920
1921



1922
1923
1924
1925
1926
1927
1928
....
2102
2103
2104
2105
2106
2107
2108




2109
2110
2111
2112
2113
2114
2115
2116
int portlistinports = 1;
int svclistinsvcs = 1;
int sendclearmsgs = 1;
int sendclearfiles = 1;
int sendclearports = 1;
int sendclearsvcs = 1;
int localmode     = 0;

int noreportcolor = COL_CLEAR;

typedef struct updinfo_t {
	char *hostname;
	time_t updtime;
	int updseq;
} updinfo_t;
................................................................................

	init_status(msgscolor);

	group = getalertgroups();
	if (group) sprintf(msgline, "status/group:%s ", group); else strcpy(msgline, "status ");
	addtostatus(msgline);

	sprintf(msgline, "%s.msgs %s %s - System logs %s\n",
		commafy(hostname), colorname(msgscolor), 
		(timestr ? timestr : "<No timestamp data>"),
		(((msgscolor == COL_RED) || (msgscolor == COL_YELLOW)) ? "NOT ok" : "ok"));
	addtostatus(msgline);

	if (STRBUFLEN(reddata)) {
		addtostrstatus(reddata);
................................................................................
#include "client/bbwin.c"
#include "client/powershell.c"	/* Must go after client/bbwin.c */
#include "client/zvm.c"
#include "client/zvse.c"
#include "client/zos.c"
#include "client/mqcollect.c"
#include "client/snmpcollect.c"


static volatile int reloadconfig = 0;

void sig_handler(int signum)
{
	switch (signum) {
	  case SIGHUP:
................................................................................
			tok = strtok(lp, ","); i = 0; collectors = (char **)calloc(1, sizeof(char *));
			while (tok) {
				collectors = (char **)realloc(collectors, (i+2)*sizeof(char *));
				if (strcasecmp(tok, "default") == 0) tok = "";
				collectors[i++] = tok; collectors[i] = NULL;
				tok = strtok(NULL, ",");
			}



		}
		else if (argnmatch(argv[argi], "--dump-config")) {
			load_client_config(configfn);
			dump_client_config();
			return 0;
		}
		else if (strcmp(argv[argi], "--local") == 0) {
................................................................................
				break;

			  case OS_MQCOLLECT:
				handle_mqcollect_client(hostname, clientclass, os, hinfo, sender, timestamp, restofmsg);
				break;

			  default:




                                errprintf("No client backend for OS '%s' sent by %s\n", clientos, sender);
                                break;
			}
			combo_end();
		}
		else if (strncmp(metadata[0], "@@shutdown", 10) == 0) {
			printf("Shutting down\n");
			running = 0;







>







 







|







 







>







 







>
>
>







 







>
>
>
>
|







36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
....
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
....
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
....
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
....
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
int portlistinports = 1;
int svclistinsvcs = 1;
int sendclearmsgs = 1;
int sendclearfiles = 1;
int sendclearports = 1;
int sendclearsvcs = 1;
int localmode     = 0;
int unknownclientosok = 0;
int noreportcolor = COL_CLEAR;

typedef struct updinfo_t {
	char *hostname;
	time_t updtime;
	int updseq;
} updinfo_t;
................................................................................

	init_status(msgscolor);

	group = getalertgroups();
	if (group) sprintf(msgline, "status/group:%s ", group); else strcpy(msgline, "status ");
	addtostatus(msgline);

	sprintf(msgline, "%s.msgs %s %s - Log files %s\n",
		commafy(hostname), colorname(msgscolor), 
		(timestr ? timestr : "<No timestamp data>"),
		(((msgscolor == COL_RED) || (msgscolor == COL_YELLOW)) ? "NOT ok" : "ok"));
	addtostatus(msgline);

	if (STRBUFLEN(reddata)) {
		addtostrstatus(reddata);
................................................................................
#include "client/bbwin.c"
#include "client/powershell.c"	/* Must go after client/bbwin.c */
#include "client/zvm.c"
#include "client/zvse.c"
#include "client/zos.c"
#include "client/mqcollect.c"
#include "client/snmpcollect.c"
#include "client/generic.c"

static volatile int reloadconfig = 0;

void sig_handler(int signum)
{
	switch (signum) {
	  case SIGHUP:
................................................................................
			tok = strtok(lp, ","); i = 0; collectors = (char **)calloc(1, sizeof(char *));
			while (tok) {
				collectors = (char **)realloc(collectors, (i+2)*sizeof(char *));
				if (strcasecmp(tok, "default") == 0) tok = "";
				collectors[i++] = tok; collectors[i] = NULL;
				tok = strtok(NULL, ",");
			}
		}
		else if (strcmp(argv[argi], "--unknownclientosok") == 0) {
			unknownclientosok = 1;
		}
		else if (argnmatch(argv[argi], "--dump-config")) {
			load_client_config(configfn);
			dump_client_config();
			return 0;
		}
		else if (strcmp(argv[argi], "--local") == 0) {
................................................................................
				break;

			  case OS_MQCOLLECT:
				handle_mqcollect_client(hostname, clientclass, os, hinfo, sender, timestamp, restofmsg);
				break;

			  default:
				if (unknownclientosok) {
					dbgprintf("No client backend for OS '%s' sent by %s; using generic\n", clientos, sender);
					handle_generic_client(hostname, clientclass, os, hinfo, sender, timestamp, restofmsg);
				}
				else errprintf("No client backend for OS '%s' sent by %s\n", clientos, sender);
                                break;
			}
			combo_end();
		}
		else if (strncmp(metadata[0], "@@shutdown", 10) == 0) {
			printf("Shutting down\n");
			running = 0;

Changes to xymond/xymond_rrd.8.

53
54
55
56
57
58
59






60
61
62
63
64
65
66
have a custom script to parse the status message and extract the data
that is put into the graph.

.IP "--extra-tests=TEST[,TEST]"
List of testnames that are handled by the external script. See the
CUSTOM RRD DATA section below. Note that NCV graphs should NOT be
listed here, but in the TEST2RRD environment variable - see below.







.SH ENVIRONMENT
.IP TEST2RRD
Defines the mapping between a status-log columnname and the corresponding
RRD database format. This is normally defined in the 
.I xymonserver.cfg(5)
file.







>
>
>
>
>
>







53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
have a custom script to parse the status message and extract the data
that is put into the graph.

.IP "--extra-tests=TEST[,TEST]"
List of testnames that are handled by the external script. See the
CUSTOM RRD DATA section below. Note that NCV graphs should NOT be
listed here, but in the TEST2RRD environment variable - see below.

.IP "--no-rrd"
Disable the actual writing of RRD files. This is only really useful if
you send all of the data destined for the RRD files to an external
processor (the --extra-script option).


.SH ENVIRONMENT
.IP TEST2RRD
Defines the mapping between a status-log columnname and the corresponding
RRD database format. This is normally defined in the 
.I xymonserver.cfg(5)
file.

Changes to xymond/xymond_rrd.c.

209
210
211
212
213
214
215



216
217
218
219
220
221
222


223
224
225
226
227
228
229
		}
		else if (argnmatch(argv[argi], "--processor=")) {
			char *p = strchr(argv[argi], '=');
			processor = strdup(p+1);
		}
		else if (strcmp(argv[argi], "--no-cache") == 0) {
			use_rrd_cache = 0;



		}
		else if (net_worker_option(argv[argi])) {
			/* Handled in the subroutine */
		}
	}

	save_errbuf = 0;



	if ((rrddir == NULL) && xgetenv("XYMONRRDS")) {
		rrddir = strdup(xgetenv("XYMONRRDS"));
	}

	if (exthandler && extids) setup_exthandler(exthandler, extids);








>
>
>







>
>







209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
		}
		else if (argnmatch(argv[argi], "--processor=")) {
			char *p = strchr(argv[argi], '=');
			processor = strdup(p+1);
		}
		else if (strcmp(argv[argi], "--no-cache") == 0) {
			use_rrd_cache = 0;
		}
		else if (strcmp(argv[argi], "--no-rrd") == 0) {
			no_rrd = 1;
		}
		else if (net_worker_option(argv[argi])) {
			/* Handled in the subroutine */
		}
	}

	save_errbuf = 0;

	if (no_rrd && !processor) errprintf("RRD writing disabled, but no external processor has been specified.\n");

	if ((rrddir == NULL) && xgetenv("XYMONRRDS")) {
		rrddir = strdup(xgetenv("XYMONRRDS"));
	}

	if (exthandler && extids) setup_exthandler(exthandler, extids);

Changes to xymond/xymond_worker.c.

213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
		/* Pickup failed children */
		while ((childpid = wait3(&childstat, WNOHANG, NULL)) > 0);
	}

	/* Close the listener socket */
	close(lsocket);

	/* Kill any children that are still around */
	kill(0, SIGTERM);

	return 1;
}


int net_worker_option(char *arg)
{
	int res = 1;







<
<
<







213
214
215
216
217
218
219



220
221
222
223
224
225
226
		/* Pickup failed children */
		while ((childpid = wait3(&childstat, WNOHANG, NULL)) > 0);
	}

	/* Close the listener socket */
	close(lsocket);




	return 1;
}


int net_worker_option(char *arg)
{
	int res = 1;

Changes to xymongen/xymongen.c.

693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
		if (total_runtime() > tasksleep) {
			errprintf("WARNING: Runtime %ld longer than TASKSLEEP (%ld)\n", total_runtime(), tasksleep);
		}
		color = (errbuf ? COL_YELLOW : COL_GREEN);

		combo_start();
		init_status(color);
		sprintf(msgline, "status %s.%s %s %s\n\n", xgetenv("MACHINE"), egocolumn, colorname(color), timestamp);
		addtostatus(msgline);

		sprintf(msgline, "xymongen for Xymon version %s\n", VERSION);
		addtostatus(msgline);

		addtostatus("\nStatistics:\n");
		sprintf(msgline, " Hosts                      : %5d\n", hostcount);







|







693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
		if (total_runtime() > tasksleep) {
			errprintf("WARNING: Runtime %ld longer than TASKSLEEP (%ld)\n", total_runtime(), tasksleep);
		}
		color = (errbuf ? COL_YELLOW : COL_GREEN);

		combo_start();
		init_status(color);
		sprintf(msgline, "status %s.%s %s %s - xymongen completed in %lds\n\n", xgetenv("MACHINE"), egocolumn, colorname(color), timestamp, total_runtime());
		addtostatus(msgline);

		sprintf(msgline, "xymongen for Xymon version %s\n", VERSION);
		addtostatus(msgline);

		addtostatus("\nStatistics:\n");
		sprintf(msgline, " Hosts                      : %5d\n", hostcount);

Changes to xymonnet/xymon-snmpcollect.c.

22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
...
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
...
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
#include "libxymon.h"

/* -----------------  struct's used for the host/requests we need to do ---------------- */
/* List of the OID's we will request */
typedef struct oid_t {
	mibdef_t *mib;				/* pointer to the mib definition for mibs */
	oid Oid[MAX_OID_LEN];			/* the internal OID representation */
	unsigned int OidLen;			/* size of the oid */
	char *devname;				/* Users' chosen device name. May be a key (e.g "eth0") */
	oidds_t *oiddef;			/* Points to the oidds_t definition */
	int  setnumber;				/* All vars fetched in one PDU's have the same setnumber */
	char *result;				/* the printable result data */
	struct oid_t *next;
} oid_t;

................................................................................

/*
 * Store data received in response PDU
 */
int print_result (int status, req_t *req, struct snmp_pdu *pdu)
{
	struct variable_list *vp;
	int len;
	keyrecord_t *kwalk;
	int keyoidlen;
	oid_t *owalk;
	int done;

	switch (status) {
	  case STAT_SUCCESS:
		if (pdu->errstat == SNMP_ERR_NOERROR) {
			unsigned char *valstr = NULL, *oidstr = NULL;
			int valsz = 0, oidsz = 0;

			okcount++;

			switch (dataoperation) {
			  case GET_KEYS:
				/* 
				 * Find the keyrecord currently processed for this request, and
................................................................................
 * in snmphosts.cfg, because lots of MIB's are not being used
 * (and probably do not exist on the host where we're running) and
 * to avoid spending a lot of time to load MIB's that are not used.
 */
void setupmib(mibdef_t *mib, int verbose)
{
	mibidx_t *iwalk;
	int sz, len;

	if (mib->loadstatus != MIB_STATUS_NOTLOADED) return;

	if (mib->mibfn && (read_mib(mib->mibfn) == NULL)) {
		mib->loadstatus = MIB_STATUS_LOADFAILED;
		if (verbose) {
			errprintf("Failed to read MIB file %s\n", mib->mibfn);







|







 







|









|







 







|







22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
...
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
...
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
#include "libxymon.h"

/* -----------------  struct's used for the host/requests we need to do ---------------- */
/* List of the OID's we will request */
typedef struct oid_t {
	mibdef_t *mib;				/* pointer to the mib definition for mibs */
	oid Oid[MAX_OID_LEN];			/* the internal OID representation */
	size_t OidLen;			/* size of the oid */
	char *devname;				/* Users' chosen device name. May be a key (e.g "eth0") */
	oidds_t *oiddef;			/* Points to the oidds_t definition */
	int  setnumber;				/* All vars fetched in one PDU's have the same setnumber */
	char *result;				/* the printable result data */
	struct oid_t *next;
} oid_t;

................................................................................

/*
 * Store data received in response PDU
 */
int print_result (int status, req_t *req, struct snmp_pdu *pdu)
{
	struct variable_list *vp;
	size_t len;
	keyrecord_t *kwalk;
	int keyoidlen;
	oid_t *owalk;
	int done;

	switch (status) {
	  case STAT_SUCCESS:
		if (pdu->errstat == SNMP_ERR_NOERROR) {
			unsigned char *valstr = NULL, *oidstr = NULL;
			size_t valsz = 0, oidsz = 0;

			okcount++;

			switch (dataoperation) {
			  case GET_KEYS:
				/* 
				 * Find the keyrecord currently processed for this request, and
................................................................................
 * in snmphosts.cfg, because lots of MIB's are not being used
 * (and probably do not exist on the host where we're running) and
 * to avoid spending a lot of time to load MIB's that are not used.
 */
void setupmib(mibdef_t *mib, int verbose)
{
	mibidx_t *iwalk;
	size_t sz, len;

	if (mib->loadstatus != MIB_STATUS_NOTLOADED) return;

	if (mib->mibfn && (read_mib(mib->mibfn) == NULL)) {
		mib->loadstatus = MIB_STATUS_LOADFAILED;
		if (verbose) {
			errprintf("Failed to read MIB file %s\n", mib->mibfn);

Changes to xymonproxy/xymonproxy.c.

474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
				avgtime = 0;
			}
			else {
				avgtime = (timeinqueue.tv_sec*1000 + timeinqueue.tv_nsec/1000) / msgs_sent;
			}

			p = stentry->buf;
			p += sprintf(p, "combo\nstatus %s green %s Proxy up %s\n\nxymonproxy for Xymon version %s\n\nProxy statistics\n\nIncoming messages        : %10lu (%lu msgs/second)\nOutbound messages        : %10lu\n\nIncoming message distribution\n- Combo messages         : %10lu\n- Status messages        : %10lu\n  Messages merged        : %10lu\n  Resulting combos       : %10lu\n- Other messages         : %10lu\n\nProxy ressources\n- Connection table size  : %10d\n- Buffer space           : %10lu kByte\n",
				proxyname, timestamp, runtime_s, VERSION,
				msgs_total, (msgs_total - msgs_total_last) / (now - laststatus),
				msgs_delivered,
				msgs_combo, 
				msgs_status, msgs_merged, msgs_combined, 
				msgs_other,
				ccount, bufspace / 1024);







|







474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
				avgtime = 0;
			}
			else {
				avgtime = (timeinqueue.tv_sec*1000 + timeinqueue.tv_nsec/1000) / msgs_sent;
			}

			p = stentry->buf;
			p += sprintf(p, "combo\nstatus+11 %s green %s - xymon proxy up: %s\n\nxymonproxy for Xymon version %s\n\nProxy statistics\n\nIncoming messages        : %10lu (%lu msgs/second)\nOutbound messages        : %10lu\n\nIncoming message distribution\n- Combo messages         : %10lu\n- Status messages        : %10lu\n  Messages merged        : %10lu\n  Resulting combos       : %10lu\n- Other messages         : %10lu\n\nProxy ressources\n- Connection table size  : %10d\n- Buffer space           : %10lu kByte\n",
				proxyname, timestamp, runtime_s, VERSION,
				msgs_total, (msgs_total - msgs_total_last) / (now - laststatus),
				msgs_delivered,
				msgs_combo, 
				msgs_status, msgs_merged, msgs_combined, 
				msgs_other,
				ccount, bufspace / 1024);