summaryrefslogtreecommitdiffstats
path: root/plugins/check_nwstat.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_nwstat.c')
-rw-r--r--plugins/check_nwstat.c2151
1 files changed, 969 insertions, 1182 deletions
diff --git a/plugins/check_nwstat.c b/plugins/check_nwstat.c
index 10c493b..176dfbc 100644
--- a/plugins/check_nwstat.c
+++ b/plugins/check_nwstat.c
@@ -1,36 +1,36 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2 *
3* Monitoring check_nwstat plugin 3 * Monitoring check_nwstat plugin
4* 4 *
5* License: GPL 5 * License: GPL
6* Copyright (c) 2000-2007 Monitoring Plugins Development Team 6 * Copyright (c) 2000-2024 Monitoring Plugins Development Team
7* 7 *
8* Description: 8 * Description:
9* 9 *
10* This file contains the check_nwstat plugin 10 * This file contains the check_nwstat plugin
11* 11 *
12* This plugin attempts to contact the MRTGEXT NLM running on a 12 * This plugin attempts to contact the MRTGEXT NLM running on a
13* Novell server to gather the requested system information. 13 * Novell server to gather the requested system information.
14* 14 *
15* 15 *
16* This program is free software: you can redistribute it and/or modify 16 * This program is free software: you can redistribute it and/or modify
17* it under the terms of the GNU General Public License as published by 17 * it under the terms of the GNU General Public License as published by
18* the Free Software Foundation, either version 3 of the License, or 18 * the Free Software Foundation, either version 3 of the License, or
19* (at your option) any later version. 19 * (at your option) any later version.
20* 20 *
21* This program is distributed in the hope that it will be useful, 21 * This program is distributed in the hope that it will be useful,
22* but WITHOUT ANY WARRANTY; without even the implied warranty of 22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24* GNU General Public License for more details. 24 * GNU General Public License for more details.
25* 25 *
26* You should have received a copy of the GNU General Public License 26 * You should have received a copy of the GNU General Public License
27* along with this program. If not, see <http://www.gnu.org/licenses/>. 27 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28* 28 *
29* 29 *
30*****************************************************************************/ 30 *****************************************************************************/
31 31
32const char *progname = "check_nwstat"; 32const char *progname = "check_nwstat";
33const char *copyright = "2000-2007"; 33const char *copyright = "2000-2024";
34const char *email = "devel@monitoring-plugins.org"; 34const char *email = "devel@monitoring-plugins.org";
35 35
36#include "common.h" 36#include "common.h"
@@ -44,10 +44,10 @@ enum checkvar {
44 LOAD15, /* check 15 minute CPU load */ 44 LOAD15, /* check 15 minute CPU load */
45 CONNS, /* check number of connections */ 45 CONNS, /* check number of connections */
46 VPF, /* check % free space on volume */ 46 VPF, /* check % free space on volume */
47 VMF, /* check MB free space on volume */ 47 VMF, /* check MB free space on volume */
48 VMU, /* check MB used space on volume */ 48 VMU, /* check MB used space on volume */
49 VPU, /* check % used space on volume */ 49 VPU, /* check % used space on volume */
50 VMP, /* check MB purgeable space on volume */ 50 VMP, /* check MB purgeable space on volume */
51 VKF, /* check KB free space on volume */ 51 VKF, /* check KB free space on volume */
52 LTCH, /* check long-term cache hit percentage */ 52 LTCH, /* check long-term cache hit percentage */
53 CBUFF, /* check total cache buffers */ 53 CBUFF, /* check total cache buffers */
@@ -55,7 +55,7 @@ enum checkvar {
55 LRUM, /* check LRU sitting time in minutes */ 55 LRUM, /* check LRU sitting time in minutes */
56 DSDB, /* check to see if DS Database is open */ 56 DSDB, /* check to see if DS Database is open */
57 LOGINS, /* check to see if logins are enabled */ 57 LOGINS, /* check to see if logins are enabled */
58 NRMH, /* check to see NRM Health Status */ 58 NRMH, /* check to see NRM Health Status */
59 PUPRB, /* check % of used packet receive buffers */ 59 PUPRB, /* check % of used packet receive buffers */
60 UPRB, /* check used packet receive buffers */ 60 UPRB, /* check used packet receive buffers */
61 SAPENTRIES, /* check SAP entries */ 61 SAPENTRIES, /* check SAP entries */
@@ -73,8 +73,8 @@ enum checkvar {
73 DSVER, /* check NDS version */ 73 DSVER, /* check NDS version */
74 UPTIME, /* check server uptime */ 74 UPTIME, /* check server uptime */
75 NLM, /* check NLM loaded */ 75 NLM, /* check NLM loaded */
76 NRMP, /* check NRM Process Values */ 76 NRMP, /* check NRM Process Values */
77 NRMM, /* check NRM Memory Values */ 77 NRMM, /* check NRM Memory Values */
78 NRMS, /* check NRM Values */ 78 NRMS, /* check NRM Values */
79 NSS1, /* check Statistics from _Admin:Manage_NSS\GeneralStats.xml */ 79 NSS1, /* check Statistics from _Admin:Manage_NSS\GeneralStats.xml */
80 NSS2, /* check Statistics from _Admin:Manage_NSS\BufferCache.xml */ 80 NSS2, /* check Statistics from _Admin:Manage_NSS\BufferCache.xml */
@@ -89,1652 +89,1439 @@ enum {
89 PORT = 9999 89 PORT = 9999
90}; 90};
91 91
92char *server_address=NULL; 92static char *server_address = NULL;
93char *volume_name=NULL; 93static char *volume_name = NULL;
94char *nlm_name=NULL; 94static char *nlm_name = NULL;
95char *nrmp_name=NULL; 95static char *nrmp_name = NULL;
96char *nrmm_name=NULL; 96static char *nrmm_name = NULL;
97char *nrms_name=NULL; 97static char *nrms_name = NULL;
98char *nss1_name=NULL; 98static char *nss1_name = NULL;
99char *nss2_name=NULL; 99static char *nss2_name = NULL;
100char *nss3_name=NULL; 100static char *nss3_name = NULL;
101char *nss4_name=NULL; 101static char *nss4_name = NULL;
102char *nss5_name=NULL; 102static char *nss5_name = NULL;
103char *nss6_name=NULL; 103static char *nss6_name = NULL;
104char *nss7_name=NULL; 104static char *nss7_name = NULL;
105int server_port=PORT; 105static int server_port = PORT;
106unsigned long warning_value=0L; 106static unsigned long warning_value = 0L;
107unsigned long critical_value=0L; 107static unsigned long critical_value = 0L;
108bool check_warning_value = false; 108static bool check_warning_value = false;
109bool check_critical_value = false; 109static bool check_critical_value = false;
110bool check_netware_version = false; 110static bool check_netware_version = false;
111enum checkvar vars_to_check = NONE; 111static enum checkvar vars_to_check = NONE;
112int sap_number=-1; 112static int sap_number = -1;
113 113
114int process_arguments(int, char **); 114static int process_arguments(int /*argc*/, char ** /*argv*/);
115void print_help(void); 115static void print_help(void);
116void print_usage(void); 116void print_usage(void);
117 117
118 118int main(int argc, char **argv) {
119
120int
121main(int argc, char **argv) {
122 int result = STATE_UNKNOWN; 119 int result = STATE_UNKNOWN;
123 int sd; 120 int sd;
124 char *send_buffer=NULL; 121 char *send_buffer = NULL;
125 char recv_buffer[MAX_INPUT_BUFFER]; 122 char recv_buffer[MAX_INPUT_BUFFER];
126 char *output_message=NULL; 123 char *output_message = NULL;
127 char *temp_buffer=NULL; 124 char *temp_buffer = NULL;
128 char *netware_version=NULL; 125 char *netware_version = NULL;
129 126
130 int time_sync_status=0; 127 int time_sync_status = 0;
131 int nrm_health_status=0; 128 int nrm_health_status = 0;
132 unsigned long total_cache_buffers=0; 129 unsigned long total_cache_buffers = 0;
133 unsigned long dirty_cache_buffers=0; 130 unsigned long dirty_cache_buffers = 0;
134 unsigned long open_files=0; 131 unsigned long open_files = 0;
135 unsigned long abended_threads=0; 132 unsigned long abended_threads = 0;
136 unsigned long max_service_processes=0; 133 unsigned long max_service_processes = 0;
137 unsigned long current_service_processes=0; 134 unsigned long current_service_processes = 0;
138 unsigned long free_disk_space=0L; 135 unsigned long free_disk_space = 0L;
139 unsigned long nrmp_value=0L; 136 unsigned long nrmp_value = 0L;
140 unsigned long nrmm_value=0L; 137 unsigned long nrmm_value = 0L;
141 unsigned long nrms_value=0L; 138 unsigned long nrms_value = 0L;
142 unsigned long nss1_value=0L; 139 unsigned long nss1_value = 0L;
143 unsigned long nss2_value=0L; 140 unsigned long nss2_value = 0L;
144 unsigned long nss3_value=0L; 141 unsigned long nss3_value = 0L;
145 unsigned long nss4_value=0L; 142 unsigned long nss4_value = 0L;
146 unsigned long nss5_value=0L; 143 unsigned long nss5_value = 0L;
147 unsigned long nss6_value=0L; 144 unsigned long nss6_value = 0L;
148 unsigned long nss7_value=0L; 145 unsigned long nss7_value = 0L;
149 unsigned long total_disk_space=0L; 146 unsigned long total_disk_space = 0L;
150 unsigned long used_disk_space=0L; 147 unsigned long used_disk_space = 0L;
151 unsigned long percent_used_disk_space=0L; 148 unsigned long percent_used_disk_space = 0L;
152 unsigned long purgeable_disk_space=0L; 149 unsigned long purgeable_disk_space = 0L;
153 unsigned long non_purgeable_disk_space=0L; 150 unsigned long non_purgeable_disk_space = 0L;
154 unsigned long percent_free_space=0; 151 unsigned long percent_free_space = 0;
155 unsigned long percent_purgeable_space=0; 152 unsigned long percent_purgeable_space = 0;
156 unsigned long percent_non_purgeable_space=0; 153 unsigned long percent_non_purgeable_space = 0;
157 unsigned long current_connections=0L; 154 unsigned long current_connections = 0L;
158 unsigned long utilization=0L; 155 unsigned long utilization = 0L;
159 unsigned long cache_hits=0; 156 unsigned long cache_hits = 0;
160 unsigned long cache_buffers=0L; 157 unsigned long cache_buffers = 0L;
161 unsigned long lru_time=0L; 158 unsigned long lru_time = 0L;
162 unsigned long max_packet_receive_buffers=0; 159 unsigned long max_packet_receive_buffers = 0;
163 unsigned long used_packet_receive_buffers=0; 160 unsigned long used_packet_receive_buffers = 0;
164 unsigned long percent_used_packet_receive_buffers=0L; 161 unsigned long percent_used_packet_receive_buffers = 0L;
165 unsigned long sap_entries=0; 162 unsigned long sap_entries = 0;
166 char uptime[MAX_INPUT_BUFFER]; 163 char uptime[MAX_INPUT_BUFFER];
167 164
168 setlocale (LC_ALL, ""); 165 setlocale(LC_ALL, "");
169 bindtextdomain (PACKAGE, LOCALEDIR); 166 bindtextdomain(PACKAGE, LOCALEDIR);
170 textdomain (PACKAGE); 167 textdomain(PACKAGE);
171 168
172 /* Parse extra opts if any */ 169 /* Parse extra opts if any */
173 argv=np_extra_opts(&argc, argv, progname); 170 argv = np_extra_opts(&argc, argv, progname);
174 171
175 if (process_arguments(argc,argv) == ERROR) 172 if (process_arguments(argc, argv) == ERROR)
176 usage4 (_("Could not parse arguments")); 173 usage4(_("Could not parse arguments"));
177 174
178 /* initialize alarm signal handling */ 175 /* initialize alarm signal handling */
179 signal(SIGALRM,socket_timeout_alarm_handler); 176 signal(SIGALRM, socket_timeout_alarm_handler);
180 177
181 /* set socket timeout */ 178 /* set socket timeout */
182 alarm(socket_timeout); 179 alarm(socket_timeout);
183 180
184 /* open connection */ 181 /* open connection */
185 my_tcp_connect (server_address, server_port, &sd); 182 my_tcp_connect(server_address, server_port, &sd);
186 183
187 /* get OS version string */ 184 /* get OS version string */
188 if (check_netware_version) { 185 if (check_netware_version) {
189 send_buffer = strdup ("S19\r\n"); 186 send_buffer = strdup("S19\r\n");
190 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 187 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
191 if (result!=STATE_OK) 188 if (result != STATE_OK)
192 return result; 189 return result;
193 if (!strcmp(recv_buffer,"-1\n")) 190 if (!strcmp(recv_buffer, "-1\n"))
194 netware_version = strdup(""); 191 netware_version = strdup("");
195 else { 192 else {
196 recv_buffer[strlen(recv_buffer)-1]=0; 193 recv_buffer[strlen(recv_buffer) - 1] = 0;
197 xasprintf (&netware_version,_("NetWare %s: "),recv_buffer); 194 xasprintf(&netware_version, _("NetWare %s: "), recv_buffer);
198 } 195 }
199 } else 196 } else
200 netware_version = strdup(""); 197 netware_version = strdup("");
201 198
202
203 /* check CPU load */ 199 /* check CPU load */
204 if (vars_to_check==LOAD1 || vars_to_check==LOAD5 || vars_to_check==LOAD15) { 200 if (vars_to_check == LOAD1 || vars_to_check == LOAD5 || vars_to_check == LOAD15) {
205 201
206 switch(vars_to_check) { 202 switch (vars_to_check) {
207 case LOAD1: 203 case LOAD1:
208 temp_buffer = strdup ("1"); 204 temp_buffer = strdup("1");
209 break; 205 break;
210 case LOAD5: 206 case LOAD5:
211 temp_buffer = strdup ("5"); 207 temp_buffer = strdup("5");
212 break; 208 break;
213 default: 209 default:
214 temp_buffer = strdup ("15"); 210 temp_buffer = strdup("15");
215 break; 211 break;
216 } 212 }
217 213
218 close(sd); 214 close(sd);
219 my_tcp_connect (server_address, server_port, &sd); 215 my_tcp_connect(server_address, server_port, &sd);
220 216
221 xasprintf (&send_buffer,"UTIL%s\r\n",temp_buffer); 217 xasprintf(&send_buffer, "UTIL%s\r\n", temp_buffer);
222 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 218 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
223 if (result!=STATE_OK) 219 if (result != STATE_OK)
224 return result; 220 return result;
225 utilization=strtoul(recv_buffer,NULL,10); 221 utilization = strtoul(recv_buffer, NULL, 10);
226 222
227 close(sd); 223 close(sd);
228 my_tcp_connect (server_address, server_port, &sd); 224 my_tcp_connect(server_address, server_port, &sd);
229 225
230 send_buffer = strdup ("UPTIME\r\n"); 226 send_buffer = strdup("UPTIME\r\n");
231 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 227 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
232 if (result!=STATE_OK) 228 if (result != STATE_OK)
233 return result; 229 return result;
234 recv_buffer[strlen(recv_buffer)-1]=0; 230 recv_buffer[strlen(recv_buffer) - 1] = 0;
235 sprintf(uptime,_("Up %s,"),recv_buffer); 231 sprintf(uptime, _("Up %s,"), recv_buffer);
236 232
237 if (check_critical_value && utilization >= critical_value) 233 if (check_critical_value && utilization >= critical_value)
238 result=STATE_CRITICAL; 234 result = STATE_CRITICAL;
239 else if (check_warning_value && utilization >= warning_value) 235 else if (check_warning_value && utilization >= warning_value)
240 result=STATE_WARNING; 236 result = STATE_WARNING;
241 237
242 xasprintf (&output_message, 238 xasprintf(&output_message, _("Load %s - %s %s-min load average = %lu%%|load%s=%lu;%lu;%lu;0;100"), state_text(result), uptime,
243 _("Load %s - %s %s-min load average = %lu%%|load%s=%lu;%lu;%lu;0;100"), 239 temp_buffer, utilization, temp_buffer, utilization, warning_value, critical_value);
244 state_text(result),
245 uptime,
246 temp_buffer,
247 utilization,
248 temp_buffer,
249 utilization,
250 warning_value,
251 critical_value);
252 240
253 /* check number of user connections */ 241 /* check number of user connections */
254 } else if (vars_to_check==CONNS) { 242 } else if (vars_to_check == CONNS) {
255 243
256 close(sd); 244 close(sd);
257 my_tcp_connect (server_address, server_port, &sd); 245 my_tcp_connect(server_address, server_port, &sd);
258 246
259 send_buffer = strdup ("CONNECT\r\n"); 247 send_buffer = strdup("CONNECT\r\n");
260 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 248 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
261 if (result!=STATE_OK) 249 if (result != STATE_OK)
262 return result; 250 return result;
263 current_connections=strtoul(recv_buffer,NULL,10); 251 current_connections = strtoul(recv_buffer, NULL, 10);
264 252
265 if (check_critical_value && current_connections >= critical_value) 253 if (check_critical_value && current_connections >= critical_value)
266 result=STATE_CRITICAL; 254 result = STATE_CRITICAL;
267 else if (check_warning_value && current_connections >= warning_value) 255 else if (check_warning_value && current_connections >= warning_value)
268 result=STATE_WARNING; 256 result = STATE_WARNING;
269 257
270 xasprintf (&output_message, 258 xasprintf(&output_message, _("Conns %s - %lu current connections|Conns=%lu;%lu;%lu;;"), state_text(result), current_connections,
271 _("Conns %s - %lu current connections|Conns=%lu;%lu;%lu;;"), 259 current_connections, warning_value, critical_value);
272 state_text(result),
273 current_connections,
274 current_connections,
275 warning_value,
276 critical_value);
277 260
278 /* check % long term cache hits */ 261 /* check % long term cache hits */
279 } else if (vars_to_check==LTCH) { 262 } else if (vars_to_check == LTCH) {
280 263
281 close(sd); 264 close(sd);
282 my_tcp_connect (server_address, server_port, &sd); 265 my_tcp_connect(server_address, server_port, &sd);
283 266
284 send_buffer = strdup ("S1\r\n"); 267 send_buffer = strdup("S1\r\n");
285 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 268 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
286 if (result!=STATE_OK) 269 if (result != STATE_OK)
287 return result; 270 return result;
288 cache_hits=atoi(recv_buffer); 271 cache_hits = atoi(recv_buffer);
289 272
290 if (check_critical_value && cache_hits <= critical_value) 273 if (check_critical_value && cache_hits <= critical_value)
291 result=STATE_CRITICAL; 274 result = STATE_CRITICAL;
292 else if (check_warning_value && cache_hits <= warning_value) 275 else if (check_warning_value && cache_hits <= warning_value)
293 result=STATE_WARNING; 276 result = STATE_WARNING;
294 277
295 xasprintf (&output_message, 278 xasprintf(&output_message, _("%s: Long term cache hits = %lu%%"), state_text(result), cache_hits);
296 _("%s: Long term cache hits = %lu%%"),
297 state_text(result),
298 cache_hits);
299 279
300 /* check cache buffers */ 280 /* check cache buffers */
301 } else if (vars_to_check==CBUFF) { 281 } else if (vars_to_check == CBUFF) {
302 282
303 close(sd); 283 close(sd);
304 my_tcp_connect (server_address, server_port, &sd); 284 my_tcp_connect(server_address, server_port, &sd);
305 285
306 send_buffer = strdup ("S2\r\n"); 286 send_buffer = strdup("S2\r\n");
307 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 287 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
308 if (result!=STATE_OK) 288 if (result != STATE_OK)
309 return result; 289 return result;
310 cache_buffers=strtoul(recv_buffer,NULL,10); 290 cache_buffers = strtoul(recv_buffer, NULL, 10);
311 291
312 if (check_critical_value && cache_buffers <= critical_value) 292 if (check_critical_value && cache_buffers <= critical_value)
313 result=STATE_CRITICAL; 293 result = STATE_CRITICAL;
314 else if (check_warning_value && cache_buffers <= warning_value) 294 else if (check_warning_value && cache_buffers <= warning_value)
315 result=STATE_WARNING; 295 result = STATE_WARNING;
316 296
317 xasprintf (&output_message, 297 xasprintf(&output_message, _("%s: Total cache buffers = %lu|Cachebuffers=%lu;%lu;%lu;;"), state_text(result), cache_buffers,
318 _("%s: Total cache buffers = %lu|Cachebuffers=%lu;%lu;%lu;;"), 298 cache_buffers, warning_value, critical_value);
319 state_text(result),
320 cache_buffers,
321 cache_buffers,
322 warning_value,
323 critical_value);
324 299
325 /* check dirty cache buffers */ 300 /* check dirty cache buffers */
326 } else if (vars_to_check==CDBUFF) { 301 } else if (vars_to_check == CDBUFF) {
327 302
328 close(sd); 303 close(sd);
329 my_tcp_connect (server_address, server_port, &sd); 304 my_tcp_connect(server_address, server_port, &sd);
330 305
331 send_buffer = strdup ("S3\r\n"); 306 send_buffer = strdup("S3\r\n");
332 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 307 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
333 if (result!=STATE_OK) 308 if (result != STATE_OK)
334 return result; 309 return result;
335 cache_buffers=strtoul(recv_buffer,NULL,10); 310 cache_buffers = strtoul(recv_buffer, NULL, 10);
336 311
337 if (check_critical_value && cache_buffers >= critical_value) 312 if (check_critical_value && cache_buffers >= critical_value)
338 result=STATE_CRITICAL; 313 result = STATE_CRITICAL;
339 else if (check_warning_value && cache_buffers >= warning_value) 314 else if (check_warning_value && cache_buffers >= warning_value)
340 result=STATE_WARNING; 315 result = STATE_WARNING;
341 316
342 xasprintf (&output_message, 317 xasprintf(&output_message, _("%s: Dirty cache buffers = %lu|Dirty-Cache-Buffers=%lu;%lu;%lu;;"), state_text(result), cache_buffers,
343 _("%s: Dirty cache buffers = %lu|Dirty-Cache-Buffers=%lu;%lu;%lu;;"), 318 cache_buffers, warning_value, critical_value);
344 state_text(result),
345 cache_buffers,
346 cache_buffers,
347 warning_value,
348 critical_value);
349 319
350 /* check LRU sitting time in minutes */ 320 /* check LRU sitting time in minutes */
351 } else if (vars_to_check==LRUM) { 321 } else if (vars_to_check == LRUM) {
352 322
353 close(sd); 323 close(sd);
354 my_tcp_connect (server_address, server_port, &sd); 324 my_tcp_connect(server_address, server_port, &sd);
355 325
356 send_buffer = strdup ("S5\r\n"); 326 send_buffer = strdup("S5\r\n");
357 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 327 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
358 if (result!=STATE_OK) 328 if (result != STATE_OK)
359 return result; 329 return result;
360 lru_time=strtoul(recv_buffer,NULL,10); 330 lru_time = strtoul(recv_buffer, NULL, 10);
361 331
362 if (check_critical_value && lru_time <= critical_value) 332 if (check_critical_value && lru_time <= critical_value)
363 result=STATE_CRITICAL; 333 result = STATE_CRITICAL;
364 else if (check_warning_value && lru_time <= warning_value) 334 else if (check_warning_value && lru_time <= warning_value)
365 result=STATE_WARNING; 335 result = STATE_WARNING;
366
367 xasprintf (&output_message,
368 _("%s: LRU sitting time = %lu minutes"),
369 state_text(result),
370 lru_time);
371 336
337 xasprintf(&output_message, _("%s: LRU sitting time = %lu minutes"), state_text(result), lru_time);
372 338
373 /* check KB free space on volume */ 339 /* check KB free space on volume */
374 } else if (vars_to_check==VKF) { 340 } else if (vars_to_check == VKF) {
375 341
376 close(sd); 342 close(sd);
377 my_tcp_connect (server_address, server_port, &sd); 343 my_tcp_connect(server_address, server_port, &sd);
378 344
379 xasprintf (&send_buffer,"VKF%s\r\n",volume_name); 345 xasprintf(&send_buffer, "VKF%s\r\n", volume_name);
380 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 346 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
381 if (result!=STATE_OK) 347 if (result != STATE_OK)
382 return result; 348 return result;
383 349
384 if (!strcmp(recv_buffer,"-1\n")) { 350 if (!strcmp(recv_buffer, "-1\n")) {
385 xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name); 351 xasprintf(&output_message, _("CRITICAL - Volume '%s' does not exist!"), volume_name);
386 result=STATE_CRITICAL; 352 result = STATE_CRITICAL;
387 } else { 353 } else {
388 free_disk_space=strtoul(recv_buffer,NULL,10); 354 free_disk_space = strtoul(recv_buffer, NULL, 10);
389 if (check_critical_value && free_disk_space <= critical_value) 355 if (check_critical_value && free_disk_space <= critical_value)
390 result=STATE_CRITICAL; 356 result = STATE_CRITICAL;
391 else if (check_warning_value && free_disk_space <= warning_value) 357 else if (check_warning_value && free_disk_space <= warning_value)
392 result=STATE_WARNING; 358 result = STATE_WARNING;
393 xasprintf (&output_message, 359 xasprintf(&output_message, _("%s%lu KB free on volume %s|KBFree%s=%lu;%lu;%lu;;"), (result == STATE_OK) ? "" : _("Only "),
394 _("%s%lu KB free on volume %s|KBFree%s=%lu;%lu;%lu;;"), 360 free_disk_space, volume_name, volume_name, free_disk_space, warning_value, critical_value);
395 (result==STATE_OK)?"":_("Only "),
396 free_disk_space,
397 volume_name,
398 volume_name,
399 free_disk_space,
400 warning_value,
401 critical_value);
402 } 361 }
403 362
404 /* check MB free space on volume */ 363 /* check MB free space on volume */
405 } else if (vars_to_check==VMF) { 364 } else if (vars_to_check == VMF) {
406 365
407 xasprintf (&send_buffer,"VMF%s\r\n",volume_name); 366 xasprintf(&send_buffer, "VMF%s\r\n", volume_name);
408 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 367 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
409 if (result!=STATE_OK) 368 if (result != STATE_OK)
410 return result; 369 return result;
411 370
412 if (!strcmp(recv_buffer,"-1\n")) { 371 if (!strcmp(recv_buffer, "-1\n")) {
413 xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name); 372 xasprintf(&output_message, _("CRITICAL - Volume '%s' does not exist!"), volume_name);
414 result=STATE_CRITICAL; 373 result = STATE_CRITICAL;
415 } else { 374 } else {
416 free_disk_space=strtoul(recv_buffer,NULL,10); 375 free_disk_space = strtoul(recv_buffer, NULL, 10);
417 if (check_critical_value && free_disk_space <= critical_value) 376 if (check_critical_value && free_disk_space <= critical_value)
418 result=STATE_CRITICAL; 377 result = STATE_CRITICAL;
419 else if (check_warning_value && free_disk_space <= warning_value) 378 else if (check_warning_value && free_disk_space <= warning_value)
420 result=STATE_WARNING; 379 result = STATE_WARNING;
421 xasprintf (&output_message, 380 xasprintf(&output_message, _("%s%lu MB free on volume %s|MBFree%s=%lu;%lu;%lu;;"), (result == STATE_OK) ? "" : _("Only "),
422 _("%s%lu MB free on volume %s|MBFree%s=%lu;%lu;%lu;;"), 381 free_disk_space, volume_name, volume_name, free_disk_space, warning_value, critical_value);
423 (result==STATE_OK)?"":_("Only "),
424 free_disk_space,
425 volume_name,
426 volume_name,
427 free_disk_space,
428 warning_value,
429 critical_value);
430 } 382 }
431 /* check MB used space on volume */ 383 /* check MB used space on volume */
432 } else if (vars_to_check==VMU) { 384 } else if (vars_to_check == VMU) {
433 385
434 xasprintf (&send_buffer,"VMU%s\r\n",volume_name); 386 xasprintf(&send_buffer, "VMU%s\r\n", volume_name);
435 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 387 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
436 if (result!=STATE_OK) 388 if (result != STATE_OK)
437 return result; 389 return result;
438 390
439 if (!strcmp(recv_buffer,"-1\n")) { 391 if (!strcmp(recv_buffer, "-1\n")) {
440 xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name); 392 xasprintf(&output_message, _("CRITICAL - Volume '%s' does not exist!"), volume_name);
441 result=STATE_CRITICAL; 393 result = STATE_CRITICAL;
442 } else { 394 } else {
443 free_disk_space=strtoul(recv_buffer,NULL,10); 395 free_disk_space = strtoul(recv_buffer, NULL, 10);
444 if (check_critical_value && free_disk_space <= critical_value) 396 if (check_critical_value && free_disk_space <= critical_value)
445 result=STATE_CRITICAL; 397 result = STATE_CRITICAL;
446 else if (check_warning_value && free_disk_space <= warning_value) 398 else if (check_warning_value && free_disk_space <= warning_value)
447 result=STATE_WARNING; 399 result = STATE_WARNING;
448 xasprintf (&output_message, 400 xasprintf(&output_message, _("%s%lu MB used on volume %s|MBUsed%s=%lu;%lu;%lu;;"), (result == STATE_OK) ? "" : _("Only "),
449 _("%s%lu MB used on volume %s|MBUsed%s=%lu;%lu;%lu;;"), 401 free_disk_space, volume_name, volume_name, free_disk_space, warning_value, critical_value);
450 (result==STATE_OK)?"":_("Only "),
451 free_disk_space,
452 volume_name,
453 volume_name,
454 free_disk_space,
455 warning_value,
456 critical_value);
457 } 402 }
458 /* check % used space on volume */ 403 /* check % used space on volume */
459 } else if (vars_to_check==VPU) { 404 } else if (vars_to_check == VPU) {
460 close(sd); 405 close(sd);
461 my_tcp_connect (server_address, server_port, &sd); 406 my_tcp_connect(server_address, server_port, &sd);
462 407
463 asprintf (&send_buffer,"VMU%s\r\n",volume_name); 408 asprintf(&send_buffer, "VMU%s\r\n", volume_name);
464 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 409 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
465 410
466 if (result!=STATE_OK) 411 if (result != STATE_OK)
467 return result; 412 return result;
468 413
469 if (!strcmp(recv_buffer,"-1\n")) { 414 if (!strcmp(recv_buffer, "-1\n")) {
470 asprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name); 415 asprintf(&output_message, _("CRITICAL - Volume '%s' does not exist!"), volume_name);
471 result=STATE_CRITICAL; 416 result = STATE_CRITICAL;
472 417
473 } else { 418 } else {
474 used_disk_space=strtoul(recv_buffer,NULL,10); 419 used_disk_space = strtoul(recv_buffer, NULL, 10);
475 close(sd); 420 close(sd);
476 my_tcp_connect (server_address, server_port, &sd); 421 my_tcp_connect(server_address, server_port, &sd);
477 /* get total volume in MB */ 422 /* get total volume in MB */
478 asprintf (&send_buffer,"VMS%s\r\n",volume_name); 423 asprintf(&send_buffer, "VMS%s\r\n", volume_name);
479 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 424 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
480 if (result!=STATE_OK) 425 if (result != STATE_OK)
481 return result; 426 return result;
482 total_disk_space=strtoul(recv_buffer,NULL,10); 427 total_disk_space = strtoul(recv_buffer, NULL, 10);
483 /* calculate percent used on volume */ 428 /* calculate percent used on volume */
484 percent_used_disk_space=(unsigned long)(((double)used_disk_space/(double)total_disk_space)*100.0); 429 percent_used_disk_space = (unsigned long)(((double)used_disk_space / (double)total_disk_space) * 100.0);
485 430
486 if (check_critical_value && percent_used_disk_space >= critical_value) 431 if (check_critical_value && percent_used_disk_space >= critical_value)
487 result=STATE_CRITICAL; 432 result = STATE_CRITICAL;
488 else if (check_warning_value && percent_used_disk_space >= warning_value) 433 else if (check_warning_value && percent_used_disk_space >= warning_value)
489 result=STATE_WARNING; 434 result = STATE_WARNING;
490 435
491 asprintf (&output_message,_("%lu MB (%lu%%) used on volume %s - total %lu MB|Used space in percent on %s=%lu;%lu;%lu;0;100"), 436 asprintf(&output_message, _("%lu MB (%lu%%) used on volume %s - total %lu MB|Used space in percent on %s=%lu;%lu;%lu;0;100"),
492 used_disk_space, 437 used_disk_space, percent_used_disk_space, volume_name, total_disk_space, volume_name, percent_used_disk_space,
493 percent_used_disk_space, 438 warning_value, critical_value);
494 volume_name,
495 total_disk_space,
496 volume_name,
497 percent_used_disk_space,
498 warning_value,
499 critical_value
500 );
501 } 439 }
502 440
503 /* check % free space on volume */ 441 /* check % free space on volume */
504 } else if (vars_to_check==VPF) { 442 } else if (vars_to_check == VPF) {
505 443
506 close(sd); 444 close(sd);
507 my_tcp_connect (server_address, server_port, &sd); 445 my_tcp_connect(server_address, server_port, &sd);
508 446
509 xasprintf (&send_buffer,"VKF%s\r\n",volume_name); 447 xasprintf(&send_buffer, "VKF%s\r\n", volume_name);
510 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 448 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
511 if (result!=STATE_OK) 449 if (result != STATE_OK)
512 return result; 450 return result;
513 451
514 if (!strcmp(recv_buffer,"-1\n")) { 452 if (!strcmp(recv_buffer, "-1\n")) {
515 453
516 xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name); 454 xasprintf(&output_message, _("CRITICAL - Volume '%s' does not exist!"), volume_name);
517 result=STATE_CRITICAL; 455 result = STATE_CRITICAL;
518 456
519 } else { 457 } else {
520 458
521 free_disk_space=strtoul(recv_buffer,NULL,10); 459 free_disk_space = strtoul(recv_buffer, NULL, 10);
522 460
523 close(sd); 461 close(sd);
524 my_tcp_connect (server_address, server_port, &sd); 462 my_tcp_connect(server_address, server_port, &sd);
525 463
526 xasprintf (&send_buffer,"VKS%s\r\n",volume_name); 464 xasprintf(&send_buffer, "VKS%s\r\n", volume_name);
527 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 465 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
528 if (result!=STATE_OK) 466 if (result != STATE_OK)
529 return result; 467 return result;
530 total_disk_space=strtoul(recv_buffer,NULL,10); 468 total_disk_space = strtoul(recv_buffer, NULL, 10);
531 469
532 percent_free_space=(unsigned long)(((double)free_disk_space/(double)total_disk_space)*100.0); 470 percent_free_space = (unsigned long)(((double)free_disk_space / (double)total_disk_space) * 100.0);
533 471
534 if (check_critical_value && percent_free_space <= critical_value) 472 if (check_critical_value && percent_free_space <= critical_value)
535 result=STATE_CRITICAL; 473 result = STATE_CRITICAL;
536 else if (check_warning_value && percent_free_space <= warning_value) 474 else if (check_warning_value && percent_free_space <= warning_value)
537 result=STATE_WARNING; 475 result = STATE_WARNING;
538 free_disk_space/=1024; 476 free_disk_space /= 1024;
539 total_disk_space/=1024; 477 total_disk_space /= 1024;
540 xasprintf (&output_message,_("%lu MB (%lu%%) free on volume %s - total %lu MB|FreeMB%s=%lu;%lu;%lu;0;100"), 478 xasprintf(&output_message, _("%lu MB (%lu%%) free on volume %s - total %lu MB|FreeMB%s=%lu;%lu;%lu;0;100"), free_disk_space,
541 free_disk_space, 479 percent_free_space, volume_name, total_disk_space, volume_name, percent_free_space, warning_value, critical_value);
542 percent_free_space,
543 volume_name,
544 total_disk_space,
545 volume_name,
546 percent_free_space,
547 warning_value,
548 critical_value
549 );
550 } 480 }
551 481
552 /* check to see if DS Database is open or closed */ 482 /* check to see if DS Database is open or closed */
553 } else if (vars_to_check==DSDB) { 483 } else if (vars_to_check == DSDB) {
554 484
555 close(sd); 485 close(sd);
556 my_tcp_connect (server_address, server_port, &sd); 486 my_tcp_connect(server_address, server_port, &sd);
557 487
558 send_buffer = strdup ("S11\r\n"); 488 send_buffer = strdup("S11\r\n");
559 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 489 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
560 if (result!=STATE_OK) 490 if (result != STATE_OK)
561 return result; 491 return result;
562 if (atoi(recv_buffer)==1) 492 if (atoi(recv_buffer) == 1)
563 result=STATE_OK; 493 result = STATE_OK;
564 else 494 else
565 result=STATE_WARNING; 495 result = STATE_WARNING;
566 496
567 close(sd); 497 close(sd);
568 my_tcp_connect (server_address, server_port, &sd); 498 my_tcp_connect(server_address, server_port, &sd);
569 499
570 send_buffer = strdup ("S13\r\n"); 500 send_buffer = strdup("S13\r\n");
571 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 501 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
572 temp_buffer=strtok(recv_buffer,"\r\n"); 502 temp_buffer = strtok(recv_buffer, "\r\n");
573 503
574 xasprintf (&output_message,_("Directory Services Database is %s (DS version %s)"),(result==STATE_OK)?"open":"closed",temp_buffer); 504 xasprintf(&output_message, _("Directory Services Database is %s (DS version %s)"), (result == STATE_OK) ? "open" : "closed",
505 temp_buffer);
575 506
576 /* check to see if logins are enabled */ 507 /* check to see if logins are enabled */
577 } else if (vars_to_check==LOGINS) { 508 } else if (vars_to_check == LOGINS) {
578 509
579 close(sd); 510 close(sd);
580 my_tcp_connect (server_address, server_port, &sd); 511 my_tcp_connect(server_address, server_port, &sd);
581 512
582 send_buffer = strdup ("S12\r\n"); 513 send_buffer = strdup("S12\r\n");
583 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 514 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
584 if (result!=STATE_OK) 515 if (result != STATE_OK)
585 return result; 516 return result;
586 if (atoi(recv_buffer)==1) 517 if (atoi(recv_buffer) == 1)
587 result=STATE_OK; 518 result = STATE_OK;
588 else 519 else
589 result=STATE_WARNING; 520 result = STATE_WARNING;
590
591 xasprintf (&output_message,_("Logins are %s"),(result==STATE_OK)?_("enabled"):_("disabled"));
592 521
522 xasprintf(&output_message, _("Logins are %s"), (result == STATE_OK) ? _("enabled") : _("disabled"));
593 523
594 /* check NRM Health Status Summary*/ 524 /* check NRM Health Status Summary*/
595 } else if (vars_to_check==NRMH) { 525 } else if (vars_to_check == NRMH) {
596 526
597 xasprintf (&send_buffer,"NRMH\r\n"); 527 xasprintf(&send_buffer, "NRMH\r\n");
598 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 528 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
599 if (result!=STATE_OK) 529 if (result != STATE_OK)
600 return result; 530 return result;
601 531
602 nrm_health_status=atoi(recv_buffer); 532 nrm_health_status = atoi(recv_buffer);
603 533
604 if (nrm_health_status==2) { 534 if (nrm_health_status == 2) {
605 result=STATE_OK; 535 result = STATE_OK;
606 xasprintf (&output_message,_("CRITICAL - NRM Status is bad!")); 536 xasprintf(&output_message, _("CRITICAL - NRM Status is bad!"));
607 } 537 } else {
608 else { 538 if (nrm_health_status == 1) {
609 if (nrm_health_status==1) { 539 result = STATE_WARNING;
610 result=STATE_WARNING; 540 xasprintf(&output_message, _("Warning - NRM Status is suspect!"));
611 xasprintf (&output_message,_("Warning - NRM Status is suspect!"));
612 } 541 }
613 542
614 xasprintf (&output_message,_("OK - NRM Status is good!")); 543 xasprintf(&output_message, _("OK - NRM Status is good!"));
615 } 544 }
616 545
617
618
619 /* check packet receive buffers */ 546 /* check packet receive buffers */
620 } else if (vars_to_check==UPRB || vars_to_check==PUPRB) { 547 } else if (vars_to_check == UPRB || vars_to_check == PUPRB) {
621 548
622 close(sd); 549 close(sd);
623 my_tcp_connect (server_address, server_port, &sd); 550 my_tcp_connect(server_address, server_port, &sd);
624 551
625 xasprintf (&send_buffer,"S15\r\n"); 552 xasprintf(&send_buffer, "S15\r\n");
626 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 553 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
627 if (result!=STATE_OK) 554 if (result != STATE_OK)
628 return result; 555 return result;
629 556
630 used_packet_receive_buffers=atoi(recv_buffer); 557 used_packet_receive_buffers = atoi(recv_buffer);
631 558
632 close(sd); 559 close(sd);
633 my_tcp_connect (server_address, server_port, &sd); 560 my_tcp_connect(server_address, server_port, &sd);
634 561
635 xasprintf (&send_buffer,"S16\r\n"); 562 xasprintf(&send_buffer, "S16\r\n");
636 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 563 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
637 if (result!=STATE_OK) 564 if (result != STATE_OK)
638 return result; 565 return result;
639 566
640 max_packet_receive_buffers=atoi(recv_buffer); 567 max_packet_receive_buffers = atoi(recv_buffer);
641 568
642 percent_used_packet_receive_buffers=(unsigned long)(((double)used_packet_receive_buffers/(double)max_packet_receive_buffers)*100.0); 569 percent_used_packet_receive_buffers =
570 (unsigned long)(((double)used_packet_receive_buffers / (double)max_packet_receive_buffers) * 100.0);
643 571
644 if (vars_to_check==UPRB) { 572 if (vars_to_check == UPRB) {
645 if (check_critical_value && used_packet_receive_buffers >= critical_value) 573 if (check_critical_value && used_packet_receive_buffers >= critical_value)
646 result=STATE_CRITICAL; 574 result = STATE_CRITICAL;
647 else if (check_warning_value && used_packet_receive_buffers >= warning_value) 575 else if (check_warning_value && used_packet_receive_buffers >= warning_value)
648 result=STATE_WARNING; 576 result = STATE_WARNING;
649 } else { 577 } else {
650 if (check_critical_value && percent_used_packet_receive_buffers >= critical_value) 578 if (check_critical_value && percent_used_packet_receive_buffers >= critical_value)
651 result=STATE_CRITICAL; 579 result = STATE_CRITICAL;
652 else if (check_warning_value && percent_used_packet_receive_buffers >= warning_value) 580 else if (check_warning_value && percent_used_packet_receive_buffers >= warning_value)
653 result=STATE_WARNING; 581 result = STATE_WARNING;
654 } 582 }
655 583
656 xasprintf (&output_message,_("%lu of %lu (%lu%%) packet receive buffers used"),used_packet_receive_buffers,max_packet_receive_buffers,percent_used_packet_receive_buffers); 584 xasprintf(&output_message, _("%lu of %lu (%lu%%) packet receive buffers used"), used_packet_receive_buffers,
585 max_packet_receive_buffers, percent_used_packet_receive_buffers);
657 586
658 /* check SAP table entries */ 587 /* check SAP table entries */
659 } else if (vars_to_check==SAPENTRIES) { 588 } else if (vars_to_check == SAPENTRIES) {
660 589
661 close(sd); 590 close(sd);
662 my_tcp_connect (server_address, server_port, &sd); 591 my_tcp_connect(server_address, server_port, &sd);
663 592
664 if (sap_number==-1) 593 if (sap_number == -1)
665 xasprintf (&send_buffer,"S9\r\n"); 594 xasprintf(&send_buffer, "S9\r\n");
666 else 595 else
667 xasprintf (&send_buffer,"S9.%d\r\n",sap_number); 596 xasprintf(&send_buffer, "S9.%d\r\n", sap_number);
668 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 597 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
669 if (result!=STATE_OK) 598 if (result != STATE_OK)
670 return result; 599 return result;
671 600
672 sap_entries=atoi(recv_buffer); 601 sap_entries = atoi(recv_buffer);
673 602
674 if (check_critical_value && sap_entries >= critical_value) 603 if (check_critical_value && sap_entries >= critical_value)
675 result=STATE_CRITICAL; 604 result = STATE_CRITICAL;
676 else if (check_warning_value && sap_entries >= warning_value) 605 else if (check_warning_value && sap_entries >= warning_value)
677 result=STATE_WARNING; 606 result = STATE_WARNING;
678 607
679 if (sap_number==-1) 608 if (sap_number == -1)
680 xasprintf (&output_message,_("%lu entries in SAP table"),sap_entries); 609 xasprintf(&output_message, _("%lu entries in SAP table"), sap_entries);
681 else 610 else
682 xasprintf (&output_message,_("%lu entries in SAP table for SAP type %d"),sap_entries,sap_number); 611 xasprintf(&output_message, _("%lu entries in SAP table for SAP type %d"), sap_entries, sap_number);
683 612
684 /* check KB purgeable space on volume */ 613 /* check KB purgeable space on volume */
685 } else if (vars_to_check==VKP) { 614 } else if (vars_to_check == VKP) {
686 615
687 close(sd); 616 close(sd);
688 my_tcp_connect (server_address, server_port, &sd); 617 my_tcp_connect(server_address, server_port, &sd);
689 618
690 xasprintf (&send_buffer,"VKP%s\r\n",volume_name); 619 xasprintf(&send_buffer, "VKP%s\r\n", volume_name);
691 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 620 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
692 if (result!=STATE_OK) 621 if (result != STATE_OK)
693 return result; 622 return result;
694 623
695 if (!strcmp(recv_buffer,"-1\n")) { 624 if (!strcmp(recv_buffer, "-1\n")) {
696 xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name); 625 xasprintf(&output_message, _("CRITICAL - Volume '%s' does not exist!"), volume_name);
697 result=STATE_CRITICAL; 626 result = STATE_CRITICAL;
698 } else { 627 } else {
699 purgeable_disk_space=strtoul(recv_buffer,NULL,10); 628 purgeable_disk_space = strtoul(recv_buffer, NULL, 10);
700 if (check_critical_value && purgeable_disk_space >= critical_value) 629 if (check_critical_value && purgeable_disk_space >= critical_value)
701 result=STATE_CRITICAL; 630 result = STATE_CRITICAL;
702 else if (check_warning_value && purgeable_disk_space >= warning_value) 631 else if (check_warning_value && purgeable_disk_space >= warning_value)
703 result=STATE_WARNING; 632 result = STATE_WARNING;
704 xasprintf (&output_message,_("%s%lu KB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;"), 633 xasprintf(&output_message, _("%s%lu KB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;"), (result == STATE_OK) ? "" : _("Only "),
705 (result==STATE_OK)?"":_("Only "), 634 purgeable_disk_space, volume_name, volume_name, purgeable_disk_space, warning_value, critical_value);
706 purgeable_disk_space,
707 volume_name,
708 volume_name,
709 purgeable_disk_space,
710 warning_value,
711 critical_value);
712 } 635 }
713 /* check MB purgeable space on volume */ 636 /* check MB purgeable space on volume */
714 } else if (vars_to_check==VMP) { 637 } else if (vars_to_check == VMP) {
715 638
716 xasprintf (&send_buffer,"VMP%s\r\n",volume_name); 639 xasprintf(&send_buffer, "VMP%s\r\n", volume_name);
717 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 640 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
718 if (result!=STATE_OK) 641 if (result != STATE_OK)
719 return result; 642 return result;
720 643
721 if (!strcmp(recv_buffer,"-1\n")) { 644 if (!strcmp(recv_buffer, "-1\n")) {
722 xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name); 645 xasprintf(&output_message, _("CRITICAL - Volume '%s' does not exist!"), volume_name);
723 result=STATE_CRITICAL; 646 result = STATE_CRITICAL;
724 } else { 647 } else {
725 purgeable_disk_space=strtoul(recv_buffer,NULL,10); 648 purgeable_disk_space = strtoul(recv_buffer, NULL, 10);
726 if (check_critical_value && purgeable_disk_space >= critical_value) 649 if (check_critical_value && purgeable_disk_space >= critical_value)
727 result=STATE_CRITICAL; 650 result = STATE_CRITICAL;
728 else if (check_warning_value && purgeable_disk_space >= warning_value) 651 else if (check_warning_value && purgeable_disk_space >= warning_value)
729 result=STATE_WARNING; 652 result = STATE_WARNING;
730 xasprintf (&output_message,_("%s%lu MB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;"), 653 xasprintf(&output_message, _("%s%lu MB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;"), (result == STATE_OK) ? "" : _("Only "),
731 (result==STATE_OK)?"":_("Only "), 654 purgeable_disk_space, volume_name, volume_name, purgeable_disk_space, warning_value, critical_value);
732 purgeable_disk_space,
733 volume_name,
734 volume_name,
735 purgeable_disk_space,
736 warning_value,
737 critical_value);
738 } 655 }
739 656
740 /* check % purgeable space on volume */ 657 /* check % purgeable space on volume */
741 } else if (vars_to_check==VPP) { 658 } else if (vars_to_check == VPP) {
742 659
743 close(sd); 660 close(sd);
744 my_tcp_connect (server_address, server_port, &sd); 661 my_tcp_connect(server_address, server_port, &sd);
745 662
746 xasprintf (&send_buffer,"VKP%s\r\n",volume_name); 663 xasprintf(&send_buffer, "VKP%s\r\n", volume_name);
747 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 664 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
748 if (result!=STATE_OK) 665 if (result != STATE_OK)
749 return result; 666 return result;
750 667
751 if (!strcmp(recv_buffer,"-1\n")) { 668 if (!strcmp(recv_buffer, "-1\n")) {
752 669
753 xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name); 670 xasprintf(&output_message, _("CRITICAL - Volume '%s' does not exist!"), volume_name);
754 result=STATE_CRITICAL; 671 result = STATE_CRITICAL;
755 672
756 } else { 673 } else {
757 674
758 purgeable_disk_space=strtoul(recv_buffer,NULL,10); 675 purgeable_disk_space = strtoul(recv_buffer, NULL, 10);
759 676
760 close(sd); 677 close(sd);
761 my_tcp_connect (server_address, server_port, &sd); 678 my_tcp_connect(server_address, server_port, &sd);
762 679
763 xasprintf (&send_buffer,"VKS%s\r\n",volume_name); 680 xasprintf(&send_buffer, "VKS%s\r\n", volume_name);
764 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 681 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
765 if (result!=STATE_OK) 682 if (result != STATE_OK)
766 return result; 683 return result;
767 total_disk_space=strtoul(recv_buffer,NULL,10); 684 total_disk_space = strtoul(recv_buffer, NULL, 10);
768 685
769 percent_purgeable_space=(unsigned long)(((double)purgeable_disk_space/(double)total_disk_space)*100.0); 686 percent_purgeable_space = (unsigned long)(((double)purgeable_disk_space / (double)total_disk_space) * 100.0);
770 687
771 if (check_critical_value && percent_purgeable_space >= critical_value) 688 if (check_critical_value && percent_purgeable_space >= critical_value)
772 result=STATE_CRITICAL; 689 result = STATE_CRITICAL;
773 else if (check_warning_value && percent_purgeable_space >= warning_value) 690 else if (check_warning_value && percent_purgeable_space >= warning_value)
774 result=STATE_WARNING; 691 result = STATE_WARNING;
775 purgeable_disk_space/=1024; 692 purgeable_disk_space /= 1024;
776 xasprintf (&output_message,_("%lu MB (%lu%%) purgeable on volume %s|Purgeable%s=%lu;%lu;%lu;0;100"), 693 xasprintf(&output_message, _("%lu MB (%lu%%) purgeable on volume %s|Purgeable%s=%lu;%lu;%lu;0;100"), purgeable_disk_space,
777 purgeable_disk_space, 694 percent_purgeable_space, volume_name, volume_name, percent_purgeable_space, warning_value, critical_value);
778 percent_purgeable_space,
779 volume_name,
780 volume_name,
781 percent_purgeable_space,
782 warning_value,
783 critical_value
784 );
785 } 695 }
786 696
787 /* check KB not yet purgeable space on volume */ 697 /* check KB not yet purgeable space on volume */
788 } else if (vars_to_check==VKNP) { 698 } else if (vars_to_check == VKNP) {
789 699
790 close(sd); 700 close(sd);
791 my_tcp_connect (server_address, server_port, &sd); 701 my_tcp_connect(server_address, server_port, &sd);
792 702
793 xasprintf (&send_buffer,"VKNP%s\r\n",volume_name); 703 xasprintf(&send_buffer, "VKNP%s\r\n", volume_name);
794 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 704 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
795 if (result!=STATE_OK) 705 if (result != STATE_OK)
796 return result; 706 return result;
797 707
798 if (!strcmp(recv_buffer,"-1\n")) { 708 if (!strcmp(recv_buffer, "-1\n")) {
799 xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name); 709 xasprintf(&output_message, _("CRITICAL - Volume '%s' does not exist!"), volume_name);
800 result=STATE_CRITICAL; 710 result = STATE_CRITICAL;
801 } else { 711 } else {
802 non_purgeable_disk_space=strtoul(recv_buffer,NULL,10); 712 non_purgeable_disk_space = strtoul(recv_buffer, NULL, 10);
803 if (check_critical_value && non_purgeable_disk_space >= critical_value) 713 if (check_critical_value && non_purgeable_disk_space >= critical_value)
804 result=STATE_CRITICAL; 714 result = STATE_CRITICAL;
805 else if (check_warning_value && non_purgeable_disk_space >= warning_value) 715 else if (check_warning_value && non_purgeable_disk_space >= warning_value)
806 result=STATE_WARNING; 716 result = STATE_WARNING;
807 xasprintf (&output_message,_("%s%lu KB not yet purgeable on volume %s"),(result==STATE_OK)?"":_("Only "),non_purgeable_disk_space,volume_name); 717 xasprintf(&output_message, _("%s%lu KB not yet purgeable on volume %s"), (result == STATE_OK) ? "" : _("Only "),
718 non_purgeable_disk_space, volume_name);
808 } 719 }
809 720
810 /* check % not yet purgeable space on volume */ 721 /* check % not yet purgeable space on volume */
811 } else if (vars_to_check==VPNP) { 722 } else if (vars_to_check == VPNP) {
812 723
813 close(sd); 724 close(sd);
814 my_tcp_connect (server_address, server_port, &sd); 725 my_tcp_connect(server_address, server_port, &sd);
815 726
816 xasprintf (&send_buffer,"VKNP%s\r\n",volume_name); 727 xasprintf(&send_buffer, "VKNP%s\r\n", volume_name);
817 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 728 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
818 if (result!=STATE_OK) 729 if (result != STATE_OK)
819 return result; 730 return result;
820 731
821 if (!strcmp(recv_buffer,"-1\n")) { 732 if (!strcmp(recv_buffer, "-1\n")) {
822 733
823 xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name); 734 xasprintf(&output_message, _("CRITICAL - Volume '%s' does not exist!"), volume_name);
824 result=STATE_CRITICAL; 735 result = STATE_CRITICAL;
825 736
826 } else { 737 } else {
827 738
828 non_purgeable_disk_space=strtoul(recv_buffer,NULL,10); 739 non_purgeable_disk_space = strtoul(recv_buffer, NULL, 10);
829 740
830 close(sd); 741 close(sd);
831 my_tcp_connect (server_address, server_port, &sd); 742 my_tcp_connect(server_address, server_port, &sd);
832 743
833 xasprintf (&send_buffer,"VKS%s\r\n",volume_name); 744 xasprintf(&send_buffer, "VKS%s\r\n", volume_name);
834 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 745 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
835 if (result!=STATE_OK) 746 if (result != STATE_OK)
836 return result; 747 return result;
837 total_disk_space=strtoul(recv_buffer,NULL,10); 748 total_disk_space = strtoul(recv_buffer, NULL, 10);
838 749
839 percent_non_purgeable_space=(unsigned long)(((double)non_purgeable_disk_space/(double)total_disk_space)*100.0); 750 percent_non_purgeable_space = (unsigned long)(((double)non_purgeable_disk_space / (double)total_disk_space) * 100.0);
840 751
841 if (check_critical_value && percent_non_purgeable_space >= critical_value) 752 if (check_critical_value && percent_non_purgeable_space >= critical_value)
842 result=STATE_CRITICAL; 753 result = STATE_CRITICAL;
843 else if (check_warning_value && percent_non_purgeable_space >= warning_value) 754 else if (check_warning_value && percent_non_purgeable_space >= warning_value)
844 result=STATE_WARNING; 755 result = STATE_WARNING;
845 purgeable_disk_space/=1024; 756 purgeable_disk_space /= 1024;
846 xasprintf (&output_message,_("%lu MB (%lu%%) not yet purgeable on volume %s"),non_purgeable_disk_space,percent_non_purgeable_space,volume_name); 757 xasprintf(&output_message, _("%lu MB (%lu%%) not yet purgeable on volume %s"), non_purgeable_disk_space,
758 percent_non_purgeable_space, volume_name);
847 } 759 }
848 760
849 /* check # of open files */ 761 /* check # of open files */
850 } else if (vars_to_check==OFILES) { 762 } else if (vars_to_check == OFILES) {
851 763
852 close(sd); 764 close(sd);
853 my_tcp_connect (server_address, server_port, &sd); 765 my_tcp_connect(server_address, server_port, &sd);
854 766
855 xasprintf (&send_buffer,"S18\r\n"); 767 xasprintf(&send_buffer, "S18\r\n");
856 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 768 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
857 if (result!=STATE_OK) 769 if (result != STATE_OK)
858 return result; 770 return result;
859 771
860 open_files=atoi(recv_buffer); 772 open_files = atoi(recv_buffer);
861 773
862 if (check_critical_value && open_files >= critical_value) 774 if (check_critical_value && open_files >= critical_value)
863 result=STATE_CRITICAL; 775 result = STATE_CRITICAL;
864 else if (check_warning_value && open_files >= warning_value) 776 else if (check_warning_value && open_files >= warning_value)
865 result=STATE_WARNING; 777 result = STATE_WARNING;
866
867 xasprintf (&output_message,_("%lu open files|Openfiles=%lu;%lu;%lu;0,0"),
868 open_files,
869 open_files,
870 warning_value,
871 critical_value);
872 778
779 xasprintf(&output_message, _("%lu open files|Openfiles=%lu;%lu;%lu;0,0"), open_files, open_files, warning_value, critical_value);
873 780
874 /* check # of abended threads (Netware > 5.x only) */ 781 /* check # of abended threads (Netware > 5.x only) */
875 } else if (vars_to_check==ABENDS) { 782 } else if (vars_to_check == ABENDS) {
876 783
877 close(sd); 784 close(sd);
878 my_tcp_connect (server_address, server_port, &sd); 785 my_tcp_connect(server_address, server_port, &sd);
879 786
880 xasprintf (&send_buffer,"S17\r\n"); 787 xasprintf(&send_buffer, "S17\r\n");
881 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 788 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
882 if (result!=STATE_OK) 789 if (result != STATE_OK)
883 return result; 790 return result;
884 791
885 abended_threads=atoi(recv_buffer); 792 abended_threads = atoi(recv_buffer);
886 793
887 if (check_critical_value && abended_threads >= critical_value) 794 if (check_critical_value && abended_threads >= critical_value)
888 result=STATE_CRITICAL; 795 result = STATE_CRITICAL;
889 else if (check_warning_value && abended_threads >= warning_value) 796 else if (check_warning_value && abended_threads >= warning_value)
890 result=STATE_WARNING; 797 result = STATE_WARNING;
891 798
892 xasprintf (&output_message,_("%lu abended threads|Abends=%lu;%lu;%lu;;"), 799 xasprintf(&output_message, _("%lu abended threads|Abends=%lu;%lu;%lu;;"), abended_threads, abended_threads, warning_value,
893 abended_threads, 800 critical_value);
894 abended_threads,
895 warning_value,
896 critical_value);
897 801
898 /* check # of current service processes (Netware 5.x only) */ 802 /* check # of current service processes (Netware 5.x only) */
899 } else if (vars_to_check==CSPROCS) { 803 } else if (vars_to_check == CSPROCS) {
900 804
901 close(sd); 805 close(sd);
902 my_tcp_connect (server_address, server_port, &sd); 806 my_tcp_connect(server_address, server_port, &sd);
903 807
904 xasprintf (&send_buffer,"S20\r\n"); 808 xasprintf(&send_buffer, "S20\r\n");
905 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 809 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
906 if (result!=STATE_OK) 810 if (result != STATE_OK)
907 return result; 811 return result;
908 812
909 max_service_processes=atoi(recv_buffer); 813 max_service_processes = atoi(recv_buffer);
910 814
911 close(sd); 815 close(sd);
912 my_tcp_connect (server_address, server_port, &sd); 816 my_tcp_connect(server_address, server_port, &sd);
913 817
914 xasprintf (&send_buffer,"S21\r\n"); 818 xasprintf(&send_buffer, "S21\r\n");
915 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 819 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
916 if (result!=STATE_OK) 820 if (result != STATE_OK)
917 return result; 821 return result;
918 822
919 current_service_processes=atoi(recv_buffer); 823 current_service_processes = atoi(recv_buffer);
920 824
921 if (check_critical_value && current_service_processes >= critical_value) 825 if (check_critical_value && current_service_processes >= critical_value)
922 result=STATE_CRITICAL; 826 result = STATE_CRITICAL;
923 else if (check_warning_value && current_service_processes >= warning_value) 827 else if (check_warning_value && current_service_processes >= warning_value)
924 result=STATE_WARNING; 828 result = STATE_WARNING;
925 829
926 xasprintf (&output_message, 830 xasprintf(&output_message, _("%lu current service processes (%lu max)|Processes=%lu;%lu;%lu;0;%lu"), current_service_processes,
927 _("%lu current service processes (%lu max)|Processes=%lu;%lu;%lu;0;%lu"), 831 max_service_processes, current_service_processes, warning_value, critical_value, max_service_processes);
928 current_service_processes,
929 max_service_processes,
930 current_service_processes,
931 warning_value,
932 critical_value,
933 max_service_processes);
934 832
935 /* check # Timesync Status */ 833 /* check # Timesync Status */
936 } else if (vars_to_check==TSYNC) { 834 } else if (vars_to_check == TSYNC) {
937 835
938 close(sd); 836 close(sd);
939 my_tcp_connect (server_address, server_port, &sd); 837 my_tcp_connect(server_address, server_port, &sd);
940 838
941 xasprintf (&send_buffer,"S22\r\n"); 839 xasprintf(&send_buffer, "S22\r\n");
942 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 840 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
943 if (result!=STATE_OK) 841 if (result != STATE_OK)
944 return result; 842 return result;
945 843
946 time_sync_status=atoi(recv_buffer); 844 time_sync_status = atoi(recv_buffer);
947 845
948 if (time_sync_status==0) { 846 if (time_sync_status == 0) {
949 result=STATE_CRITICAL; 847 result = STATE_CRITICAL;
950 xasprintf (&output_message,_("CRITICAL - Time not in sync with network!")); 848 xasprintf(&output_message, _("CRITICAL - Time not in sync with network!"));
951 } 849 } else {
952 else { 850 xasprintf(&output_message, _("OK - Time in sync with network!"));
953 xasprintf (&output_message,_("OK - Time in sync with network!"));
954 } 851 }
955 852
956
957
958
959
960 /* check LRU sitting time in secondss */ 853 /* check LRU sitting time in secondss */
961 } else if (vars_to_check==LRUS) { 854 } else if (vars_to_check == LRUS) {
962 855
963 close(sd); 856 close(sd);
964 my_tcp_connect (server_address, server_port, &sd); 857 my_tcp_connect(server_address, server_port, &sd);
965 858
966 send_buffer = strdup ("S4\r\n"); 859 send_buffer = strdup("S4\r\n");
967 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 860 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
968 if (result!=STATE_OK) 861 if (result != STATE_OK)
969 return result; 862 return result;
970 lru_time=strtoul(recv_buffer,NULL,10); 863 lru_time = strtoul(recv_buffer, NULL, 10);
971 864
972 if (check_critical_value && lru_time <= critical_value) 865 if (check_critical_value && lru_time <= critical_value)
973 result=STATE_CRITICAL; 866 result = STATE_CRITICAL;
974 else if (check_warning_value && lru_time <= warning_value) 867 else if (check_warning_value && lru_time <= warning_value)
975 result=STATE_WARNING; 868 result = STATE_WARNING;
976 xasprintf (&output_message,_("LRU sitting time = %lu seconds"),lru_time); 869 xasprintf(&output_message, _("LRU sitting time = %lu seconds"), lru_time);
977
978 870
979 /* check % dirty cacheobuffers as a percentage of the total*/ 871 /* check % dirty cacheobuffers as a percentage of the total*/
980 } else if (vars_to_check==DCB) { 872 } else if (vars_to_check == DCB) {
981 873
982 close(sd); 874 close(sd);
983 my_tcp_connect (server_address, server_port, &sd); 875 my_tcp_connect(server_address, server_port, &sd);
984 876
985 send_buffer = strdup ("S6\r\n"); 877 send_buffer = strdup("S6\r\n");
986 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 878 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
987 if (result!=STATE_OK) 879 if (result != STATE_OK)
988 return result; 880 return result;
989 dirty_cache_buffers=atoi(recv_buffer); 881 dirty_cache_buffers = atoi(recv_buffer);
990 882
991 if (check_critical_value && dirty_cache_buffers <= critical_value) 883 if (check_critical_value && dirty_cache_buffers <= critical_value)
992 result=STATE_CRITICAL; 884 result = STATE_CRITICAL;
993 else if (check_warning_value && dirty_cache_buffers <= warning_value) 885 else if (check_warning_value && dirty_cache_buffers <= warning_value)
994 result=STATE_WARNING; 886 result = STATE_WARNING;
995 xasprintf (&output_message,_("Dirty cache buffers = %lu%% of the total|DCB=%lu;%lu;%lu;0;100"), 887 xasprintf(&output_message, _("Dirty cache buffers = %lu%% of the total|DCB=%lu;%lu;%lu;0;100"), dirty_cache_buffers,
996 dirty_cache_buffers, 888 dirty_cache_buffers, warning_value, critical_value);
997 dirty_cache_buffers,
998 warning_value,
999 critical_value);
1000 889
1001 /* check % total cache buffers as a percentage of the original*/ 890 /* check % total cache buffers as a percentage of the original*/
1002 } else if (vars_to_check==TCB) { 891 } else if (vars_to_check == TCB) {
1003 892
1004 close(sd); 893 close(sd);
1005 my_tcp_connect (server_address, server_port, &sd); 894 my_tcp_connect(server_address, server_port, &sd);
1006 895
1007 send_buffer = strdup ("S7\r\n"); 896 send_buffer = strdup("S7\r\n");
1008 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 897 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
1009 if (result!=STATE_OK) 898 if (result != STATE_OK)
1010 return result; 899 return result;
1011 total_cache_buffers=atoi(recv_buffer); 900 total_cache_buffers = atoi(recv_buffer);
1012 901
1013 if (check_critical_value && total_cache_buffers <= critical_value) 902 if (check_critical_value && total_cache_buffers <= critical_value)
1014 result=STATE_CRITICAL; 903 result = STATE_CRITICAL;
1015 else if (check_warning_value && total_cache_buffers <= warning_value) 904 else if (check_warning_value && total_cache_buffers <= warning_value)
1016 result=STATE_WARNING; 905 result = STATE_WARNING;
1017 xasprintf (&output_message,_("Total cache buffers = %lu%% of the original|TCB=%lu;%lu;%lu;0;100"), 906 xasprintf(&output_message, _("Total cache buffers = %lu%% of the original|TCB=%lu;%lu;%lu;0;100"), total_cache_buffers,
1018 total_cache_buffers, 907 total_cache_buffers, warning_value, critical_value);
1019 total_cache_buffers,
1020 warning_value,
1021 critical_value);
1022 908
1023 } else if (vars_to_check==DSVER) { 909 } else if (vars_to_check == DSVER) {
1024 910
1025 close(sd); 911 close(sd);
1026 my_tcp_connect (server_address, server_port, &sd); 912 my_tcp_connect(server_address, server_port, &sd);
1027 913
1028 xasprintf (&send_buffer,"S13\r\n"); 914 xasprintf(&send_buffer, "S13\r\n");
1029 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 915 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
1030 if (result!=STATE_OK) 916 if (result != STATE_OK)
1031 return result; 917 return result;
1032 918
1033 recv_buffer[strlen(recv_buffer)-1]=0; 919 recv_buffer[strlen(recv_buffer) - 1] = 0;
1034 920
1035 xasprintf (&output_message,_("NDS Version %s"),recv_buffer); 921 xasprintf(&output_message, _("NDS Version %s"), recv_buffer);
1036 922
1037 } else if (vars_to_check==UPTIME) { 923 } else if (vars_to_check == UPTIME) {
1038 924
1039 close(sd); 925 close(sd);
1040 my_tcp_connect (server_address, server_port, &sd); 926 my_tcp_connect(server_address, server_port, &sd);
1041
1042 xasprintf (&send_buffer,"UPTIME\r\n");
1043 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
1044 if (result!=STATE_OK)
1045 return result;
1046 927
928 xasprintf(&send_buffer, "UPTIME\r\n");
929 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
930 if (result != STATE_OK)
931 return result;
1047 932
1048 recv_buffer[sizeof(recv_buffer)-1]=0; 933 recv_buffer[sizeof(recv_buffer) - 1] = 0;
1049 recv_buffer[strlen(recv_buffer)-1]=0; 934 recv_buffer[strlen(recv_buffer) - 1] = 0;
1050 935
1051 xasprintf (&output_message,_("Up %s"),recv_buffer); 936 xasprintf(&output_message, _("Up %s"), recv_buffer);
1052 937
1053 } else if (vars_to_check==NLM) { 938 } else if (vars_to_check == NLM) {
1054 939
1055 close(sd); 940 close(sd);
1056 my_tcp_connect (server_address, server_port, &sd); 941 my_tcp_connect(server_address, server_port, &sd);
1057 942
1058 xasprintf (&send_buffer,"S24:%s\r\n",nlm_name); 943 xasprintf(&send_buffer, "S24:%s\r\n", nlm_name);
1059 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 944 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
1060 if (result!=STATE_OK) 945 if (result != STATE_OK)
1061 return result; 946 return result;
1062 947
1063 recv_buffer[strlen(recv_buffer)-1]=0; 948 recv_buffer[strlen(recv_buffer) - 1] = 0;
1064 if (strcmp(recv_buffer,"-1")) { 949 if (strcmp(recv_buffer, "-1")) {
1065 xasprintf (&output_message,_("Module %s version %s is loaded"),nlm_name,recv_buffer); 950 xasprintf(&output_message, _("Module %s version %s is loaded"), nlm_name, recv_buffer);
1066 } else { 951 } else {
1067 result=STATE_CRITICAL; 952 result = STATE_CRITICAL;
1068 xasprintf (&output_message,_("Module %s is not loaded"),nlm_name); 953 xasprintf(&output_message, _("Module %s is not loaded"), nlm_name);
1069 954 }
1070 } 955 } else if (vars_to_check == NRMP) {
1071 } else if (vars_to_check==NRMP) {
1072 956
1073 xasprintf (&send_buffer,"NRMP:%s\r\n",nrmp_name); 957 xasprintf(&send_buffer, "NRMP:%s\r\n", nrmp_name);
1074 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 958 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
1075 if (result!=STATE_OK) 959 if (result != STATE_OK)
1076 return result; 960 return result;
1077 961
1078 if (!strcmp(recv_buffer,"-1\n")) { 962 if (!strcmp(recv_buffer, "-1\n")) {
1079 xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nrmp_name); 963 xasprintf(&output_message, _("CRITICAL - Value '%s' does not exist!"), nrmp_name);
1080 result=STATE_CRITICAL; 964 result = STATE_CRITICAL;
1081 } else { 965 } else {
1082 nrmp_value=strtoul(recv_buffer,NULL,10); 966 nrmp_value = strtoul(recv_buffer, NULL, 10);
1083 if (check_critical_value && nrmp_value <= critical_value) 967 if (check_critical_value && nrmp_value <= critical_value)
1084 result=STATE_CRITICAL; 968 result = STATE_CRITICAL;
1085 else if (check_warning_value && nrmp_value <= warning_value) 969 else if (check_warning_value && nrmp_value <= warning_value)
1086 result=STATE_WARNING; 970 result = STATE_WARNING;
1087 xasprintf (&output_message, 971 xasprintf(&output_message, _("%s is %lu|%s=%lu;%lu;%lu;;"), nrmp_name, nrmp_value, nrmp_name, nrmp_value, warning_value,
1088 _("%s is %lu|%s=%lu;%lu;%lu;;"), 972 critical_value);
1089 nrmp_name,
1090 nrmp_value,
1091 nrmp_name,
1092 nrmp_value,
1093 warning_value,
1094 critical_value);
1095 } 973 }
1096 974
1097 } else if (vars_to_check==NRMM) { 975 } else if (vars_to_check == NRMM) {
1098 976
1099 xasprintf (&send_buffer,"NRMM:%s\r\n",nrmm_name); 977 xasprintf(&send_buffer, "NRMM:%s\r\n", nrmm_name);
1100 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 978 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
1101 if (result!=STATE_OK) 979 if (result != STATE_OK)
1102 return result; 980 return result;
1103 981
1104 if (!strcmp(recv_buffer,"-1\n")) { 982 if (!strcmp(recv_buffer, "-1\n")) {
1105 xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nrmm_name); 983 xasprintf(&output_message, _("CRITICAL - Value '%s' does not exist!"), nrmm_name);
1106 result=STATE_CRITICAL; 984 result = STATE_CRITICAL;
1107 } else { 985 } else {
1108 nrmm_value=strtoul(recv_buffer,NULL,10); 986 nrmm_value = strtoul(recv_buffer, NULL, 10);
1109 if (check_critical_value && nrmm_value <= critical_value) 987 if (check_critical_value && nrmm_value <= critical_value)
1110 result=STATE_CRITICAL; 988 result = STATE_CRITICAL;
1111 else if (check_warning_value && nrmm_value <= warning_value) 989 else if (check_warning_value && nrmm_value <= warning_value)
1112 result=STATE_WARNING; 990 result = STATE_WARNING;
1113 xasprintf (&output_message, 991 xasprintf(&output_message, _("%s is %lu|%s=%lu;%lu;%lu;;"), nrmm_name, nrmm_value, nrmm_name, nrmm_value, warning_value,
1114 _("%s is %lu|%s=%lu;%lu;%lu;;"), 992 critical_value);
1115 nrmm_name,
1116 nrmm_value,
1117 nrmm_name,
1118 nrmm_value,
1119 warning_value,
1120 critical_value);
1121 } 993 }
1122 994
1123 } else if (vars_to_check==NRMS) { 995 } else if (vars_to_check == NRMS) {
1124 996
1125 xasprintf (&send_buffer,"NRMS:%s\r\n",nrms_name); 997 xasprintf(&send_buffer, "NRMS:%s\r\n", nrms_name);
1126 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 998 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
1127 if (result!=STATE_OK) 999 if (result != STATE_OK)
1128 return result; 1000 return result;
1129 1001
1130 if (!strcmp(recv_buffer,"-1\n")) { 1002 if (!strcmp(recv_buffer, "-1\n")) {
1131 xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nrms_name); 1003 xasprintf(&output_message, _("CRITICAL - Value '%s' does not exist!"), nrms_name);
1132 result=STATE_CRITICAL; 1004 result = STATE_CRITICAL;
1133 } else { 1005 } else {
1134 nrms_value=strtoul(recv_buffer,NULL,10); 1006 nrms_value = strtoul(recv_buffer, NULL, 10);
1135 if (check_critical_value && nrms_value >= critical_value) 1007 if (check_critical_value && nrms_value >= critical_value)
1136 result=STATE_CRITICAL; 1008 result = STATE_CRITICAL;
1137 else if (check_warning_value && nrms_value >= warning_value) 1009 else if (check_warning_value && nrms_value >= warning_value)
1138 result=STATE_WARNING; 1010 result = STATE_WARNING;
1139 xasprintf (&output_message, 1011 xasprintf(&output_message, _("%s is %lu|%s=%lu;%lu;%lu;;"), nrms_name, nrms_value, nrms_name, nrms_value, warning_value,
1140 _("%s is %lu|%s=%lu;%lu;%lu;;"), 1012 critical_value);
1141 nrms_name,
1142 nrms_value,
1143 nrms_name,
1144 nrms_value,
1145 warning_value,
1146 critical_value);
1147 } 1013 }
1148 1014
1149 } else if (vars_to_check==NSS1) { 1015 } else if (vars_to_check == NSS1) {
1150 1016
1151 xasprintf (&send_buffer,"NSS1:%s\r\n",nss1_name); 1017 xasprintf(&send_buffer, "NSS1:%s\r\n", nss1_name);
1152 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 1018 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
1153 if (result!=STATE_OK) 1019 if (result != STATE_OK)
1154 return result; 1020 return result;
1155 1021
1156 if (!strcmp(recv_buffer,"-1\n")) { 1022 if (!strcmp(recv_buffer, "-1\n")) {
1157 xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss1_name); 1023 xasprintf(&output_message, _("CRITICAL - Value '%s' does not exist!"), nss1_name);
1158 result=STATE_CRITICAL; 1024 result = STATE_CRITICAL;
1159 } else { 1025 } else {
1160 nss1_value=strtoul(recv_buffer,NULL,10); 1026 nss1_value = strtoul(recv_buffer, NULL, 10);
1161 if (check_critical_value && nss1_value >= critical_value) 1027 if (check_critical_value && nss1_value >= critical_value)
1162 result=STATE_CRITICAL; 1028 result = STATE_CRITICAL;
1163 else if (check_warning_value && nss1_value >= warning_value) 1029 else if (check_warning_value && nss1_value >= warning_value)
1164 result=STATE_WARNING; 1030 result = STATE_WARNING;
1165 xasprintf (&output_message, 1031 xasprintf(&output_message, _("%s is %lu|%s=%lu;%lu;%lu;;"), nss1_name, nss1_value, nss1_name, nss1_value, warning_value,
1166 _("%s is %lu|%s=%lu;%lu;%lu;;"), 1032 critical_value);
1167 nss1_name,
1168 nss1_value,
1169 nss1_name,
1170 nss1_value,
1171 warning_value,
1172 critical_value);
1173 } 1033 }
1174 1034
1175 } else if (vars_to_check==NSS2) { 1035 } else if (vars_to_check == NSS2) {
1176 1036
1177 xasprintf (&send_buffer,"NSS2:%s\r\n",nss2_name); 1037 xasprintf(&send_buffer, "NSS2:%s\r\n", nss2_name);
1178 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 1038 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
1179 if (result!=STATE_OK) 1039 if (result != STATE_OK)
1180 return result; 1040 return result;
1181 1041
1182 if (!strcmp(recv_buffer,"-1\n")) { 1042 if (!strcmp(recv_buffer, "-1\n")) {
1183 xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss2_name); 1043 xasprintf(&output_message, _("CRITICAL - Value '%s' does not exist!"), nss2_name);
1184 result=STATE_CRITICAL; 1044 result = STATE_CRITICAL;
1185 } else { 1045 } else {
1186 nss2_value=strtoul(recv_buffer,NULL,10); 1046 nss2_value = strtoul(recv_buffer, NULL, 10);
1187 if (check_critical_value && nss2_value >= critical_value) 1047 if (check_critical_value && nss2_value >= critical_value)
1188 result=STATE_CRITICAL; 1048 result = STATE_CRITICAL;
1189 else if (check_warning_value && nss2_value >= warning_value) 1049 else if (check_warning_value && nss2_value >= warning_value)
1190 result=STATE_WARNING; 1050 result = STATE_WARNING;
1191 xasprintf (&output_message, 1051 xasprintf(&output_message, _("%s is %lu|%s=%lu;%lu;%lu;;"), nss2_name, nss2_value, nss2_name, nss2_value, warning_value,
1192 _("%s is %lu|%s=%lu;%lu;%lu;;"), 1052 critical_value);
1193 nss2_name,
1194 nss2_value,
1195 nss2_name,
1196 nss2_value,
1197 warning_value,
1198 critical_value);
1199 } 1053 }
1200 1054
1201 } else if (vars_to_check==NSS3) { 1055 } else if (vars_to_check == NSS3) {
1202 1056
1203 xasprintf (&send_buffer,"NSS3:%s\r\n",nss3_name); 1057 xasprintf(&send_buffer, "NSS3:%s\r\n", nss3_name);
1204 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 1058 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
1205 if (result!=STATE_OK) 1059 if (result != STATE_OK)
1206 return result; 1060 return result;
1207 1061
1208 if (!strcmp(recv_buffer,"-1\n")) { 1062 if (!strcmp(recv_buffer, "-1\n")) {
1209 xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss3_name); 1063 xasprintf(&output_message, _("CRITICAL - Value '%s' does not exist!"), nss3_name);
1210 result=STATE_CRITICAL; 1064 result = STATE_CRITICAL;
1211 } else { 1065 } else {
1212 nss3_value=strtoul(recv_buffer,NULL,10); 1066 nss3_value = strtoul(recv_buffer, NULL, 10);
1213 if (check_critical_value && nss3_value >= critical_value) 1067 if (check_critical_value && nss3_value >= critical_value)
1214 result=STATE_CRITICAL; 1068 result = STATE_CRITICAL;
1215 else if (check_warning_value && nss3_value >= warning_value) 1069 else if (check_warning_value && nss3_value >= warning_value)
1216 result=STATE_WARNING; 1070 result = STATE_WARNING;
1217 xasprintf (&output_message, 1071 xasprintf(&output_message, _("%s is %lu|%s=%lu;%lu;%lu;;"), nss3_name, nss3_value, nss3_name, nss3_value, warning_value,
1218 _("%s is %lu|%s=%lu;%lu;%lu;;"), 1072 critical_value);
1219 nss3_name,
1220 nss3_value,
1221 nss3_name,
1222 nss3_value,
1223 warning_value,
1224 critical_value);
1225 } 1073 }
1226 1074
1227 } else if (vars_to_check==NSS4) { 1075 } else if (vars_to_check == NSS4) {
1228 1076
1229 xasprintf (&send_buffer,"NSS4:%s\r\n",nss4_name); 1077 xasprintf(&send_buffer, "NSS4:%s\r\n", nss4_name);
1230 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 1078 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
1231 if (result!=STATE_OK) 1079 if (result != STATE_OK)
1232 return result; 1080 return result;
1233 1081
1234 if (!strcmp(recv_buffer,"-1\n")) { 1082 if (!strcmp(recv_buffer, "-1\n")) {
1235 xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss4_name); 1083 xasprintf(&output_message, _("CRITICAL - Value '%s' does not exist!"), nss4_name);
1236 result=STATE_CRITICAL; 1084 result = STATE_CRITICAL;
1237 } else { 1085 } else {
1238 nss4_value=strtoul(recv_buffer,NULL,10); 1086 nss4_value = strtoul(recv_buffer, NULL, 10);
1239 if (check_critical_value && nss4_value >= critical_value) 1087 if (check_critical_value && nss4_value >= critical_value)
1240 result=STATE_CRITICAL; 1088 result = STATE_CRITICAL;
1241 else if (check_warning_value && nss4_value >= warning_value) 1089 else if (check_warning_value && nss4_value >= warning_value)
1242 result=STATE_WARNING; 1090 result = STATE_WARNING;
1243 xasprintf (&output_message, 1091 xasprintf(&output_message, _("%s is %lu|%s=%lu;%lu;%lu;;"), nss4_name, nss4_value, nss4_name, nss4_value, warning_value,
1244 _("%s is %lu|%s=%lu;%lu;%lu;;"), 1092 critical_value);
1245 nss4_name,
1246 nss4_value,
1247 nss4_name,
1248 nss4_value,
1249 warning_value,
1250 critical_value);
1251 } 1093 }
1252 1094
1253 } else if (vars_to_check==NSS5) { 1095 } else if (vars_to_check == NSS5) {
1254 1096
1255 xasprintf (&send_buffer,"NSS5:%s\r\n",nss5_name); 1097 xasprintf(&send_buffer, "NSS5:%s\r\n", nss5_name);
1256 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 1098 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
1257 if (result!=STATE_OK) 1099 if (result != STATE_OK)
1258 return result; 1100 return result;
1259 1101
1260 if (!strcmp(recv_buffer,"-1\n")) { 1102 if (!strcmp(recv_buffer, "-1\n")) {
1261 xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss5_name); 1103 xasprintf(&output_message, _("CRITICAL - Value '%s' does not exist!"), nss5_name);
1262 result=STATE_CRITICAL; 1104 result = STATE_CRITICAL;
1263 } else { 1105 } else {
1264 nss5_value=strtoul(recv_buffer,NULL,10); 1106 nss5_value = strtoul(recv_buffer, NULL, 10);
1265 if (check_critical_value && nss5_value >= critical_value) 1107 if (check_critical_value && nss5_value >= critical_value)
1266 result=STATE_CRITICAL; 1108 result = STATE_CRITICAL;
1267 else if (check_warning_value && nss5_value >= warning_value) 1109 else if (check_warning_value && nss5_value >= warning_value)
1268 result=STATE_WARNING; 1110 result = STATE_WARNING;
1269 xasprintf (&output_message, 1111 xasprintf(&output_message, _("%s is %lu|%s=%lu;%lu;%lu;;"), nss5_name, nss5_value, nss5_name, nss5_value, warning_value,
1270 _("%s is %lu|%s=%lu;%lu;%lu;;"), 1112 critical_value);
1271 nss5_name,
1272 nss5_value,
1273 nss5_name,
1274 nss5_value,
1275 warning_value,
1276 critical_value);
1277 } 1113 }
1278 1114
1279 } else if (vars_to_check==NSS6) { 1115 } else if (vars_to_check == NSS6) {
1280 1116
1281 xasprintf (&send_buffer,"NSS6:%s\r\n",nss6_name); 1117 xasprintf(&send_buffer, "NSS6:%s\r\n", nss6_name);
1282 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 1118 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
1283 if (result!=STATE_OK) 1119 if (result != STATE_OK)
1284 return result; 1120 return result;
1285 1121
1286 if (!strcmp(recv_buffer,"-1\n")) { 1122 if (!strcmp(recv_buffer, "-1\n")) {
1287 xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss6_name); 1123 xasprintf(&output_message, _("CRITICAL - Value '%s' does not exist!"), nss6_name);
1288 result=STATE_CRITICAL; 1124 result = STATE_CRITICAL;
1289 } else { 1125 } else {
1290 nss6_value=strtoul(recv_buffer,NULL,10); 1126 nss6_value = strtoul(recv_buffer, NULL, 10);
1291 if (check_critical_value && nss6_value >= critical_value) 1127 if (check_critical_value && nss6_value >= critical_value)
1292 result=STATE_CRITICAL; 1128 result = STATE_CRITICAL;
1293 else if (check_warning_value && nss6_value >= warning_value) 1129 else if (check_warning_value && nss6_value >= warning_value)
1294 result=STATE_WARNING; 1130 result = STATE_WARNING;
1295 xasprintf (&output_message, 1131 xasprintf(&output_message, _("%s is %lu|%s=%lu;%lu;%lu;;"), nss6_name, nss6_value, nss6_name, nss6_value, warning_value,
1296 _("%s is %lu|%s=%lu;%lu;%lu;;"), 1132 critical_value);
1297 nss6_name,
1298 nss6_value,
1299 nss6_name,
1300 nss6_value,
1301 warning_value,
1302 critical_value);
1303 } 1133 }
1304 1134
1305 } else if (vars_to_check==NSS7) { 1135 } else if (vars_to_check == NSS7) {
1306 1136
1307 xasprintf (&send_buffer,"NSS7:%s\r\n",nss7_name); 1137 xasprintf(&send_buffer, "NSS7:%s\r\n", nss7_name);
1308 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 1138 result = send_tcp_request(sd, send_buffer, recv_buffer, sizeof(recv_buffer));
1309 if (result!=STATE_OK) 1139 if (result != STATE_OK)
1310 return result; 1140 return result;
1311 1141
1312 if (!strcmp(recv_buffer,"-1\n")) { 1142 if (!strcmp(recv_buffer, "-1\n")) {
1313 xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss7_name); 1143 xasprintf(&output_message, _("CRITICAL - Value '%s' does not exist!"), nss7_name);
1314 result=STATE_CRITICAL; 1144 result = STATE_CRITICAL;
1315 } else { 1145 } else {
1316 nss7_value=strtoul(recv_buffer,NULL,10); 1146 nss7_value = strtoul(recv_buffer, NULL, 10);
1317 if (check_critical_value && nss7_value >= critical_value) 1147 if (check_critical_value && nss7_value >= critical_value)
1318 result=STATE_CRITICAL; 1148 result = STATE_CRITICAL;
1319 else if (check_warning_value && nss7_value >= warning_value) 1149 else if (check_warning_value && nss7_value >= warning_value)
1320 result=STATE_WARNING; 1150 result = STATE_WARNING;
1321 xasprintf (&output_message, 1151 xasprintf(&output_message, _("%s is %lu|%s=%lu;%lu;%lu;;"), nss7_name, nss7_value, nss7_name, nss7_value, warning_value,
1322 _("%s is %lu|%s=%lu;%lu;%lu;;"), 1152 critical_value);
1323 nss7_name,
1324 nss7_value,
1325 nss7_name,
1326 nss7_value,
1327 warning_value,
1328 critical_value);
1329 } 1153 }
1330 1154
1155 } else {
1331 1156
1332} 1157 output_message = strdup(_("Nothing to check!\n"));
1333 else { 1158 result = STATE_UNKNOWN;
1334
1335 output_message = strdup (_("Nothing to check!\n"));
1336 result=STATE_UNKNOWN;
1337
1338 } 1159 }
1339 1160
1340 close (sd); 1161 close(sd);
1341 1162
1342 /* reset timeout */ 1163 /* reset timeout */
1343 alarm(0); 1164 alarm(0);
1344 1165
1345 printf("%s%s\n",netware_version,output_message); 1166 printf("%s%s\n", netware_version, output_message);
1346 1167
1347 return result; 1168 return result;
1348} 1169}
1349 1170
1350
1351
1352/* process command-line arguments */ 1171/* process command-line arguments */
1353int process_arguments(int argc, char **argv) { 1172int process_arguments(int argc, char **argv) {
1354 int c; 1173 int c;
1355 1174
1356 int option = 0; 1175 int option = 0;
1357 static struct option longopts[] = 1176 static struct option longopts[] = {{"port", required_argument, 0, 'p'}, {"timeout", required_argument, 0, 't'},
1358 { 1177 {"critical", required_argument, 0, 'c'}, {"warning", required_argument, 0, 'w'},
1359 {"port", required_argument,0,'p'}, 1178 {"variable", required_argument, 0, 'v'}, {"hostname", required_argument, 0, 'H'},
1360 {"timeout", required_argument,0,'t'}, 1179 {"osversion", no_argument, 0, 'o'}, {"version", no_argument, 0, 'V'},
1361 {"critical", required_argument,0,'c'}, 1180 {"help", no_argument, 0, 'h'}, {0, 0, 0, 0}};
1362 {"warning", required_argument,0,'w'},
1363 {"variable", required_argument,0,'v'},
1364 {"hostname", required_argument,0,'H'},
1365 {"osversion",no_argument, 0,'o'},
1366 {"version", no_argument, 0,'V'},
1367 {"help", no_argument, 0,'h'},
1368 {0,0,0,0}
1369 };
1370 1181
1371 /* no options were supplied */ 1182 /* no options were supplied */
1372 if (argc<2) return ERROR; 1183 if (argc < 2)
1184 return ERROR;
1373 1185
1374 /* backwards compatibility */ 1186 /* backwards compatibility */
1375 if (! is_option(argv[1])) { 1187 if (!is_option(argv[1])) {
1376 server_address=argv[1]; 1188 server_address = argv[1];
1377 argv[1]=argv[0]; 1189 argv[1] = argv[0];
1378 argv=&argv[1]; 1190 argv = &argv[1];
1379 argc--; 1191 argc--;
1380 } 1192 }
1381 1193
1382 for (c=1;c<argc;c++) { 1194 for (c = 1; c < argc; c++) {
1383 if (strcmp("-to",argv[c])==0) 1195 if (strcmp("-to", argv[c]) == 0)
1384 strcpy(argv[c],"-t"); 1196 strcpy(argv[c], "-t");
1385 else if (strcmp("-wv",argv[c])==0) 1197 else if (strcmp("-wv", argv[c]) == 0)
1386 strcpy(argv[c],"-w"); 1198 strcpy(argv[c], "-w");
1387 else if (strcmp("-cv",argv[c])==0) 1199 else if (strcmp("-cv", argv[c]) == 0)
1388 strcpy(argv[c],"-c"); 1200 strcpy(argv[c], "-c");
1389 } 1201 }
1390 1202
1391 while (1) { 1203 while (1) {
1392 c = getopt_long(argc,argv,"+hoVH:t:c:w:p:v:",longopts,&option); 1204 c = getopt_long(argc, argv, "+hoVH:t:c:w:p:v:", longopts, &option);
1393 1205
1394 if (c==-1||c==EOF||c==1) 1206 if (c == -1 || c == EOF || c == 1)
1395 break; 1207 break;
1396 1208
1397 switch (c) 1209 switch (c) {
1398 { 1210 case '?': /* print short usage statement if args not parsable */
1399 case '?': /* print short usage statement if args not parsable */ 1211 usage5();
1400 usage5 (); 1212 case 'h': /* help */
1401 case 'h': /* help */ 1213 print_help();
1402 print_help(); 1214 exit(STATE_UNKNOWN);
1403 exit(STATE_UNKNOWN); 1215 case 'V': /* version */
1404 case 'V': /* version */ 1216 print_revision(progname, NP_VERSION);
1405 print_revision(progname, NP_VERSION); 1217 exit(STATE_UNKNOWN);
1406 exit(STATE_UNKNOWN); 1218 case 'H': /* hostname */
1407 case 'H': /* hostname */ 1219 server_address = optarg;
1408 server_address=optarg; 1220 break;
1409 break; 1221 case 'o': /* display nos version */
1410 case 'o': /* display nos version */ 1222 check_netware_version = true;
1411 check_netware_version = true; 1223 break;
1412 break; 1224 case 'p': /* port */
1413 case 'p': /* port */ 1225 if (is_intnonneg(optarg))
1414 if (is_intnonneg(optarg)) 1226 server_port = atoi(optarg);
1415 server_port=atoi(optarg); 1227 else
1228 die(STATE_UNKNOWN, _("Server port an integer\n"));
1229 break;
1230 case 'v':
1231 if (strlen(optarg) < 3)
1232 return ERROR;
1233 if (!strcmp(optarg, "LOAD1"))
1234 vars_to_check = LOAD1;
1235 else if (!strcmp(optarg, "LOAD5"))
1236 vars_to_check = LOAD5;
1237 else if (!strcmp(optarg, "LOAD15"))
1238 vars_to_check = LOAD15;
1239 else if (!strcmp(optarg, "CONNS"))
1240 vars_to_check = CONNS;
1241 else if (!strcmp(optarg, "LTCH"))
1242 vars_to_check = LTCH;
1243 else if (!strcmp(optarg, "DCB"))
1244 vars_to_check = DCB;
1245 else if (!strcmp(optarg, "TCB"))
1246 vars_to_check = TCB;
1247 else if (!strcmp(optarg, "CBUFF"))
1248 vars_to_check = CBUFF;
1249 else if (!strcmp(optarg, "CDBUFF"))
1250 vars_to_check = CDBUFF;
1251 else if (!strcmp(optarg, "LRUM"))
1252 vars_to_check = LRUM;
1253 else if (!strcmp(optarg, "LRUS"))
1254 vars_to_check = LRUS;
1255 else if (strncmp(optarg, "VPF", 3) == 0) {
1256 vars_to_check = VPF;
1257 volume_name = strdup(optarg + 3);
1258 if (!strcmp(volume_name, ""))
1259 volume_name = strdup("SYS");
1260 } else if (strncmp(optarg, "VKF", 3) == 0) {
1261 vars_to_check = VKF;
1262 volume_name = strdup(optarg + 3);
1263 if (!strcmp(volume_name, ""))
1264 volume_name = strdup("SYS");
1265 } else if (strncmp(optarg, "VMF", 3) == 0) {
1266 vars_to_check = VMF;
1267 volume_name = strdup(optarg + 3);
1268 if (!strcmp(volume_name, ""))
1269 volume_name = strdup("SYS");
1270 } else if (!strcmp(optarg, "DSDB"))
1271 vars_to_check = DSDB;
1272 else if (!strcmp(optarg, "LOGINS"))
1273 vars_to_check = LOGINS;
1274 else if (!strcmp(optarg, "NRMH"))
1275 vars_to_check = NRMH;
1276 else if (!strcmp(optarg, "UPRB"))
1277 vars_to_check = UPRB;
1278 else if (!strcmp(optarg, "PUPRB"))
1279 vars_to_check = PUPRB;
1280 else if (!strncmp(optarg, "SAPENTRIES", 10)) {
1281 vars_to_check = SAPENTRIES;
1282 if (strlen(optarg) > 10)
1283 sap_number = atoi(optarg + 10);
1416 else 1284 else
1417 die(STATE_UNKNOWN,_("Server port an integer\n")); 1285 sap_number = -1;
1418 break; 1286 } else if (!strcmp(optarg, "OFILES"))
1419 case 'v': 1287 vars_to_check = OFILES;
1420 if (strlen(optarg)<3) 1288 else if (strncmp(optarg, "VKP", 3) == 0) {
1421 return ERROR; 1289 vars_to_check = VKP;
1422 if (!strcmp(optarg,"LOAD1")) 1290 volume_name = strdup(optarg + 3);
1423 vars_to_check=LOAD1; 1291 if (!strcmp(volume_name, ""))
1424 else if (!strcmp(optarg,"LOAD5")) 1292 volume_name = strdup("SYS");
1425 vars_to_check=LOAD5; 1293 } else if (strncmp(optarg, "VMP", 3) == 0) {
1426 else if (!strcmp(optarg,"LOAD15")) 1294 vars_to_check = VMP;
1427 vars_to_check=LOAD15; 1295 volume_name = strdup(optarg + 3);
1428 else if (!strcmp(optarg,"CONNS")) 1296 if (!strcmp(volume_name, ""))
1429 vars_to_check=CONNS; 1297 volume_name = strdup("SYS");
1430 else if (!strcmp(optarg,"LTCH")) 1298 } else if (strncmp(optarg, "VMU", 3) == 0) {
1431 vars_to_check=LTCH; 1299 vars_to_check = VMU;
1432 else if (!strcmp(optarg,"DCB")) 1300 volume_name = strdup(optarg + 3);
1433 vars_to_check=DCB; 1301 if (!strcmp(volume_name, ""))
1434 else if (!strcmp(optarg,"TCB")) 1302 volume_name = strdup("SYS");
1435 vars_to_check=TCB; 1303 } else if (strncmp(optarg, "VPU", 3) == 0) {
1436 else if (!strcmp(optarg,"CBUFF")) 1304 vars_to_check = VPU;
1437 vars_to_check=CBUFF; 1305 volume_name = strdup(optarg + 3);
1438 else if (!strcmp(optarg,"CDBUFF")) 1306 if (!strcmp(volume_name, ""))
1439 vars_to_check=CDBUFF; 1307 volume_name = strdup("SYS");
1440 else if (!strcmp(optarg,"LRUM")) 1308 } else if (strncmp(optarg, "VPP", 3) == 0) {
1441 vars_to_check=LRUM; 1309 vars_to_check = VPP;
1442 else if (!strcmp(optarg,"LRUS")) 1310 volume_name = strdup(optarg + 3);
1443 vars_to_check=LRUS; 1311 if (!strcmp(volume_name, ""))
1444 else if (strncmp(optarg,"VPF",3)==0) { 1312 volume_name = strdup("SYS");
1445 vars_to_check=VPF; 1313 } else if (strncmp(optarg, "VKNP", 4) == 0) {
1446 volume_name = strdup (optarg+3); 1314 vars_to_check = VKNP;
1447 if (!strcmp(volume_name,"")) 1315 volume_name = strdup(optarg + 4);
1448 volume_name = strdup ("SYS"); 1316 if (!strcmp(volume_name, ""))
1449 } 1317 volume_name = strdup("SYS");
1450 else if (strncmp(optarg,"VKF",3)==0) { 1318 } else if (strncmp(optarg, "VPNP", 4) == 0) {
1451 vars_to_check=VKF; 1319 vars_to_check = VPNP;
1452 volume_name = strdup (optarg+3); 1320 volume_name = strdup(optarg + 4);
1453 if (!strcmp(volume_name,"")) 1321 if (!strcmp(volume_name, ""))
1454 volume_name = strdup ("SYS"); 1322 volume_name = strdup("SYS");
1455 } 1323 } else if (!strcmp(optarg, "ABENDS"))
1456 else if (strncmp(optarg,"VMF",3)==0) { 1324 vars_to_check = ABENDS;
1457 vars_to_check=VMF; 1325 else if (!strcmp(optarg, "CSPROCS"))
1458 volume_name = strdup (optarg+3); 1326 vars_to_check = CSPROCS;
1459 if (!strcmp(volume_name,"")) 1327 else if (!strcmp(optarg, "TSYNC"))
1460 volume_name = strdup ("SYS"); 1328 vars_to_check = TSYNC;
1461 } 1329 else if (!strcmp(optarg, "DSVER"))
1462 else if (!strcmp(optarg,"DSDB")) 1330 vars_to_check = DSVER;
1463 vars_to_check=DSDB; 1331 else if (!strcmp(optarg, "UPTIME")) {
1464 else if (!strcmp(optarg,"LOGINS")) 1332 vars_to_check = UPTIME;
1465 vars_to_check=LOGINS; 1333 } else if (strncmp(optarg, "NLM:", 4) == 0) {
1466 else if (!strcmp(optarg,"NRMH")) 1334 vars_to_check = NLM;
1467 vars_to_check=NRMH; 1335 nlm_name = strdup(optarg + 4);
1468 else if (!strcmp(optarg,"UPRB")) 1336 } else if (strncmp(optarg, "NRMP", 4) == 0) {
1469 vars_to_check=UPRB; 1337 vars_to_check = NRMP;
1470 else if (!strcmp(optarg,"PUPRB")) 1338 nrmp_name = strdup(optarg + 4);
1471 vars_to_check=PUPRB; 1339 if (!strcmp(nrmp_name, ""))
1472 else if (!strncmp(optarg,"SAPENTRIES",10)) { 1340 nrmp_name = strdup("AVAILABLE_MEMORY");
1473 vars_to_check=SAPENTRIES; 1341 } else if (strncmp(optarg, "NRMM", 4) == 0) {
1474 if (strlen(optarg)>10) 1342 vars_to_check = NRMM;
1475 sap_number=atoi(optarg+10); 1343 nrmm_name = strdup(optarg + 4);
1476 else 1344 if (!strcmp(nrmm_name, ""))
1477 sap_number=-1; 1345 nrmm_name = strdup("AVAILABLE_CACHE_MEMORY");
1478 }
1479 else if (!strcmp(optarg,"OFILES"))
1480 vars_to_check=OFILES;
1481 else if (strncmp(optarg,"VKP",3)==0) {
1482 vars_to_check=VKP;
1483 volume_name = strdup (optarg+3);
1484 if (!strcmp(volume_name,""))
1485 volume_name = strdup ("SYS");
1486 }
1487 else if (strncmp(optarg,"VMP",3)==0) {
1488 vars_to_check=VMP;
1489 volume_name = strdup (optarg+3);
1490 if (!strcmp(volume_name,""))
1491 volume_name = strdup ("SYS");
1492 }
1493 else if (strncmp(optarg,"VMU",3)==0) {
1494 vars_to_check=VMU;
1495 volume_name = strdup (optarg+3);
1496 if (!strcmp(volume_name,""))
1497 volume_name = strdup ("SYS");
1498 }
1499 else if (strncmp(optarg,"VPU",3)==0) {
1500 vars_to_check=VPU;
1501 volume_name = strdup (optarg+3);
1502 if (!strcmp(volume_name,""))
1503 volume_name = strdup ("SYS");
1504 }
1505 else if (strncmp(optarg,"VPP",3)==0) {
1506 vars_to_check=VPP;
1507 volume_name = strdup (optarg+3);
1508 if (!strcmp(volume_name,""))
1509 volume_name = strdup ("SYS");
1510 }
1511 else if (strncmp(optarg,"VKNP",4)==0) {
1512 vars_to_check=VKNP;
1513 volume_name = strdup (optarg+4);
1514 if (!strcmp(volume_name,""))
1515 volume_name = strdup ("SYS");
1516 }
1517 else if (strncmp(optarg,"VPNP",4)==0) {
1518 vars_to_check=VPNP;
1519 volume_name = strdup (optarg+4);
1520 if (!strcmp(volume_name,""))
1521 volume_name = strdup("SYS");
1522 }
1523 else if (!strcmp(optarg,"ABENDS"))
1524 vars_to_check=ABENDS;
1525 else if (!strcmp(optarg,"CSPROCS"))
1526 vars_to_check=CSPROCS;
1527 else if (!strcmp(optarg,"TSYNC"))
1528 vars_to_check=TSYNC;
1529 else if (!strcmp(optarg,"DSVER"))
1530 vars_to_check=DSVER;
1531 else if (!strcmp(optarg,"UPTIME")) {
1532 vars_to_check=UPTIME;
1533 }
1534 else if (strncmp(optarg,"NLM:",4)==0) {
1535 vars_to_check=NLM;
1536 nlm_name=strdup (optarg+4);
1537 }
1538 else if (strncmp(optarg,"NRMP",4)==0) {
1539 vars_to_check=NRMP;
1540 nrmp_name = strdup (optarg+4);
1541 if (!strcmp(nrmp_name,""))
1542 nrmp_name = strdup ("AVAILABLE_MEMORY");
1543 }
1544 else if (strncmp(optarg,"NRMM",4)==0) {
1545 vars_to_check=NRMM;
1546 nrmm_name = strdup (optarg+4);
1547 if (!strcmp(nrmm_name,""))
1548 nrmm_name = strdup ("AVAILABLE_CACHE_MEMORY");
1549
1550 }
1551
1552 else if (strncmp(optarg,"NRMS",4)==0) {
1553 vars_to_check=NRMS;
1554 nrms_name = strdup (optarg+4);
1555 if (!strcmp(nrms_name,""))
1556 nrms_name = strdup ("USED_SWAP_SPACE");
1557
1558 }
1559
1560 else if (strncmp(optarg,"NSS1",4)==0) {
1561 vars_to_check=NSS1;
1562 nss1_name = strdup (optarg+4);
1563 if (!strcmp(nss1_name,""))
1564 nss1_name = strdup ("CURRENTBUFFERCACHESIZE");
1565
1566 }
1567
1568 else if (strncmp(optarg,"NSS2",4)==0) {
1569 vars_to_check=NSS2;
1570 nss2_name = strdup (optarg+4);
1571 if (!strcmp(nss2_name,""))
1572 nss2_name = strdup ("CACHEHITS");
1573
1574 }
1575
1576 else if (strncmp(optarg,"NSS3",4)==0) {
1577 vars_to_check=NSS3;
1578 nss3_name = strdup (optarg+4);
1579 if (!strcmp(nss3_name,""))
1580 nss3_name = strdup ("CACHEGITPERCENT");
1581
1582 }
1583
1584 else if (strncmp(optarg,"NSS4",4)==0) {
1585 vars_to_check=NSS4;
1586 nss4_name = strdup (optarg+4);
1587 if (!strcmp(nss4_name,""))
1588 nss4_name = strdup ("CURRENTOPENCOUNT");
1589
1590 }
1591
1592 else if (strncmp(optarg,"NSS5",4)==0) {
1593 vars_to_check=NSS5;
1594 nss5_name = strdup (optarg+4);
1595 if (!strcmp(nss5_name,""))
1596 nss5_name = strdup ("CACHEMISSES");
1597
1598 }
1599
1600
1601 else if (strncmp(optarg,"NSS6",4)==0) {
1602 vars_to_check=NSS6;
1603 nss6_name = strdup (optarg+4);
1604 if (!strcmp(nss6_name,""))
1605 nss6_name = strdup ("PENDINGWORKSCOUNT");
1606
1607 }
1608
1609
1610 else if (strncmp(optarg,"NSS7",4)==0) {
1611 vars_to_check=NSS7;
1612 nss7_name = strdup (optarg+4);
1613 if (!strcmp(nss7_name,""))
1614 nss7_name = strdup ("CACHESIZE");
1615
1616 }
1617 1346
1347 }
1348
1349 else if (strncmp(optarg, "NRMS", 4) == 0) {
1350 vars_to_check = NRMS;
1351 nrms_name = strdup(optarg + 4);
1352 if (!strcmp(nrms_name, ""))
1353 nrms_name = strdup("USED_SWAP_SPACE");
1618 1354
1619 else
1620 return ERROR;
1621 break;
1622 case 'w': /* warning threshold */
1623 warning_value=strtoul(optarg,NULL,10);
1624 check_warning_value = true;
1625 break;
1626 case 'c': /* critical threshold */
1627 critical_value=strtoul(optarg,NULL,10);
1628 check_critical_value = true;
1629 break;
1630 case 't': /* timeout */
1631 socket_timeout=atoi(optarg);
1632 if (socket_timeout<=0)
1633 return ERROR;
1634 } 1355 }
1635 1356
1357 else if (strncmp(optarg, "NSS1", 4) == 0) {
1358 vars_to_check = NSS1;
1359 nss1_name = strdup(optarg + 4);
1360 if (!strcmp(nss1_name, ""))
1361 nss1_name = strdup("CURRENTBUFFERCACHESIZE");
1362
1363 }
1364
1365 else if (strncmp(optarg, "NSS2", 4) == 0) {
1366 vars_to_check = NSS2;
1367 nss2_name = strdup(optarg + 4);
1368 if (!strcmp(nss2_name, ""))
1369 nss2_name = strdup("CACHEHITS");
1370
1371 }
1372
1373 else if (strncmp(optarg, "NSS3", 4) == 0) {
1374 vars_to_check = NSS3;
1375 nss3_name = strdup(optarg + 4);
1376 if (!strcmp(nss3_name, ""))
1377 nss3_name = strdup("CACHEGITPERCENT");
1378
1379 }
1380
1381 else if (strncmp(optarg, "NSS4", 4) == 0) {
1382 vars_to_check = NSS4;
1383 nss4_name = strdup(optarg + 4);
1384 if (!strcmp(nss4_name, ""))
1385 nss4_name = strdup("CURRENTOPENCOUNT");
1386
1387 }
1388
1389 else if (strncmp(optarg, "NSS5", 4) == 0) {
1390 vars_to_check = NSS5;
1391 nss5_name = strdup(optarg + 4);
1392 if (!strcmp(nss5_name, ""))
1393 nss5_name = strdup("CACHEMISSES");
1394
1395 }
1396
1397 else if (strncmp(optarg, "NSS6", 4) == 0) {
1398 vars_to_check = NSS6;
1399 nss6_name = strdup(optarg + 4);
1400 if (!strcmp(nss6_name, ""))
1401 nss6_name = strdup("PENDINGWORKSCOUNT");
1402
1403 }
1404
1405 else if (strncmp(optarg, "NSS7", 4) == 0) {
1406 vars_to_check = NSS7;
1407 nss7_name = strdup(optarg + 4);
1408 if (!strcmp(nss7_name, ""))
1409 nss7_name = strdup("CACHESIZE");
1410
1411 }
1412
1413 else
1414 return ERROR;
1415 break;
1416 case 'w': /* warning threshold */
1417 warning_value = strtoul(optarg, NULL, 10);
1418 check_warning_value = true;
1419 break;
1420 case 'c': /* critical threshold */
1421 critical_value = strtoul(optarg, NULL, 10);
1422 check_critical_value = true;
1423 break;
1424 case 't': /* timeout */
1425 socket_timeout = atoi(optarg);
1426 if (socket_timeout <= 0)
1427 return ERROR;
1428 }
1636 } 1429 }
1637 1430
1638 return OK; 1431 return OK;
1639} 1432}
1640 1433
1641 1434void print_help(void) {
1642
1643void print_help(void)
1644{
1645 char *myport; 1435 char *myport;
1646 xasprintf (&myport, "%d", PORT); 1436 xasprintf(&myport, "%d", PORT);
1647 1437
1648 print_revision (progname, NP_VERSION); 1438 print_revision(progname, NP_VERSION);
1649 1439
1650 printf ("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n"); 1440 printf("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n");
1651 printf (COPYRIGHT, copyright, email); 1441 printf(COPYRIGHT, copyright, email);
1652 1442
1653 printf ("%s\n", _("This plugin attempts to contact the MRTGEXT NLM running on a")); 1443 printf("%s\n", _("This plugin attempts to contact the MRTGEXT NLM running on a"));
1654 printf ("%s\n", _("Novell server to gather the requested system information.")); 1444 printf("%s\n", _("Novell server to gather the requested system information."));
1655 1445
1656 printf ("\n\n"); 1446 printf("\n\n");
1657 1447
1658 print_usage(); 1448 print_usage();
1659 1449
1660 printf (UT_HELP_VRSN); 1450 printf(UT_HELP_VRSN);
1661 printf (UT_EXTRA_OPTS); 1451 printf(UT_EXTRA_OPTS);
1662 1452
1663 printf (UT_HOST_PORT, 'p', myport); 1453 printf(UT_HOST_PORT, 'p', myport);
1664 1454
1665 printf (" %s\n", "-v, --variable=STRING"); 1455 printf(" %s\n", "-v, --variable=STRING");
1666 printf (" %s\n", _("Variable to check. Valid variables include:")); 1456 printf(" %s\n", _("Variable to check. Valid variables include:"));
1667 printf (" %s\n", _("LOAD1 = 1 minute average CPU load")); 1457 printf(" %s\n", _("LOAD1 = 1 minute average CPU load"));
1668 printf (" %s\n", _("LOAD5 = 5 minute average CPU load")); 1458 printf(" %s\n", _("LOAD5 = 5 minute average CPU load"));
1669 printf (" %s\n", _("LOAD15 = 15 minute average CPU load")); 1459 printf(" %s\n", _("LOAD15 = 15 minute average CPU load"));
1670 printf (" %s\n", _("CSPROCS = number of current service processes (NW 5.x only)")); 1460 printf(" %s\n", _("CSPROCS = number of current service processes (NW 5.x only)"));
1671 printf (" %s\n", _("ABENDS = number of abended threads (NW 5.x only)")); 1461 printf(" %s\n", _("ABENDS = number of abended threads (NW 5.x only)"));
1672 printf (" %s\n", _("UPTIME = server uptime")); 1462 printf(" %s\n", _("UPTIME = server uptime"));
1673 printf (" %s\n", _("LTCH = percent long term cache hits")); 1463 printf(" %s\n", _("LTCH = percent long term cache hits"));
1674 printf (" %s\n", _("CBUFF = current number of cache buffers")); 1464 printf(" %s\n", _("CBUFF = current number of cache buffers"));
1675 printf (" %s\n", _("CDBUFF = current number of dirty cache buffers")); 1465 printf(" %s\n", _("CDBUFF = current number of dirty cache buffers"));
1676 printf (" %s\n", _("DCB = dirty cache buffers as a percentage of the total")); 1466 printf(" %s\n", _("DCB = dirty cache buffers as a percentage of the total"));
1677 printf (" %s\n", _("TCB = dirty cache buffers as a percentage of the original")); 1467 printf(" %s\n", _("TCB = dirty cache buffers as a percentage of the original"));
1678 printf (" %s\n", _("OFILES = number of open files")); 1468 printf(" %s\n", _("OFILES = number of open files"));
1679 printf (" %s\n", _(" VMF<vol> = MB of free space on Volume <vol>")); 1469 printf(" %s\n", _(" VMF<vol> = MB of free space on Volume <vol>"));
1680 printf (" %s\n", _(" VMU<vol> = MB used space on Volume <vol>")); 1470 printf(" %s\n", _(" VMU<vol> = MB used space on Volume <vol>"));
1681 printf (" %s\n", _(" VPU<vol> = percent used space on Volume <vol>")); 1471 printf(" %s\n", _(" VPU<vol> = percent used space on Volume <vol>"));
1682 printf (" %s\n", _(" VMP<vol> = MB of purgeable space on Volume <vol>")); 1472 printf(" %s\n", _(" VMP<vol> = MB of purgeable space on Volume <vol>"));
1683 printf (" %s\n", _(" VPF<vol> = percent free space on volume <vol>")); 1473 printf(" %s\n", _(" VPF<vol> = percent free space on volume <vol>"));
1684 printf (" %s\n", _(" VKF<vol> = KB of free space on volume <vol>")); 1474 printf(" %s\n", _(" VKF<vol> = KB of free space on volume <vol>"));
1685 printf (" %s\n", _(" VPP<vol> = percent purgeable space on volume <vol>")); 1475 printf(" %s\n", _(" VPP<vol> = percent purgeable space on volume <vol>"));
1686 printf (" %s\n", _(" VKP<vol> = KB of purgeable space on volume <vol>")); 1476 printf(" %s\n", _(" VKP<vol> = KB of purgeable space on volume <vol>"));
1687 printf (" %s\n", _(" VPNP<vol> = percent not yet purgeable space on volume <vol>")); 1477 printf(" %s\n", _(" VPNP<vol> = percent not yet purgeable space on volume <vol>"));
1688 printf (" %s\n", _(" VKNP<vol> = KB of not yet purgeable space on volume <vol>")); 1478 printf(" %s\n", _(" VKNP<vol> = KB of not yet purgeable space on volume <vol>"));
1689 printf (" %s\n", _(" LRUM = LRU sitting time in minutes")); 1479 printf(" %s\n", _(" LRUM = LRU sitting time in minutes"));
1690 printf (" %s\n", _(" LRUS = LRU sitting time in seconds")); 1480 printf(" %s\n", _(" LRUS = LRU sitting time in seconds"));
1691 printf (" %s\n", _(" DSDB = check to see if DS Database is open")); 1481 printf(" %s\n", _(" DSDB = check to see if DS Database is open"));
1692 printf (" %s\n", _(" DSVER = NDS version")); 1482 printf(" %s\n", _(" DSVER = NDS version"));
1693 printf (" %s\n", _(" UPRB = used packet receive buffers")); 1483 printf(" %s\n", _(" UPRB = used packet receive buffers"));
1694 printf (" %s\n", _(" PUPRB = percent (of max) used packet receive buffers")); 1484 printf(" %s\n", _(" PUPRB = percent (of max) used packet receive buffers"));
1695 printf (" %s\n", _(" SAPENTRIES = number of entries in the SAP table")); 1485 printf(" %s\n", _(" SAPENTRIES = number of entries in the SAP table"));
1696 printf (" %s\n", _(" SAPENTRIES<n> = number of entries in the SAP table for SAP type <n>")); 1486 printf(" %s\n", _(" SAPENTRIES<n> = number of entries in the SAP table for SAP type <n>"));
1697 printf (" %s\n", _(" TSYNC = timesync status")); 1487 printf(" %s\n", _(" TSYNC = timesync status"));
1698 printf (" %s\n", _(" LOGINS = check to see if logins are enabled")); 1488 printf(" %s\n", _(" LOGINS = check to see if logins are enabled"));
1699 printf (" %s\n", _(" CONNS = number of currently licensed connections")); 1489 printf(" %s\n", _(" CONNS = number of currently licensed connections"));
1700 printf (" %s\n", _(" NRMH = NRM Summary Status")); 1490 printf(" %s\n", _(" NRMH = NRM Summary Status"));
1701 printf (" %s\n", _(" NRMP<stat> = Returns the current value for a NRM health item")); 1491 printf(" %s\n", _(" NRMP<stat> = Returns the current value for a NRM health item"));
1702 printf (" %s\n", _(" NRMM<stat> = Returns the current memory stats from NRM")); 1492 printf(" %s\n", _(" NRMM<stat> = Returns the current memory stats from NRM"));
1703 printf (" %s\n", _(" NRMS<stat> = Returns the current Swapfile stats from NRM")); 1493 printf(" %s\n", _(" NRMS<stat> = Returns the current Swapfile stats from NRM"));
1704 printf (" %s\n", _(" NSS1<stat> = Statistics from _Admin:Manage_NSS\\GeneralStats.xml")); 1494 printf(" %s\n", _(" NSS1<stat> = Statistics from _Admin:Manage_NSS\\GeneralStats.xml"));
1705 printf (" %s\n", _(" NSS3<stat> = Statistics from _Admin:Manage_NSS\\NameCache.xml")); 1495 printf(" %s\n", _(" NSS3<stat> = Statistics from _Admin:Manage_NSS\\NameCache.xml"));
1706 printf (" %s\n", _(" NSS4<stat> = Statistics from _Admin:Manage_NSS\\FileStats.xml")); 1496 printf(" %s\n", _(" NSS4<stat> = Statistics from _Admin:Manage_NSS\\FileStats.xml"));
1707 printf (" %s\n", _(" NSS5<stat> = Statistics from _Admin:Manage_NSS\\ObjectCache.xml")); 1497 printf(" %s\n", _(" NSS5<stat> = Statistics from _Admin:Manage_NSS\\ObjectCache.xml"));
1708 printf (" %s\n", _(" NSS6<stat> = Statistics from _Admin:Manage_NSS\\Thread.xml")); 1498 printf(" %s\n", _(" NSS6<stat> = Statistics from _Admin:Manage_NSS\\Thread.xml"));
1709 printf (" %s\n", _(" NSS7<stat> = Statistics from _Admin:Manage_NSS\\AuthorizationCache.xml")); 1499 printf(" %s\n", _(" NSS7<stat> = Statistics from _Admin:Manage_NSS\\AuthorizationCache.xml"));
1710 printf (" %s\n", _(" NLM:<nlm> = check if NLM is loaded and report version")); 1500 printf(" %s\n", _(" NLM:<nlm> = check if NLM is loaded and report version"));
1711 printf (" %s\n", _(" (e.g. NLM:TSANDS.NLM)")); 1501 printf(" %s\n", _(" (e.g. NLM:TSANDS.NLM)"));
1712 printf ("\n"); 1502 printf("\n");
1713 printf (" %s\n", "-w, --warning=INTEGER"); 1503 printf(" %s\n", "-w, --warning=INTEGER");
1714 printf (" %s\n", _("Threshold which will result in a warning status")); 1504 printf(" %s\n", _("Threshold which will result in a warning status"));
1715 printf (" %s\n", "-c, --critical=INTEGER"); 1505 printf(" %s\n", "-c, --critical=INTEGER");
1716 printf (" %s\n", _("Threshold which will result in a critical status")); 1506 printf(" %s\n", _("Threshold which will result in a critical status"));
1717 printf (" %s\n", "-o, --osversion"); 1507 printf(" %s\n", "-o, --osversion");
1718 printf (" %s\n", _("Include server version string in results")); 1508 printf(" %s\n", _("Include server version string in results"));
1719 1509
1720 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 1510 printf(UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
1721 1511
1722 printf ("\n"); 1512 printf("\n");
1723 printf ("%s\n", _("Notes:")); 1513 printf("%s\n", _("Notes:"));
1724 printf (" %s\n", _("- This plugin requires that the MRTGEXT.NLM file from James Drews' MRTG")); 1514 printf(" %s\n", _("- This plugin requires that the MRTGEXT.NLM file from James Drews' MRTG"));
1725 printf (" %s\n", _(" extension for NetWare be loaded on the Novell servers you wish to check.")); 1515 printf(" %s\n", _(" extension for NetWare be loaded on the Novell servers you wish to check."));
1726 printf (" %s\n", _(" (available from http://www.engr.wisc.edu/~drews/mrtg/)")); 1516 printf(" %s\n", _(" (available from http://www.engr.wisc.edu/~drews/mrtg/)"));
1727 printf (" %s\n", _("- Values for critical thresholds should be lower than warning thresholds")); 1517 printf(" %s\n", _("- Values for critical thresholds should be lower than warning thresholds"));
1728 printf (" %s\n", _(" when the following variables are checked: VPF, VKF, LTCH, CBUFF, DCB, ")); 1518 printf(" %s\n", _(" when the following variables are checked: VPF, VKF, LTCH, CBUFF, DCB, "));
1729 printf (" %s\n", _(" TCB, LRUS and LRUM.")); 1519 printf(" %s\n", _(" TCB, LRUS and LRUM."));
1730 1520
1731 printf (UT_SUPPORT); 1521 printf(UT_SUPPORT);
1732} 1522}
1733 1523
1734 1524void print_usage(void) {
1735 1525 printf("%s\n", _("Usage:"));
1736void print_usage(void) 1526 printf("%s -H host [-p port] [-v variable] [-w warning] [-c critical] [-t timeout]\n", progname);
1737{
1738 printf ("%s\n", _("Usage:"));
1739 printf ("%s -H host [-p port] [-v variable] [-w warning] [-c critical] [-t timeout]\n",progname);
1740} 1527}