summaryrefslogtreecommitdiffstats
path: root/plugins/check_nt.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_nt.c')
-rw-r--r--plugins/check_nt.c618
1 files changed, 320 insertions, 298 deletions
diff --git a/plugins/check_nt.c b/plugins/check_nt.c
index dec0b668..35ca92cd 100644
--- a/plugins/check_nt.c
+++ b/plugins/check_nt.c
@@ -13,7 +13,7 @@
13 * This plugin collects data from the NSClient service running on a 13 * This plugin collects data from the NSClient service running on a
14 * Windows NT/2000/XP/2003 server. 14 * Windows NT/2000/XP/2003 server.
15 * This plugin requires NSClient software to run on NT 15 * This plugin requires NSClient software to run on NT
16 * (http://nsclient.ready2run.nl/) 16 * (https://nsclient.org/)
17 * 17 *
18 * 18 *
19 * This program is free software: you can redistribute it and/or modify 19 * This program is free software: you can redistribute it and/or modify
@@ -39,82 +39,28 @@ const char *email = "devel@monitoring-plugins.org";
39#include "common.h" 39#include "common.h"
40#include "netutils.h" 40#include "netutils.h"
41#include "utils.h" 41#include "utils.h"
42 42#include "check_nt.d/config.h"
43enum checkvars {
44 CHECK_NONE,
45 CHECK_CLIENTVERSION,
46 CHECK_CPULOAD,
47 CHECK_UPTIME,
48 CHECK_USEDDISKSPACE,
49 CHECK_SERVICESTATE,
50 CHECK_PROCSTATE,
51 CHECK_MEMUSE,
52 CHECK_COUNTER,
53 CHECK_FILEAGE,
54 CHECK_INSTANCES
55};
56 43
57enum { 44enum {
58 MAX_VALUE_LIST = 30, 45 MAX_VALUE_LIST = 30,
59 PORT = 1248
60}; 46};
61 47
62static char *server_address = NULL;
63static int server_port = PORT;
64static char *value_list = NULL;
65static char *req_password = NULL;
66static unsigned long lvalue_list[MAX_VALUE_LIST];
67static unsigned long warning_value = 0L;
68static unsigned long critical_value = 0L;
69static bool check_warning_value = false;
70static bool check_critical_value = false;
71static enum checkvars vars_to_check = CHECK_NONE;
72static bool show_all = false;
73
74static char recv_buffer[MAX_INPUT_BUFFER]; 48static char recv_buffer[MAX_INPUT_BUFFER];
75 49
76static void fetch_data(const char *address, int port, const char *sendb); 50static void fetch_data(const char *address, int port, const char *sendb);
77static int process_arguments(int /*argc*/, char ** /*argv*/); 51
52typedef struct {
53 int errorcode;
54 check_nt_config config;
55} check_nt_config_wrapper;
56static check_nt_config_wrapper process_arguments(int /*argc*/, char ** /*argv*/);
57
78static void preparelist(char *string); 58static void preparelist(char *string);
79static bool strtoularray(unsigned long *array, char *string, const char *delim); 59static bool strtoularray(unsigned long *array, char *string, const char *delim);
80static void print_help(void); 60static void print_help(void);
81void print_usage(void); 61void print_usage(void);
82 62
83int main(int argc, char **argv) { 63int main(int argc, char **argv) {
84
85 /* should be int result = STATE_UNKNOWN; */
86
87 int return_code = STATE_UNKNOWN;
88 char *send_buffer = NULL;
89 char *output_message = NULL;
90 char *perfdata = NULL;
91 char *temp_string = NULL;
92 char *temp_string_perf = NULL;
93 char *description = NULL, *counter_unit = NULL;
94 char *minval = NULL, *maxval = NULL, *errcvt = NULL;
95 char *fds = NULL, *tds = NULL;
96 char *numstr;
97
98 double total_disk_space = 0;
99 double free_disk_space = 0;
100 double percent_used_space = 0;
101 double warning_used_space = 0;
102 double critical_used_space = 0;
103 double mem_commitLimit = 0;
104 double mem_commitByte = 0;
105 double fminval = 0, fmaxval = 0;
106 unsigned long utilization;
107 unsigned long uptime;
108 unsigned long age_in_minutes;
109 double counter_value = 0.0;
110 int offset = 0;
111 int updays = 0;
112 int uphours = 0;
113 int upminutes = 0;
114
115 bool isPercent = false;
116 bool allRight = false;
117
118 setlocale(LC_ALL, ""); 64 setlocale(LC_ALL, "");
119 bindtextdomain(PACKAGE, LOCALEDIR); 65 bindtextdomain(PACKAGE, LOCALEDIR);
120 textdomain(PACKAGE); 66 textdomain(PACKAGE);
@@ -122,8 +68,12 @@ int main(int argc, char **argv) {
122 /* Parse extra opts if any */ 68 /* Parse extra opts if any */
123 argv = np_extra_opts(&argc, argv, progname); 69 argv = np_extra_opts(&argc, argv, progname);
124 70
125 if (process_arguments(argc, argv) == ERROR) 71 check_nt_config_wrapper tmp_config = process_arguments(argc, argv);
72 if (tmp_config.errorcode == ERROR) {
126 usage4(_("Could not parse arguments")); 73 usage4(_("Could not parse arguments"));
74 }
75
76 const check_nt_config config = tmp_config.config;
127 77
128 /* initialize alarm signal handling */ 78 /* initialize alarm signal handling */
129 signal(SIGALRM, socket_timeout_alarm_handler); 79 signal(SIGALRM, socket_timeout_alarm_handler);
@@ -131,54 +81,68 @@ int main(int argc, char **argv) {
131 /* set socket timeout */ 81 /* set socket timeout */
132 alarm(socket_timeout); 82 alarm(socket_timeout);
133 83
134 switch (vars_to_check) { 84 int return_code = STATE_UNKNOWN;
135 85 char *send_buffer = NULL;
86 char *output_message = NULL;
87 char *perfdata = NULL;
88 char *temp_string = NULL;
89 char *temp_string_perf = NULL;
90 char *description = NULL;
91 char *counter_unit = NULL;
92 char *errcvt = NULL;
93 unsigned long lvalue_list[MAX_VALUE_LIST];
94 switch (config.vars_to_check) {
136 case CHECK_CLIENTVERSION: 95 case CHECK_CLIENTVERSION:
137 96 xasprintf(&send_buffer, "%s&1", config.req_password);
138 xasprintf(&send_buffer, "%s&1", req_password); 97 fetch_data(config.server_address, config.server_port, send_buffer);
139 fetch_data(server_address, server_port, send_buffer); 98 if (config.value_list != NULL && strcmp(recv_buffer, config.value_list) != 0) {
140 if (value_list != NULL && strcmp(recv_buffer, value_list) != 0) { 99 xasprintf(&output_message, _("Wrong client version - running: %s, required: %s"),
141 xasprintf(&output_message, _("Wrong client version - running: %s, required: %s"), recv_buffer, value_list); 100 recv_buffer, config.value_list);
142 return_code = STATE_WARNING; 101 return_code = STATE_WARNING;
143 } else { 102 } else {
144 xasprintf(&output_message, "%s", recv_buffer); 103 xasprintf(&output_message, "%s", recv_buffer);
145 return_code = STATE_OK; 104 return_code = STATE_OK;
146 } 105 }
147 break; 106 break;
148
149 case CHECK_CPULOAD: 107 case CHECK_CPULOAD:
150 108 if (config.value_list == NULL) {
151 if (value_list == NULL)
152 output_message = strdup(_("missing -l parameters")); 109 output_message = strdup(_("missing -l parameters"));
153 else if (!strtoularray(lvalue_list, value_list, ",")) 110 } else if (!strtoularray(lvalue_list, config.value_list, ",")) {
154 output_message = strdup(_("wrong -l parameter.")); 111 output_message = strdup(_("wrong -l parameter."));
155 else { 112 } else {
156 /* -l parameters is present with only integers */ 113 /* -l parameters is present with only integers */
157 return_code = STATE_OK; 114 return_code = STATE_OK;
158 temp_string = strdup(_("CPU Load")); 115 temp_string = strdup(_("CPU Load"));
159 temp_string_perf = strdup(" "); 116 temp_string_perf = strdup(" ");
160 117
161 /* loop until one of the parameters is wrong or not present */ 118 /* loop until one of the parameters is wrong or not present */
162 while (lvalue_list[0 + offset] > (unsigned long)0 && lvalue_list[0 + offset] <= (unsigned long)17280 && 119 int offset = 0;
163 lvalue_list[1 + offset] > (unsigned long)0 && lvalue_list[1 + offset] <= (unsigned long)100 && 120 while (lvalue_list[0 + offset] > (unsigned long)0 &&
164 lvalue_list[2 + offset] > (unsigned long)0 && lvalue_list[2 + offset] <= (unsigned long)100) { 121 lvalue_list[0 + offset] <= (unsigned long)17280 &&
122 lvalue_list[1 + offset] > (unsigned long)0 &&
123 lvalue_list[1 + offset] <= (unsigned long)100 &&
124 lvalue_list[2 + offset] > (unsigned long)0 &&
125 lvalue_list[2 + offset] <= (unsigned long)100) {
165 126
166 /* Send request and retrieve data */ 127 /* Send request and retrieve data */
167 xasprintf(&send_buffer, "%s&2&%lu", req_password, lvalue_list[0 + offset]); 128 xasprintf(&send_buffer, "%s&2&%lu", config.req_password, lvalue_list[0 + offset]);
168 fetch_data(server_address, server_port, send_buffer); 129 fetch_data(config.server_address, config.server_port, send_buffer);
169 130
170 utilization = strtoul(recv_buffer, NULL, 10); 131 unsigned long utilization = strtoul(recv_buffer, NULL, 10);
171 132
172 /* Check if any of the request is in a warning or critical state */ 133 /* Check if any of the request is in a warning or critical state */
173 if (utilization >= lvalue_list[2 + offset]) 134 if (utilization >= lvalue_list[2 + offset]) {
174 return_code = STATE_CRITICAL; 135 return_code = STATE_CRITICAL;
175 else if (utilization >= lvalue_list[1 + offset] && return_code < STATE_WARNING) 136 } else if (utilization >= lvalue_list[1 + offset] && return_code < STATE_WARNING) {
176 return_code = STATE_WARNING; 137 return_code = STATE_WARNING;
138 }
177 139
178 xasprintf(&output_message, _(" %lu%% (%lu min average)"), utilization, lvalue_list[0 + offset]); 140 xasprintf(&output_message, _(" %lu%% (%lu min average)"), utilization,
141 lvalue_list[0 + offset]);
179 xasprintf(&temp_string, "%s%s", temp_string, output_message); 142 xasprintf(&temp_string, "%s%s", temp_string, output_message);
180 xasprintf(&perfdata, _(" '%lu min avg Load'=%lu%%;%lu;%lu;0;100"), lvalue_list[0 + offset], utilization, 143 xasprintf(&perfdata, _(" '%lu min avg Load'=%lu%%;%lu;%lu;0;100"),
181 lvalue_list[1 + offset], lvalue_list[2 + offset]); 144 lvalue_list[0 + offset], utilization, lvalue_list[1 + offset],
145 lvalue_list[2 + offset]);
182 xasprintf(&temp_string_perf, "%s%s", temp_string_perf, perfdata); 146 xasprintf(&temp_string_perf, "%s%s", temp_string_perf, perfdata);
183 offset += 3; /* move across the array */ 147 offset += 3; /* move across the array */
184 } 148 }
@@ -186,82 +150,97 @@ int main(int argc, char **argv) {
186 if (strlen(temp_string) > 10) { /* we had at least one loop */ 150 if (strlen(temp_string) > 10) { /* we had at least one loop */
187 output_message = strdup(temp_string); 151 output_message = strdup(temp_string);
188 perfdata = temp_string_perf; 152 perfdata = temp_string_perf;
189 } else 153 } else {
190 output_message = strdup(_("not enough values for -l parameters")); 154 output_message = strdup(_("not enough values for -l parameters"));
155 }
191 } 156 }
192 break; 157 break;
193 158 case CHECK_UPTIME: {
194 case CHECK_UPTIME: 159 char *tmp_value_list = config.value_list;
195 160 if (config.value_list == NULL) {
196 if (value_list == NULL) { 161 tmp_value_list = "minutes";
197 value_list = "minutes";
198 } 162 }
199 if (strncmp(value_list, "seconds", strlen("seconds") + 1) && strncmp(value_list, "minutes", strlen("minutes") + 1) && 163 if (strncmp(tmp_value_list, "seconds", strlen("seconds") + 1) &&
200 strncmp(value_list, "hours", strlen("hours") + 1) && strncmp(value_list, "days", strlen("days") + 1)) { 164 strncmp(tmp_value_list, "minutes", strlen("minutes") + 1) &&
165 strncmp(config.value_list, "hours", strlen("hours") + 1) &&
166 strncmp(tmp_value_list, "days", strlen("days") + 1)) {
201 167
202 output_message = strdup(_("wrong -l argument")); 168 output_message = strdup(_("wrong -l argument"));
203 } else { 169 } else {
204 xasprintf(&send_buffer, "%s&3", req_password); 170 xasprintf(&send_buffer, "%s&3", config.req_password);
205 fetch_data(server_address, server_port, send_buffer); 171 fetch_data(config.server_address, config.server_port, send_buffer);
206 uptime = strtoul(recv_buffer, NULL, 10); 172 unsigned long uptime = strtoul(recv_buffer, NULL, 10);
207 updays = uptime / 86400; 173 int updays = uptime / 86400;
208 uphours = (uptime % 86400) / 3600; 174 int uphours = (uptime % 86400) / 3600;
209 upminutes = ((uptime % 86400) % 3600) / 60; 175 int upminutes = ((uptime % 86400) % 3600) / 60;
210 176
211 if (!strncmp(value_list, "minutes", strlen("minutes"))) 177 if (!strncmp(tmp_value_list, "minutes", strlen("minutes"))) {
212 uptime = uptime / 60; 178 uptime = uptime / 60;
213 else if (!strncmp(value_list, "hours", strlen("hours"))) 179 } else if (!strncmp(tmp_value_list, "hours", strlen("hours"))) {
214 uptime = uptime / 3600; 180 uptime = uptime / 3600;
215 else if (!strncmp(value_list, "days", strlen("days"))) 181 } else if (!strncmp(tmp_value_list, "days", strlen("days"))) {
216 uptime = uptime / 86400; 182 uptime = uptime / 86400;
183 }
217 /* else uptime in seconds, nothing to do */ 184 /* else uptime in seconds, nothing to do */
218 185
219 xasprintf(&output_message, _("System Uptime - %u day(s) %u hour(s) %u minute(s) |uptime=%lu"), updays, uphours, upminutes, 186 xasprintf(&output_message,
220 uptime); 187 _("System Uptime - %u day(s) %u hour(s) %u minute(s) |uptime=%lu"), updays,
188 uphours, upminutes, uptime);
221 189
222 if (check_critical_value && uptime <= critical_value) 190 if (config.check_critical_value && uptime <= config.critical_value) {
223 return_code = STATE_CRITICAL; 191 return_code = STATE_CRITICAL;
224 else if (check_warning_value && uptime <= warning_value) 192 } else if (config.check_warning_value && uptime <= config.warning_value) {
225 return_code = STATE_WARNING; 193 return_code = STATE_WARNING;
226 else 194 } else {
227 return_code = STATE_OK; 195 return_code = STATE_OK;
196 }
228 } 197 }
229 break; 198 } break;
230
231 case CHECK_USEDDISKSPACE: 199 case CHECK_USEDDISKSPACE:
232 200 if (config.value_list == NULL) {
233 if (value_list == NULL)
234 output_message = strdup(_("missing -l parameters")); 201 output_message = strdup(_("missing -l parameters"));
235 else if (strlen(value_list) != 1) 202 } else if (strlen(config.value_list) != 1) {
236 output_message = strdup(_("wrong -l argument")); 203 output_message = strdup(_("wrong -l argument"));
237 else { 204 } else {
238 xasprintf(&send_buffer, "%s&4&%s", req_password, value_list); 205 xasprintf(&send_buffer, "%s&4&%s", config.req_password, config.value_list);
239 fetch_data(server_address, server_port, send_buffer); 206 fetch_data(config.server_address, config.server_port, send_buffer);
240 fds = strtok(recv_buffer, "&"); 207 char *fds = strtok(recv_buffer, "&");
241 tds = strtok(NULL, "&"); 208 char *tds = strtok(NULL, "&");
242 if (fds != NULL) 209 double total_disk_space = 0;
210 double free_disk_space = 0;
211 if (fds != NULL) {
243 free_disk_space = atof(fds); 212 free_disk_space = atof(fds);
244 if (tds != NULL) 213 }
214 if (tds != NULL) {
245 total_disk_space = atof(tds); 215 total_disk_space = atof(tds);
216 }
246 217
247 if (total_disk_space > 0 && free_disk_space >= 0) { 218 if (total_disk_space > 0 && free_disk_space >= 0) {
248 percent_used_space = ((total_disk_space - free_disk_space) / total_disk_space) * 100; 219 double percent_used_space =
249 warning_used_space = ((float)warning_value / 100) * total_disk_space; 220 ((total_disk_space - free_disk_space) / total_disk_space) * 100;
250 critical_used_space = ((float)critical_value / 100) * total_disk_space; 221 double warning_used_space = ((float)config.warning_value / 100) * total_disk_space;
251 222 double critical_used_space =
252 xasprintf(&temp_string, _("%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)"), value_list, 223 ((float)config.critical_value / 100) * total_disk_space;
253 total_disk_space / 1073741824, (total_disk_space - free_disk_space) / 1073741824, percent_used_space, 224
254 free_disk_space / 1073741824, (free_disk_space / total_disk_space) * 100); 225 xasprintf(
255 xasprintf(&temp_string_perf, _("'%s:\\ Used Space'=%.2fGb;%.2f;%.2f;0.00;%.2f"), value_list, 226 &temp_string,
256 (total_disk_space - free_disk_space) / 1073741824, warning_used_space / 1073741824, 227 _("%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)"),
257 critical_used_space / 1073741824, total_disk_space / 1073741824); 228 config.value_list, total_disk_space / 1073741824,
258 229 (total_disk_space - free_disk_space) / 1073741824, percent_used_space,
259 if (check_critical_value && percent_used_space >= critical_value) 230 free_disk_space / 1073741824, (free_disk_space / total_disk_space) * 100);
231 xasprintf(&temp_string_perf, _("'%s:\\ Used Space'=%.2fGb;%.2f;%.2f;0.00;%.2f"),
232 config.value_list, (total_disk_space - free_disk_space) / 1073741824,
233 warning_used_space / 1073741824, critical_used_space / 1073741824,
234 total_disk_space / 1073741824);
235
236 if (config.check_critical_value && percent_used_space >= config.critical_value) {
260 return_code = STATE_CRITICAL; 237 return_code = STATE_CRITICAL;
261 else if (check_warning_value && percent_used_space >= warning_value) 238 } else if (config.check_warning_value &&
239 percent_used_space >= config.warning_value) {
262 return_code = STATE_WARNING; 240 return_code = STATE_WARNING;
263 else 241 } else {
264 return_code = STATE_OK; 242 return_code = STATE_OK;
243 }
265 244
266 output_message = strdup(temp_string); 245 output_message = strdup(temp_string);
267 perfdata = temp_string_perf; 246 perfdata = temp_string_perf;
@@ -271,60 +250,64 @@ int main(int argc, char **argv) {
271 } 250 }
272 } 251 }
273 break; 252 break;
274
275 case CHECK_SERVICESTATE: 253 case CHECK_SERVICESTATE:
276 case CHECK_PROCSTATE: 254 case CHECK_PROCSTATE:
277 255 if (config.value_list == NULL) {
278 if (value_list == NULL)
279 output_message = strdup(_("No service/process specified")); 256 output_message = strdup(_("No service/process specified"));
280 else { 257 } else {
281 preparelist(value_list); /* replace , between services with & to send the request */ 258 preparelist(
282 xasprintf(&send_buffer, "%s&%u&%s&%s", req_password, (vars_to_check == CHECK_SERVICESTATE) ? 5 : 6, 259 config.value_list); /* replace , between services with & to send the request */
283 (show_all) ? "ShowAll" : "ShowFail", value_list); 260 xasprintf(&send_buffer, "%s&%u&%s&%s", config.req_password,
284 fetch_data(server_address, server_port, send_buffer); 261 (config.vars_to_check == CHECK_SERVICESTATE) ? 5 : 6,
285 numstr = strtok(recv_buffer, "&"); 262 (config.show_all) ? "ShowAll" : "ShowFail", config.value_list);
286 if (numstr == NULL) 263 fetch_data(config.server_address, config.server_port, send_buffer);
264 char *numstr = strtok(recv_buffer, "&");
265 if (numstr == NULL) {
287 die(STATE_UNKNOWN, _("could not fetch information from server\n")); 266 die(STATE_UNKNOWN, _("could not fetch information from server\n"));
267 }
288 return_code = atoi(numstr); 268 return_code = atoi(numstr);
289 temp_string = strtok(NULL, "&"); 269 temp_string = strtok(NULL, "&");
290 output_message = strdup(temp_string); 270 output_message = strdup(temp_string);
291 } 271 }
292 break; 272 break;
293
294 case CHECK_MEMUSE: 273 case CHECK_MEMUSE:
295 274 xasprintf(&send_buffer, "%s&7", config.req_password);
296 xasprintf(&send_buffer, "%s&7", req_password); 275 fetch_data(config.server_address, config.server_port, send_buffer);
297 fetch_data(server_address, server_port, send_buffer); 276 char *numstr = strtok(recv_buffer, "&");
298 numstr = strtok(recv_buffer, "&"); 277 if (numstr == NULL) {
299 if (numstr == NULL)
300 die(STATE_UNKNOWN, _("could not fetch information from server\n")); 278 die(STATE_UNKNOWN, _("could not fetch information from server\n"));
301 mem_commitLimit = atof(numstr); 279 }
280 double mem_commitLimit = atof(numstr);
302 numstr = strtok(NULL, "&"); 281 numstr = strtok(NULL, "&");
303 if (numstr == NULL) 282 if (numstr == NULL) {
304 die(STATE_UNKNOWN, _("could not fetch information from server\n")); 283 die(STATE_UNKNOWN, _("could not fetch information from server\n"));
305 mem_commitByte = atof(numstr); 284 }
306 percent_used_space = (mem_commitByte / mem_commitLimit) * 100; 285 double mem_commitByte = atof(numstr);
307 warning_used_space = ((float)warning_value / 100) * mem_commitLimit; 286 double percent_used_space = (mem_commitByte / mem_commitLimit) * 100;
308 critical_used_space = ((float)critical_value / 100) * mem_commitLimit; 287 double warning_used_space = ((float)config.warning_value / 100) * mem_commitLimit;
288 double critical_used_space = ((float)config.critical_value / 100) * mem_commitLimit;
309 289
310 /* Divisor should be 1048567, not 3044515, as we are measuring "Commit Charge" here, 290 /* Divisor should be 1048567, not 3044515, as we are measuring "Commit Charge" here,
311 which equals RAM + Pagefiles. */ 291 which equals RAM + Pagefiles. */
312 xasprintf(&output_message, _("Memory usage: total:%.2f MB - used: %.2f MB (%.0f%%) - free: %.2f MB (%.0f%%)"), 292 xasprintf(
313 mem_commitLimit / 1048567, mem_commitByte / 1048567, percent_used_space, (mem_commitLimit - mem_commitByte) / 1048567, 293 &output_message,
314 (mem_commitLimit - mem_commitByte) / mem_commitLimit * 100); 294 _("Memory usage: total:%.2f MB - used: %.2f MB (%.0f%%) - free: %.2f MB (%.0f%%)"),
315 xasprintf(&perfdata, _("'Memory usage'=%.2fMB;%.2f;%.2f;0.00;%.2f"), mem_commitByte / 1048567, warning_used_space / 1048567, 295 mem_commitLimit / 1048567, mem_commitByte / 1048567, percent_used_space,
296 (mem_commitLimit - mem_commitByte) / 1048567,
297 (mem_commitLimit - mem_commitByte) / mem_commitLimit * 100);
298 xasprintf(&perfdata, _("'Memory usage'=%.2fMB;%.2f;%.2f;0.00;%.2f"),
299 mem_commitByte / 1048567, warning_used_space / 1048567,
316 critical_used_space / 1048567, mem_commitLimit / 1048567); 300 critical_used_space / 1048567, mem_commitLimit / 1048567);
317 301
318 return_code = STATE_OK; 302 return_code = STATE_OK;
319 if (check_critical_value && percent_used_space >= critical_value) 303 if (config.check_critical_value && percent_used_space >= config.critical_value) {
320 return_code = STATE_CRITICAL; 304 return_code = STATE_CRITICAL;
321 else if (check_warning_value && percent_used_space >= warning_value) 305 } else if (config.check_warning_value && percent_used_space >= config.warning_value) {
322 return_code = STATE_WARNING; 306 return_code = STATE_WARNING;
307 }
323 308
324 break; 309 break;
325 310 case CHECK_COUNTER: {
326 case CHECK_COUNTER:
327
328 /* 311 /*
329 CHECK_COUNTER has been modified to provide extensive perfdata information. 312 CHECK_COUNTER has been modified to provide extensive perfdata information.
330 In order to do this, some modifications have been done to the code 313 In order to do this, some modifications have been done to the code
@@ -341,31 +324,38 @@ int main(int argc, char **argv) {
341 the counter unit - that is, the dimensions of the counter you're getting. Examples: 324 the counter unit - that is, the dimensions of the counter you're getting. Examples:
342 pages/s, packets transferred, etc. 325 pages/s, packets transferred, etc.
343 326
344 4) If you want, you may provide the minimum and maximum values to expect. They aren't mandatory, 327 4) If you want, you may provide the minimum and maximum values to expect. They aren't
345 but once specified they MUST have the same order of magnitude and units of -w and -c; otherwise. 328 mandatory, but once specified they MUST have the same order of magnitude and units of -w and
346 strange things will happen when you make graphs of your data. 329 -c; otherwise. strange things will happen when you make graphs of your data.
347 */ 330 */
348 331
349 if (value_list == NULL) 332 double counter_value = 0.0;
333 if (config.value_list == NULL) {
350 output_message = strdup(_("No counter specified")); 334 output_message = strdup(_("No counter specified"));
351 else { 335 } else {
352 preparelist(value_list); /* replace , between services with & to send the request */ 336 preparelist(
353 isPercent = (strchr(value_list, '%') != NULL); 337 config.value_list); /* replace , between services with & to send the request */
338 bool isPercent = (strchr(config.value_list, '%') != NULL);
354 339
355 strtok(value_list, "&"); /* burn the first parameters */ 340 strtok(config.value_list, "&"); /* burn the first parameters */
356 description = strtok(NULL, "&"); 341 description = strtok(NULL, "&");
357 counter_unit = strtok(NULL, "&"); 342 counter_unit = strtok(NULL, "&");
358 xasprintf(&send_buffer, "%s&8&%s", req_password, value_list); 343 xasprintf(&send_buffer, "%s&8&%s", config.req_password, config.value_list);
359 fetch_data(server_address, server_port, send_buffer); 344 fetch_data(config.server_address, config.server_port, send_buffer);
360 counter_value = atof(recv_buffer); 345 counter_value = atof(recv_buffer);
361 346
362 if (description == NULL) 347 bool allRight = false;
348 if (description == NULL) {
363 xasprintf(&output_message, "%.f", counter_value); 349 xasprintf(&output_message, "%.f", counter_value);
364 else if (isPercent) { 350 } else if (isPercent) {
365 counter_unit = strdup("%"); 351 counter_unit = strdup("%");
366 allRight = true; 352 allRight = true;
367 } 353 }
368 354
355 char *minval = NULL;
356 char *maxval = NULL;
357 double fminval = 0;
358 double fmaxval = 0;
369 if ((counter_unit != NULL) && (!allRight)) { 359 if ((counter_unit != NULL) && (!allRight)) {
370 minval = strtok(NULL, "&"); 360 minval = strtok(NULL, "&");
371 maxval = strtok(NULL, "&"); 361 maxval = strtok(NULL, "&");
@@ -375,84 +365,92 @@ int main(int argc, char **argv) {
375 fminval = (minval != NULL) ? strtod(minval, &errcvt) : -1; 365 fminval = (minval != NULL) ? strtod(minval, &errcvt) : -1;
376 fmaxval = (minval != NULL) ? strtod(maxval, &errcvt) : -1; 366 fmaxval = (minval != NULL) ? strtod(maxval, &errcvt) : -1;
377 367
378 if ((fminval == 0) && (minval == errcvt)) 368 if ((fminval == 0) && (minval == errcvt)) {
379 output_message = strdup(_("Minimum value contains non-numbers")); 369 output_message = strdup(_("Minimum value contains non-numbers"));
380 else { 370 } else {
381 if ((fmaxval == 0) && (maxval == errcvt)) 371 if ((fmaxval == 0) && (maxval == errcvt)) {
382 output_message = strdup(_("Maximum value contains non-numbers")); 372 output_message = strdup(_("Maximum value contains non-numbers"));
383 else 373 } else {
384 allRight = true; /* Everything is OK. */ 374 allRight = true; /* Everything is OK. */
375 }
385 } 376 }
386 } else if ((counter_unit == NULL) && (description != NULL)) 377 } else if ((counter_unit == NULL) && (description != NULL)) {
387 output_message = strdup(_("No unit counter specified")); 378 output_message = strdup(_("No unit counter specified"));
379 }
388 380
389 if (allRight) { 381 if (allRight) {
390 /* Let's format the output string, finally... */ 382 /* Let's format the output string, finally... */
391 if (strstr(description, "%") == NULL) { 383 if (strstr(description, "%") == NULL) {
392 xasprintf(&output_message, "%s = %.2f %s", description, counter_value, counter_unit); 384 xasprintf(&output_message, "%s = %.2f %s", description, counter_value,
385 counter_unit);
393 } else { 386 } else {
394 /* has formatting, will segv if wrong */ 387 /* has formatting, will segv if wrong */
395 xasprintf(&output_message, description, counter_value); 388 xasprintf(&output_message, description, counter_value);
396 } 389 }
397 xasprintf(&output_message, "%s |", output_message); 390 xasprintf(&output_message, "%s |", output_message);
398 xasprintf(&output_message, "%s %s", output_message, 391 xasprintf(&output_message, "%s %s", output_message,
399 fperfdata(description, counter_value, counter_unit, 1, warning_value, 1, critical_value, 392 fperfdata(description, counter_value, counter_unit, 1,
400 (!(isPercent) && (minval != NULL)), fminval, (!(isPercent) && (minval != NULL)), fmaxval)); 393 config.warning_value, 1, config.critical_value,
394 (!(isPercent) && (minval != NULL)), fminval,
395 (!(isPercent) && (minval != NULL)), fmaxval));
401 } 396 }
402 } 397 }
403 398
404 if (critical_value > warning_value) { /* Normal thresholds */ 399 if (config.critical_value > config.warning_value) { /* Normal thresholds */
405 if (check_critical_value && counter_value >= critical_value) 400 if (config.check_critical_value && counter_value >= config.critical_value) {
406 return_code = STATE_CRITICAL; 401 return_code = STATE_CRITICAL;
407 else if (check_warning_value && counter_value >= warning_value) 402 } else if (config.check_warning_value && counter_value >= config.warning_value) {
408 return_code = STATE_WARNING; 403 return_code = STATE_WARNING;
409 else 404 } else {
410 return_code = STATE_OK; 405 return_code = STATE_OK;
406 }
411 } else { /* inverse thresholds */ 407 } else { /* inverse thresholds */
412 return_code = STATE_OK; 408 return_code = STATE_OK;
413 if (check_critical_value && counter_value <= critical_value) 409 if (config.check_critical_value && counter_value <= config.critical_value) {
414 return_code = STATE_CRITICAL; 410 return_code = STATE_CRITICAL;
415 else if (check_warning_value && counter_value <= warning_value) 411 } else if (config.check_warning_value && counter_value <= config.warning_value) {
416 return_code = STATE_WARNING; 412 return_code = STATE_WARNING;
413 }
417 } 414 }
418 break; 415 } break;
419
420 case CHECK_FILEAGE: 416 case CHECK_FILEAGE:
421 417 if (config.value_list == NULL) {
422 if (value_list == NULL)
423 output_message = strdup(_("No counter specified")); 418 output_message = strdup(_("No counter specified"));
424 else { 419 } else {
425 preparelist(value_list); /* replace , between services with & to send the request */ 420 preparelist(
426 xasprintf(&send_buffer, "%s&9&%s", req_password, value_list); 421 config.value_list); /* replace , between services with & to send the request */
427 fetch_data(server_address, server_port, send_buffer); 422 xasprintf(&send_buffer, "%s&9&%s", config.req_password, config.value_list);
428 age_in_minutes = atoi(strtok(recv_buffer, "&")); 423 fetch_data(config.server_address, config.server_port, send_buffer);
424 unsigned long age_in_minutes = atoi(strtok(recv_buffer, "&"));
429 description = strtok(NULL, "&"); 425 description = strtok(NULL, "&");
430 output_message = strdup(description); 426 output_message = strdup(description);
431 427
432 if (critical_value > warning_value) { /* Normal thresholds */ 428 if (config.critical_value > config.warning_value) { /* Normal thresholds */
433 if (check_critical_value && age_in_minutes >= critical_value) 429 if (config.check_critical_value && age_in_minutes >= config.critical_value) {
434 return_code = STATE_CRITICAL; 430 return_code = STATE_CRITICAL;
435 else if (check_warning_value && age_in_minutes >= warning_value) 431 } else if (config.check_warning_value && age_in_minutes >= config.warning_value) {
436 return_code = STATE_WARNING; 432 return_code = STATE_WARNING;
437 else 433 } else {
438 return_code = STATE_OK; 434 return_code = STATE_OK;
435 }
439 } else { /* inverse thresholds */ 436 } else { /* inverse thresholds */
440 if (check_critical_value && age_in_minutes <= critical_value) 437 if (config.check_critical_value && age_in_minutes <= config.critical_value) {
441 return_code = STATE_CRITICAL; 438 return_code = STATE_CRITICAL;
442 else if (check_warning_value && age_in_minutes <= warning_value) 439 } else if (config.check_warning_value && age_in_minutes <= config.warning_value) {
443 return_code = STATE_WARNING; 440 return_code = STATE_WARNING;
444 else 441 } else {
445 return_code = STATE_OK; 442 return_code = STATE_OK;
443 }
446 } 444 }
447 } 445 }
448 break; 446 break;
449 447
450 case CHECK_INSTANCES: 448 case CHECK_INSTANCES:
451 if (value_list == NULL) 449 if (config.value_list == NULL) {
452 output_message = strdup(_("No counter specified")); 450 output_message = strdup(_("No counter specified"));
453 else { 451 } else {
454 xasprintf(&send_buffer, "%s&10&%s", req_password, value_list); 452 xasprintf(&send_buffer, "%s&10&%s", config.req_password, config.value_list);
455 fetch_data(server_address, server_port, send_buffer); 453 fetch_data(config.server_address, config.server_port, send_buffer);
456 if (!strncmp(recv_buffer, "ERROR", 5)) { 454 if (!strncmp(recv_buffer, "ERROR", 5)) {
457 printf("NSClient - %s\n", recv_buffer); 455 printf("NSClient - %s\n", recv_buffer);
458 exit(STATE_UNKNOWN); 456 exit(STATE_UNKNOWN);
@@ -471,18 +469,16 @@ int main(int argc, char **argv) {
471 /* reset timeout */ 469 /* reset timeout */
472 alarm(0); 470 alarm(0);
473 471
474 if (perfdata == NULL) 472 if (perfdata == NULL) {
475 printf("%s\n", output_message); 473 printf("%s\n", output_message);
476 else 474 } else {
477 printf("%s | %s\n", output_message, perfdata); 475 printf("%s | %s\n", output_message, perfdata);
476 }
478 return return_code; 477 return return_code;
479} 478}
480 479
481/* process command-line arguments */ 480/* process command-line arguments */
482int process_arguments(int argc, char **argv) { 481check_nt_config_wrapper process_arguments(int argc, char **argv) {
483 int c;
484
485 int option = 0;
486 static struct option longopts[] = {{"port", required_argument, 0, 'p'}, 482 static struct option longopts[] = {{"port", required_argument, 0, 'p'},
487 {"timeout", required_argument, 0, 't'}, 483 {"timeout", required_argument, 0, 't'},
488 {"critical", required_argument, 0, 'c'}, 484 {"critical", required_argument, 0, 'c'},
@@ -497,34 +493,44 @@ int process_arguments(int argc, char **argv) {
497 {"help", no_argument, 0, 'h'}, 493 {"help", no_argument, 0, 'h'},
498 {0, 0, 0, 0}}; 494 {0, 0, 0, 0}};
499 495
496 check_nt_config_wrapper result = {
497 .errorcode = OK,
498 .config = check_nt_config_init(),
499 };
500
500 /* no options were supplied */ 501 /* no options were supplied */
501 if (argc < 2) 502 if (argc < 2) {
502 return ERROR; 503 result.errorcode = ERROR;
504 return result;
505 }
503 506
504 /* backwards compatibility */ 507 /* backwards compatibility */
505 if (!is_option(argv[1])) { 508 if (!is_option(argv[1])) {
506 server_address = strdup(argv[1]); 509 result.config.server_address = strdup(argv[1]);
507 argv[1] = argv[0]; 510 argv[1] = argv[0];
508 argv = &argv[1]; 511 argv = &argv[1];
509 argc--; 512 argc--;
510 } 513 }
511 514
512 for (c = 1; c < argc; c++) { 515 for (int index = 1; index < argc; index++) {
513 if (strcmp("-to", argv[c]) == 0) 516 if (strcmp("-to", argv[index]) == 0) {
514 strcpy(argv[c], "-t"); 517 strcpy(argv[index], "-t");
515 else if (strcmp("-wv", argv[c]) == 0) 518 } else if (strcmp("-wv", argv[index]) == 0) {
516 strcpy(argv[c], "-w"); 519 strcpy(argv[index], "-w");
517 else if (strcmp("-cv", argv[c]) == 0) 520 } else if (strcmp("-cv", argv[index]) == 0) {
518 strcpy(argv[c], "-c"); 521 strcpy(argv[index], "-c");
522 }
519 } 523 }
520 524
521 while (1) { 525 int option = 0;
522 c = getopt_long(argc, argv, "+hVH:t:c:w:p:v:l:s:d:u", longopts, &option); 526 while (true) {
527 int option_index = getopt_long(argc, argv, "+hVH:t:c:w:p:v:l:s:d:u", longopts, &option);
523 528
524 if (c == -1 || c == EOF || c == 1) 529 if (option_index == -1 || option_index == EOF || option_index == 1) {
525 break; 530 break;
531 }
526 532
527 switch (c) { 533 switch (option_index) {
528 case '?': /* print short usage statement if args not parsable */ 534 case '?': /* print short usage statement if args not parsable */
529 usage5(); 535 usage5();
530 case 'h': /* help */ 536 case 'h': /* help */
@@ -534,118 +540,128 @@ int process_arguments(int argc, char **argv) {
534 print_revision(progname, NP_VERSION); 540 print_revision(progname, NP_VERSION);
535 exit(STATE_UNKNOWN); 541 exit(STATE_UNKNOWN);
536 case 'H': /* hostname */ 542 case 'H': /* hostname */
537 server_address = optarg; 543 result.config.server_address = optarg;
538 break; 544 break;
539 case 's': /* password */ 545 case 's': /* password */
540 req_password = optarg; 546 result.config.req_password = optarg;
541 break; 547 break;
542 case 'p': /* port */ 548 case 'p': /* port */
543 if (is_intnonneg(optarg)) 549 if (is_intnonneg(optarg)) {
544 server_port = atoi(optarg); 550 result.config.server_port = atoi(optarg);
545 else 551 } else {
546 die(STATE_UNKNOWN, _("Server port must be an integer\n")); 552 die(STATE_UNKNOWN, _("Server port must be an integer\n"));
553 }
547 break; 554 break;
548 case 'v': 555 case 'v':
549 if (strlen(optarg) < 4) 556 if (strlen(optarg) < 4) {
550 return ERROR; 557 result.errorcode = ERROR;
551 if (!strcmp(optarg, "CLIENTVERSION")) 558 return result;
552 vars_to_check = CHECK_CLIENTVERSION; 559 }
553 else if (!strcmp(optarg, "CPULOAD")) 560 if (!strcmp(optarg, "CLIENTVERSION")) {
554 vars_to_check = CHECK_CPULOAD; 561 result.config.vars_to_check = CHECK_CLIENTVERSION;
555 else if (!strcmp(optarg, "UPTIME")) 562 } else if (!strcmp(optarg, "CPULOAD")) {
556 vars_to_check = CHECK_UPTIME; 563 result.config.vars_to_check = CHECK_CPULOAD;
557 else if (!strcmp(optarg, "USEDDISKSPACE")) 564 } else if (!strcmp(optarg, "UPTIME")) {
558 vars_to_check = CHECK_USEDDISKSPACE; 565 result.config.vars_to_check = CHECK_UPTIME;
559 else if (!strcmp(optarg, "SERVICESTATE")) 566 } else if (!strcmp(optarg, "USEDDISKSPACE")) {
560 vars_to_check = CHECK_SERVICESTATE; 567 result.config.vars_to_check = CHECK_USEDDISKSPACE;
561 else if (!strcmp(optarg, "PROCSTATE")) 568 } else if (!strcmp(optarg, "SERVICESTATE")) {
562 vars_to_check = CHECK_PROCSTATE; 569 result.config.vars_to_check = CHECK_SERVICESTATE;
563 else if (!strcmp(optarg, "MEMUSE")) 570 } else if (!strcmp(optarg, "PROCSTATE")) {
564 vars_to_check = CHECK_MEMUSE; 571 result.config.vars_to_check = CHECK_PROCSTATE;
565 else if (!strcmp(optarg, "COUNTER")) 572 } else if (!strcmp(optarg, "MEMUSE")) {
566 vars_to_check = CHECK_COUNTER; 573 result.config.vars_to_check = CHECK_MEMUSE;
567 else if (!strcmp(optarg, "FILEAGE")) 574 } else if (!strcmp(optarg, "COUNTER")) {
568 vars_to_check = CHECK_FILEAGE; 575 result.config.vars_to_check = CHECK_COUNTER;
569 else if (!strcmp(optarg, "INSTANCES")) 576 } else if (!strcmp(optarg, "FILEAGE")) {
570 vars_to_check = CHECK_INSTANCES; 577 result.config.vars_to_check = CHECK_FILEAGE;
571 else 578 } else if (!strcmp(optarg, "INSTANCES")) {
572 return ERROR; 579 result.config.vars_to_check = CHECK_INSTANCES;
580 } else {
581 result.errorcode = ERROR;
582 return result;
583 }
573 break; 584 break;
574 case 'l': /* value list */ 585 case 'l': /* value list */
575 value_list = optarg; 586 result.config.value_list = optarg;
576 break; 587 break;
577 case 'w': /* warning threshold */ 588 case 'w': /* warning threshold */
578 warning_value = strtoul(optarg, NULL, 10); 589 result.config.warning_value = strtoul(optarg, NULL, 10);
579 check_warning_value = true; 590 result.config.check_warning_value = true;
580 break; 591 break;
581 case 'c': /* critical threshold */ 592 case 'c': /* critical threshold */
582 critical_value = strtoul(optarg, NULL, 10); 593 result.config.critical_value = strtoul(optarg, NULL, 10);
583 check_critical_value = true; 594 result.config.check_critical_value = true;
584 break; 595 break;
585 case 'd': /* Display select for services */ 596 case 'd': /* Display select for services */
586 if (!strcmp(optarg, "SHOWALL")) 597 if (!strcmp(optarg, "SHOWALL")) {
587 show_all = true; 598 result.config.show_all = true;
599 }
588 break; 600 break;
589 case 'u': 601 case 'u':
590 socket_timeout_state = STATE_UNKNOWN; 602 socket_timeout_state = STATE_UNKNOWN;
591 break; 603 break;
592 case 't': /* timeout */ 604 case 't': /* timeout */
593 socket_timeout = atoi(optarg); 605 socket_timeout = atoi(optarg);
594 if (socket_timeout <= 0) 606 if (socket_timeout <= 0) {
595 return ERROR; 607 result.errorcode = ERROR;
608 return result;
609 }
596 } 610 }
597 } 611 }
598 if (server_address == NULL) 612 if (result.config.server_address == NULL) {
599 usage4(_("You must provide a server address or host name")); 613 usage4(_("You must provide a server address or host name"));
614 }
600 615
601 if (vars_to_check == CHECK_NONE) 616 if (result.config.vars_to_check == CHECK_NONE) {
602 return ERROR; 617 result.errorcode = ERROR;
618 return result;
619 }
603 620
604 if (req_password == NULL) 621 if (result.config.req_password == NULL) {
605 req_password = strdup(_("None")); 622 result.config.req_password = strdup(_("None"));
623 }
606 624
607 return OK; 625 return result;
608} 626}
609 627
610void fetch_data(const char *address, int port, const char *sendb) { 628void fetch_data(const char *address, int port, const char *sendb) {
611 int result; 629 int result = process_tcp_request(address, port, sendb, recv_buffer, sizeof(recv_buffer));
612
613 result = process_tcp_request(address, port, sendb, recv_buffer, sizeof(recv_buffer));
614 630
615 if (result != STATE_OK) 631 if (result != STATE_OK) {
616 die(result, _("could not fetch information from server\n")); 632 die(result, _("could not fetch information from server\n"));
633 }
617 634
618 if (!strncmp(recv_buffer, "ERROR", 5)) 635 if (!strncmp(recv_buffer, "ERROR", 5)) {
619 die(STATE_UNKNOWN, "NSClient - %s\n", recv_buffer); 636 die(STATE_UNKNOWN, "NSClient - %s\n", recv_buffer);
637 }
620} 638}
621 639
622bool strtoularray(unsigned long *array, char *string, const char *delim) { 640bool strtoularray(unsigned long *array, char *string, const char *delim) {
623 /* split a <delim> delimited string into a long array */ 641 /* split a <delim> delimited string into a long array */
624 int idx = 0; 642 for (int idx = 0; idx < MAX_VALUE_LIST; idx++) {
625 char *t1;
626
627 for (idx = 0; idx < MAX_VALUE_LIST; idx++)
628 array[idx] = 0; 643 array[idx] = 0;
644 }
629 645
630 idx = 0; 646 int idx = 0;
631 for (t1 = strtok(string, delim); t1 != NULL; t1 = strtok(NULL, delim)) { 647 for (char *t1 = strtok(string, delim); t1 != NULL; t1 = strtok(NULL, delim)) {
632 if (is_numeric(t1) && idx < MAX_VALUE_LIST) { 648 if (is_numeric(t1) && idx < MAX_VALUE_LIST) {
633 array[idx] = strtoul(t1, NULL, 10); 649 array[idx] = strtoul(t1, NULL, 10);
634 idx++; 650 idx++;
635 } else 651 } else {
636 return false; 652 return false;
653 }
637 } 654 }
638 return true; 655 return true;
639} 656}
640 657
641void preparelist(char *string) { 658void preparelist(char *string) {
642 /* Replace all , with & which is the delimiter for the request */ 659 /* Replace all , with & which is the delimiter for the request */
643 int i; 660 for (int i = 0; (size_t)i < strlen(string); i++) {
644
645 for (i = 0; (size_t)i < strlen(string); i++)
646 if (string[i] == ',') { 661 if (string[i] == ',') {
647 string[i] = '&'; 662 string[i] = '&';
648 } 663 }
664 }
649} 665}
650 666
651void print_help(void) { 667void print_help(void) {
@@ -735,25 +751,31 @@ void print_help(void) {
735 printf(" %s\n", "\"%%.f %%%% paging file used.\""); 751 printf(" %s\n", "\"%%.f %%%% paging file used.\"");
736 printf(" %s\n", "INSTANCES ="); 752 printf(" %s\n", "INSTANCES =");
737 printf(" %s\n", _("Check any performance counter object of Windows NT/2000.")); 753 printf(" %s\n", _("Check any performance counter object of Windows NT/2000."));
738 printf(" %s\n", _("Syntax: check_nt -H <hostname> -p <port> -v INSTANCES -l <counter object>")); 754 printf(" %s\n",
755 _("Syntax: check_nt -H <hostname> -p <port> -v INSTANCES -l <counter object>"));
739 printf(" %s\n", _("<counter object> is a Windows Perfmon Counter object (eg. Process),")); 756 printf(" %s\n", _("<counter object> is a Windows Perfmon Counter object (eg. Process),"));
740 printf(" %s\n", _("if it is two words, it should be enclosed in quotes")); 757 printf(" %s\n", _("if it is two words, it should be enclosed in quotes"));
741 printf(" %s\n", _("The returned results will be a comma-separated list of instances on ")); 758 printf(" %s\n", _("The returned results will be a comma-separated list of instances on "));
742 printf(" %s\n", _(" the selected computer for that object.")); 759 printf(" %s\n", _(" the selected computer for that object."));
743 printf(" %s\n", _("The purpose of this is to be run from command line to determine what instances")); 760 printf(" %s\n",
744 printf(" %s\n", _(" are available for monitoring without having to log onto the Windows server")); 761 _("The purpose of this is to be run from command line to determine what instances"));
762 printf(" %s\n",
763 _(" are available for monitoring without having to log onto the Windows server"));
745 printf(" %s\n", _(" to run Perfmon directly.")); 764 printf(" %s\n", _(" to run Perfmon directly."));
746 printf(" %s\n", _("It can also be used in scripts that automatically create the monitoring service")); 765 printf(" %s\n",
766 _("It can also be used in scripts that automatically create the monitoring service"));
747 printf(" %s\n", _(" configuration files.")); 767 printf(" %s\n", _(" configuration files."));
748 printf(" %s\n", _("Some examples:")); 768 printf(" %s\n", _("Some examples:"));
749 printf(" %s\n\n", _("check_nt -H 192.168.1.1 -p 1248 -v INSTANCES -l Process")); 769 printf(" %s\n\n", _("check_nt -H 192.168.1.1 -p 1248 -v INSTANCES -l Process"));
750 770
751 printf("%s\n", _("Notes:")); 771 printf("%s\n", _("Notes:"));
752 printf(" %s\n", _("- The NSClient service should be running on the server to get any information")); 772 printf(" %s\n",
773 _("- The NSClient service should be running on the server to get any information"));
753 printf(" %s\n", "(http://nsclient.ready2run.nl)."); 774 printf(" %s\n", "(http://nsclient.ready2run.nl).");
754 printf(" %s\n", _("- Critical thresholds should be lower than warning thresholds")); 775 printf(" %s\n", _("- Critical thresholds should be lower than warning thresholds"));
755 printf(" %s\n", _("- Default port 1248 is sometimes in use by other services. The error")); 776 printf(" %s\n", _("- Default port 1248 is sometimes in use by other services. The error"));
756 printf(" %s\n", _("output when this happens contains \"Cannot map xxxxx to protocol number\".")); 777 printf(" %s\n",
778 _("output when this happens contains \"Cannot map xxxxx to protocol number\"."));
757 printf(" %s\n", _("One fix for this is to change the port to something else on check_nt ")); 779 printf(" %s\n", _("One fix for this is to change the port to something else on check_nt "));
758 printf(" %s\n", _("and on the client service it\'s connecting to.")); 780 printf(" %s\n", _("and on the client service it\'s connecting to."));
759 781