~ubuntu-dev/ubuntu/lucid/zabbix/lucid-201002110857

« back to all changes in this revision

Viewing changes to src/zabbix_server/poller/checks_simple.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Ablassmeier
  • Date: 2007-07-02 09:06:51 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070702090651-8l6fl3fjw9rh6l2u
Tags: 1:1.4.1-2
Add patch from SVN in order to fix Incorrect processing of character '%'
in user parameters and remote commands.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
 
37
37
        init_result(result);
38
38
 
39
 
        zabbix_log( LOG_LEVEL_DEBUG, "In get_value_simple([%s]", item->key);
 
39
        zabbix_log( LOG_LEVEL_DEBUG, "In get_value_simple([%s]",
 
40
                item->key);
40
41
 
41
42
        if(0 == strncmp(item->key,"service.ntp",11))
42
43
        {
43
 
                l=strstr(item->key,"[");
44
 
                r=strstr(item->key,"]");
 
44
                l=strchr(item->key,'[');
 
45
                r=strrchr(item->key,']');
45
46
                if(l==NULL || r==NULL)
46
 
                        snprintf(c,sizeof(c)-1,"net.tcp.service[%s]",item->key);
 
47
                        zbx_snprintf(c,sizeof(c),"net.tcp.service[%s]",
 
48
                                item->key);
47
49
                else
48
50
                {
49
51
                        zbx_strlcpy( param,l+1, r-l-1);
50
 
                        param[r-l-1]=0;
51
52
                        if(item->useip==1)
52
53
                        {
53
 
                                snprintf(c,sizeof(c)-1,"net.tcp.service[%s,%s]",item->key,item->ip);
 
54
                                zbx_snprintf(c,sizeof(c),"net.tcp.service[%s,%s]",
 
55
                                        item->key,
 
56
                                        item->host_ip);
54
57
                        }
55
58
                        else
56
59
                        {
57
 
                                snprintf(c,sizeof(c)-1,"net.tcp.service[%s,%s]",item->key,item->host);
 
60
                                zbx_snprintf(c,sizeof(c),"net.tcp.service[%s,%s]",
 
61
                                        item->key,
 
62
                                        item->host_ip);
58
63
                        }
59
64
                }
60
65
        }
62
67
        {
63
68
                if(item->useip==1)
64
69
                {
65
 
                        l=strstr(item->key,"[");
66
 
                        r=strstr(item->key,"]");
 
70
                        l=strchr(item->key,'[');
 
71
                        r=strrchr(item->key,']');
67
72
                        if(l==NULL || r==NULL)
68
 
                                snprintf(c,sizeof(c)-1,"%s",item->key);
 
73
                                zbx_snprintf(c,sizeof(c),"%s",
 
74
                                        item->key);
69
75
                        else
70
76
                        {
71
77
                                zbx_strlcpy( param,l+1, r-l-1);
72
 
                                param[r-l-1]=0;
73
 
/*                              snprintf(c,sizeof(c)-1,"dns[%s,%s]",item->ip,param);*/
74
 
                                snprintf(c,sizeof(c)-1,"dns[%s]",param);
 
78
/*                              zbx_snprintf(c,sizeof(c),"dns[%s,%s]",item->ip,param);*/
 
79
                                zbx_snprintf(c,sizeof(c),"dns[%s]",
 
80
                                        param);
75
81
                        }
76
82
                }
77
83
                else
78
84
                {
79
 
                        snprintf(error,MAX_STRING_LEN-1,"You must use IP address in Host %s definition", item->host);
80
 
                        zabbix_log( LOG_LEVEL_WARNING, "%s", error);
 
85
                        zbx_snprintf(error,sizeof(error),"You must use IP address in Host %s definition",
 
86
                                item->host_name);
 
87
                        zabbix_log( LOG_LEVEL_WARNING, "%s",
 
88
                                error);
81
89
                        result->str=strdup(error);
82
90
                        return NOTSUPPORTED;
83
91
                }
110
118
                        }
111
119
                        else
112
120
                        {
113
 
                                snprintf(error,MAX_STRING_LEN-1,"Port number must be numeric in [%s]", item->key);
114
 
                                zabbix_log( LOG_LEVEL_WARNING, "%s", error);
 
121
                                zbx_snprintf(error,sizeof(error),"Port number must be numeric in [%s]",
 
122
                                        item->key);
 
123
                                zabbix_log( LOG_LEVEL_WARNING, "%s",
 
124
                                        error);
115
125
                                result->str=strdup(error);
116
126
                                ret = NOTSUPPORTED;
117
127
                        }
