summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-05-08 10:11:27 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-05-08 10:11:27 +0000
commit3617b3e8eb03c91a0b91c9ac7bc561b4e54495e8 (patch)
treedda9d0f577331e7ab67557c3a10d44c94a917253 /src
parentb0b461e16794a94a61a05ed0fd84ddee77af4682 (diff)
- fixed coniguration scripts for mysql/net-snmp/curl (Eugene)
- fixed SMS sender (Eugene) - timeout for sending emails and SMS was increased to 40 seconds (Eugene) git-svn-id: svn://svn.zabbix.com/trunk@4096 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src')
-rw-r--r--src/libs/zbxcommon/zbxgetopt.c2
-rw-r--r--src/libs/zbxdbhigh/host.c2
-rw-r--r--src/libs/zbxlog/log.c1
-rw-r--r--src/libs/zbxsms/sms.c35
-rw-r--r--src/zabbix_server/alerter/alerter.c4
-rw-r--r--src/zabbix_server/server.c24
6 files changed, 48 insertions, 20 deletions
diff --git a/src/libs/zbxcommon/zbxgetopt.c b/src/libs/zbxcommon/zbxgetopt.c
index 0f70660e..d23a6df7 100644
--- a/src/libs/zbxcommon/zbxgetopt.c
+++ b/src/libs/zbxcommon/zbxgetopt.c
@@ -603,7 +603,7 @@ int zbx_getopt_long(int argc, char **argv, const char *options,
}
-#ifdef TEST
+#ifdef TEST2
/* Compile with -DTEST to make an executable for use in testing
the above definition of `getopt'. */
diff --git a/src/libs/zbxdbhigh/host.c b/src/libs/zbxdbhigh/host.c
index 81068de2..1b1408ed 100644
--- a/src/libs/zbxdbhigh/host.c
+++ b/src/libs/zbxdbhigh/host.c
@@ -2052,7 +2052,7 @@ static int DBupdate_trigger(
{
ZBX_STR2UINT64(chd_hostid, chd_host_data[0]);
- replace = zbx_dsprintf(replace, "{%s:", db_chd_hosts[0] /* child host */);
+ replace = zbx_dsprintf(replace, "{%s:", chd_host_data[0] /* child host */);
new_expression = string_replace(expression, search, replace);
diff --git a/src/libs/zbxlog/log.c b/src/libs/zbxlog/log.c
index 97656f96..3027dca9 100644
--- a/src/libs/zbxlog/log.c
+++ b/src/libs/zbxlog/log.c
@@ -191,6 +191,7 @@ void zabbix_log(int level, const char *fmt, ...)
va_end(ap);
printf("\n");
+ return;
#else /* TEST */
FILE *log_file = NULL;
diff --git a/src/libs/zbxsms/sms.c b/src/libs/zbxsms/sms.c
index c09966e3..1ab7a32b 100644
--- a/src/libs/zbxsms/sms.c
+++ b/src/libs/zbxsms/sms.c
@@ -48,7 +48,6 @@ static int write_gsm(int fd, char *str, char *error, int max_error_len)
if (write(fd, str, len) < len)
{
zabbix_log(LOG_LEVEL_DEBUG, "Error writing to GSM modem [%s]", strerror(errno));
- zabbix_syslog("Error writing to GSM modem [%s]", strerror(errno));
zbx_snprintf(error,max_error_len, "Error writing to GSM modem [%s]", strerror(errno));
return FAIL;
}
@@ -74,6 +73,13 @@ static int read_gsm(int fd, const char *expect, char *error, int max_error_len)
}
/* nul terminate the string and see if we got an OK response */
*ebuf = '\0';
+SDI2("BUFFER: [%s]", sbuf);
+
+ if( '\0' == *expect ) /* empty */
+ {
+ sbuf = ebuf = buffer;
+ return ret;
+ }
for( ; sbuf < ebuf && (*sbuf == '\n' || *sbuf == '\r'); sbuf++); /* left trim of '\r' & '\n' */
for(i = 0 ; i < (ebuf - sbuf) && (sbuf[i] != '\n' && sbuf[i] != '\r'); i++); /* find first '\r' & '\n' */
@@ -89,7 +95,6 @@ static int read_gsm(int fd, const char *expect, char *error, int max_error_len)
if (strstr(sbuf, expect) == NULL)
{
zabbix_log(LOG_LEVEL_DEBUG, "Read something unexpected from GSM modem. Expected [%s]", expect);
- zabbix_syslog("Read something unexpected from GSM modem");
zbx_snprintf(error,max_error_len, "Read something unexpected from GSM modem. Expected [%s]", expect);
ret = FAIL;
}
@@ -114,15 +119,16 @@ typedef struct {
int send_sms(char *device,char *number,char *message, char *error, int max_error_len)
{
zbx_sms_scenario scenario[] = {
-/* 0 */ {"ATE0\r" , "OK" }, /* Turn off echo */
-/* 1 */ {"AT\r" , "OK" }, /* Init modem */
-/* 2 */ {"AT+CMGF=1\r" , "OK" }, /* Switch to text mode */
-/* 3 */ {"AT+CMGS=\"" , NULL }, /* Set phone number */
-/* 4 */ {number , NULL }, /* Write phone number */
-/* 5 */ {"\"\r" , ">" }, /* Set phone number */
-/* 6 */ {message , NULL }, /* Write message */
-/* 7 */ {"\x01a" , "+CMGS: " }, /* Send message */
-/* 8 */ {NULL , "OK" },
+/* 0 */ {"\x01b" , "" }, /* Send <ESC> */
+/* 1 */ {"ATE0\r" , "OK" }, /* Turn off echo */
+/* 2 */ {"AT\r" , "OK" }, /* Init modem */
+/* 3 */ {"AT+CMGF=1\r" , "OK" }, /* Switch to text mode */
+/* 4 */ {"AT+CMGS=\"" , NULL }, /* Set phone number */
+/* 5 */ {number , NULL }, /* Write phone number */
+/* 6 */ {"\"\r" , ">" }, /* Set phone number */
+/* 7 */ {message , NULL }, /* Write message */
+/* 8 */ {"\x01a" , "+CMGS: " }, /* Send message */
+/* 9 */ {NULL , "OK" },
/* EOS */ {NULL , NULL }
};
@@ -140,7 +146,6 @@ int send_sms(char *device,char *number,char *message, char *error, int max_error
if(f == -1)
{
zabbix_log(LOG_LEVEL_DEBUG, "Error open(%s) [%s]", device, strerror(errno));
- zabbix_syslog("Error open(%s) [%s]", device, strerror(errno));
zbx_snprintf(error,max_error_len, "Error open(%s) [%s]", device, strerror(errno));
return FAIL;
}
@@ -155,7 +160,7 @@ int send_sms(char *device,char *number,char *message, char *error, int max_error
options.c_oflag = ONOCR;
#endif /* ONOCR */
- options.c_cflag = B38400 | CRTSCTS | CS8 | CLOCAL | CREAD;
+ options.c_cflag = old_options.c_cflag | CRTSCTS | CS8 | CLOCAL | CREAD;
options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
options.c_cc[VMIN] = 0;
options.c_cc[VTIME] = 100;
@@ -166,11 +171,11 @@ int send_sms(char *device,char *number,char *message, char *error, int max_error
{
if(step->message)
{
- if(FAIL == write_gsm(f, step->message, error, max_error_len)) break;
+ if(FAIL == (ret = write_gsm(f, step->message, error, max_error_len))) break;
}
if(step->result)
{
- if(FAIL == read_gsm(f, step->result, error, max_error_len)) break;
+ if(FAIL == (ret = read_gsm(f, step->result, error, max_error_len))) break;
}
}
diff --git a/src/zabbix_server/alerter/alerter.c b/src/zabbix_server/alerter/alerter.c
index d38b9f1a..558709e3 100644
--- a/src/zabbix_server/alerter/alerter.c
+++ b/src/zabbix_server/alerter/alerter.c
@@ -228,8 +228,8 @@ int main_alerter_loop()
sigaction(SIGALRM, &phan, NULL);
/* Hardcoded value */
- /* SMS requires 12.5s for sending */
- alarm(20);
+ /* SMS requires 15s for sending */
+ alarm(40);
res=execute_action(&alert,&mediatype,error,sizeof(error));
alarm(0);
diff --git a/src/zabbix_server/server.c b/src/zabbix_server/server.c
index d1770472..6febae2c 100644
--- a/src/zabbix_server/server.c
+++ b/src/zabbix_server/server.c
@@ -238,12 +238,34 @@ void init_config(void)
#ifdef TEST
+int send_sms(char *device,char *number,char *message, char *error, int max_error_len);
+
void test()
{
+ char error[0xFF];
+
+ error[0] = '\0';
+
zabbix_set_log_level(LOG_LEVEL_DEBUG);
printf("-= Test Started =-\n\n");
+ if ( SUCCEED == send_sms(
+ "/dev/ttyS0",
+ <phone>,
+ "test from zabbix",
+ error,
+ (int)sizeof(error)
+ ) )
+ {
+ SDI("SUCCEED!!!");
+ }
+ else
+ {
+ SDI("FAIL!!!");
+ SDI2("ERROR: %s", error);
+ }
+
printf("\n-= Test completed =-\n");
@@ -355,7 +377,7 @@ int main(int argc, char **argv)
#ifdef TEST
if(CONFIG_LOG_FILE == NULL)
{
- zabbix_open_log(LOG_TYPE_SYSLOG,CONFIG_LOG_LEVEL,NULL);
+ zabbix_open_log(LOG_TYPE_UNDEFINED,CONFIG_LOG_LEVEL,NULL);
}
else
{