En:Yacy-Cacti interface driver

Aus YaCyWiki
Wechseln zu: Navigation, Suche

Goal

One way of creating graphs in Cacti to monitor Yacy variables is to code a driver that will output values in a format aknowledged by Cacti.

Below are two programs to do that. The first code below parses YourPeerIp:8090/Network.xml and prints most of its values. The second one parses status_p.xml.

It is aimed to run in a schedulle defined by Cacti (typically each 5 minutes, by default; in the authors environment, each 1 minute)

It assumes a wget command is also schedulled to run each 5 minutes (or whatever is your Cacti installation execution cycle) and save the Network.xml in some local file, which will be the input to the driver.

It is written in C and compiles with GCC.

To install it, copy and save it to somename.c

Compile somename.c.

To test it, save a Network.xml file on your local environment and make sure the path to it matches the path in the fopen command in the program.

You should get a couple of lines showing Yacy counts.

Then move the binary file to the scripts folder located inside your Cacti folder.

After that, you will have to manually follow the steps to create a new Cacti report.

You can find a tutorial on how to create a Cacti graph for Yacy here http://forum.yacy-websuche.de/viewtopic.php?f=18&t=5468

Yacy_status_s_1.c

#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

int main ( )
{
FILE *in;
/*extern FILE *popen();*/
int snmp_version, snmp_port, snmp_timeout, x;
char active_count[21], active_links[21], active_words[21];
char passive_count[21], passive_links[21], passive_words[21];
char potential_count[21], potential_links[21], potential_words[21];
char peer_links[21], peer_words[21];
char peer_rurls[21], peer_acceptcrawl[21], peer_acceptindex[21], peer_sentwords[21], peer_senturls[21], peer_receivedwords[21], peer_receivedurls[21];
char peer_ppm[21], peer_seeds[21], peer_connects[21];
char peer_qph[21], peer_qph_publocal[21], peer_qph_pubremote[21];
char * pch;
char keyword_current[21];
int const max_buff=512;
char buff[512];
bool active=false;
bool passive=false;
bool potential=false;
bool your=false; 

//*
//*Enter bellow your local Network.xml path and file name
//*This will be the same produced by a crontab wget on your peer's Network.xml page
//*
if(!(in = fopen("/home/youruser/bin/Network.xml", "r")))
{  
	printf ("Error\n"); 
	return(1);
}
memset(active_count, '\0', sizeof(active_count));
memset(active_links, '\0', sizeof(active_links));
memset(active_words, '\0', sizeof(active_words));
memset(passive_count, '\0', sizeof(passive_count));
memset(passive_links, '\0', sizeof(passive_links));
memset(passive_words, '\0', sizeof(passive_words));
memset(potential_count, '\0', sizeof(potential_count));
memset(potential_links, '\0', sizeof(potential_links));
memset(potential_words, '\0', sizeof(potential_words));
memset(peer_links, '\0', sizeof(peer_links));
memset(peer_words, '\0', sizeof(peer_words));
memset(peer_rurls, '\0', sizeof(peer_rurls));
memset(peer_acceptcrawl, '\0', sizeof(peer_acceptcrawl));
memset(peer_acceptindex, '\0', sizeof(peer_acceptindex));
memset(peer_sentwords, '\0', sizeof(peer_sentwords));
memset(peer_senturls, '\0', sizeof(peer_senturls));
memset(peer_receivedwords, '\0', sizeof(peer_receivedwords));
memset(peer_receivedurls, '\0', sizeof(peer_receivedurls));
memset(peer_ppm, '\0', sizeof(peer_ppm));
memset(peer_seeds, '\0', sizeof(peer_seeds));
memset(peer_connects, '\0', sizeof(peer_connects));
memset(peer_senturls, '\0', sizeof(peer_senturls));
memset(peer_qph, '\0', sizeof(peer_qph));
memset(peer_qph_publocal, '\0', sizeof(peer_qph_publocal));
memset(peer_qph_pubremote, '\0', sizeof(peer_qph_pubremote));
while(fgets(buff, sizeof(buff), in)!=NULL)
{
	memset(keyword_current, '\0', sizeof(keyword_current));
	snprintf(keyword_current, 20, "%s", buff);
	pch=strtok(keyword_current, "<");
	pch=strtok(NULL, ">");
	snprintf(keyword_current, 20, "%s", pch);
	if (strcmp ( keyword_current, "active" ) == 0)
	{
		active = true;
	}
	else if (strcmp ( keyword_current, "passive" ) == 0)
	{
		passive = true;
	}
	else if (strcmp ( keyword_current, "potential" ) == 0)
	{
		potential = true;
	}
	else if (strcmp ( keyword_current, "your" ) == 0)
	{
		your = true;
	}
	else if (strcmp ( keyword_current, "count" ) == 0)
	{
		if (active)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(active_count, 20, "%s", pch);
			}
		}
		else if (passive)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(passive_count, 20, "%s", pch);
			}
		}
		else if (potential)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(potential_count, 20, "%s", pch);
			}
		}
	}
	else if (strcmp ( keyword_current, "links" ) == 0)
	{
		if (active)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(active_links, 20, "%s", pch);
			}
		}
		else if (passive)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(passive_links, 20, "%s", pch);
			}
		}
		else if (potential)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(potential_links, 20, "%s", pch);
			}
		}
		else if (your)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(peer_links, 20, "%s", pch);
			}
		}
	}
	else if (strcmp ( keyword_current, "words" ) == 0)
	{
		if (active)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(active_words, 20, "%s", pch);
				active=false;
			}
		}
		else if (passive)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(passive_words, 20, "%s", pch);
				passive=false;
			}
		}
		else if (potential)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(potential_words, 20, "%s", pch);
				potential=false;
			}
		}
		else if (your)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(peer_words, 20, "%s", pch);
			}
		}
	}
	else if (strcmp ( keyword_current, "rurls" ) == 0)
	{
		pch=strchr(buff,'>');
		if (pch != NULL)
		{
			buff[pch-buff]='@';
			pch=strrchr(buff, '<');
			buff[pch-buff]='@';
			pch=strtok(buff, " @");
			pch=strtok(NULL, " @");
			snprintf(peer_rurls, 20, "%s", pch);
		}
	}
	else if (strcmp ( keyword_current, "acceptcrawl" ) == 0)
	{
		pch=strchr(buff,'>');
		if (pch != NULL)
		{
			buff[pch-buff]='@';
			pch=strrchr(buff, '<');
			buff[pch-buff]='@';
			pch=strtok(buff, " @");
			pch=strtok(NULL, " @");
			snprintf(peer_acceptcrawl, 20, "%s", pch);
		}
	}
	else if (strcmp ( keyword_current, "acceptindex" ) == 0)
	{
		pch=strchr(buff,'>');
		if (pch != NULL)
		{
			buff[pch-buff]='@';
			pch=strrchr(buff, '<');
			buff[pch-buff]='@';
			pch=strtok(buff, " @");
			pch=strtok(NULL, " @");
			snprintf(peer_acceptindex, 20, "%s", pch);
		}
	}
	else if (strcmp ( keyword_current, "sentwords" ) == 0)
	{
		pch=strchr(buff,'>');
		if (pch != NULL)
		{
			buff[pch-buff]='@';
			pch=strrchr(buff, '<');
			buff[pch-buff]='@';
			pch=strtok(buff, " @");
			pch=strtok(NULL, " @");
			snprintf(peer_sentwords, 20, "%s", pch);
		}
	}
	else if (strcmp ( keyword_current, "senturls" ) == 0)
	{
		pch=strchr(buff,'>');
		if (pch != NULL)
		{
			buff[pch-buff]='@';
			pch=strrchr(buff, '<');
			buff[pch-buff]='@';
			pch=strtok(buff, " @");
			pch=strtok(NULL, " @");
			snprintf(peer_senturls, 20, "%s", pch);
		}
	}
	else if (strcmp ( keyword_current, "receivedwords" ) == 0)
	{
		pch=strchr(buff,'>');
		if (pch != NULL)
		{
			buff[pch-buff]='@';
			pch=strrchr(buff, '<');
			buff[pch-buff]='@';
			pch=strtok(buff, " @");
			pch=strtok(NULL, " @");
			snprintf(peer_receivedwords, 20, "%s", pch);
		}
	}
	else if (strcmp ( keyword_current, "receivedurls" ) == 0)
	{
		pch=strchr(buff,'>');
		if (pch != NULL)
		{
			buff[pch-buff]='@';
			pch=strrchr(buff, '<');
			buff[pch-buff]='@';
			pch=strtok(buff, " @");
			pch=strtok(NULL, " @");
			snprintf(peer_receivedurls, 20, "%s", pch);
		}
	}
	else if (strcmp ( keyword_current, "ppm" ) == 0)
	{
		if (your)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(peer_ppm, 20, "%s", pch);
			}
		}
	}
	else if (strcmp ( keyword_current, "qph" ) == 0)
	{
		if (your)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(peer_qph, 20, "%s", pch);
				your=false;
			}
		}
	}
	else if (strcmp ( keyword_current, "qph-publocal" ) == 0)
	{
		pch=strchr(buff,'>');
		if (pch != NULL)
		{
			buff[pch-buff]='@';
			pch=strrchr(buff, '<');
			buff[pch-buff]='@';
			pch=strtok(buff, " @");
			pch=strtok(NULL, " @");
			snprintf(peer_qph_publocal, 20, "%s", pch);
		}
	}
	else if (strcmp ( keyword_current, "qph-pubremote" ) == 0)
	{
		pch=strchr(buff,'>');
		if (pch != NULL)
		{
			buff[pch-buff]='@';
			pch=strrchr(buff, '<');
			buff[pch-buff]='@';
			pch=strtok(buff, " @");
			pch=strtok(NULL, " @");
			snprintf(peer_qph_pubremote, 20, "%s", pch);
		}
	}
	else if (strcmp ( keyword_current, "seeds" ) == 0)
	{
		pch=strchr(buff,'>');
		if (pch != NULL)
		{
			buff[pch-buff]='@';
			pch=strrchr(buff, '<');
			buff[pch-buff]='@';
			pch=strtok(buff, " @");
			pch=strtok(NULL, " @");
			snprintf(peer_seeds, 20, "%s", pch);
		}
	}
	else if (strcmp ( keyword_current, "connects" ) == 0)
	{
		pch=strchr(buff,'>');
		if (pch != NULL)
		{
			buff[pch-buff]='@';
			pch=strrchr(buff, '<');
			buff[pch-buff]='@';
			pch=strtok(buff, " @");
			pch=strtok(NULL, " @");
			snprintf(peer_connects, 20, "%s", pch);
		}
	}
} 
memset(buff, '\0', sizeof(buff));
snprintf (buff, sizeof(buff), "logger yacy_status - active_count:%s active_links:%s active_words:%s passive_count:%s passive_links:%s passive_words:%s  potential_count:%s potential_links:%s potential_words:%s peer_acceptcrawl:%s peer_acceptindex:%s peer_sentwords:%s peer_senturls:%s peer_receivedwords:%s peer_receivedurls:%s peer_ppm:%s peer_seeds:%s peer_connects:%s peer_qph:%s peer_qph_publocal:%s peer_qph_pubremote:%s\n", active_count, active_links, active_words, passive_count, passive_links, passive_words, potential_count, potential_links, potential_words, peer_acceptcrawl, peer_acceptindex, peer_sentwords, peer_senturls, peer_receivedwords, peer_receivedurls, peer_ppm, peer_seeds, peer_connects, peer_qph, peer_qph_publocal, peer_qph_pubremote);
/*printf ("Log = %s", buff);*/
if(!(in = popen(buff, "r")))
{
	printf ("Error\n");
	return(1);
} 