118
128
                }
119
129
                else
120
130
                {
121
 
                        snprintf(error,MAX_STRING_LEN-1,"Too many parameters in [%s]", item->key);
122
 
                        zabbix_log( LOG_LEVEL_WARNING, "%s", error);
 
131
                        zbx_snprintf(error,sizeof(error),"Too many parameters in [%s]",
 
132
                                item->key);
 
133
                        zabbix_log( LOG_LEVEL_WARNING, "%s",
 
134
                                error);
123
135
                        result->str=strdup(error);
124
136
                        ret = NOTSUPPORTED;
125
137
                }
128
140
                {
129
141
                        if(item->useip==1)
130
142
                        {
131
 
                                strscpy(ip,item->ip);
 
143
                                strscpy(ip,item->host_ip);
132
144
                        }
133
145
                        else
134
146
                        {
135
 
                                strscpy(ip,item->host);
 
147
                                strscpy(ip,item->host_dns);
136
148
                        }
137
149
 
138
150
                        t = strstr(service,"_perf");
145
157
 
146
158
                        if(port_int == 0)
147
159
                        {
148
 
                                snprintf(c,sizeof(c)-1,"%s[%s,%s]",service_sysinfo,service,ip);
 
160
                                zbx_snprintf(c,sizeof(c),"%s[%s,%s]",
 
161
                                        service_sysinfo,
 
162
                                        service,
 
163
                                        ip);
149
164
                        }
150
165
                        else
151
166
                        {
152
 
                                snprintf(c,sizeof(c)-1,"%s[%s,%s,%d]",service_sysinfo,service,ip,port_int);
 
167
                                zbx_snprintf(c,sizeof(c),"%s[%s,%s,%d]",
 
168
                                        service_sysinfo,
 
169
                                        service,
 
170
                                        ip,
 
171
                                        port_int);
153
172
                        }
154
 
                        zabbix_log( LOG_LEVEL_DEBUG, "Sysinfo [%s]", c);
 
173
                        zabbix_log( LOG_LEVEL_DEBUG, "Sysinfo [%s]",
 
174
                                c);
155
175
                }
156
176
                else
157
177
                {
163
183
        {
164
184
                if(item->useip==1)
165
185
                {
166
 
                        snprintf(c,sizeof(c)-1,"net.tcp.service[%s,%s]",item->key,item->ip);
 
186
                        zbx_snprintf(c,sizeof(c),"net.tcp.service[%s,%s]",item->key,item->ip);
167
187
                }
168
188
                else
169
189
                {
170
 
                        snprintf(c,sizeof(c)-1,"net.tcp.service[%s,%s]",item->key,item->host);
 
190
                        zbx_snprintf(c,sizeof(c),"net.tcp.service[%s,%s]",item->key,item->host);
171
191
                }
172
192
        }
173
193
        else
178
198
                
179
199
                if(item->useip==1)
180
200
                {
181
 
                        snprintf(c,sizeof(c)-1,"net.tcp.service.perf[%s,%s]",s,item->ip);
 
201
                        zbx_snprintf(c,sizeof(c),"net.tcp.service.perf[%s,%s]",s,item->ip);
182
202
                }
183
203
                else
184
204
                {
185
 
                        snprintf(c,sizeof(c)-1,"net.tcp.service.perf[%s,%s]",s,item->host);
 
205
                        zbx_snprintf(c,sizeof(c),"net.tcp.service.perf[%s,%s]",s,item->host);
186
206
                }
187
207
        }
188
208
*/
189
209
 
190
210
        if(process(c, 0, result) == NOTSUPPORTED)
191
211
        {
192
 
                snprintf(error,MAX_STRING_LEN-1,"Simple check [%s] is not supported", c);
193
 
                zabbix_log( LOG_LEVEL_WARNING, "%s", error);
 
212
                zbx_snprintf(error,sizeof(error),"Simple check [%s] is not supported",
 
213
                        c);
 
214
                zabbix_log( LOG_LEVEL_WARNING, "%s",
 
215
                        error);
194
216
                result->str=strdup(error);
195
217
                ret = NOTSUPPORTED;
196
218
        }