Exemplo n.º 1
0
int do_filesizes_rrd(char *hostname, char *testname, char *msg, time_t tstamp) 
{ 
	char *boln, *eoln;

	if (filesize_tpl == NULL) filesize_tpl = setup_template(filesize_params);

	boln = strchr(msg, '\n'); if (boln) boln++;
	while (boln && *boln) {
		char *fn, *szstr = NULL;

		eoln = strchr(boln, '\n'); if (eoln) *eoln = '\0';

		fn = strtok(boln, ":"); if (fn) szstr = strtok(NULL, ":");
		if (fn && szstr) {
			char *p;

			for (p=strchr(fn, '/'); (p); p = strchr(p, '/')) *p = ',';
			setupfn("filesizes.%s.rrd", fn);

			sprintf(rrdvalues, "%d:%s", (int)tstamp, szstr);
			create_and_update_rrd(hostname, rrdfn, filesize_params, filesize_tpl);
		}

		boln = (eoln ? eoln+1 : NULL);
	}

	return 0;
}
Exemplo n.º 2
0
int do_beastat_jms_rrd(char *hostname, char *testname, char *classname, char *pagepaths, char *msg, time_t tstamp)
{
static char *beastat_jms_params[] = { "DS:CurrConn:GAUGE:600:0:U",
                                     "DS:HighConn:GAUGE:600:0:U",
                                     "DS:TotalConn:DERIVE:600:0:U",
                                     "DS:CurrJMSSrv:GAUGE:600:0:U",
                                     "DS:HighJMSSrv:GAUGE:600:0:U",
                                     "DS:TotalJMSSrv:DERIVE:600:0:U",
                                     NULL };
static void *beastat_jms_tpl      = NULL;

        unsigned long conncurr=0, connhigh=0, conntotal=0, jmscurr=0, jmshigh=0, jmstotal=0;
	
	dbgprintf("beastat: host %s test %s\n",hostname, testname);

	if (strstr(msg, "beastat.pl")) {
		setupfn("%s.rrd",testname);
		if (beastat_jms_tpl == NULL) beastat_jms_tpl = setup_template(beastat_jms_params);
		conncurr=get_long_data(msg, "ConnectionsCurrentCount");
		connhigh=get_long_data(msg,"ConnectionsHighCount");
		conntotal=get_long_data(msg,"ConnectionsTotalCount");
		jmscurr=get_long_data(msg,"JMSServersCurrentCount");
		jmshigh=get_long_data(msg,"JMSServersHighCount");
		jmstotal=get_long_data(msg,"JMSServersTotalCount");
		dbgprintf("beastat: host %s test %s conncurr %ld connhigh %ld conntotal %ld\n",
			hostname, testname, conncurr, connhigh, conntotal);
		dbgprintf("beastat: host %s test %s jmscurr %ld jmshigh %ld jmstotal %ld\n",
			hostname, testname, jmscurr, jmshigh,jmstotal);
		snprintf(rrdvalues, sizeof(rrdvalues), "%d:%ld:%ld:%ld:%ld:%ld:%ld",
			(int) tstamp, conncurr, connhigh, conntotal, jmscurr, jmshigh, jmstotal);
		create_and_update_rrd(hostname, testname, classname, pagepaths, beastat_jms_params, beastat_jms_tpl);
	}
	return 0;
}
Exemplo n.º 3
0
int do_beastat_exec_rrd(char *hostname, char *testname, char *classname, char *pagepaths, char *msg, time_t tstamp)
{
static char *beastat_exec_params[] = { "DS:ExecThrCurrIdleCnt:GAUGE:600:0:U",
					"DS:ExecThrTotalCnt:GAUGE:600:0:U",
					"DS:PendReqCurrCnt:GAUGE:600:0:U",
					"DS:ServReqTotalCnt:DERIVE:600:0:U",
					NULL };
static void *beastat_exec_tpl		= NULL;
static char *checktest			= "Type=ExecuteQueueRuntime";

	char *curline;
	char *eoln;		
	dbgprintf("beastat: host %s test %s\n",hostname, testname);

	if (strstr(msg, "beastat.pl")) {
		if (beastat_exec_tpl == NULL) beastat_exec_tpl = setup_template(beastat_exec_params);
/*
---- Full Status Report ----
	Type=ExecuteQueueRuntime - Location=admin - Name=weblogic.kernel.System
*/
                curline=strstr(msg, "---- Full Status Report ----");
                if (curline) {
			eoln = strchr(curline, '\n');
                	curline = (eoln ? (eoln+1) : NULL);
		}
		while (curline)	{
			unsigned long currthr=0, totthr=0,currprq=0,totservrq=0;
			char *start=NULL, *execname=NULL, *nameptr=NULL;
			if ((start = strstr(curline,checktest))==NULL) break;
			if ((eoln = strchr(start, '\n')) == NULL) break; 
			*eoln = '\0';
			if ((nameptr=strstr(start,"Name=")) == NULL ) {
				dbgprintf("do_beastat.c: No name found in  host %s test %s line %s\n",
					hostname,testname,start);
				goto nextline;
			}
			execname=xstrdup(nameptr+5);
	                *eoln = '\n';
			start=eoln+1;
			if ((eoln = strstr(start,checktest))==NULL) eoln=strstr(start,"dbcheck.pl");
			if (eoln)  *(--eoln)='\0';
			setupfn2("%s,%s.rrd",testname,execname);
			currthr=get_long_data(start, "ExecuteThreadCurrentIdleCount");
			totthr=get_long_data(start,"ExecuteThreadTotalCount");
			currprq=get_long_data(start,"PendingRequestCurrentCount");
			totservrq=get_long_data(start,"ServicedRequestTotalCount");
			dbgprintf("beastat: host %s test %s name %s currthr %ld totthr %ld currprq %ld totservrq %ld\n",
				hostname, testname, execname, currthr, totthr, currprq, totservrq);
			snprintf(rrdvalues, sizeof(rrdvalues), "%d:%ld:%ld:%ld:%ld",
				(int) tstamp, currthr, totthr, currprq, totservrq);
			create_and_update_rrd(hostname, testname, classname, pagepaths, beastat_exec_params, beastat_exec_tpl);
			if (execname) { xfree(execname); execname = NULL; }
nextline:
			if (eoln) *(eoln)='\n';
			curline = (eoln ? (eoln+1) : NULL);
		}
	}
	return 0;
}
Exemplo n.º 4
0
int do_iishealth_rrd(char *hostname, char *testname, char *classname, char *pagepaths, char *msg, time_t tstamp) 
{ 
	static char *iishealth_params[] = { "DS:realmempct:GAUGE:600:0:U", NULL };
	static void *iishealth_tpl      = NULL;

	char *bol, *eoln, *tok;

	if (iishealth_tpl == NULL) iishealth_tpl = setup_template(iishealth_params);

	bol = strchr(msg, '\n'); if (bol) bol++; else return 0;

	while (bol && *bol) {
		eoln = strchr(bol, '\n'); if (eoln) *eoln = '\0';

		tok = strtok(bol, " \t\r\n");	/* Get color marker */
		if (tok) tok = strtok(NULL, " \t\r\n");	/* Get keyword */
		if (tok) {
			int havedata = 0;

			if (strcmp(tok, "Connections:") == 0) {
				tok = strtok(NULL, " \t\r\n");
				if (tok == NULL) continue;

				setupfn2("%s.%s.rrd", "iishealth", "connections");
				sprintf(rrdvalues, "%d:%lu", (int)tstamp, atol(tok));
				havedata = 1;
			}
			else if (strcmp(tok, "RequestsQueued:") == 0) {
				tok = strtok(NULL, " \t\r\n");
				if (tok == NULL) continue;

				setupfn2("%s.%s.rrd", "iishealth", "requestqueued");
				sprintf(rrdvalues, "%d:%lu", (int)tstamp, atol(tok));
				havedata = 1;
			}
			else if (strcmp(tok, "Sessions:") == 0) {
				tok = strtok(NULL, " \t\r\n");
				if (tok == NULL) continue;

				setupfn2("%s.%s.rrd", "iishealth", "sessions");
				sprintf(rrdvalues, "%d:%lu", (int)tstamp, atol(tok));
				havedata = 1;
			}

			if (havedata) create_and_update_rrd(hostname, testname, classname, pagepaths, iishealth_params, iishealth_tpl);
		}

		bol = (eoln ? eoln+1 : NULL);
	}

	return 0;
}
Exemplo n.º 5
0
int do_beastat_jta_rrd(char *hostname, char *testname, char *classname, char *pagepaths, char *msg, time_t tstamp)
{
static char *beastat_jta_params[] = { "DS:ActiveTrans:GAUGE:600:0:U",
					"DS:SecondsActive:DERIVE:600:0:U",
					"DS:TransAbandoned:DERIVE:600:0:U",
					"DS:TransCommitted:DERIVE:600:0:U",
					"DS:TransHeuristics:DERIVE:600:0:U",
					"DS:TransRBackApp:DERIVE:600:0:U",
					"DS:TransRBackResource:DERIVE:600:0:U",
					"DS:TransRBackSystem:DERIVE:600:0:U",
					"DS:TransRBackTimeout:DERIVE:600:0:U",
					"DS:TransRBack:DERIVE:600:0:U",
					"DS:TransTotCount:DERIVE:600:0:U",
                                     NULL };
static void *beastat_jta_tpl      = NULL;

	unsigned long heapfree=0, heapsize=0;
	unsigned long acttrans=0, secact=0, trab=0, trcomm=0, trheur=0, totot=0;
	unsigned long trrbapp=0, trrbres=0, trrbsys=0, trrbto=0, trrb=0, trtot=0;
	
	dbgprintf("beastat: host %s test %s\n",hostname, testname);

	if (strstr(msg, "beastat.pl")) {
		setupfn("%s.rrd",testname);
		if (beastat_jta_tpl == NULL) beastat_jta_tpl = setup_template(beastat_jta_params);
		acttrans=get_long_data(msg,"ActiveTransactionsTotalCount");
		secact=get_long_data(msg,"SecondsActiveTotalCount");
		trab=get_long_data(msg,"TransactionAbandonedTotalCount");
		trcomm=get_long_data(msg,"TransactionCommittedTotalCount");
		trheur=get_long_data(msg,"TransactionHeuristicsTotalCount");
		trrbapp=get_long_data(msg,"TransactionRolledBackAppTotalCount");
		trrbres=get_long_data(msg,"TransactionRolledBackResourceTotalCount");
		trrbsys=get_long_data(msg,"TransactionRolledBackSystemTotalCount");
		trrbto=get_long_data(msg,"TransactionRolledBackTimeoutTotalCount");
		trrb=get_long_data(msg,"TransactionRolledBackTotalCount");
		trtot=get_long_data(msg,"TransactionTotalCount");
		dbgprintf("beastat: host %s test %s acttrans %ld secact %ld\n",
			 hostname, testname, acttrans, secact);
		dbgprintf("beastat: host %s test %s TRANS: aband %ld comm %ld heur %ld total\n",
			hostname, testname, trab, trcomm, trheur, trtot);
		dbgprintf("beastat: host %s test %s RB: app %ld res %ld sys %ld timout %ld total %ld\n",
			hostname, testname, trrbapp, trrbres, trrbsys, trrbto, trrb);
		snprintf(rrdvalues, sizeof(rrdvalues), "%d:%ld:%ld:%ld:%ld:%ld:%ld:%ld:%ld:%ld:%ld:%ld",
			(int) tstamp, acttrans, secact, trab, trcomm, trheur, trrbapp, 
			trrbres, trrbsys, trrbto, trrb, trtot);
		create_and_update_rrd(hostname, testname, classname, pagepaths, beastat_jta_params, beastat_jta_tpl);
	}
	return 0;
}
Exemplo n.º 6
0
int do_dbcheck_hitcache_rrd(char *hostname, char *testname, char *msg, time_t tstamp)
{
static char *dbcheck_hitcache_params[] = { "rrdcreate", rrdfn,
                                     "DS:PinSQLArea:GAUGE:600:0:100",
                                     "DS:PinTblProc:GAUGE:600:0:100",
                                     "DS:PinBody:GAUGE:600:0:100",
                                     "DS:PinTrigger:GAUGE:600:0:100",
                                     "DS:HitSQLArea:GAUGE:600:0:100",
                                     "DS:HitTblProc:GAUGE:600:0:100",
                                     "DS:HitBody:GAUGE:600:0:100",
                                     "DS:HitTrigger:GAUGE:600:0:100",
                                     "DS:BlBuffHit:GAUGE:600:0:100",
                                     "DS:RowCache:GAUGE:600:0:100",
                                     rra1, rra2, rra3, rra4, NULL };
static char *dbcheck_hitcache_tpl      = NULL;

	static time_t starttime = 0;
	double pinsql=0, pintbl=0, pinbody=0, pintrig=0, hitsql=0, hittbl=0, hitbody=0, hittrig=0, blbuff=0, rowchache=0;
	time_t now = time(NULL);
	dbgprintf("dbcheck: host %s test %s\n",hostname, testname);
	
	if (starttime == 0) starttime = now;
	if (strstr(msg, "dbcheck.pl")) {
		sprintf(rrdfn, "%s.rrd",testname);
		if (dbcheck_hitcache_tpl == NULL) dbcheck_hitcache_tpl = setup_template(dbcheck_hitcache_params);
		pinsql=get_double_data(msg,"PinSQLArea");
		pintbl=get_double_data(msg,"PinTblProc");
		pinbody=get_double_data(msg,"PinBody");
		pintrig=get_double_data(msg,"PinTrigger");
		hitsql=get_double_data(msg,"HitSQLArea");
		hittbl=get_double_data(msg,"HitTblProc");
		hitbody=get_double_data(msg,"HitBody");
		hittrig=get_double_data(msg,"HitTrigger");
		blbuff=get_double_data(msg,"BlBuffHit");
		rowchache=get_double_data(msg,"RowCache");
		dbgprintf("dbcheck: host %s test %s pinsql %5.2f pintbl %5.2f pinbody %5.2f pintrig %5.2f\n",
			hostname, testname, pinsql, pintbl, pinbody, pintrig);
		dbgprintf("dbcheck: host %s test %s hitsql %5.2f hittbl %5.2f hitbody %5.2f hittrig %5.2f\n",
			hostname, testname, hitsql, hittbl, hitbody, hittrig);
		dbgprintf("dbcheck: host %s test %s blbuff %5.2f rowchache %5.2f\n",
			hostname, testname, blbuff, rowchache);
		sprintf(rrdvalues, "%d:%5.2f:%5.2f:%5.2f:%5.2f:%5.2f:%5.2f:%5.2f:%5.2f:%5.2f:%5.2f",
			(int) tstamp, pinsql, pintbl, pinbody, pintrig,
			hitsql, hittbl, hitbody, hittrig, blbuff, rowchache);
		create_and_update_rrd(hostname, rrdfn, dbcheck_hitcache_params, dbcheck_hitcache_tpl);
	}
	return 0;
}
Exemplo n.º 7
0
int do_dbcheck_invobj_rrd(char *hostname, char *testname, char *msg, time_t tstamp)
{
/* This check can be done in slow mode so put a long heartbeat */
static char *dbcheck_invobj_params[] = { "rrdcreate", rrdfn,
                                        "DS:red:GAUGE:28800:0:U",
                                        "DS:yellow:GAUGE:28800:0:U",
                                        "DS:green:GAUGE:28800:0:U",
                                        rra1, rra2, rra3, rra4, NULL };
static char *dbcheck_invobj_tpl    = NULL;

        char *curline;
        char *eoln;
	unsigned long yellow=0,red=0,green=0;
        static time_t starttime = 0;
        time_t now = time(NULL);
        dbgprintf("dbcheck: host %s test %s\n",hostname, testname);

        if (starttime == 0) starttime = now;
        if (strstr(msg, "dbcheck.pl")) {
                if (dbcheck_invobj_tpl == NULL) dbcheck_invobj_tpl = setup_template(dbcheck_invobj_params);
                curline=strstr(msg, "Invalid Object Checking");
                if (curline) {
                        eoln = strchr(curline, '\n');
                        curline = (eoln ? (eoln+1) : NULL);
                }
                while (curline) {
			if ( *curline == '\n') { curline++; continue; }
                        if ((eoln = strchr(curline, '\n')) == NULL) break;
                        *eoln = '\0';
			if ( *curline =='&' ) curline++;
			if ( strstr(curline,"red") == curline) red++;
			if ( strstr(curline,"yellow") == curline) yellow++;
			if ( strstr(curline,"green") == curline) green++;
nextline:
                        if (eoln) *(eoln)='\n';
                        curline = (eoln ? (eoln+1) : NULL);
                }
                sprintf(rrdfn, "%s.rrd",testname);
                dbgprintf("dbcheck: host %s test %s  red %ld yellow %ld green %ld\n", 
			hostname, testname, red,yellow,green);
                sprintf(rrdvalues, "%d:%ld:%ld:%ld", (int) tstamp, red,yellow,green);
                        create_and_update_rrd(hostname, rrdfn, dbcheck_invobj_params, dbcheck_invobj_tpl);
        }
        return 0;
}
Exemplo n.º 8
0
int do_apache_rrd(char *hostname, char *testname, char *msg, time_t tstamp)
{
	static char *apache_params[] = { "rrdcreate", rrdfn, 
					 "DS:TA:DERIVE:600:0:U",
					 "DS:TKB:DERIVE:600:0:U",
					 "DS:BW:GAUGE:600:1:U",
					 "DS:IW:GAUGE:600:1:U",
					 "DS:CPU:GAUGE:600:0:U",
					 "DS:REQPERSEC:GAUGE:600:0:U",
					 rra1, rra2, rra3, rra4, NULL };
	static char *apache_tpl      = NULL;

	char *markers[] = { "Total Accesses:", "Total kBytes:", 
			    "BusyWorkers:", "IdleWorkers:", "CPULoad:", "ReqPerSec:", NULL };
	int i;
	char *p, *eoln;

	if (apache_tpl == NULL) apache_tpl = setup_template(apache_params);

	/* Apache 1.x uses BusyServers/IdleServers. Convert the status to Apache 2.0 format */
	if ((p = strstr(msg, "BusyServers:")) != NULL) memcpy(p, "BusyWorkers:", strlen("BusyWorkers:"));
	if ((p = strstr(msg, "IdleServers:")) != NULL) memcpy(p, "IdleWorkers:", strlen("IdleWorkers:"));

	strcpy(rrdfn, "apache.rrd");
	sprintf(rrdvalues, "%d", (int)tstamp);
	i = 0;
	while (markers[i]) {
		strcat(rrdvalues, ":"); 
		p = strstr(msg, markers[i]);
		if (p) {
			eoln = strchr(p, '\n');
			if (eoln) *eoln = '\0';
			p = strchr(p, ':')+1;
			p += strspn(p, " ");
			strcat(rrdvalues, p);
			if (eoln) *eoln = '\n';
		}
		else {
			strcat(rrdvalues, "U");
		}
		i++;
	}

	return create_and_update_rrd(hostname, rrdfn, apache_params, apache_tpl);
}
Exemplo n.º 9
0
int do_dbcheck_memreq_rrd(char *hostname, char *testname, char *msg, time_t tstamp)
{
static char *dbcheck_memreq_params[] = { "rrdcreate", rrdfn,
                                     "DS:ResFree:GAUGE:600:0:U",
                                     "DS:ResAvgFree:GAUGE:600:0:U",
                                     "DS:ResUsed:GAUGE:600:0:U",
                                     "DS:ResAvgUsed:GAUGE:600:0:U",
                                     "DS:ReqFail:DERIVE:600:0:U",
                                     "DS:FailSize:GAUGE:600:0:U",
                                     rra1, rra2, rra3, rra4, NULL };
static char *dbcheck_memreq_tpl      = NULL;

	unsigned long free=0,used=0,reqf=0,fsz=0;	
	double avfr=0,avus=0;
	char *start,*end;
	static time_t starttime = 0;
	time_t now = time(NULL);
	dbgprintf("dbcheck: host %s test %s\n",hostname, testname);
	if (starttime == 0) starttime = now;
	if (strstr(msg, "dbcheck.pl")) {
		if (dbcheck_memreq_tpl == NULL) dbcheck_memreq_tpl = setup_template(dbcheck_memreq_params);
                if ((start=strstr(msg, "<!--"))==NULL) return 0;
                if ((end=strstr(start,"-->"))==NULL) return 0;
		*end='\0';
		free=get_long_data(start,"ResFree");
		avfr=get_double_data(start,"ResAvgFree");
		used=get_long_data(start,"ResUsed");
		avus=get_double_data(start,"ResAvgUsed");
		reqf=get_long_data(start,"ReqFail");
		fsz=get_long_data(start,"FailSize");
		*end='-';
		dbgprintf("dbcheck: host %s test %s free %ld avgfree %f\n",
			hostname, testname, free, avfr);
		dbgprintf("dbcheck: host %s test %s used %ld avgused %f\n",
			hostname, testname, used, avus);
		dbgprintf("dbcheck: host %s test %s reqfail %ld failsize %ld\n",
			hostname, testname, reqf, fsz);
		sprintf(rrdvalues, "%d:%ld:%f:%ld:%f:%ld:%ld",
			(int) tstamp, free, avfr, used, avus, reqf,fsz);
		sprintf(rrdfn, "%s.rrd",testname);
		create_and_update_rrd(hostname, rrdfn, dbcheck_memreq_params, dbcheck_memreq_tpl);
	}
	return 0;
}
Exemplo n.º 10
0
int do_dbcheck_rb_rrd(char *hostname, char *testname, char *msg, time_t tstamp)
{
/* This check can be done in slow mode so put a long heartbeat */
static char *dbcheck_rb_params[] = { "rrdcreate", rrdfn,
                                        "DS:pct:GAUGE:28800:0:100",
                                        rra1, rra2, rra3, rra4, NULL };
static char *dbcheck_rb_tpl    = NULL;

        char *curline;
        char *eoln;
        static time_t starttime = 0;
        time_t now = time(NULL);
        dbgprintf("dbcheck: host %s test %s\n",hostname, testname);

        if (starttime == 0) starttime = now;
        if (strstr(msg, "dbcheck.pl")) {
                if (dbcheck_rb_tpl == NULL) dbcheck_rb_tpl = setup_template(dbcheck_rb_params);
                curline=strstr(msg, "Rollback Checking");
                if (curline) {
                        eoln = strchr(curline, '\n');
                        curline = (eoln ? (eoln+1) : NULL);
                }
                while (curline) {
                        float pct=0;
                        char *execname=NULL;
			char *start;
			if ((start = strstr(curline,"ROLLBACK")) == NULL) break;
                        if ((eoln = strchr(start, '\n')) == NULL) break;
                        *eoln = '\0';
			dbgprintf("dbcheck: host %s test %s line %s\n", hostname, testname, start);
			execname=xmalloc(strlen(start));
                        if ( sscanf(start,"ROLLBACK percentage for %s is %f",execname,&pct) !=2) goto nextline;
                        sprintf(rrdfn, "%s,%s.rrd",testname,execname);
                        dbgprintf("dbcheck: host %s test %s name %s pct %5.2f\n", hostname, testname, execname, pct);
                        sprintf(rrdvalues, "%d:%5.2f", (int) tstamp, pct);
                        create_and_update_rrd(hostname, rrdfn, dbcheck_rb_params, dbcheck_rb_tpl);
nextline:
                        if (execname) { xfree(execname); execname = NULL; }
                        if (eoln) *(eoln)='\n';
                        curline = (eoln ? (eoln+1) : NULL);
                }
        }
        return 0;
}
Exemplo n.º 11
0
int do_citrix_rrd(char *hostname, char *testname, char *msg, time_t tstamp)
{
	static char *citrix_params[] = { "rrdcreate", rrdfn, "DS:users:GAUGE:600:0:U", rra1, rra2, rra3, rra4, NULL };
	static char *citrix_tpl      = NULL;

	char *p;
	int users;

	if (citrix_tpl == NULL) citrix_tpl = setup_template(citrix_params);

	p = strstr(msg, " users active\n");
	while (p && (p > msg) && (*p != '\n')) p--;
	if (p && (sscanf(p+1, "\n%d users active\n", &users) == 1)) {
		sprintf(rrdfn, "citrix.rrd");
		sprintf(rrdvalues, "%d:%d", (int)tstamp, users);
		return create_and_update_rrd(hostname, rrdfn, citrix_params, citrix_tpl);
	}

	return 0;
}
Exemplo n.º 12
0
int do_paging_rrd(char *hostname, char *testname, char *classname, char *pagepaths, char *msg, time_t tstamp) 
{ 
	char *pr;
	char *fn = NULL;
	int pagerate, xstore, migrate;

	if (paging_tpl == NULL) paging_tpl = setup_template(paging_params);

	pr=(strstr(msg, "Rate"));
	if (pr) {
		pr += 5;
		sscanf(pr, "%d per", &pagerate);
		setupfn("paging.pagerate.rrd", fn);

		sprintf(rrdvalues, "%d:%d", (int)tstamp, pagerate);
		create_and_update_rrd(hostname, testname, classname, pagepaths, paging_params, paging_tpl);
                if (strstr(msg, "z/VM")) {  /*  Additional handling for z/VM  */
                        pr=strstr(msg,"XSTORE-");
                        if (pr) {    /* Extract values if we find XSTORE in results of 'IND' command  */
                                pr += 7;  /*  Add 7 to get past literal (XSTORE).  */
                                sscanf(pr, "%d/SEC", &xstore);
                                pr=strstr(msg,"MIGRATE-");
                                pr += 8;  /*  Add 8 to get past literal (MIGRATE).  */
                                sscanf(pr, "%d/SEC", &migrate);
 
                                setupfn("paging.xstore.rrd", fn);
                                sprintf(rrdvalues, "%d:%d", (int)tstamp, xstore);
                                create_and_update_rrd(hostname, testname, classname, pagepaths, paging_params, paging_tpl);
 
                                setupfn("paging.migrate.rrd", fn);
                                sprintf(rrdvalues, "%d:%d", (int)tstamp, migrate);
                                create_and_update_rrd(hostname, testname, classname, pagepaths, paging_params, paging_tpl);
                        }

		}

	}
	return 0;
}
Exemplo n.º 13
0
int do_dbcheck_session_rrd(char *hostname, char *testname, char *msg, time_t tstamp)
{

static char *dbcheck_session_params[] = { "rrdcreate", rrdfn,
                                     "DS:MaxSession:GAUGE:600:0:U",
                                     "DS:CurrSession:GAUGE:600:0:U",
                                     "DS:SessUsedPct:GAUGE:600:0:100",
                                     "DS:MaxProcs:GAUGE:600:0:U",
                                     "DS:CurrProcs:GAUGE:600:0:U",
                                     "DS:ProcsUsedPct:GAUGE:600:0:100",
                                     rra1, rra2, rra3, rra4, NULL };
static char *dbcheck_session_tpl      = NULL;

	static time_t starttime = 0;
        unsigned long maxsess=0, currsess=0, maxproc=0, currproc=0 ;
	double pctsess=0, pctproc=0;
	time_t now = time(NULL);
	dbgprintf("dbcheck: host %s test %s\n",hostname, testname);
	
	if (starttime == 0) starttime = now;
	if (strstr(msg, "dbcheck.pl")) {
		sprintf(rrdfn, "%s.rrd",testname);
		if (dbcheck_session_tpl == NULL) dbcheck_session_tpl = setup_template(dbcheck_session_params);
		maxsess=get_long_data(msg, "MaxSession");
		currsess=get_long_data(msg,"CurrSession");
		pctsess=get_double_data(msg,"SessUsedPct");
		maxproc=get_long_data(msg,"MaxProcs");
		currproc=get_long_data(msg,"CurrProcs");
		pctproc=get_double_data(msg,"ProcsUsedPct");
		dbgprintf("dbcheck: host %s test %s maxsess %ld currsess %ld pctsess %5.2f\n",
		hostname, testname, maxsess, currsess, pctsess);
			dbgprintf("dbcheck: host %s test %s maxproc %ld currproc %ld pctproc %5.2f\n",
		hostname, testname, maxproc, currproc, pctproc);
                        sprintf(rrdvalues, "%d:%ld:%ld:%5.2f:%ld:%ld:%5.2f",
                       	(int) tstamp, maxsess, currsess, pctsess, maxproc, currproc, pctproc);
		create_and_update_rrd(hostname, rrdfn, dbcheck_session_params, dbcheck_session_tpl);
	}
	return 0;
}
Exemplo n.º 14
0
int do_bbproxy_rrd(char *hostname, char *testname, char *classname, char *pagepaths, char *msg, time_t tstamp)
{ 
	static char *bbproxy_params[]       = { "DS:runtime:GAUGE:600:0:U", NULL };
	static void *bbproxy_tpl            = NULL;

	char	*p;
	float	runtime;

	if (bbproxy_tpl == NULL) bbproxy_tpl = setup_template(bbproxy_params);

	p = strstr(msg, "Average queue time");
	if (p && (sscanf(p, "Average queue time : %f", &runtime) == 1)) {
		if (strcmp("bbproxy", testname) != 0) {
			setupfn2("%s.%s.rrd", "bbproxy", testname);
		}
		else {
			setupfn("%s.rrd", "bbproxy");
		}
		sprintf(rrdvalues, "%d:%.2f", (int) tstamp, runtime);
		return create_and_update_rrd(hostname, testname, classname, pagepaths, bbproxy_params, bbproxy_tpl);
	}

	return 0;
}
Exemplo n.º 15
0
int do_beastat_jvm_rrd(char *hostname, char *testname, char *classname, char *pagepaths, char *msg, time_t tstamp)
{
static char *beastat_jvm_params[] = { "DS:HeapFreeCurrent:GAUGE:600:0:U",
                                     "DS:HeapSizeCurrent:GAUGE:600:0:U",
                                     NULL };
static void *beastat_jvm_tpl      = NULL;

	unsigned long heapfree=0, heapsize=0;
	
	dbgprintf("beastat: host %s test %s\n",hostname, testname);

	if (strstr(msg, "beastat.pl")) {
		setupfn("%s.rrd",testname);
		if (beastat_jvm_tpl == NULL) beastat_jvm_tpl = setup_template(beastat_jvm_params);
		heapfree=get_long_data(msg, "HeapFreeCurrent");
		heapsize=get_long_data(msg,"HeapSizeCurrent");
		dbgprintf("beastat: host %s test %s heapfree %ld heapsize %ld\n",
			hostname, testname, heapfree, heapsize);
		snprintf(rrdvalues, sizeof(rrdvalues), "%d:%ld:%ld",
			(int) tstamp, heapfree, heapsize);
		create_and_update_rrd(hostname, testname, classname, pagepaths, beastat_jvm_params, beastat_jvm_tpl);
	}
	return 0;
}
Exemplo n.º 16
0
int do_xymond_rrd(char *hostname, char *testname, char *classname, char *pagepaths, char *msg, time_t tstamp) 
{ 
	static char *xymond_params[] = { "DS:inmessages:DERIVE:600:0:U", 
					 "DS:statusmessages:DERIVE:600:0:U", 
					 "DS:combomessages:DERIVE:600:0:U", 
					 "DS:pagemessages:DERIVE:600:0:U", 
					 "DS:summarymessages:DERIVE:600:0:U", 
					 "DS:datamessages:DERIVE:600:0:U", 
					 "DS:notesmessages:DERIVE:600:0:U", 
					 "DS:enablemessages:DERIVE:600:0:U", 
					 "DS:disablemessages:DERIVE:600:0:U", 
					 "DS:ackmessages:DERIVE:600:0:U", 
					 "DS:configmessages:DERIVE:600:0:U", 
					 "DS:querymessages:DERIVE:600:0:U", 
					 "DS:boardmessages:DERIVE:600:0:U", 
					 "DS:listmessages:DERIVE:600:0:U", 
					 "DS:logmessages:DERIVE:600:0:U", 
					 "DS:dropmessages:DERIVE:600:0:U", 
					 "DS:renamemessages:DERIVE:600:0:U", 
					 "DS:statuschmsgs:DERIVE:600:0:U", 
					 "DS:stachgchmsgs:DERIVE:600:0:U", 
					 "DS:pagechmsgs:DERIVE:600:0:U", 
					 "DS:datachmsgs:DERIVE:600:0:U", 
					 "DS:noteschmsgs:DERIVE:600:0:U", 
					 "DS:enadischmsgs:DERIVE:600:0:U", 
					 NULL };
	static void *xymond_tpl        = NULL;

	struct {
		char *marker;
		unsigned long val;
	} xymond_data[] = {
		{ "\nIncoming messages", 0 },
		{ "\n- status", 0 },
		{ "\n- combo", 0 },
		{ "\n- page", 0 },
		{ "\n- summary", 0 },
		{ "\n- data", 0 },
		{ "\n- notes", 0 },
		{ "\n- enable", 0 },
		{ "\n- disable", 0 },
		{ "\n- ack", 0 },
		{ "\n- config", 0 },
		{ "\n- query", 0 },
		{ "\n- xymondboard", 0 },
		{ "\n- xymondlist", 0 },
		{ "\n- xymondlog", 0 },
		{ "\n- drop", 0 },
		{ "\n- rename", 0 },
		{ "\nstatus channel messages", 0 },
		{ "\nstachg channel messages", 0 },
		{ "\npage   channel messages", 0 },
		{ "\ndata   channel messages", 0 },
		{ "\nnotes  channel messages", 0 },
		{ "\nenadis channel messages", 0 },
		{ NULL, 0 }
	};

	int	i, gotany = 0;
	char	*p;
	char	valstr[10];

	MEMDEFINE(valstr);

	if (xymond_tpl == NULL) xymond_tpl = setup_template(xymond_params);

	sprintf(rrdvalues, "%d", (int)tstamp);
	i = 0;
	while (xymond_data[i].marker) {
		p = strstr(msg, xymond_data[i].marker);
		if (p) {
			if (*p == '\n') p++;
			p += strcspn(p, ":\r\n");
			if (*p == ':') {
				xymond_data[i].val = atol(p+1);
				gotany++;
				sprintf(valstr, ":%lu", xymond_data[i].val);
				strcat(rrdvalues, valstr);
			}
			else strcat(rrdvalues, ":U");
		}
		else strcat(rrdvalues, ":U");

		i++;
	}

	if (gotany) {
		if (strcmp("xymond", testname) != 0) {
			setupfn2("%s.%s.rrd", "xymond", testname);
		}
		else {
			setupfn("%s.rrd", "xymond");
		}

		MEMUNDEFINE(valstr);
		return create_and_update_rrd(hostname, testname, classname, pagepaths, xymond_params, xymond_tpl);
	}

	MEMUNDEFINE(valstr);
	return 0;
}
Exemplo n.º 17
0
int do_derives_rrd(char *counttype, char *hostname, char *testname, char *classname, char *pagepaths, char *msg, time_t tstamp) 
{
	if (derive_tpl == NULL) derive_tpl = setup_template(derive_params);

	return do_one_counts_rrd(counttype, hostname, testname, classname, pagepaths, msg, tstamp, derive_params, derive_tpl);
}
Exemplo n.º 18
0
int do_beastat_jdbc_rrd(char *hostname, char *testname, char *classname, char *pagepaths, char *msg, time_t tstamp)
{
static char *beastat_jdbc_params[] = { "DS:ActConnAvgCnt:GAUGE:600:0:U",
					"DS:ActConnCurrCnt:GAUGE:600:0:U",
					"DS:ActConnHighCnt:GAUGE:600:0:U",
					"DS:WtForConnCurrCnt:GAUGE:600:0:U",
					"DS:ConnDelayTime:GAUGE:600:0:U",
					"DS:ConnLeakProfileCnt:GAUGE:600:0:U",
					"DS:LeakedConnCnt:GAUGE:600:0:U",
					"DS:MaxCapacity:GAUGE:600:0:U",
					"DS:NumAvailable:GAUGE:600:0:U",
					"DS:NumUnavailable:GAUGE:600:0:U",
					"DS:HighNumAvailable:GAUGE:600:0:U",
					"DS:HighNumUnavailable:GAUGE:600:0:U",
					"DS:WaitSecHighCnt:GAUGE:600:0:U",
					"DS:ConnTotalCnt:DERIVE:600:0:U",
					"DS:FailToReconnCnt:DERIVE:600:0:U",
					"DS:WaitForConnHighCnt:GAUGE:600:0:U",
					NULL };
static void *beastat_jdbc_tpl		= NULL;
static char *checktest			= "Type=JDBCConnectionPoolRuntime";

	char *curline;
	char *eoln;		
	dbgprintf("beastat: host %s test %s\n",hostname, testname);

	if (strstr(msg, "beastat.pl")) {
		if (beastat_jdbc_tpl == NULL) beastat_jdbc_tpl = setup_template(beastat_jdbc_params);
/*
---- Full Status Report ----
	Type=ExecuteQueueRuntime - Location=admin - Name=weblogic.kernel.System
*/
                curline=strstr(msg, "---- Full Status Report ----");
                if (curline) {
			eoln = strchr(curline, '\n');
                	curline = (eoln ? (eoln+1) : NULL);
		}
		while (curline)	{
			unsigned long acac=0, accc=0, achc=0, wfccc=0, cdt=0, clpc=0, lcc=0; 
			unsigned long mc=0, na=0, nu=0, hna=0, hnu=0, wshc=0, ctc=0, ftrc=0, wfchc=0;
			char *start=NULL, *execname=NULL, *nameptr=NULL;
			if ((start = strstr(curline,checktest))==NULL) break;
			if ((eoln = strchr(start, '\n')) == NULL) break; 
			*eoln = '\0';
			if ((nameptr=strstr(start,"Name=")) == NULL ) {
				dbgprintf("do_beastat.c: No name found in  host %s test %s line %s\n",
					hostname,testname,start);
				goto nextline;
			}
			execname=xstrdup(nameptr+5);
	                *eoln = '\n';
			start=eoln+1;
			if ((eoln = strstr(start,checktest))==NULL) eoln=strstr(start,"dbcheck.pl");
			if (eoln)  *(--eoln)='\0';
			setupfn2("%s,%s.rrd",testname,execname);
			acac=get_long_data(start,"ActiveConnectionsAverageCount");
			accc=get_long_data(start,"ActiveConnectionsCurrentCount");
			achc=get_long_data(start,"ActiveConnectionsHighCount");
			wfccc=get_long_data(start,"WaitingForConnectionCurrentCount");
			cdt=get_long_data(start,"ConnectionDelayTime");
			clpc=get_long_data(start,"ConnectionLeakProfileCount");
			lcc=get_long_data(start,"LeakedConnectionCount");
			mc=get_long_data(start,"MaxCapacity");
			na=get_long_data(start,"NumAvailable");
			nu=get_long_data(start,"NumUnavailable");
			hna=get_long_data(start,"HighestNumAvailable");
			hnu=get_long_data(start,"HighestNumUnavailable");
			wshc=get_long_data(start,"WaitSecondsHighCount");
			ctc=get_long_data(start,"ConnectionsTotalCount");
			ftrc=get_long_data(start,"FailuresToReconnectCount");
			wfchc=get_long_data(start,"WaitingForConnectionHighCount");


			dbgprintf("beastat: host %s test %s name %s acac %ld accc %ld achc %ld wfccc %ld cdt %ld clpc %ld lcc %ld\n", hostname, testname, execname, acac, accc, achc, wfccc, cdt, clpc, lcc);
			dbgprintf("beastat: host %s test %s name %s mc %ld na %ld nu %ld hna %ld hnu %ld wshc %ld ctc %ld ftrc %ld wfchc %ld\n",hostname, testname, execname, mc, na, nu, hna, hnu, wshc, ctc, ftrc, wfchc);

			snprintf(rrdvalues, sizeof(rrdvalues), "%d:%ld:%ld:%ld:%ld:%ld:%ld:%ld:%ld:%ld:%ld:%ld:%ld:%ld:%ld:%ld:%ld",
				(int) tstamp, acac, accc, achc, wfccc, cdt, clpc, lcc, 
				mc, na, nu, hna, hnu, wshc, ctc, ftrc, wfchc);
			create_and_update_rrd(hostname, testname, classname, pagepaths, beastat_jdbc_params, beastat_jdbc_tpl);
			if (execname) { xfree(execname); execname = NULL; }
nextline:
			if (eoln) *(eoln)='\n';
			curline = (eoln ? (eoln+1) : NULL);
		}
	}
	return 0;
}
Exemplo n.º 19
0
int do_temperature_rrd(char *hostname, char *testname, char *classname, char *pagepaths, char *msg, time_t tstamp) 
{ 
	static char *temperature_params[] = { "DS:temperature:GAUGE:600:1:U",
					      NULL };
	static void *temperature_tpl      = NULL;

	/* Sample input report:
	Device             Temp(C)  Temp(F)
	-----------------------------------
	&green Motherboard#0      31       87
	&green Motherboard#1      28       82
	&green AMBIENT            25       77
	&green CPU0               40      104
	&green CPU1               40      104
	&green CPU2               40      104
	&green CPU3               40      104
	&green Board 0            29       84
	&green Board 1            35       95
	&green Board 2            30       86
	&green Board 3            37       98
	&green Board 4            28       82
	&green Board 6            28       82
	&green Board CLK          27       80
	&green MB                 24       75
	&green IOB                19       66
	&green DBP0               19       66
	&green CPU 0 Die          79      174
	&green CPU 0 Ambient      27       80
	&green CPU 1 Die          73      163
	&green CPU 1 Ambient      26       78
	-----------------------------------
	Status green: All devices look okay
	*/

	char *bol, *eol, *comment, *p;
	int tmpC;

	if (temperature_tpl == NULL) temperature_tpl = setup_template(temperature_params);

	bol = eol = msg;
	while (eol && ((p = strstr(eol, "\n&")) != NULL)) {
		int gotone = 0;

		bol = p + 1;
		eol = strchr(bol, '\n'); if (eol) *eol = '\0';

		/* See if there's a comment in parenthesis */
		comment = strchr(bol, '('); /* Begin comment */
		p = strchr(bol, ')');       /* End comment */
		if (comment && p && (comment < p)) *comment = '\0'; /* Cut off the comment */

		if      (strncmp(bol, "&green", 6) == 0)  { bol += 6; gotone = 1; }
		else if (strncmp(bol, "&yellow", 7) == 0) { bol += 7; gotone = 1; }
		else if (strncmp(bol, "&red", 4) == 0)    { bol += 4; gotone = 1; }
		else if (strncmp(bol, "&clear", 6) == 0)  { bol += 6; gotone = 1; }

		if (gotone) {
			char savech;

			bol += strspn(bol, " \t");

			/* Strip off any leading bold and italic HTML tags */
			if      (strncasecmp(bol, "<i><b>", 6) == 0)  { bol += 6; }
			else if (strncasecmp(bol, "<i>", 3) == 0)  { bol += 3; }
			else if (strncasecmp(bol, "<b><i>", 6) == 0)  { bol += 6; }
			else if (strncasecmp(bol, "<b>", 3) == 0)  { bol += 3; } 
			bol += strspn(bol, " \t");

			p = bol + strlen(bol) - 1;
			while ((p > bol) && isspace((int)*p)) p--;
			while ((p > bol) && isdigit((int)*p)) p--;
			// tmpF = atoi(p);
			while ((p > bol) && isspace((int)*p)) p--;
			while ((p > bol) && isdigit((int)*p)) p--;
			tmpC = atoi(p);
			while ((p > bol) && isspace((int)*p)) p--;

			savech = *(p+1); *(p+1) = '\0'; 
			setupfn2("%s.%s.rrd", "temperature", bol); *(p+1) = savech;

			snprintf(rrdvalues, sizeof(rrdvalues), "%d:%d", (int)tstamp, tmpC);
			create_and_update_rrd(hostname, testname, classname, pagepaths, temperature_params, temperature_tpl);
		}

		if (comment) *comment = '(';
		if (eol) *eol = '\n';
	}

	return 0;
}
Exemplo n.º 20
0
int do_net_rrd(char *hostname, char *testname, char *msg, time_t tstamp)
{
	static char *bbnet_params[]       = { "rrdcreate", rrdfn, "DS:sec:GAUGE:600:0:U", rra1, rra2, rra3, rra4, NULL };
	static char *bbnet_tpl            = NULL;

	char *p;
	float seconds;

	if (bbnet_tpl == NULL) bbnet_tpl = setup_template(bbnet_params);

	if (strcmp(testname, "http") == 0) {
		char *line1, *url = NULL, *eoln;

		line1 = msg;
		while ((line1 = strchr(line1, '\n')) != NULL) {
			line1++; /* Skip the newline */
			eoln = strchr(line1, '\n'); if (eoln) *eoln = '\0';

			if ( (strncmp(line1, "&green", 6) == 0) || 
			     (strncmp(line1, "&yellow", 7) == 0) ||
			     (strncmp(line1, "&red", 4) == 0) ) {
				p = strstr(line1, "http");
				if (p) {
					url = xstrdup(p);
					p = strchr(url, ' ');
					if (p) *p = '\0';
				}
			}
			else if (url && ((p = strstr(line1, "Seconds:")) != NULL) && (sscanf(p, "Seconds: %f", &seconds) == 1)) {
				char *urlfn = url;

				if (strncmp(urlfn, "http://", 7) == 0) urlfn += 7;
				p = urlfn; while ((p = strchr(p, '/')) != NULL) *p = ',';
				setupfn("tcp.http.%s.rrd", urlfn);
				sprintf(rrdvalues, "%d:%.2f", (int)tstamp, seconds);
				create_and_update_rrd(hostname, rrdfn, bbnet_params, bbnet_tpl);
				xfree(url); url = NULL;
			}

			if (eoln) *eoln = '\n';
		}

		if (url) xfree(url);
	}
	else if (strcmp(testname, xgetenv("PINGCOLUMN")) == 0) {
		/*
		 * Ping-tests, possibly using fping.
		 */
		char *tmod = "ms";

		if ((p = strstr(msg, "time=")) != NULL) {
			/* Standard ping, reports ".... time=0.2 ms" */
			seconds = atof(p+5);
			tmod = p + 5; tmod += strspn(tmod, "0123456789. ");
		}
		else if ((p = strstr(msg, "alive")) != NULL) {
			/* fping, reports ".... alive (0.43 ms)" */
			seconds = atof(p+7);
			tmod = p + 7; tmod += strspn(tmod, "0123456789. ");
		}

		if (strncmp(tmod, "ms", 2) == 0) seconds = seconds / 1000.0;
		else if (strncmp(tmod, "usec", 4) == 0) seconds = seconds / 1000000.0;

		setupfn("tcp.%s.rrd", testname);
		sprintf(rrdvalues, "%d:%.6f", (int)tstamp, seconds);
		return create_and_update_rrd(hostname, rrdfn, bbnet_params, bbnet_tpl);
	}
	else {
		/*
		 * Normal network tests - pick up the "Seconds:" value
		 */
		p = strstr(msg, "\nSeconds:");
		if (p && (sscanf(p+1, "Seconds: %f", &seconds) == 1)) {
			setupfn("tcp.%s.rrd", testname);
			sprintf(rrdvalues, "%d:%.2f", (int)tstamp, seconds);
			return create_and_update_rrd(hostname, rrdfn, bbnet_params, bbnet_tpl);
		}
	}

	return 0;
}
Exemplo n.º 21
0
int do_xymongen_rrd(char *hostname, char *testname, char *classname, char *pagepaths, char *msg, time_t tstamp) 
{ 
	static char *xymon_params[] = { "DS:runtime:GAUGE:600:0:U", NULL };
	static void *xymon_tpl      = NULL;
	static char *xymon2_params[] = { "DS:hostcount:GAUGE:600:0:U", "DS:statuscount:GAUGE:600:0:U", NULL };
	static void *xymon2_tpl      = NULL;
	static char *xymon3_params[] = { "DS:redcount:GAUGE:600:0:U", "DS:rednopropcount:GAUGE:600:0:U",
					 "DS:yellowcount:GAUGE:600:0:U", "DS:yellownopropcount:GAUGE:600:0:U",
					 "DS:greencount:GAUGE:600:0:U",
					 "DS:purplecount:GAUGE:600:0:U",
					 "DS:clearcount:GAUGE:600:0:U",
					 "DS:bluecount:GAUGE:600:0:U",
					 "DS:redpct:GAUGE:600:0:100", "DS:rednoproppct:GAUGE:600:0:100",
					 "DS:yellowpct:GAUGE:600:0:100", "DS:yellownoproppct:GAUGE:600:0:100",
					 "DS:greenpct:GAUGE:600:0:100",
					 "DS:purplepct:GAUGE:600:0:100",
					 "DS:clearpct:GAUGE:600:0:100",
					 "DS:bluepct:GAUGE:600:0:100",
					NULL };
	static void *xymon3_tpl      = NULL;

	char	*p, *bol, *eoln;
	float	runtime;
	int	hostcount, statuscount;
	int	redcount, rednopropcount, yellowcount, yellownopropcount,
		greencount, purplecount, clearcount, bluecount;
	double	pctredcount, pctrednopropcount, pctyellowcount, pctyellownopropcount,
		pctgreencount, pctpurplecount, pctclearcount, pctbluecount;

	if (xymon_tpl == NULL) xymon_tpl = setup_template(xymon_params);
	if (xymon2_tpl == NULL) xymon2_tpl = setup_template(xymon2_params);
	if (xymon3_tpl == NULL) xymon3_tpl = setup_template(xymon3_params);

	runtime = 0.0;
	hostcount = statuscount = 0;
	redcount = rednopropcount = yellowcount = yellownopropcount = 0;
	greencount = purplecount = clearcount = bluecount = 0;
	pctredcount = pctrednopropcount = pctyellowcount = pctyellownopropcount = 0.0;
	pctgreencount = pctpurplecount = pctclearcount = pctbluecount = 0.0;

	bol = msg;
	do {
		int *valptr = NULL;
		double *pctvalptr = NULL;

		eoln = strchr(bol, '\n'); if (eoln) *eoln = '\0';

		p = bol + strspn(bol, " \t");
		if (strncmp(p, "TIME TOTAL", 10) == 0) sscanf(p, "TIME TOTAL %f", &runtime);
		else if (strncmp(p, "Hosts", 5) == 0) valptr = &hostcount;
		else if (strncmp(p, "Status messages", 15) == 0) valptr = &statuscount;
		else if (strncmp(p, "- Red (non-propagating)", 23) == 0) {
			valptr = &rednopropcount;
			pctvalptr = &pctrednopropcount;
		}
		else if (strncmp(p, "- Red", 5) == 0) {
			valptr = &redcount;
			pctvalptr = &pctredcount;
		}
		else if (strncmp(p, "- Yellow (non-propagating)", 26) == 0) {
			valptr = &yellownopropcount;
			pctvalptr = &pctyellownopropcount;
		}
		else if (strncmp(p, "- Yellow", 8) == 0) {
			valptr = &yellowcount;
			pctvalptr = &pctyellowcount;
		}
		else if (strncmp(p, "- Green", 7) == 0) {
			valptr = &greencount;
			pctvalptr = &pctgreencount;
		}
		else if (strncmp(p, "- Purple", 8) == 0) {
			valptr = &purplecount;
			pctvalptr = &pctpurplecount;
		}
		else if (strncmp(p, "- Clear", 7) == 0) {
			valptr = &clearcount;
			pctvalptr = &pctclearcount;
		}
		else if (strncmp(p, "- Blue", 6) == 0) {
			valptr = &bluecount;
			pctvalptr = &pctbluecount;
		}

		if (valptr) {
			p = strchr(bol, ':');
			if (p) {
				*valptr = atoi(p+1);

				if (pctvalptr) {
					p = strchr(p, '(');
					if (p) *pctvalptr = atof(p+1);
				}
			}
		}

		bol = (eoln ? eoln+1 : NULL);
	} while (bol);


	if (strcmp("xymongen", testname) != 0) {
		setupfn2("%s.%s.rrd", "xymongen", testname);
	}
	else {
		setupfn("%s.rrd", "xymongen");
	}
	snprintf(rrdvalues, sizeof(rrdvalues), "%d:%.2f", (int)tstamp, runtime);
	create_and_update_rrd(hostname, testname, classname, pagepaths, xymon_params, xymon_tpl);


	if (strcmp("xymongen", testname) != 0) {
		setupfn2("%s.%s.rrd", "xymon", testname);
	}
	else {
		setupfn("%s.rrd", "xymon");
	}
	snprintf(rrdvalues, sizeof(rrdvalues), "%d:%d:%d", (int)tstamp, hostcount, statuscount);
	create_and_update_rrd(hostname, testname, classname, pagepaths, xymon2_params, xymon2_tpl);


	if (strcmp("xymongen", testname) != 0) {
		setupfn2("%s.%s.rrd", "xymon2", testname);
	}
	else {
		setupfn("%s.rrd", "xymon2");
	}
	snprintf(rrdvalues, sizeof(rrdvalues), "%d:%d:%d:%d:%d:%d:%d:%d:%d:%5.2f:%5.2f:%5.2f:%5.2f:%5.2f:%5.2f:%5.2f:%5.2f", 
		(int)tstamp, 
		redcount, rednopropcount, yellowcount, yellownopropcount,
		greencount, purplecount, clearcount, bluecount,
		pctredcount, pctrednopropcount, pctyellowcount, pctyellownopropcount,
		pctgreencount, pctpurplecount, pctclearcount, pctbluecount);
	create_and_update_rrd(hostname, testname, classname, pagepaths, xymon3_params, xymon3_tpl);


	return 0;
}
Exemplo n.º 22
0
int do_devmon_rrd(char *hostname, char *testname, char *classname, char *pagepaths, char *msg, time_t tstamp)
{
#define MAXCOLS 20
	char *devmon_params[MAXCOLS+7];
	static void *devmon_tpl      = NULL;

	char *eoln, *curline;
	static int ptnsetup = 0;
	static pcre *inclpattern = NULL;
	static pcre *exclpattern = NULL;
	int in_devmon = 1;
	int numds = 0;

	curline = msg;
	while (curline)  {
		char *fsline, *p;
		char *columns[MAXCOLS];
		int columncount;
		char *ifname = NULL;
		int pused = -1;
		int wanteddisk = 1;
		long long aused = 0;
		char *dsval;
		int i;

		eoln = strchr(curline, '\n'); if (eoln) *eoln = '\0';

		if(!strncmp(curline, "<!--DEVMON",10)) {
			in_devmon = 0;
			goto nextline;
		}
		if(in_devmon == 0 && !strncmp(curline, "-->",3)) {
			in_devmon = 1;
			goto nextline;
		}
		if (in_devmon != 0 ) goto nextline;

		for (columncount=0; (columncount<MAXCOLS); columncount++) columns[columncount] = "";
		fsline = xstrdup(curline); columncount = 0; p = strtok(fsline, " ");
		while (p && (columncount < MAXCOLS)) { columns[columncount++] = p; p = strtok(NULL, " "); }

		/* DS:ds0:COUNTER:600:0:U DS:ds1:COUNTER:600:0:U */
		if (!strncmp(curline, "DS:",3)) {
			dbgprintf("Looking for DS defintions in %s\n",curline);
			while ( numds < MAXCOLS) {
				dbgprintf("Seeing if column %d that has %s is a DS\n",numds,columns[numds]);
				if (strncmp(columns[numds],"DS:",3)) break;
				devmon_params[numds] = xstrdup(columns[numds]);
				numds++;
			}
			dbgprintf("Found %d DS definitions\n",numds);
			devmon_params[numds] = NULL;

			devmon_tpl = setup_template(devmon_params);
			goto nextline;
		}

		dbgprintf("Found %d columns in devmon rrd data\n",columncount);
		if (columncount > 2) {
			dbgprintf("Skipping line, found %d (max 2) columns in devmon rrd data, space in repeater name?\n",columncount);
			goto nextline;
		}

		/* Now we should be on to values:
		 * eth0.0 4678222:9966777
		 */
		ifname = xstrdup(columns[0]);
		dsval = strtok(columns[1],":");
		sprintf(rrdvalues, "%d:", (int)tstamp);
		strcat(rrdvalues,dsval);
		for (i=1;i < numds;i++) {
			dsval = strtok(NULL,":");
			strcat(rrdvalues,":");
			strcat(rrdvalues,dsval);
		}
		/* File names in the format if_load.eth0.0.rrd */
		setupfn2("%s.%s.rrd", testname, ifname);
		dbgprintf("Sending from devmon to RRD for %s %s: %s\n",testname,ifname,rrdvalues);
		create_and_update_rrd(hostname, testname, classname, pagepaths, devmon_params, devmon_tpl);
		if (ifname) { xfree(ifname); ifname = NULL; }

		if (eoln) *eoln = '\n';
		xfree(fsline);

nextline:
		curline = (eoln ? (eoln+1) : NULL);
	}

	return 0;
}
Exemplo n.º 23
0
int do_iostat_rrd(char *hostname, char *testname, char *classname, char *pagepaths, char *msg, time_t tstamp)
{
	/*
	 * BEGINKEY
	 * d0 /
	 * d5 /var
	 * d6 /export
	 * ENDKEY
	 * BEGINDATA
	 *     r/s    w/s   kr/s   kw/s wait actv wsvc_t asvc_t  %w  %b s/w h/w trn tot device
	 *     0.9    2.8    7.3    1.8  0.0  0.0    2.7    9.3   1   2   0   0   0   0 d0
	 *     0.1    0.3    0.8    0.5  0.0  0.0    5.2   11.0   0   0   0   0   0   0 d5
	 *     0.1    0.2    1.0    1.1  0.0  0.0    6.9   12.9   0   0   0   0   0   0 d6
	 * ENDDATA
	 */

	typedef struct iostatkey_t { 
		char *key; 
		char *value; 
		struct iostatkey_t *next;
	} iostatkey_t;

	enum { S_NONE, S_KEYS, S_DATA } state;
	iostatkey_t *keyhead = NULL;
	iostatkey_t *newkey;
	char *eoln, *curline;
	char *buf, *p;
	float v[14];
	char marker[MAX_LINE_LEN];

	MEMDEFINE(marker);

	if (iostat_tpl == NULL) iostat_tpl = setup_template(iostat_params);

	curline = msg; state = S_NONE;
	while (curline) {
		eoln = strchr(curline, '\n'); if (eoln) *eoln = '\0';

		if (strncmp(curline, "BEGINKEY", 8) == 0) { state = S_KEYS; }
		else if (strncmp(curline, "ENDKEY", 6) == 0) { state = S_NONE; }
		else if (strncmp(curline, "BEGINDATA", 9) == 0) { state = S_DATA; }
		else if (strncmp(curline, "ENDDATA", 7) == 0) { state = S_NONE; }
		else {
			switch (state) {
			  case S_NONE:
				break;

			  case S_KEYS:
				buf = xstrdup(curline);
				newkey = (iostatkey_t *)xcalloc(1, sizeof(iostatkey_t));

				p = strtok(buf, " "); 
				if (p) newkey->key = xstrdup(p);

				p = strtok(NULL, " "); 
				if (p) {
					if (strcmp(p, "/") == 0) newkey->value = xstrdup(",root");
					else {
						newkey->value = xstrdup(p);
						p = newkey->value; while ((p = strchr(p, '/')) != NULL) *p = ',';
					}
				}
				xfree(buf);

				if (newkey->key && newkey->value) {
					newkey->next = keyhead; keyhead = newkey;
				}
				else {
					if (newkey->key) xfree(newkey->key);
					if (newkey->value) xfree(newkey->value);
					xfree(newkey);
				}
				break;

			  case S_DATA:
				buf = xstrdup(curline);
				if (sscanf(buf, "%f %f %f %f %f %f %f %f %f %f %f %f %f %f %s",
					   &v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6],
					   &v[7], &v[8], &v[9], &v[10], &v[11], &v[12], &v[13], marker) == 15) {

					/* Find the disk name */
					for (newkey = keyhead; (newkey && strcmp(newkey->key, marker)); newkey = newkey->next) ;

					if (newkey) {
						setupfn2("%s.%s.rrd", "iostat", newkey->value);
						sprintf(rrdvalues, "%d:%.1f:%.1f:%.1f:%.1f:%.1f:%.1f:%.1f:%.1f:%.1f:%.1f:%.1f:%.1f:%.1f:%.1f",
							(int) tstamp, 
							v[0], v[1], v[2], v[3], v[4], v[5], v[6],
							v[7], v[8], v[9], v[10], v[11], v[12], v[13]);
						create_and_update_rrd(hostname, testname, classname, pagepaths, iostat_params, iostat_tpl);
					}
				}
				xfree(buf);
				break;
			}
		}

		if (eoln) { *eoln = '\n'; curline = eoln + 1; }
		else { curline = NULL; }
	}

	/* Free the keylist */
	while (keyhead) {
		newkey = keyhead;
		keyhead = keyhead->next;
		if (newkey->key) xfree(newkey->key);
		if (newkey->value) xfree(newkey->value);
		xfree(newkey);
	}

	MEMUNDEFINE(marker);

	return 0;
}
Exemplo n.º 24
0
int do_iostatdisk_rrd(char *hostname, char *testname, char *classname, char *pagepaths, char *msg, time_t tstamp)
{
	char *dataline;

	/*
	 * This format is reported in the "iostatdisk" section:
	 *
	 * data HOSTNAME.iostatdisk
	 * solaris
	 * extended device statistics
	 * device,r/s,w/s,kr/s,kw/s,wait,actv,svc_t,%w,%b,
	 * dad0,a,0.0,0.7,0.0,5.8,0.0,0.0,4.3,0,0
	 * dad0,b,0.0,0.0,0.0,0.0,0.0,0.0,27.9,0,0
	 * dad0,c,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0,0
	 * dad0,e,0.0,0.6,0.0,4.1,0.0,0.0,3.7,0,0
	 * dad0,f,0.0,17.2,0.0,89.7,0.0,0.0,0.2,0,0
	 * dad0,h,0.0,0.5,0.0,2.7,0.0,0.0,2.2,0,0
	 * dad1,c,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0,0
	 * dad1,h,0.0,0.0,0.0,0.0,0.0,0.0,27.1,0,0
	 * nfs1,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0,0
	 * extended device statistics
	 * device,r/s,w/s,kr/s,kw/s,wait,actv,svc_t,%w,%b,
	 * dad0,a,0.0,0.6,0.0,5.1,0.0,0.0,4.2,0,0
	 * dad0,b,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0,0
	 * dad0,c,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0,0
	 * dad0,e,0.0,0.5,0.0,3.4,0.0,0.0,3.2,0,0
	 * dad0,f,0.0,12.6,0.0,65.6,0.0,0.0,0.2,0,0
	 * dad0,h,0.0,0.4,0.0,2.4,0.0,0.0,1.8,0,0
	 * dad1,c,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0,0
	 * dad1,h,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0,0
	 * nfs1,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0,0
	 *
	 * There are two chunks of data: Like vmstat, we first get a
	 * summary at the start of data collection, and then another
	 * with the 5-minute average. So we must skip the first chunk.
	 *
	 * Note that real disks are identified by "dad0,a" whereas
	 * NFS mounts show up as "nfs1" (no comma!).
	 */

	if (iostat_tpl == NULL) iostat_tpl = setup_template(iostat_params);

	dataline = strstr(msg, "\ndevice,r/s,w/s,kr/s,kw/s,wait,actv,svc_t,%w,%b,");
	if (!dataline) return -1;
	dataline = strstr(dataline+1, "\ndevice,r/s,w/s,kr/s,kw/s,wait,actv,svc_t,%w,%b,");
	if (!dataline) return -1;

	dataline++;
	while (dataline && *dataline) {
		char *elems[12];
		char *eoln, *p, *id;
		int i, valofs;

		eoln = strchr(dataline, '\n'); if (eoln) *eoln = '\0';

		memset(elems, 0, sizeof(elems));
		p = elems[0] = dataline; i=0;
		do {
			p = strchr(p+1, ',');
			i++;
			if (p) {
				*p = '\0';
				elems[i] = p+1;
			}
		} while (p);

		if (elems[9] == NULL) goto nextline;
		else if (elems[10] == NULL) {
			/* NFS "disk" */
			id = elems[0];
			valofs = 1;
		}
		else {
			/* Normal disk - re-instate the "," between elems[0] and elems[1] */
			*(elems[1]-1) = ','; /* Hack! */
			valofs = 2;
		}

		setupfn2("%s.%s.rrd", "iostat", id);
		sprintf(rrdvalues, "%d:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s",
			(int) tstamp, 
			elems[valofs],		/* r/s */
			elems[valofs+1],	/* w/s */
			elems[valofs+2],	/* kr/s */
			elems[valofs+3],	/* kw/s */
			elems[valofs+4],	/* wait */
			elems[valofs+5],	/* actv */
			elems[valofs+6],	/* wsvc_t - we use svc_t here */
			"U",			/* asvc_t not in this format */
			elems[valofs+7],	/* %w */
			elems[valofs+8],	/* %b */
			"U", "U", "U", "U"	/* sw, hw, trn, tot not in this format */
		       );

nextline:
		dataline = (eoln ? eoln+1 : NULL);
	}

	return 0;
}
Exemplo n.º 25
0
int do_la_rrd(char *hostname, char *testname, char *classname, char *pagepaths, char *msg, time_t tstamp)
{
	static char *la_params[]          = { "DS:la:GAUGE:600:U:U", NULL };
	static void *la_tpl               = NULL;
	static char *clock_params[]       = { "DS:la:GAUGE:600:U:U", NULL }; /* "la" is a misnomer, but to stay compatiable with existing RRD files */
	static void *clock_tpl            = NULL;

	static pcre *as400_exp = NULL;
	static pcre *zVM_exp = NULL;
	static time_t starttime = 0;

	char *p, *eoln = NULL;
	int gotusers=0, gotprocs=0, gotload=0, gotclock=0;
	int users=0, procs=0, load=0, clockdiff=0;
	time_t now = getcurrenttime(NULL);

	if (la_tpl == NULL) la_tpl = setup_template(la_params);
	if (clock_tpl == NULL) clock_tpl = setup_template(clock_params);
	if (starttime == 0) starttime = now;

	if (strstr(msg, "bb-xsnmp")) {
		/*
		 * bb-xsnmp.pl script output.
		 *
		 * green Tue Apr  5 12:57:37 2005 up: 254.58 days, CPU Usage=  9%
		 *
		 * &green  CPU Time in Busy Mode:   9%
		 * &green  CPU Time in Idle Mode:  91%
		 *
		 * &yellow CPU Usage Threshold: 90%
		 * &red CPU Usage Threshold: 95%
		 *
		 * <!-- Enterprise: netapp , Version: 6.42 -->
		 * bb-xsnmp.pl Version: 1.78
		 */

		p = strstr(msg, "CPU Usage=");
		if (p) {
			p += strlen("CPU Usage=");
			gotload = 1;
			load = atoi(p);
		}

		goto done_parsing;
	}
	else if (strstr(msg, "z/VM") || strstr(msg, "VSE/ESA") || strstr(msg, "z/VSE") || strstr(msg, "z/OS")) {
		/* z/VM cpu message. Looks like this, from Rich Smrcina (client config mode):
		 * green 5 Apr 2005 20:07:34  CPU Utilization  7% z/VM Version 4 Release 4.0, service level 0402 (32-bit) AVGPROC-007% 01
		 * VSE/ESA or z/VSE cpu message.
		 * VSE/ESA 2.7.2 cr IPLed on ...
		 * or
		 * z/VSE 3.1.1 cr IPLed on ...
		 * In server (centralized) config mode or for z/OS (which is centralized config only)
		 * the operating system name is part of the message (as in the tests above).
		 */

		int ovector[30];
		char w[100];
		int res;

		if (zVM_exp == NULL) {
			const char *errmsg = NULL;
			int errofs = 0;

			zVM_exp = pcre_compile(".* CPU Utilization *([0-9]+)%", PCRE_CASELESS, &errmsg, &errofs, NULL);
		}

		res = pcre_exec(zVM_exp, NULL, msg, strlen(msg), 0, 0, ovector, (sizeof(ovector)/sizeof(int)));
		if (res >= 0) {
			/* We have a match - pick up the data. */
			*w = '\0'; if (res > 0) pcre_copy_substring(msg, ovector, res, 1, w, sizeof(w));
			if (strlen(w)) {
				load = atoi(w); gotload = 1;
			}
		}

		goto done_parsing;
	}

	eoln = strchr(msg, '\n'); if (eoln) *eoln = '\0';
	p = strstr(msg, "up: ");
	if (!p) p = strstr(msg, "Uptime:");	/* Netapp filerstats2bb script */
	if (!p) p = strstr(msg, "uptime:");
	if (p) {
		/* First line of cpu report, contains "up: 159 days, 1 users, 169 procs, load=21" */
		p = strchr(p, ',');
		if (p) {
			gotusers = (sscanf(p, ", %d users", &users) == 1);
			p = strchr(p+1, ',');
		}

		if (p) {
			gotprocs = (sscanf(p, ", %d procs", &procs) == 1);
			p = strchr(p+1, ',');
		}

		/*
		 * Load can be either 
		 * -  "load=xx%"   (Windows)
		 * -  "load=xx.xx" (Unix, DISPREALLOADAVG=TRUE)
		 * -  "load=xx"    (Unix, DISPREALLOADAVG=FALSE)
		 *
		 * We want the load in percent (Windows), or LA*100 (Unix).
		 */
		p = strstr(msg, "load="); 
		if (p) { 
			p += 5;
			if (strchr(p, '%')) {
				gotload = 1; 
				load = atoi(p);
			}
			else if (strchr(p, '.')) {
				gotload = 1; 
				load = 100*atoi(p);
				/* Find the decimal part, and cut off at 2 decimals */
				p = strchr(p, '.'); if (strlen(p) > 3) *(p+3) = '\0';
				load += atoi(p+1);
			}
			else {
				gotload = 1; 
				load = atoi(p);
			}
		}
	}
	else {
		/* 
		 * No "uptime" in message - could be from an AS/400. They look like this:
		 * green March 21, 2005 12:33:24 PM EST deltacdc 108 users 45525 jobs(126 batch,0 waiting for message), load=26%
		 */
		int ovector[30];
		char w[100];
		int res;

		if (as400_exp == NULL) {
			const char *errmsg = NULL;
			int errofs = 0;

			as400_exp = pcre_compile(".* ([0-9]+) users ([0-9]+) jobs.* load=([0-9]+)\\%", 
						 PCRE_CASELESS, &errmsg, &errofs, NULL);
		}

		res = pcre_exec(as400_exp, NULL, msg, strlen(msg), 0, 0, ovector, (sizeof(ovector)/sizeof(int)));
		if (res >= 0) {
			/* We have a match - pick up the AS/400 data. */
			*w = '\0'; if (res > 0) pcre_copy_substring(msg, ovector, res, 1, w, sizeof(w));
			if (strlen(w)) {
				users = atoi(w); gotusers = 1;
			}

			*w = '\0'; if (res > 0) pcre_copy_substring(msg, ovector, res, 3, w, sizeof(w));
			if (strlen(w)) {
				load = atoi(w); gotload = 1;
			}
		}
	}

done_parsing:
	if (eoln) *eoln = '\n';

	p = strstr(msg, "System clock is ");
	if (p) {
		if (sscanf(p, "System clock is %d seconds off", &clockdiff) == 1) gotclock = 1;
	}

	if (!gotload) {
		/* See if it's a report from the ciscocpu.pl script. */
		p = strstr(msg, "<br>CPU 5 min average:");
		if (p) {
			/* It reports in % cpu utilization */
			p = strchr(p, ':');
			load = atoi(p+1);
			gotload = 1;
		}
	}

	if (gotload) {
		setupfn("%s.rrd", "la");
		snprintf(rrdvalues, sizeof(rrdvalues), "%d:%d", (int)tstamp, load);
		create_and_update_rrd(hostname, testname, classname, pagepaths, la_params, la_tpl);
	}

	if (gotprocs) {
		setupfn("%s.rrd", "procs");
		snprintf(rrdvalues, sizeof(rrdvalues), "%d:%d", (int)tstamp, procs);
		create_and_update_rrd(hostname, testname, classname, pagepaths, la_params, la_tpl);
	}

	if (gotusers) {
		setupfn("%s.rrd", "users");
		snprintf(rrdvalues, sizeof(rrdvalues), "%d:%d", (int)tstamp, users);
		create_and_update_rrd(hostname, testname, classname, pagepaths, la_params, la_tpl);
	}

	if (gotclock) {
		setupfn("%s.rrd", "clock");
		snprintf(rrdvalues, sizeof(rrdvalues), "%d:%d", (int)tstamp, clockdiff);
		create_and_update_rrd(hostname, testname, classname, pagepaths, clock_params, clock_tpl);
	}

	/*
	 * If we have run for less than 6 minutes, drop the memory updates here.
	 * We want to be sure not to use memory statistics from the CPU report
	 * if there is a memory add-on sending a separate memory statistics
	 */
	if ((now - starttime) < 360) return 0;

	if (!memhosts_init || (xtreeFind(memhosts, hostname) == xtreeEnd(memhosts))) {
		/* Pick up memory statistics */
		int found, overflow, realuse, swapuse;
		long long phystotal, physavail, pagetotal, pageavail;

		found = overflow = realuse = swapuse = 0;
		phystotal = physavail = pagetotal = pageavail = 0;

		p = strstr(msg, "Total Physical memory:");
		if (p) { 
			phystotal = str2ll(strchr(p, ':') + 1, NULL); 
			if (phystotal != LONG_MAX) found++; else overflow++;
		}

		if (found == 1) {
			p = strstr(msg, "Available Physical memory:");
			if (p) { 
				physavail = str2ll(strchr(p, ':') + 1, NULL); 
				if (physavail != LONG_MAX) found++; else overflow++;
			}
		}

		if (found == 2) {
			p = strstr(msg, "Total PageFile size:"); 
			if (p) { 
				pagetotal = str2ll(strchr(p, ':') + 1, NULL); 
				if (pagetotal != LONG_MAX) found++; else overflow++;
			}
		}

		if (found == 3) {
			p = strstr(msg, "Available PageFile size:"); 
			if (p) { 
				pageavail = str2ll(strchr(p, ':') + 1, NULL); 
				if (pageavail != LONG_MAX) found++; else overflow++;
			}
		}

		if (found == 4) {
			if (!phystotal || !pagetotal) { errprintf("Host %s cpu report had 0 total physical/pagefile memory listed\n", hostname); return 0; }
			phystotal = phystotal / 100;
			pagetotal = pagetotal / 100;
			realuse = 100 - (physavail / phystotal);
			swapuse = 100 - (pageavail / pagetotal);
			do_memory_rrd_update(tstamp, hostname, testname, classname, pagepaths, realuse, swapuse, -1);
		}
		else if (overflow) {
			errprintf("Host %s cpu report overflows in memory usage calculation\n", hostname);
		}
	}

	return 0;
}
Exemplo n.º 26
0
int do_mailq_rrd(char *hostname, char *testname, char *classname, char *pagepaths, char *msg, time_t tstamp)
{
	static char *mailq_params[]       = { "DS:mailq:GAUGE:600:0:U", NULL };
	static void *mailq_tpl            = NULL;

	char	*p;
	char    *inqueue, *outqueue;
	int	mailq, inq, outq;

	if (mailq_tpl == NULL) mailq_tpl = setup_template(mailq_params);

	/* 
	 * The normail "mailq" report only has a "... N requests" line and a single graph.
	 * Erik's enhanced script has both an incoming and an outgoing mail queue, with 
	 * two different RRD's. We'll try to handle both setups.
	 */

	outqueue = strstr(msg, "\nMail queue out:");
	inqueue = strstr(msg, "\nMail queue in:");
	if (inqueue && outqueue) {
		/* Dual queue message */

		/* Skip the "Mail queue X" line */
		outqueue = strchr(outqueue+1, '\n');
		inqueue = strchr(inqueue+1, '\n');
		if ((outqueue == NULL) || (inqueue == NULL)) return 0;
		outqueue++; inqueue++;

		/* Next line has "&green          Mail Queue (26 requests)". Cut string at end-of-line */
		p = strchr(outqueue, '\n'); if (p) *p = '\0';
		p = strchr(inqueue, '\n'); if (p) *p = '\0';

		/* Skip until we find a number, and get the digit. */
		p = outqueue + strcspn(outqueue, "0123456789"); outq = atoi(p);
		p = inqueue + strcspn(inqueue, "0123456789"); inq = atoi(p);

		/* Update RRD's */
		setupfn("%s.rrd", "mailqin");
		snprintf(rrdvalues, sizeof(rrdvalues), "%d:%d", (int)tstamp, inq);
		create_and_update_rrd(hostname, testname, classname, pagepaths, mailq_params, mailq_tpl);

		setupfn("%s.rrd", "mailqout");
		snprintf(rrdvalues, sizeof(rrdvalues), "%d:%d", (int)tstamp, outq);
		create_and_update_rrd(hostname, testname, classname, pagepaths, mailq_params, mailq_tpl);
		return 0;

	}
	else {
		char *valptr;

		/* Looking for "... N requests ... " */
		valptr = strstr(msg, "requests");
		if (valptr) {
			/* Go back past any whitespace before "requests" */
			do { valptr--; } while ((valptr > msg) && (*valptr != '\n') && isspace((int)*valptr));

			/* Go back to the beginning of the number */
			while ((valptr > msg) && isdigit((int) *(valptr-1))) valptr--;

			mailq = atoi(valptr);

			setupfn("%s.rrd", "mailq");
			snprintf(rrdvalues, sizeof(rrdvalues), "%d:%d", (int)tstamp, mailq);
			return create_and_update_rrd(hostname, testname, classname, pagepaths, mailq_params, mailq_tpl);
		}
	}

	return 0;
}
Exemplo n.º 27
0
int do_ifstat_rrd(char *hostname, char *testname, char *classname, char *pagepaths, char *msg, time_t tstamp)
{
	static int pcres_compiled = 0;
	static pcre **ifstat_linux_pcres = NULL;
	static pcre **ifstat_freebsd_pcres = NULL;
	static pcre **ifstat_openbsd_pcres = NULL;
	static pcre **ifstat_netbsd_pcres = NULL;
	static pcre **ifstat_darwin_pcres = NULL;
	static pcre **ifstat_solaris_pcres = NULL;
	static pcre **ifstat_aix_pcres = NULL;
	static pcre **ifstat_hpux_pcres = NULL;
	static pcre **ifstat_sco_sv_pcres = NULL;
	static pcre **ifstat_bbwin_pcres = NULL;

	enum ostype_t ostype;
	char *datapart = msg;
	char *outp;
	char *bol, *eoln, *ifname, *rxstr, *txstr, *dummy;
	int dmatch;

	if (pcres_compiled == 0) {
		pcres_compiled = 1;
		ifstat_linux_pcres = compile_exprs("LINUX", ifstat_linux_exprs, 
						 (sizeof(ifstat_linux_exprs) / sizeof(ifstat_linux_exprs[0])));
		ifstat_freebsd_pcres = compile_exprs("FREEBSD", ifstat_freebsd_exprs, 
						 (sizeof(ifstat_freebsd_exprs) / sizeof(ifstat_freebsd_exprs[0])));
		ifstat_openbsd_pcres = compile_exprs("OPENBSD", ifstat_openbsd_exprs, 
						 (sizeof(ifstat_openbsd_exprs) / sizeof(ifstat_openbsd_exprs[0])));
		ifstat_netbsd_pcres = compile_exprs("NETBSD", ifstat_netbsd_exprs, 
						 (sizeof(ifstat_netbsd_exprs) / sizeof(ifstat_netbsd_exprs[0])));
		ifstat_darwin_pcres = compile_exprs("DARWIN", ifstat_darwin_exprs, 
						 (sizeof(ifstat_darwin_exprs) / sizeof(ifstat_darwin_exprs[0])));
		ifstat_solaris_pcres = compile_exprs("SOLARIS", ifstat_solaris_exprs, 
						 (sizeof(ifstat_solaris_exprs) / sizeof(ifstat_solaris_exprs[0])));
		ifstat_aix_pcres = compile_exprs("AIX", ifstat_aix_exprs, 
						 (sizeof(ifstat_aix_exprs) / sizeof(ifstat_aix_exprs[0])));
		ifstat_hpux_pcres = compile_exprs("HPUX", ifstat_hpux_exprs, 
						 (sizeof(ifstat_hpux_exprs) / sizeof(ifstat_hpux_exprs[0])));
		ifstat_sco_sv_pcres = compile_exprs("SCO_SV", ifstat_sco_sv_exprs, 
						 (sizeof(ifstat_sco_sv_exprs) / sizeof(ifstat_sco_sv_exprs[0])));
		ifstat_bbwin_pcres = compile_exprs("BBWIN", ifstat_bbwin_exprs, 
						 (sizeof(ifstat_bbwin_exprs) / sizeof(ifstat_bbwin_exprs[0])));
	}


	if (ifstat_tpl == NULL) ifstat_tpl = setup_template(ifstat_params);

	if ((strncmp(msg, "status", 6) == 0) || (strncmp(msg, "data", 4) == 0)) {
		/* Skip the first line of full status- and data-messages. */
		datapart = strchr(msg, '\n');
		if (datapart) datapart++; else datapart = msg;
	}

	ostype = get_ostype(datapart);
	datapart = strchr(datapart, '\n');
	if (datapart) {
		datapart++; 
	}
	else {
		errprintf("Too few lines in ifstat report from %s\n", hostname);
		return -1;
	}

	/* Setup the update string */
	outp = rrdvalues + sprintf(rrdvalues, "%d", (int)tstamp);

	dmatch = 0;
	ifname = rxstr = txstr = dummy = NULL;

	bol = datapart;
	while (bol) {
		eoln = strchr(bol, '\n'); if (eoln) *eoln = '\0';

		switch (ostype) {
		  case OS_LINUX22:
		  case OS_LINUX:
		  case OS_RHEL3:
		  case OS_ZVM:
		  case OS_ZVSE:
		  case OS_ZOS:
			if (pickdata(bol, ifstat_linux_pcres[0], 1, &ifname)) {
				/*
				 * Linux' netif aliases mess up things. 
				 * Clear everything when we see an interface name.
				 * But we dont want to track the "lo" interface.
				 */
				if (strcmp(ifname, "lo") == 0) {
					xfree(ifname); ifname = NULL;
				}
				else {
					dmatch = 1;
					if (rxstr) { xfree(rxstr); rxstr = NULL; }
					if (txstr) { xfree(txstr); txstr = NULL; }
				}
			}
			else if (pickdata(bol, ifstat_linux_pcres[1], 1, &rxstr, &txstr)) dmatch |= 6;
			break;

		  case OS_FREEBSD:
			if (pickdata(bol, ifstat_freebsd_pcres[0], 0, &ifname, &rxstr, &txstr)) dmatch = 7;
			break;

		  case OS_OPENBSD:
			if (pickdata(bol, ifstat_openbsd_pcres[0], 0, &ifname, &rxstr, &txstr)) dmatch = 7;
			break;

		  case OS_NETBSD:
			if (pickdata(bol, ifstat_netbsd_pcres[0], 0, &ifname, &rxstr, &txstr)) dmatch = 7;
			break;

		  case OS_SOLARIS: 
			if (pickdata(bol, ifstat_solaris_pcres[0], 0, &ifname, &txstr)) dmatch |= 1;
			else if (pickdata(bol, ifstat_solaris_pcres[1], 0, &dummy, &rxstr)) dmatch |= 6;

			if (ifname && dummy && (strcmp(ifname, dummy) != 0)) {
				/* They must match, drop the data */
				errprintf("Host %s has weird ifstat data - device name mismatch %s:%s\n", hostname, ifname, dummy);
				xfree(ifname); xfree(txstr); xfree(rxstr); xfree(dummy);
				dmatch = 0;
			}
			break;

		  case OS_AIX: 
			if (pickdata(bol, ifstat_aix_pcres[0], 1, &ifname)) {
				/* Interface names comes first, so any rx/tx data is discarded */
				dmatch |= 1;
				if (rxstr) { xfree(rxstr); rxstr = NULL; }
				if (txstr) { xfree(txstr); txstr = NULL; }
			}
			else if (pickdata(bol, ifstat_aix_pcres[1], 1, &txstr, &rxstr)) dmatch |= 6;
			break;

		  case OS_HPUX: 
			if (pickdata(bol, ifstat_hpux_pcres[0], 1, &ifname)) {
				/* Interface names comes first, so any rx/tx data is discarded */
				dmatch |= 1;
				if (rxstr) { xfree(rxstr); rxstr = NULL; }
				if (txstr) { xfree(txstr); txstr = NULL; }
			}
			else if (pickdata(bol, ifstat_hpux_pcres[1], 1, &rxstr)) dmatch |= 2;
			else if (pickdata(bol, ifstat_hpux_pcres[2], 1, &txstr)) dmatch |= 4;
			break;

		  case OS_DARWIN:
			if (pickdata(bol, ifstat_darwin_pcres[0], 0, &ifname, &rxstr, &txstr)) dmatch = 7;
			break;
			
 		  case OS_SCO_SV:
		        if (pickdata(bol, ifstat_sco_sv_pcres[0], 0, &ifname, &rxstr, &txstr)) dmatch = 7;
			break;
			
		  case OS_WIN32_BBWIN:
			if (pickdata(bol, ifstat_bbwin_pcres[0], 0, &ifname, &rxstr, &txstr)) dmatch = 7;
			break;

		  default:
			break;
		}

		if ((dmatch == 7) && ifname && rxstr && txstr) {
			setupfn2("%s.%s.rrd", "ifstat", ifname);
			sprintf(rrdvalues, "%d:%s:%s", (int)tstamp, txstr, rxstr);
			create_and_update_rrd(hostname, testname, classname, pagepaths, ifstat_params, ifstat_tpl);
			xfree(ifname); xfree(rxstr); xfree(txstr);
			if (dummy) xfree(dummy);
			ifname = rxstr = txstr = dummy = NULL;
			dmatch = 0;
		}

		if (eoln) {
			*eoln = '\n';
			bol = eoln+1;
			if (*bol == '\0') bol = NULL;
		}
		else {
			bol = NULL;
		}
	}

	if (ifname) xfree(ifname);
	if (rxstr) xfree(rxstr);
	if (txstr) xfree(txstr);
	if (dummy) xfree(dummy);

	return 0;
}
Exemplo n.º 28
0
int do_net_rrd(char *hostname, char *testname, char *classname, char *pagepaths, char *msg, time_t tstamp)
{
	static char *xymonnet_params[]       = { "DS:sec:GAUGE:600:0:U", NULL };
	static void *xymonnet_tpl            = NULL;

	char *p;
	float seconds = 0.0;
	int do_default = 1;

	if (xymonnet_tpl == NULL) xymonnet_tpl = setup_template(xymonnet_params);

	if (strcmp(testname, "http") == 0) {
		char *line1, *url = NULL, *eoln;

		do_default = 0;

		line1 = msg;
		while ((line1 = strchr(line1, '\n')) != NULL) {
			line1++; /* Skip the newline */
			eoln = strchr(line1, '\n'); if (eoln) *eoln = '\0';

			if ( (strncmp(line1, "&green", 6) == 0) || 
			     (strncmp(line1, "&yellow", 7) == 0) ||
			     (strncmp(line1, "&red", 4) == 0) ) {
				p = strstr(line1, "http");
				if (p) {
					url = xstrdup(p);
					p = strchr(url, ' ');
					if (p) *p = '\0';
				}
			}
			else if (url && ((p = strstr(line1, "Seconds:")) != NULL) && (sscanf(p, "Seconds: %f", &seconds) == 1)) {
				char *urlfn = url;

				if (strncmp(urlfn, "http://", 7) == 0) urlfn += 7;
				p = urlfn; while ((p = strchr(p, '/')) != NULL) *p = ',';
				setupfn3("%s.%s.%s.rrd", "tcp", "http", urlfn);
				snprintf(rrdvalues, sizeof(rrdvalues), "%d:%.2f", (int)tstamp, seconds);
				create_and_update_rrd(hostname, testname, classname, pagepaths, xymonnet_params, xymonnet_tpl);
				xfree(url); url = NULL;
			}

			if (eoln) *eoln = '\n';
		}

		if (url) xfree(url);
	}
	else if (strcmp(testname, xgetenv("PINGCOLUMN")) == 0) {
		/*
		 * Ping-tests, possibly using fping.
		 */
		char *tmod = "ms";

		do_default = 0;

		if ((p = strstr(msg, "time=")) != NULL) {
			/* Standard ping, reports ".... time=0.2 ms" */
			seconds = atof(p+5);
			tmod = p + 5; tmod += strspn(tmod, "0123456789. ");
		}
		else if ((p = strstr(msg, "alive")) != NULL) {
			/* fping, reports ".... alive (0.43 ms)" */
			seconds = atof(p+7);
			tmod = p + 7; tmod += strspn(tmod, "0123456789. ");
		}

		if (strncmp(tmod, "ms", 2) == 0) seconds = seconds / 1000.0;
		else if (strncmp(tmod, "usec", 4) == 0) seconds = seconds / 1000000.0;

		setupfn2("%s.%s.rrd", "tcp", testname);
		snprintf(rrdvalues, sizeof(rrdvalues), "%d:%.6f", (int)tstamp, seconds);
		return create_and_update_rrd(hostname, testname, classname, pagepaths, xymonnet_params, xymonnet_tpl);
	}
	else if (strcmp(testname, "ntp") == 0) {
		/*
		 * sntp output: 
		 *    2009 Nov 13 11:29:10.000313 + 0.038766 +/- 0.052900 secs
		 * ntpdate output: 
		 *    server 172.16.10.2, stratum 3, offset -0.040324, delay 0.02568
		 *    13 Nov 11:29:06 ntpdate[7038]: adjust time server 172.16.10.2 offset -0.040324 sec
		 */

		char dataforntpstat[100];
		char *offsetval = NULL;
		char offsetbuf[40];
		char *msgcopy = strdup(msg);

		if (strstr(msgcopy, "ntpdate") != NULL) {
			/* Old-style "ntpdate" output */
			char *p;

			p = strstr(msgcopy, "offset ");
			if (p) {
				p += 7;
				offsetval = strtok(p, " \r\n\t");
			}
		}
		else if (strstr(msgcopy, " secs") != NULL) {
			/* Probably new "sntp" output */
			char *year, *tm, *offsetdirection, *offset, *plusminus, *errorbound, *secs;

			tm = offsetdirection = plusminus = errorbound = secs = NULL;
			year = strtok(msgcopy, " ");
			tm = year ? strtok(NULL, " ") : NULL;
			offsetdirection = tm ? strtok(NULL, " ") : NULL;
			offset = offsetdirection ? strtok(NULL, " ") : NULL;
			plusminus = offset ? strtok(NULL, " ") : NULL;
			errorbound = plusminus ? strtok(NULL, " ") : NULL;
			secs = errorbound ? strtok(NULL, " ") : NULL;

			if ( offsetdirection && ((strcmp(offsetdirection, "+") == 0) || (strcmp(offsetdirection, "-") == 0)) &&
			     plusminus && (strcmp(plusminus, "+/-") == 0) && 
			     secs && (strcmp(secs, "secs") == 0) ) {
				/* Looks sane */
				snprintf(offsetbuf, sizeof(offsetbuf), "%s%s", offsetdirection, offset);
				offsetval = offsetbuf;
			}
		}
		
		if (offsetval) {
			snprintf(dataforntpstat, sizeof(dataforntpstat), "offset=%s", offsetval);
			do_ntpstat_rrd(hostname, testname, classname, pagepaths, dataforntpstat, tstamp);
		}

		xfree(msgcopy);
	}


	if (do_default) {
		/*
		 * Normal network tests - pick up the "Seconds:" value
		 */
		p = strstr(msg, "\nSeconds:");
		if (p && (sscanf(p+1, "Seconds: %f", &seconds) == 1)) {
			setupfn2("%s.%s.rrd", "tcp", testname);
			snprintf(rrdvalues, sizeof(rrdvalues), "%d:%f", (int)tstamp, seconds);
			return create_and_update_rrd(hostname, testname, classname, pagepaths, xymonnet_params, xymonnet_tpl);
		}
	}

	return 0;
}
Exemplo n.º 29
0
int do_ifstat_rrd(char *hostname, char *testname, char *classname, char *pagepaths, char *msg, time_t tstamp)
{
	static int pcres_compiled = 0;
	static pcre **ifstat_linux_pcres = NULL;
	static pcre **ifstat_freebsd_pcres = NULL;
	static pcre **ifstat_freebsdV8_pcres = NULL;
	static pcre **ifstat_openbsd_pcres = NULL;
	static pcre **ifstat_netbsd_pcres = NULL;
	static pcre **ifstat_darwin_pcres = NULL;
	static pcre **ifstat_solaris_pcres = NULL;
	static pcre **ifstat_aix_pcres = NULL;
	static pcre **ifstat_hpux_pcres = NULL;
	static pcre **ifstat_sco_sv_pcres = NULL;
	static pcre **ifstat_bbwin_pcres = NULL;

	enum ostype_t ostype;
	char *datapart = msg;
	char *bol, *eoln, *ifname, *rxstr, *txstr, *dummy;
	int dmatch;

	void *xmh;
	pcre *ifname_filter_pcre = NULL;

	xmh = hostinfo(hostname);
	if (xmh) {
		char *ifname_filter_expr = xmh_item(xmh, XMH_INTERFACES);
		if (ifname_filter_expr && *ifname_filter_expr) 
			ifname_filter_pcre = compileregex(ifname_filter_expr);
	}

	if (pcres_compiled == 0) {
		pcres_compiled = 1;
		ifstat_linux_pcres = compile_exprs("LINUX", ifstat_linux_exprs, 
						 (sizeof(ifstat_linux_exprs) / sizeof(ifstat_linux_exprs[0])));
		ifstat_freebsd_pcres = compile_exprs("FREEBSD", ifstat_freebsd_exprs, 
						 (sizeof(ifstat_freebsd_exprs) / sizeof(ifstat_freebsd_exprs[0])));
		ifstat_freebsdV8_pcres = compile_exprs("FREEBSD", ifstat_freebsdV8_exprs, 
						 (sizeof(ifstat_freebsdV8_exprs) / sizeof(ifstat_freebsdV8_exprs[0])));
		ifstat_openbsd_pcres = compile_exprs("OPENBSD", ifstat_openbsd_exprs, 
						 (sizeof(ifstat_openbsd_exprs) / sizeof(ifstat_openbsd_exprs[0])));
		ifstat_netbsd_pcres = compile_exprs("NETBSD", ifstat_netbsd_exprs, 
						 (sizeof(ifstat_netbsd_exprs) / sizeof(ifstat_netbsd_exprs[0])));
		ifstat_darwin_pcres = compile_exprs("DARWIN", ifstat_darwin_exprs, 
						 (sizeof(ifstat_darwin_exprs) / sizeof(ifstat_darwin_exprs[0])));
		ifstat_solaris_pcres = compile_exprs("SOLARIS", ifstat_solaris_exprs, 
						 (sizeof(ifstat_solaris_exprs) / sizeof(ifstat_solaris_exprs[0])));
		ifstat_aix_pcres = compile_exprs("AIX", ifstat_aix_exprs, 
						 (sizeof(ifstat_aix_exprs) / sizeof(ifstat_aix_exprs[0])));
		ifstat_hpux_pcres = compile_exprs("HPUX", ifstat_hpux_exprs, 
						 (sizeof(ifstat_hpux_exprs) / sizeof(ifstat_hpux_exprs[0])));
		ifstat_sco_sv_pcres = compile_exprs("SCO_SV", ifstat_sco_sv_exprs, 
						 (sizeof(ifstat_sco_sv_exprs) / sizeof(ifstat_sco_sv_exprs[0])));
		ifstat_bbwin_pcres = compile_exprs("BBWIN", ifstat_bbwin_exprs, 
						 (sizeof(ifstat_bbwin_exprs) / sizeof(ifstat_bbwin_exprs[0])));
	}


	if (ifstat_tpl == NULL) ifstat_tpl = setup_template(ifstat_params);

	if ((strncmp(msg, "status", 6) == 0) || (strncmp(msg, "data", 4) == 0)) {
		/* Skip the first line of full status- and data-messages. */
		datapart = strchr(msg, '\n');
		if (datapart) datapart++; else datapart = msg;
	}

	ostype = get_ostype(datapart);
	datapart = strchr(datapart, '\n');
	if (datapart) {
		datapart++; 
	}
	else {
		errprintf("Too few lines in ifstat report from %s\n", hostname);
		return -1;
	}

	dmatch = 0;
	ifname = rxstr = txstr = dummy = NULL;

	bol = datapart;
	while (bol) {
		eoln = strchr(bol, '\n'); if (eoln) *eoln = '\0';

		switch (ostype) {
		  case OS_LINUX22:
		  case OS_LINUX:
		  case OS_RHEL3:
		  case OS_ZVM:
		  case OS_ZVSE:
		  case OS_ZOS:
			if (pickdata(bol, ifstat_linux_pcres[0], 1, &ifname)) {
				/*
				 * Linux' netif aliases mess up things. 
				 * Clear everything when we see an interface name.
				 * But we dont want to track the "lo" interface.
				 */

				/* Strip off the last character if it is a colon (:) */
				if (ifname[strlen(ifname)-1] == ':') ifname[strlen(ifname)-1] = '\0';

				if (strcmp(ifname, "lo") == 0) {
					xfree(ifname); ifname = NULL;
				}
				else {
					dmatch = 1;
					if (rxstr) { xfree(rxstr); rxstr = NULL; }
					if (txstr) { xfree(txstr); txstr = NULL; }
				}
			}
			else if (pickdata(bol, ifstat_linux_pcres[1], 1, &rxstr, &txstr)) dmatch |= 6;
			else if (pickdata(bol, ifstat_linux_pcres[2], 1, &rxstr)) dmatch |= 2;
			else if (pickdata(bol, ifstat_linux_pcres[3], 1, &txstr)) dmatch |= 4;
			break;

		  case OS_FREEBSD:
			/*
			 * FreeBSD 8 added an "Idrop" counter in the middle of the data.
			 * See if we match this expression, and if not then fall back to
			 * the old regex without that field.
			 */
			if (pickdata(bol, ifstat_freebsdV8_pcres[0], 0, &ifname, &rxstr, &txstr)) dmatch = 7;
			else if (pickdata(bol, ifstat_freebsd_pcres[0], 0, &ifname, &rxstr, &txstr)) dmatch = 7;
			break;

		  case OS_OPENBSD:
			if (pickdata(bol, ifstat_openbsd_pcres[0], 0, &ifname, &rxstr, &txstr)) dmatch = 7;
			break;

		  case OS_NETBSD:
			if (pickdata(bol, ifstat_netbsd_pcres[0], 0, &ifname, &rxstr, &txstr)) dmatch = 7;
			break;

		  case OS_SOLARIS: 
			if (pickdata(bol, ifstat_solaris_pcres[0], 0, &ifname, &txstr)) dmatch |= 1;
			else if (pickdata(bol, ifstat_solaris_pcres[1], 0, &dummy, &rxstr)) dmatch |= 6;

			if (ifname && dummy && (strcmp(ifname, dummy) != 0)) {
				/* They must match, drop the data */
				errprintf("Host %s has weird ifstat data - device name mismatch %s:%s\n", hostname, ifname, dummy);
				xfree(ifname); xfree(txstr); xfree(rxstr); xfree(dummy);
				dmatch = 0;
			}

			/* Ignore "mac" and "wrsmd" entries - these are for sub-devices for multiple nic's aggregated into one */
			/* See http://www.xymon.com/archive/2009/06/msg00204.html for more info */
			if (ifname && ((strcmp(ifname, "mac") == 0) || (strcmp(ifname, "wrsmd") == 0)) ) {
				xfree(ifname); xfree(txstr);
				dmatch = 0;
			}
			if (dummy && ((strcmp(dummy, "mac") == 0) || (strcmp(dummy, "wrsmd") == 0)) ) {
				xfree(dummy); xfree(rxstr);
				dmatch = 0;
			}
			break;

		  case OS_AIX: 
			if (pickdata(bol, ifstat_aix_pcres[0], 1, &ifname)) {
				/* Interface names comes first, so any rx/tx data is discarded */
				dmatch |= 1;
				if (rxstr) { xfree(rxstr); rxstr = NULL; }
				if (txstr) { xfree(txstr); txstr = NULL; }
			}
			else if (pickdata(bol, ifstat_aix_pcres[1], 1, &txstr, &rxstr)) dmatch |= 6;
			break;

		  case OS_HPUX: 
			if (pickdata(bol, ifstat_hpux_pcres[0], 1, &ifname)) {
				/* Interface names comes first, so any rx/tx data is discarded */
				dmatch |= 1;
				if (rxstr) { xfree(rxstr); rxstr = NULL; }
				if (txstr) { xfree(txstr); txstr = NULL; }
			}
			else if (pickdata(bol, ifstat_hpux_pcres[1], 1, &rxstr)) dmatch |= 2;
			else if (pickdata(bol, ifstat_hpux_pcres[2], 1, &txstr)) dmatch |= 4;
			break;

		  case OS_DARWIN:
			if (pickdata(bol, ifstat_darwin_pcres[0], 0, &ifname, &rxstr, &txstr)) dmatch = 7;
			break;
			
 		  case OS_SCO_SV:
		        if (pickdata(bol, ifstat_sco_sv_pcres[0], 0, &ifname, &rxstr, &txstr)) dmatch = 7;
			break;
			
		  case OS_WIN32_BBWIN:
			if (pickdata(bol, ifstat_bbwin_pcres[0], 0, &ifname, &rxstr, &txstr)) dmatch = 7;
			break;

		  default:
			break;
		}

		if ((dmatch == 7) && ifname && rxstr && txstr) {
			if (!ifname_filter_pcre || matchregex(ifname, ifname_filter_pcre)) {
				setupfn2("%s.%s.rrd", "ifstat", ifname);
				snprintf(rrdvalues, sizeof(rrdvalues), "%d:%s:%s", (int)tstamp, txstr, rxstr);
				create_and_update_rrd(hostname, testname, classname, pagepaths, ifstat_params, ifstat_tpl);
			}

			xfree(ifname); xfree(rxstr); xfree(txstr);
			if (dummy) xfree(dummy);
			ifname = rxstr = txstr = dummy = NULL;
			dmatch = 0;
		}

		if (eoln) {
			*eoln = '\n';
			bol = eoln+1;
			if (*bol == '\0') bol = NULL;
		}
		else {
			bol = NULL;
		}
	}

	if (ifname_filter_pcre) freeregex(ifname_filter_pcre);

	if (ifname) xfree(ifname);
	if (rxstr) xfree(rxstr);
	if (txstr) xfree(txstr);
	if (dummy) xfree(dummy);

	return 0;
}