31 |
|
#include <stdarg.h> |
32 |
|
#include <errno.h> |
33 |
|
#include <netdb.h> |
34 |
+ |
#include <netinet/in.h> |
35 |
|
|
36 |
< |
#include "ukcprog.h" |
37 |
< |
#include "statgrab.h" |
36 |
> |
#include <ukcprog.h> |
37 |
> |
#include <statgrab.h> |
38 |
|
|
39 |
|
#define LOG_CRIT 0 |
40 |
|
#define LOG_ERR 1 |
76 |
|
|
77 |
|
ihost_config_t ihost_config; |
78 |
|
|
79 |
+ |
extern int errno; |
80 |
+ |
|
81 |
+ |
/* Taken from the OpenSSH code. Its licence included in function.*/ |
82 |
+ |
#ifndef HAVE_STRLCAT |
83 |
+ |
|
84 |
+ |
/* |
85 |
+ |
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> |
86 |
+ |
* All rights reserved. |
87 |
+ |
* |
88 |
+ |
* Redistribution and use in source and binary forms, with or without |
89 |
+ |
* modification, are permitted provided that the following conditions |
90 |
+ |
* are met: |
91 |
+ |
* 1. Redistributions of source code must retain the above copyright |
92 |
+ |
* notice, this list of conditions and the following disclaimer. |
93 |
+ |
* 2. Redistributions in binary form must reproduce the above copyright |
94 |
+ |
* notice, this list of conditions and the following disclaimer in the |
95 |
+ |
* documentation and/or other materials provided with the distribution. |
96 |
+ |
* 3. The name of the author may not be used to endorse or promote products |
97 |
+ |
* derived from this software without specific prior written permission. |
98 |
+ |
* |
99 |
+ |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, |
100 |
+ |
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
101 |
+ |
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
102 |
+ |
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
103 |
+ |
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
104 |
+ |
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
105 |
+ |
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
106 |
+ |
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
107 |
+ |
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
108 |
+ |
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
109 |
+ |
*/ |
110 |
+ |
|
111 |
+ |
/* |
112 |
+ |
* Appends src to string dst of size siz (unlike strncat, siz is the |
113 |
+ |
* full size of dst, not space left). At most siz-1 characters |
114 |
+ |
* will be copied. Always NUL terminates (unless siz <= strlen(dst)). |
115 |
+ |
* Returns strlen(src) + MIN(siz, strlen(initial dst)). |
116 |
+ |
* If retval >= siz, truncation occurred. |
117 |
+ |
*/ |
118 |
+ |
size_t |
119 |
+ |
strlcat(dst, src, siz) |
120 |
+ |
char *dst; |
121 |
+ |
const char *src; |
122 |
+ |
size_t siz; |
123 |
+ |
{ |
124 |
+ |
register char *d = dst; |
125 |
+ |
register const char *s = src; |
126 |
+ |
register size_t n = siz; |
127 |
+ |
size_t dlen; |
128 |
+ |
|
129 |
+ |
/* Find the end of dst and adjust bytes left but don't go past end */ |
130 |
+ |
while (n-- != 0 && *d != '\0') |
131 |
+ |
d++; |
132 |
+ |
dlen = d - dst; |
133 |
+ |
n = siz - dlen; |
134 |
+ |
|
135 |
+ |
if (n == 0) |
136 |
+ |
return(dlen + strlen(s)); |
137 |
+ |
while (*s != '\0') { |
138 |
+ |
if (n != 1) { |
139 |
+ |
*d++ = *s; |
140 |
+ |
n--; |
141 |
+ |
} |
142 |
+ |
s++; |
143 |
+ |
} |
144 |
+ |
*d = '\0'; |
145 |
+ |
|
146 |
+ |
return(dlen + (s - src)); /* count does not include NUL */ |
147 |
+ |
} |
148 |
+ |
|
149 |
+ |
#endif |
150 |
+ |
/* End strlcat function taken from OpenSSH */ |
151 |
+ |
|
152 |
|
void log_msg(int level, char *format, ...){ |
79 |
– |
extern int errno; |
153 |
|
int cur_errno; |
154 |
|
va_list ap; |
155 |
|
|
164 |
|
}else{ |
165 |
|
fprintf(ihost_config.log, "\n"); |
166 |
|
} |
167 |
+ |
fflush(ihost_config.log); |
168 |
|
} |
169 |
|
} |
170 |
|
|
224 |
|
|
225 |
|
if((get_host_addr(hostname, &haddr))!=0){ |
226 |
|
log_msg(LOG_CRIT, "Failed to lookup name for %s", hostname); |
227 |
+ |
close(sock); |
228 |
|
return NULL; |
229 |
|
} |
230 |
|
|
236 |
|
log_msg(LOG_DEBUG, "Creating a tcp connection"); |
237 |
|
if(connect(sock, (struct sockaddr *)&addr, sizeof(addr)) !=0){ |
238 |
|
log_msg(LOG_CRIT, "Failed to connect to hostname %s on port %d", hostname, port); |
239 |
+ |
close(sock); |
240 |
|
return NULL; |
241 |
|
} |
242 |
|
|
297 |
|
time_t config_ttl=0; |
298 |
|
|
299 |
|
if((tcp_con=create_tcp_connection(ihost_state->filtermanager_host, ihost_state->filtermanager_port))==NULL){ |
300 |
< |
goto error; |
300 |
> |
return -1; |
301 |
|
} |
302 |
|
|
303 |
|
if(ihost_state->file_list!=NULL || ihost_state->last_modified!=NULL){ |
582 |
|
y=page_stats->pages_pageout; |
583 |
|
} |
584 |
|
snprintf(tmp, size, \ |
585 |
< |
"<pages><swapins>%lld</swapins><swapouts>%lld</swapouts></pages>", \ |
585 |
> |
"<pages><pageins>%lld</pageins><pageouts>%lld</pageouts></pages>", \ |
586 |
|
x, \ |
587 |
|
y); |
588 |
|
|