darveesh
16-05-2005, 19:00
I have an item of simple check type with key tcp_perf,443 used in 2 hosts. For 1 host, all seems alright as I recevie positive values. But the other one keeps getting 0 and nothing else. The working IP is 64dot233dot167dot107 and the non-working IP is 69dot15dot122dot102. Both IPs respond to https traffic if you test via the browser.
Something I am doing wrong or is it the way the sockets are handled in CHECK_SERVICE_PERF?
I am running 1.0 and would like to see if others are able to replicate this and/or suggest a fix.
Thanks.
Try to connect manually to the hosts, telnet <ip> 443 , to see if the response is different for different IPs.
darveesh
16-05-2005, 20:26
Both IPs show a connected status in telnet, although the screen is blank for both as well.
Edit: I also went ahead and added a tcp,443 key for the hosts. I get the value 1 (which i believe means up)... one key says up and the other down... :confused:
darveesh
17-05-2005, 00:35
I should have suspected something when I realized that tcp_perf is actually an undocumented key.
It turns out that the code ignores any port information for "_perf" keys: In get_value_Simple it was blanking out the port information.
if(NULL == strstr(item->key,"_perf"))
{
if(item->useip==1)
{
snprintf(c,sizeof(c)-1,"check_service[%s,%s]",item->key,item->ip);
}
else
{
snprintf(c,sizeof(c)-1,"check_service[%s,%s]",item->key,item->host);
}
}
else
{
/* CHANGE: check_service_perf will handle any key anomalies...
strscpy(s,item->key);
t=strstr(s,"_perf");
t[0]=0;
*/
if(item->useip==1)
{
snprintf(c,sizeof(c)-1,"check_service_perf[%s,%s]",item->key,item->ip);
}
else
{
snprintf(c,sizeof(c)-1,"check_service_perf[%s,%s]",item->key,item->host);
}
}
Next, I used the string parsing code from check_service and removed any "_perf" in the incoming request key.
/* Default IP address */
strscpy(ip,"127.0.0.1");
zabbix_log(LOG_LEVEL_DEBUG, "Perf Service and IP and Port: [%s].", service_and_ip_and_port);
strscpy(tmp,service_and_ip_and_port);
s=strtok(tmp,",");
if(s)
{
strscpy(service,s);
s = strtok(NULL,",");
}
if(s)
{
if(strchr(s,'.')!=NULL)
{
strscpy(ip,s);
}
else
{
strscpy(port_str,s);
port=atoi(port_str);
}
s = strtok(NULL,",");
}
if(s)
{
if(strchr(s,'.')!=NULL)
{
strscpy(ip,s);
}
else
{
strscpy(port_str,s);
port=atoi(port_str);
}
s = strtok(NULL,",");
}
/*
c=strchr(service_and_ip_and_port,',');
strscpy(service,service_and_ip_and_port);
if(c != NULL)
{
strscpy(ip,c+1);
service[c-service_and_ip_and_port]=0;
c1=strchr(ip,',');
if(c1!=NULL)
{
strscpy(port_str,c1+1);
ip[c1-ip]=0;
port=atoi(port_str);
}
else
{
if(strchr(ip,'.')==NULL)
{
strscpy(port_str,ip);
port=atoi(port_str);
strcpy(ip,"127.0.0.1");
}
}
}
else
{
strcpy(ip,"127.0.0.1");
}
*/
/* CHANGE: remove _perf from the service name */
s=strstr(service,"_perf");
s[0]=0;
/*
printf("IP:[%s]",ip);
printf("Service:[%s]",service);
printf("Port:[%d]",port);
*/
....
And that did it... now the tcp_perf works as well. Hopefully didn't introduce any other bugs, but it you find something wrong, give me a shout..