printf ("active_count:%s active_links:%s active_words:%s passive_count:%s passive_links:%s passive_words:%s potential_count:%s potential_links:%s potential_words:%s peer_acceptcrawl:%s peer_acceptindex:%s peer_sentwords:%s peer_senturls:%s peer_receivedwords:%s peer_receivedurls:%s peer_ppm:%s peer_seeds:%s peer_connects:%s peer_qph:%s peer_qph_publocal:%s peer_qph_pubremote:%s\n", active_count, active_links, active_words, passive_count, passive_links, passive_words, potential_count, potential_links, potential_words, peer_acceptcrawl, peer_acceptindex, peer_sentwords, peer_senturls, peer_receivedwords, peer_receivedurls, peer_ppm, peer_seeds, peer_connects, peer_qph, peer_qph_publocal, peer_qph_pubremote);
pclose(in);
return 0;
}

The second program:

Yacy_status_s_2.c

/* Teste:
# Validando resultado de:
# 
*/
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

int main ( )
{
FILE *in;
/*extern FILE *popen();*/
int snmp_version, snmp_port, snmp_timeout, x;
char memory_used[21], memory_free[21], memory_total[21], memory_max[21];
char ppm[21], wordCacheSize[21], wordCacheMaxSize[21];
char disk_used[21], disk_free[21], processors[21];
char load[21], traffic_in[21], traffic_proxy[21];
char traffic_crawler[21], dbsize_urlpublictext[21];
char dbsize_urlpublictextSegmentCount[21], dbsize_webgraph[21], dbsize_webgraphSegmentCount[21], dbsize_citation[21], dbsize_citationSegmentCount[21],   dbsize_rwipublictext[21], dbsize_rwipublictextSegmentCount[21];
char loaderqueue_size[21], loaderqueue_max[21], localcrawlerqueue_size[21];
char localcrawlerqueue_state[21], limitcrawlerqueue_size[21], limitcrawlerqueue_state[21];
char remotecrawlerqueue_size[21], remotecrawlerqueue_state[21], noloadcrawlerqueue_size[21];
char noloadcrawlerqueue_state[21], crawls_count[21], post_collectionRemainingCount[21];
char post_webgraphRemainingCount[21], post_status[21], post_speed[21];
char post_elapsedTime[21], post_remainingTime[21], post_remainingTimeMinutes[21];
char post_remainingTimeSeconds[21];
char * pch;
char keyword_current[41];
int const max_buff=512;
char buff[512];
bool memory=false;
bool disk=false;
bool traffic=false;
bool dbsize=false;
bool loaderqueue=false;
bool localcrawlerqueue=false;
bool limitcrawlerqueue=false;
bool remotecrawlerqueue=false;
bool noloadcrawlerqueue=false;
bool crawls=false;
bool postprocessing=false;

//*
//*Call cpufreq-info and parse its output
//*
/*printf ("Executing cpufreq-info...\n");*/
if(!(in = fopen("/home/gustavo/bin/status_p.xml", "r")))
{ 
	printf ("Error\n");
	return(1);
}
memset(memory_used, '\0', sizeof(memory_used));
memset(memory_free, '\0', sizeof(memory_free));
memset(memory_total, '\0', sizeof(memory_total));
memset(memory_max, '\0', sizeof(memory_max));
memset(ppm, '\0', sizeof(ppm));
memset(wordCacheSize, '\0', sizeof(wordCacheSize));
memset(wordCacheMaxSize, '\0', sizeof(wordCacheMaxSize));
memset(disk_used, '\0', sizeof(disk_used));
memset(disk_free, '\0', sizeof(disk_free));
memset(processors, '\0', sizeof(processors));
memset(load, '\0', sizeof(load));
memset(traffic_in, '\0', sizeof(traffic_in));
memset(traffic_proxy, '\0', sizeof(traffic_proxy));
memset(traffic_crawler, '\0', sizeof(traffic_crawler));
memset(dbsize_urlpublictext, '\0', sizeof(dbsize_urlpublictext));
memset(dbsize_urlpublictextSegmentCount, '\0', sizeof(dbsize_urlpublictextSegmentCount));
memset(dbsize_webgraph, '\0', sizeof(dbsize_webgraph));
memset(dbsize_webgraphSegmentCount, '\0', sizeof(dbsize_webgraphSegmentCount));
memset(dbsize_citation, '\0', sizeof(dbsize_citation));
memset(dbsize_citationSegmentCount, '\0', sizeof(dbsize_citationSegmentCount));
memset(dbsize_rwipublictext, '\0', sizeof(dbsize_rwipublictext));
memset(dbsize_rwipublictextSegmentCount, '\0', sizeof(dbsize_rwipublictextSegmentCount));
memset(loaderqueue_size, '\0', sizeof(loaderqueue_size));
memset(loaderqueue_max, '\0', sizeof(loaderqueue_max));
memset(localcrawlerqueue_size, '\0', sizeof(localcrawlerqueue_size));
memset(localcrawlerqueue_state, '\0', sizeof(localcrawlerqueue_state));
memset(limitcrawlerqueue_size, '\0', sizeof(limitcrawlerqueue_size));
memset(limitcrawlerqueue_state, '\0', sizeof(limitcrawlerqueue_state));
memset(remotecrawlerqueue_size, '\0', sizeof(remotecrawlerqueue_size));
memset(remotecrawlerqueue_state, '\0', sizeof(remotecrawlerqueue_state));
memset(noloadcrawlerqueue_size, '\0', sizeof(noloadcrawlerqueue_size));
memset(noloadcrawlerqueue_state, '\0', sizeof(noloadcrawlerqueue_state));
memset(crawls_count, '\0', sizeof(crawls_count));
memset(post_collectionRemainingCount, '\0', sizeof(post_collectionRemainingCount));
memset(post_webgraphRemainingCount, '\0', sizeof(post_webgraphRemainingCount));
memset(post_status, '\0', sizeof(post_status));
memset(post_speed, '\0', sizeof(post_speed));
memset(post_elapsedTime, '\0', sizeof(post_elapsedTime));
memset(post_remainingTime, '\0', sizeof(post_remainingTime));
memset(post_remainingTimeMinutes, '\0', sizeof(post_remainingTimeMinutes));
memset(post_remainingTimeSeconds, '\0', sizeof(post_remainingTimeSeconds));
while(fgets(buff, sizeof(buff), in)!=NULL)
{ 
	memset(keyword_current, '\0', sizeof(keyword_current));
	snprintf(keyword_current, 40, "%s", buff);
	pch=strtok(keyword_current, "<");
	pch=strtok(NULL, ">");
	snprintf(keyword_current, 40, "%s", pch);
	if (strcmp ( keyword_current, "memory" ) == 0)
	{
		memory = true;
	}
	else if (strcmp ( keyword_current, "/memory" ) == 0)
	{
		memory = false;
	}
	else if (strcmp ( keyword_current, "disk" ) == 0)
	{
		disk = true;
	}
	else if (strcmp ( keyword_current, "/disk" ) == 0)
	{
		disk = false;
	}
	else if (strcmp ( keyword_current, "traffic" ) == 0)
	{
		traffic = true;
	}
	else if (strcmp ( keyword_current, "/traffic" ) == 0)
	{
		traffic = false;
	}
	else if (strcmp ( keyword_current, "dbsize" ) == 0)
	{
		dbsize = true;
	}
	else if (strcmp ( keyword_current, "/dbsize" ) == 0)
	{
		dbsize = false;
	}
	else if (strcmp ( keyword_current, "loaderqueue" ) == 0)
	{
		loaderqueue = true;
	}
	else if (strcmp ( keyword_current, "/loaderqueue" ) == 0)
	{
		loaderqueue = false;
	}
	else if (strcmp ( keyword_current, "localcrawlerqueue" ) == 0)
	{
		localcrawlerqueue = true;
	}
       else if (strcmp ( keyword_current, "/localcrawlerqueue" ) == 0)
	{
		localcrawlerqueue = false;
	}
	else if (strcmp ( keyword_current, "limitcrawlerqueue" ) == 0)
	{
		limitcrawlerqueue = true;
	}
	else if (strcmp ( keyword_current, "/limitcrawlerqueue" ) == 0)
	{
		limitcrawlerqueue = false;
	}
	else if (strcmp ( keyword_current, "remotecrawlerqueue" ) == 0)
	{
		remotecrawlerqueue = true;
	}
	else if (strcmp ( keyword_current, "/remotecrawlerqueue" ) == 0)
	{
		remotecrawlerqueue = false;
	}
	else if (strcmp ( keyword_current, "noloadcrawlerqueue" ) == 0)
	{
		noloadcrawlerqueue = true;
	}
	else if (strcmp ( keyword_current, "/noloadcrawlerqueue" ) == 0)
	{
		noloadcrawlerqueue = false;
	}
	else if (strcmp ( keyword_current, "crawl" ) == 0)
	{
		crawls = true;
	}
	else if (strcmp ( keyword_current, "/crawl" ) == 0)
	{
		crawls = false;
	}
	else if (strcmp ( keyword_current, "postprocessing" ) == 0)
	{
		postprocessing = true;
	}
	else if (strcmp ( keyword_current, "/postprocessing" ) == 0)
	{
		postprocessing = false; 
       }
//*
//* Beggining to get the values
//*
	else if (strcmp ( keyword_current, "ppm" ) == 0)
	{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(ppm, 20, "%s", pch);
			}
	}
	else if (strcmp ( keyword_current, "wordCacheSize" ) == 0)
	{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(wordCacheSize, 20, "%s", pch);
			}
	}
	else if (strcmp ( keyword_current, "wordCacheMaxSize" ) == 0)
	{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(wordCacheMaxSize, 20, "%s", pch);
			}
	}
	else if (strcmp ( keyword_current, "used" ) == 0)
	{
		if (memory)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(memory_used, 20, "%s", pch);
			}
		}
		else if (disk)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(disk_used, 20, "%s", pch);
			}
		}
	}
	else if (strcmp ( keyword_current, "free" ) == 0)
	{
		if (memory)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(memory_free, 20, "%s", pch);
			}
		}
		else if (disk)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(disk_free, 20, "%s", pch);
			}
		}
	}
	else if (strcmp ( keyword_current, "total" ) == 0)
	{
		if (memory)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(memory_total, 20, "%s", pch);
			}
		}
	}
	else if (strcmp ( keyword_current, "max" ) == 0)
	{
		if (memory)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(memory_max, 20, "%s", pch);
			}
		}
		else if (loaderqueue)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(loaderqueue_max, 20, "%s", pch);
			}
		}
	}
	else if (strcmp ( keyword_current, "processors" ) == 0)
	{
		pch=strchr(buff,'>');
		if (pch != NULL)
		{
			buff[pch-buff]='@';
			pch=strrchr(buff, '<');
			buff[pch-buff]='@';
			pch=strtok(buff, " @");
			pch=strtok(NULL, " @");
			snprintf(processors, 20, "%s", pch);
		}
	}
	else if (strcmp ( keyword_current, "load" ) == 0)
	{
		pch=strchr(buff,'>');
		if (pch != NULL)
		{
			buff[pch-buff]='@';
			pch=strrchr(buff, '<');
			buff[pch-buff]='@';
			pch=strtok(buff, " @");
			pch=strtok(NULL, " @");
			snprintf(load, 20, "%s", pch);
		}
	}
	else if (strcmp ( keyword_current, "in" ) == 0)
	{
		if (traffic)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(traffic_in, 20, "%s", pch);
			}
		}
	}
	else if (strcmp ( keyword_current, "proxy" ) == 0)
	{
		if (traffic)
		{
 			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(traffic_proxy, 20, "%s", pch);
			}
		}
	}
	else if (strcmp ( keyword_current, "crawler" ) == 0)
	{
		if (traffic)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(traffic_crawler, 20, "%s", pch);
			}
		}
	}
	else if (strcmp ( keyword_current, "urlpublictext" ) == 0)
	{
		if (dbsize)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(dbsize_urlpublictext, 20, "%s", pch);
			}
		}
	}
	else if (strcmp ( keyword_current, "urlpublictextSegmentCount" ) == 0)
	{
		if (dbsize)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(dbsize_urlpublictextSegmentCount, 20, "%s", pch);
			}
		}
	}
	else if (strcmp ( keyword_current, "webgraph" ) == 0)
	{
		if (dbsize)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(dbsize_webgraph, 20, "%s", pch);
			}
		}
	}
	else if (strcmp ( keyword_current, "webgraphSegmentCount" ) == 0)
	{
		if (dbsize)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(dbsize_webgraphSegmentCount, 20, "%s", pch);
			}
		}
	}
	else if (strcmp ( keyword_current, "citation" ) == 0)
	{
		if (dbsize)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(dbsize_citation, 20, "%s", pch);
			}
		}
	}
	else if (strcmp ( keyword_current, "citationSegmentCount" ) == 0)
	{
		if (dbsize)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(dbsize_citationSegmentCount, 20, "%s", pch);
			}
		}
	}
	else if (strcmp ( keyword_current, "rwipublictext" ) == 0)
	{
		if (dbsize)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(dbsize_rwipublictext, 20, "%s", pch);
			}
		}
	}
	else if (strcmp ( keyword_current, "rwipublictextSegmentCount" ) == 0)
	{
		if (dbsize)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(dbsize_rwipublictextSegmentCount, 20, "%s", pch);
			}
		}
	}
	else if (strcmp ( keyword_current, "rwipublictextSegmentCount" ) == 0)
	{
		if (dbsize)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(dbsize_rwipublictextSegmentCount, 20, "%s", pch);
			}
		}
	}
	else if (strcmp ( keyword_current, "size" ) == 0)
	{
		if (loaderqueue)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(loaderqueue_size, 20, "%s", pch);
			}
		}
		else if (localcrawlerqueue)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(localcrawlerqueue_size, 20, "%s", pch);
			}
		}
		else if (limitcrawlerqueue)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(limitcrawlerqueue_size, 20, "%s", pch);
			}
		}
		else if (remotecrawlerqueue)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(remotecrawlerqueue_size, 20, "%s", pch);
			}
		}
		else if (noloadcrawlerqueue)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(noloadcrawlerqueue_size, 20, "%s", pch);
			}
		}
	}
	else if (strcmp ( keyword_current, "state" ) == 0)
	{
		if (localcrawlerqueue)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(localcrawlerqueue_state, 20, "%s", pch);
			}
		}
		else if (limitcrawlerqueue)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(limitcrawlerqueue_state, 20, "%s", pch);
			}
		}
		else if (remotecrawlerqueue)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(remotecrawlerqueue_state, 20, "%s", pch);
			}
		}
		else if (noloadcrawlerqueue)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(noloadcrawlerqueue_state, 20, "%s", pch);
			}
		}
	}
	else if (strcmp ( keyword_current, "count" ) == 0)
	{
		if (crawls)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(crawls_count, 20, "%s", pch);
			}
		}
	}
	else if (strcmp ( keyword_current, "collectionRemainingCount" ) == 0)
	{
		if (postprocessing)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(post_collectionRemainingCount, 20, "%s", pch);
			}
		}
	}
	else if (strcmp ( keyword_current, "webgraphRemainingCount" ) == 0)
	{
		if (postprocessing)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(post_webgraphRemainingCount, 20, "%s", pch);
			}
		}
	}
	else if (strcmp ( keyword_current, "status" ) == 0)
	{
		if (postprocessing)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(post_status, 20, "%s", pch);
			}
		}
	}
	else if (strcmp ( keyword_current, "speed" ) == 0)
	{
		if (postprocessing)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(post_speed, 20, "%s", pch);
			}
		}
	}
	else if (strcmp ( keyword_current, "elapsedTime" ) == 0)
	{
		if (postprocessing)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(post_elapsedTime, 20, "%s", pch);
			}
		}
	}
	else if (strcmp ( keyword_current, "remainingTime" ) == 0)
	{
		if (postprocessing)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(post_remainingTime, 20, "%s", pch);
			}
		}
	}
	else if (strcmp ( keyword_current, "remainingTimeMinutes" ) == 0)
	{
		if (postprocessing)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
 				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
                               snprintf(post_remainingTimeMinutes, 20, "%s", pch);
			}
		}
	}
	else if (strcmp ( keyword_current, "remainingTimeSeconds" ) == 0)
	{
		if (postprocessing)
		{
			pch=strchr(buff,'>');
			if (pch != NULL)
			{
				buff[pch-buff]='@';
				pch=strrchr(buff, '<');
				buff[pch-buff]='@';
				pch=strtok(buff, " @");
				pch=strtok(NULL, " @");
				snprintf(post_remainingTimeSeconds, 20, "%s", pch);
			}
		}
	}
}
memset(buff, '\0', sizeof(buff));
snprintf (buff, sizeof(buff), "logger yacy_status - memory_used:%s memory_free:%s memory_total:%s memory_max:%s ppm:%s wordCacheSize:%s wordCacheMaxSize:%s disk_used:%s disk_free:%s processors:%s load:%s traffic_in:%s traffic_proxy:%s traffic_crawler:%s dbsize_urlpublictext:%s dbsize_urlpublictextSegmentCount:%s dbsize_webgraph:%s dbsize_webgraphSegmentCount:%s dbsize_citation:%s dbsize_citationSegmentCount:%s dbsize_rwipublictext:%s dbsize_rwipublictextSegmentCount:%s loaderqueue_size:%s loaderqueue_max:%s localcrawlerqueue_size:%s localcrawlerqueue_state:%s limitcrawlerqueue_size:%s limitcrawlerqueue_state:%s remotecrawlerqueue_size:%s remotecrawlerqueue_state:%s noloadcrawlerqueue_size:%s noloadcrawlerqueue_state:%s crawls_count:%s post_collectionRemainingCount:%s post_webgraphRemainingCount:%s post_status:%s post_speed:%s post_elapsedTime:%s post_remainingTime:%s post_remainingTimeMinutes:%s post_remainingTimeSeconds:%s\n", memory_used, memory_free, memory_total, memory_max, ppm, wordCacheSize, wordCacheMaxSize, disk_used, disk_free, processors, load, traffic_in, traffic_proxy, traffic_crawler, dbsize_urlpublictext, dbsize_urlpublictextSegmentCount, dbsize_webgraph, dbsize_webgraphSegmentCount, dbsize_citation, dbsize_citationSegmentCount, dbsize_rwipublictext, dbsize_rwipublictextSegmentCount, loaderqueue_size, loaderqueue_max, localcrawlerqueue_size, localcrawlerqueue_state, limitcrawlerqueue_size, limitcrawlerqueue_state, remotecrawlerqueue_size, remotecrawlerqueue_state, noloadcrawlerqueue_size, noloadcrawlerqueue_state, crawls_count, post_collectionRemainingCount, post_webgraphRemainingCount, post_status, post_speed, post_elapsedTime, post_remainingTime,  post_remainingTimeMinutes, post_remainingTimeSeconds);
/*printf ("Log = %s", buff);*/
if(!(in = popen(buff, "r")))
{
	printf ("Error\n");
	return(1);
}

printf ("memory_used:%s memory_free:%s memory_total:%s memory_max:%s ppm:%s wordCacheSize:%s wordCacheMaxSize:%s disk_used:%s disk_free:%s processors:%s load:%s  traffic_in:%s traffic_proxy:%s traffic_crawler:%s dbsize_urlpublictext:%s dbsize_urlpublictextSegmentCount:%s dbsize_webgraph:%s dbsize_webgraphSegmentCount:%s dbsize_citation:%s dbsize_citationSegmentCount:%s dbsize_rwipublictext:%s dbsize_rwipublictextSegmentCount:%s loaderqueue_size:%s loaderqueue_max:%s localcrawlerqueue_size:%s localcrawlerqueue_state:%s limitcrawlerqueue_size:%s limitcrawlerqueue_state:%s remotecrawlerqueue_size:%s remotecrawlerqueue_state:%s noloadcrawlerqueue_size:%s noloadcrawlerqueue_state:%s crawls_count:%s post_collectionRemainingCount:%s post_webgraphRemainingCount:%s post_status:%s post_speed:%s post_elapsedTime:%s post_remainingTime:%s post_remainingTimeMinutes:%s post_remainingTimeSeconds:%s\n", memory_used, memory_free, memory_total, memory_max, ppm, wordCacheSize, wordCacheMaxSize, disk_used, disk_free, processors, load, traffic_in, traffic_proxy, traffic_crawler, dbsize_urlpublictext, dbsize_urlpublictextSegmentCount, dbsize_webgraph, dbsize_webgraphSegmentCount, dbsize_citation, dbsize_citationSegmentCount, dbsize_rwipublictext, dbsize_rwipublictextSegmentCount, loaderqueue_size, loaderqueue_max, localcrawlerqueue_size, localcrawlerqueue_state, limitcrawlerqueue_size, limitcrawlerqueue_state, remotecrawlerqueue_size, remotecrawlerqueue_state, noloadcrawlerqueue_size, noloadcrawlerqueue_state, crawls_count,  post_collectionRemainingCount, post_webgraphRemainingCount, post_status, post_speed, post_elapsedTime, post_remainingTime, post_remainingTimeMinutes,  post_remainingTimeSeconds);
pclose(in);
return 0;
}