1 /*****************************************************************************
3 * Monitoring check_nwstat plugin
6 * Copyright (c) 2000-2024 Monitoring Plugins Development Team
10 * This file contains the check_nwstat plugin
12 * This plugin attempts to contact the MRTGEXT NLM running on a
13 * Novell server to gather the requested system information.
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
18 * the Free Software Foundation, either version 3 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
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/>.
30 *****************************************************************************/
32 const char *progname
= "check_nwstat";
33 const char *copyright
= "2000-2024";
34 const char *email
= "devel@monitoring-plugins.org";
42 LOAD1
, /* check 1 minute CPU load */
43 LOAD5
, /* check 5 minute CPU load */
44 LOAD15
, /* check 15 minute CPU load */
45 CONNS
, /* check number of connections */
46 VPF
, /* check % free space on volume */
47 VMF
, /* check MB free space on volume */
48 VMU
, /* check MB used space on volume */
49 VPU
, /* check % used space on volume */
50 VMP
, /* check MB purgeable space on volume */
51 VKF
, /* check KB free space on volume */
52 LTCH
, /* check long-term cache hit percentage */
53 CBUFF
, /* check total cache buffers */
54 CDBUFF
, /* check dirty cache buffers */
55 LRUM
, /* check LRU sitting time in minutes */
56 DSDB
, /* check to see if DS Database is open */
57 LOGINS
, /* check to see if logins are enabled */
58 NRMH
, /* check to see NRM Health Status */
59 PUPRB
, /* check % of used packet receive buffers */
60 UPRB
, /* check used packet receive buffers */
61 SAPENTRIES
, /* check SAP entries */
62 OFILES
, /* check number of open files */
63 VKP
, /* check KB purgeable space on volume */
64 VPP
, /* check % purgeable space on volume */
65 VKNP
, /* check KB not yet purgeable space on volume */
66 VPNP
, /* check % not yet purgeable space on volume */
67 ABENDS
, /* check abended thread count */
68 CSPROCS
, /* check number of current service processes */
69 TSYNC
, /* check timesync status 0=no 1=yes in sync to the network */
70 LRUS
, /* check LRU sitting time in seconds */
71 DCB
, /* check dirty cache buffers as a percentage of the total */
72 TCB
, /* check total cache buffers as a percentage of the original */
73 DSVER
, /* check NDS version */
74 UPTIME
, /* check server uptime */
75 NLM
, /* check NLM loaded */
76 NRMP
, /* check NRM Process Values */
77 NRMM
, /* check NRM Memory Values */
78 NRMS
, /* check NRM Values */
79 NSS1
, /* check Statistics from _Admin:Manage_NSS\GeneralStats.xml */
80 NSS2
, /* check Statistics from _Admin:Manage_NSS\BufferCache.xml */
81 NSS3
, /* check statistics from _Admin:Manage_NSS\NameCache.xml */
82 NSS4
, /* check statistics from _Admin:Manage_NSS\FileStats.xml */
83 NSS5
, /* check statistics from _Admin:Manage_NSS\ObjectCache.xml */
84 NSS6
, /* check statistics from _Admin:Manage_NSS\Thread.xml */
85 NSS7
/* check statistics from _Admin:Manage_NSS\AuthorizationCache.xml */
92 static char *server_address
= NULL
;
93 static char *volume_name
= NULL
;
94 static char *nlm_name
= NULL
;
95 static char *nrmp_name
= NULL
;
96 static char *nrmm_name
= NULL
;
97 static char *nrms_name
= NULL
;
98 static char *nss1_name
= NULL
;
99 static char *nss2_name
= NULL
;
100 static char *nss3_name
= NULL
;
101 static char *nss4_name
= NULL
;
102 static char *nss5_name
= NULL
;
103 static char *nss6_name
= NULL
;
104 static char *nss7_name
= NULL
;
105 static int server_port
= PORT
;
106 static unsigned long warning_value
= 0L;
107 static unsigned long critical_value
= 0L;
108 static bool check_warning_value
= false;
109 static bool check_critical_value
= false;
110 static bool check_netware_version
= false;
111 static enum checkvar vars_to_check
= NONE
;
112 static int sap_number
= -1;
114 static int process_arguments(int /*argc*/, char ** /*argv*/);
115 static void print_help(void);
116 void print_usage(void);
118 int main(int argc
, char **argv
) {
119 int result
= STATE_UNKNOWN
;
121 char *send_buffer
= NULL
;
122 char recv_buffer
[MAX_INPUT_BUFFER
];
123 char *output_message
= NULL
;
124 char *temp_buffer
= NULL
;
125 char *netware_version
= NULL
;
127 int time_sync_status
= 0;
128 int nrm_health_status
= 0;
129 unsigned long total_cache_buffers
= 0;
130 unsigned long dirty_cache_buffers
= 0;
131 unsigned long open_files
= 0;
132 unsigned long abended_threads
= 0;
133 unsigned long max_service_processes
= 0;
134 unsigned long current_service_processes
= 0;
135 unsigned long free_disk_space
= 0L;
136 unsigned long nrmp_value
= 0L;
137 unsigned long nrmm_value
= 0L;
138 unsigned long nrms_value
= 0L;
139 unsigned long nss1_value
= 0L;
140 unsigned long nss2_value
= 0L;
141 unsigned long nss3_value
= 0L;
142 unsigned long nss4_value
= 0L;
143 unsigned long nss5_value
= 0L;
144 unsigned long nss6_value
= 0L;
145 unsigned long nss7_value
= 0L;
146 unsigned long total_disk_space
= 0L;
147 unsigned long used_disk_space
= 0L;
148 unsigned long percent_used_disk_space
= 0L;
149 unsigned long purgeable_disk_space
= 0L;
150 unsigned long non_purgeable_disk_space
= 0L;
151 unsigned long percent_free_space
= 0;
152 unsigned long percent_purgeable_space
= 0;
153 unsigned long percent_non_purgeable_space
= 0;
154 unsigned long current_connections
= 0L;
155 unsigned long utilization
= 0L;
156 unsigned long cache_hits
= 0;
157 unsigned long cache_buffers
= 0L;
158 unsigned long lru_time
= 0L;
159 unsigned long max_packet_receive_buffers
= 0;
160 unsigned long used_packet_receive_buffers
= 0;
161 unsigned long percent_used_packet_receive_buffers
= 0L;
162 unsigned long sap_entries
= 0;
163 char uptime
[MAX_INPUT_BUFFER
];
165 setlocale(LC_ALL
, "");
166 bindtextdomain(PACKAGE
, LOCALEDIR
);
169 /* Parse extra opts if any */
170 argv
= np_extra_opts(&argc
, argv
, progname
);
172 if (process_arguments(argc
, argv
) == ERROR
)
173 usage4(_("Could not parse arguments"));
175 /* initialize alarm signal handling */
176 signal(SIGALRM
, socket_timeout_alarm_handler
);
178 /* set socket timeout */
179 alarm(socket_timeout
);
181 /* open connection */
182 my_tcp_connect(server_address
, server_port
, &sd
);
184 /* get OS version string */
185 if (check_netware_version
) {
186 send_buffer
= strdup("S19\r\n");
187 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
188 if (result
!= STATE_OK
)
190 if (!strcmp(recv_buffer
, "-1\n"))
191 netware_version
= strdup("");
193 recv_buffer
[strlen(recv_buffer
) - 1] = 0;
194 xasprintf(&netware_version
, _("NetWare %s: "), recv_buffer
);
197 netware_version
= strdup("");
200 if (vars_to_check
== LOAD1
|| vars_to_check
== LOAD5
|| vars_to_check
== LOAD15
) {
202 switch (vars_to_check
) {
204 temp_buffer
= strdup("1");
207 temp_buffer
= strdup("5");
210 temp_buffer
= strdup("15");
215 my_tcp_connect(server_address
, server_port
, &sd
);
217 xasprintf(&send_buffer
, "UTIL%s\r\n", temp_buffer
);
218 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
219 if (result
!= STATE_OK
)
221 utilization
= strtoul(recv_buffer
, NULL
, 10);
224 my_tcp_connect(server_address
, server_port
, &sd
);
226 send_buffer
= strdup("UPTIME\r\n");
227 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
228 if (result
!= STATE_OK
)
230 recv_buffer
[strlen(recv_buffer
) - 1] = 0;
231 sprintf(uptime
, _("Up %s,"), recv_buffer
);
233 if (check_critical_value
&& utilization
>= critical_value
)
234 result
= STATE_CRITICAL
;
235 else if (check_warning_value
&& utilization
>= warning_value
)
236 result
= STATE_WARNING
;
238 xasprintf(&output_message
, _("Load %s - %s %s-min load average = %lu%%|load%s=%lu;%lu;%lu;0;100"), state_text(result
), uptime
,
239 temp_buffer
, utilization
, temp_buffer
, utilization
, warning_value
, critical_value
);
241 /* check number of user connections */
242 } else if (vars_to_check
== CONNS
) {
245 my_tcp_connect(server_address
, server_port
, &sd
);
247 send_buffer
= strdup("CONNECT\r\n");
248 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
249 if (result
!= STATE_OK
)
251 current_connections
= strtoul(recv_buffer
, NULL
, 10);
253 if (check_critical_value
&& current_connections
>= critical_value
)
254 result
= STATE_CRITICAL
;
255 else if (check_warning_value
&& current_connections
>= warning_value
)
256 result
= STATE_WARNING
;
258 xasprintf(&output_message
, _("Conns %s - %lu current connections|Conns=%lu;%lu;%lu;;"), state_text(result
), current_connections
,
259 current_connections
, warning_value
, critical_value
);
261 /* check % long term cache hits */
262 } else if (vars_to_check
== LTCH
) {
265 my_tcp_connect(server_address
, server_port
, &sd
);
267 send_buffer
= strdup("S1\r\n");
268 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
269 if (result
!= STATE_OK
)
271 cache_hits
= atoi(recv_buffer
);
273 if (check_critical_value
&& cache_hits
<= critical_value
)
274 result
= STATE_CRITICAL
;
275 else if (check_warning_value
&& cache_hits
<= warning_value
)
276 result
= STATE_WARNING
;
278 xasprintf(&output_message
, _("%s: Long term cache hits = %lu%%"), state_text(result
), cache_hits
);
280 /* check cache buffers */
281 } else if (vars_to_check
== CBUFF
) {
284 my_tcp_connect(server_address
, server_port
, &sd
);
286 send_buffer
= strdup("S2\r\n");
287 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
288 if (result
!= STATE_OK
)
290 cache_buffers
= strtoul(recv_buffer
, NULL
, 10);
292 if (check_critical_value
&& cache_buffers
<= critical_value
)
293 result
= STATE_CRITICAL
;
294 else if (check_warning_value
&& cache_buffers
<= warning_value
)
295 result
= STATE_WARNING
;
297 xasprintf(&output_message
, _("%s: Total cache buffers = %lu|Cachebuffers=%lu;%lu;%lu;;"), state_text(result
), cache_buffers
,
298 cache_buffers
, warning_value
, critical_value
);
300 /* check dirty cache buffers */
301 } else if (vars_to_check
== CDBUFF
) {
304 my_tcp_connect(server_address
, server_port
, &sd
);
306 send_buffer
= strdup("S3\r\n");
307 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
308 if (result
!= STATE_OK
)
310 cache_buffers
= strtoul(recv_buffer
, NULL
, 10);
312 if (check_critical_value
&& cache_buffers
>= critical_value
)
313 result
= STATE_CRITICAL
;
314 else if (check_warning_value
&& cache_buffers
>= warning_value
)
315 result
= STATE_WARNING
;
317 xasprintf(&output_message
, _("%s: Dirty cache buffers = %lu|Dirty-Cache-Buffers=%lu;%lu;%lu;;"), state_text(result
), cache_buffers
,
318 cache_buffers
, warning_value
, critical_value
);
320 /* check LRU sitting time in minutes */
321 } else if (vars_to_check
== LRUM
) {
324 my_tcp_connect(server_address
, server_port
, &sd
);
326 send_buffer
= strdup("S5\r\n");
327 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
328 if (result
!= STATE_OK
)
330 lru_time
= strtoul(recv_buffer
, NULL
, 10);
332 if (check_critical_value
&& lru_time
<= critical_value
)
333 result
= STATE_CRITICAL
;
334 else if (check_warning_value
&& lru_time
<= warning_value
)
335 result
= STATE_WARNING
;
337 xasprintf(&output_message
, _("%s: LRU sitting time = %lu minutes"), state_text(result
), lru_time
);
339 /* check KB free space on volume */
340 } else if (vars_to_check
== VKF
) {
343 my_tcp_connect(server_address
, server_port
, &sd
);
345 xasprintf(&send_buffer
, "VKF%s\r\n", volume_name
);
346 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
347 if (result
!= STATE_OK
)
350 if (!strcmp(recv_buffer
, "-1\n")) {
351 xasprintf(&output_message
, _("CRITICAL - Volume '%s' does not exist!"), volume_name
);
352 result
= STATE_CRITICAL
;
354 free_disk_space
= strtoul(recv_buffer
, NULL
, 10);
355 if (check_critical_value
&& free_disk_space
<= critical_value
)
356 result
= STATE_CRITICAL
;
357 else if (check_warning_value
&& free_disk_space
<= warning_value
)
358 result
= STATE_WARNING
;
359 xasprintf(&output_message
, _("%s%lu KB free on volume %s|KBFree%s=%lu;%lu;%lu;;"), (result
== STATE_OK
) ? "" : _("Only "),
360 free_disk_space
, volume_name
, volume_name
, free_disk_space
, warning_value
, critical_value
);
363 /* check MB free space on volume */
364 } else if (vars_to_check
== VMF
) {
366 xasprintf(&send_buffer
, "VMF%s\r\n", volume_name
);
367 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
368 if (result
!= STATE_OK
)
371 if (!strcmp(recv_buffer
, "-1\n")) {
372 xasprintf(&output_message
, _("CRITICAL - Volume '%s' does not exist!"), volume_name
);
373 result
= STATE_CRITICAL
;
375 free_disk_space
= strtoul(recv_buffer
, NULL
, 10);
376 if (check_critical_value
&& free_disk_space
<= critical_value
)
377 result
= STATE_CRITICAL
;
378 else if (check_warning_value
&& free_disk_space
<= warning_value
)
379 result
= STATE_WARNING
;
380 xasprintf(&output_message
, _("%s%lu MB free on volume %s|MBFree%s=%lu;%lu;%lu;;"), (result
== STATE_OK
) ? "" : _("Only "),
381 free_disk_space
, volume_name
, volume_name
, free_disk_space
, warning_value
, critical_value
);
383 /* check MB used space on volume */
384 } else if (vars_to_check
== VMU
) {
386 xasprintf(&send_buffer
, "VMU%s\r\n", volume_name
);
387 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
388 if (result
!= STATE_OK
)
391 if (!strcmp(recv_buffer
, "-1\n")) {
392 xasprintf(&output_message
, _("CRITICAL - Volume '%s' does not exist!"), volume_name
);
393 result
= STATE_CRITICAL
;
395 free_disk_space
= strtoul(recv_buffer
, NULL
, 10);
396 if (check_critical_value
&& free_disk_space
<= critical_value
)
397 result
= STATE_CRITICAL
;
398 else if (check_warning_value
&& free_disk_space
<= warning_value
)
399 result
= STATE_WARNING
;
400 xasprintf(&output_message
, _("%s%lu MB used on volume %s|MBUsed%s=%lu;%lu;%lu;;"), (result
== STATE_OK
) ? "" : _("Only "),
401 free_disk_space
, volume_name
, volume_name
, free_disk_space
, warning_value
, critical_value
);
403 /* check % used space on volume */
404 } else if (vars_to_check
== VPU
) {
406 my_tcp_connect(server_address
, server_port
, &sd
);
408 asprintf(&send_buffer
, "VMU%s\r\n", volume_name
);
409 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
411 if (result
!= STATE_OK
)
414 if (!strcmp(recv_buffer
, "-1\n")) {
415 asprintf(&output_message
, _("CRITICAL - Volume '%s' does not exist!"), volume_name
);
416 result
= STATE_CRITICAL
;
419 used_disk_space
= strtoul(recv_buffer
, NULL
, 10);
421 my_tcp_connect(server_address
, server_port
, &sd
);
422 /* get total volume in MB */
423 asprintf(&send_buffer
, "VMS%s\r\n", volume_name
);
424 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
425 if (result
!= STATE_OK
)
427 total_disk_space
= strtoul(recv_buffer
, NULL
, 10);
428 /* calculate percent used on volume */
429 percent_used_disk_space
= (unsigned long)(((double)used_disk_space
/ (double)total_disk_space
) * 100.0);
431 if (check_critical_value
&& percent_used_disk_space
>= critical_value
)
432 result
= STATE_CRITICAL
;
433 else if (check_warning_value
&& percent_used_disk_space
>= warning_value
)
434 result
= STATE_WARNING
;
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"),
437 used_disk_space
, percent_used_disk_space
, volume_name
, total_disk_space
, volume_name
, percent_used_disk_space
,
438 warning_value
, critical_value
);
441 /* check % free space on volume */
442 } else if (vars_to_check
== VPF
) {
445 my_tcp_connect(server_address
, server_port
, &sd
);
447 xasprintf(&send_buffer
, "VKF%s\r\n", volume_name
);
448 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
449 if (result
!= STATE_OK
)
452 if (!strcmp(recv_buffer
, "-1\n")) {
454 xasprintf(&output_message
, _("CRITICAL - Volume '%s' does not exist!"), volume_name
);
455 result
= STATE_CRITICAL
;
459 free_disk_space
= strtoul(recv_buffer
, NULL
, 10);
462 my_tcp_connect(server_address
, server_port
, &sd
);
464 xasprintf(&send_buffer
, "VKS%s\r\n", volume_name
);
465 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
466 if (result
!= STATE_OK
)
468 total_disk_space
= strtoul(recv_buffer
, NULL
, 10);
470 percent_free_space
= (unsigned long)(((double)free_disk_space
/ (double)total_disk_space
) * 100.0);
472 if (check_critical_value
&& percent_free_space
<= critical_value
)
473 result
= STATE_CRITICAL
;
474 else if (check_warning_value
&& percent_free_space
<= warning_value
)
475 result
= STATE_WARNING
;
476 free_disk_space
/= 1024;
477 total_disk_space
/= 1024;
478 xasprintf(&output_message
, _("%lu MB (%lu%%) free on volume %s - total %lu MB|FreeMB%s=%lu;%lu;%lu;0;100"), free_disk_space
,
479 percent_free_space
, volume_name
, total_disk_space
, volume_name
, percent_free_space
, warning_value
, critical_value
);
482 /* check to see if DS Database is open or closed */
483 } else if (vars_to_check
== DSDB
) {
486 my_tcp_connect(server_address
, server_port
, &sd
);
488 send_buffer
= strdup("S11\r\n");
489 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
490 if (result
!= STATE_OK
)
492 if (atoi(recv_buffer
) == 1)
495 result
= STATE_WARNING
;
498 my_tcp_connect(server_address
, server_port
, &sd
);
500 send_buffer
= strdup("S13\r\n");
501 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
502 temp_buffer
= strtok(recv_buffer
, "\r\n");
504 xasprintf(&output_message
, _("Directory Services Database is %s (DS version %s)"), (result
== STATE_OK
) ? "open" : "closed",
507 /* check to see if logins are enabled */
508 } else if (vars_to_check
== LOGINS
) {
511 my_tcp_connect(server_address
, server_port
, &sd
);
513 send_buffer
= strdup("S12\r\n");
514 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
515 if (result
!= STATE_OK
)
517 if (atoi(recv_buffer
) == 1)
520 result
= STATE_WARNING
;
522 xasprintf(&output_message
, _("Logins are %s"), (result
== STATE_OK
) ? _("enabled") : _("disabled"));
524 /* check NRM Health Status Summary*/
525 } else if (vars_to_check
== NRMH
) {
527 xasprintf(&send_buffer
, "NRMH\r\n");
528 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
529 if (result
!= STATE_OK
)
532 nrm_health_status
= atoi(recv_buffer
);
534 if (nrm_health_status
== 2) {
536 xasprintf(&output_message
, _("CRITICAL - NRM Status is bad!"));
538 if (nrm_health_status
== 1) {
539 result
= STATE_WARNING
;
540 xasprintf(&output_message
, _("Warning - NRM Status is suspect!"));
543 xasprintf(&output_message
, _("OK - NRM Status is good!"));
546 /* check packet receive buffers */
547 } else if (vars_to_check
== UPRB
|| vars_to_check
== PUPRB
) {
550 my_tcp_connect(server_address
, server_port
, &sd
);
552 xasprintf(&send_buffer
, "S15\r\n");
553 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
554 if (result
!= STATE_OK
)
557 used_packet_receive_buffers
= atoi(recv_buffer
);
560 my_tcp_connect(server_address
, server_port
, &sd
);
562 xasprintf(&send_buffer
, "S16\r\n");
563 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
564 if (result
!= STATE_OK
)
567 max_packet_receive_buffers
= atoi(recv_buffer
);
569 percent_used_packet_receive_buffers
=
570 (unsigned long)(((double)used_packet_receive_buffers
/ (double)max_packet_receive_buffers
) * 100.0);
572 if (vars_to_check
== UPRB
) {
573 if (check_critical_value
&& used_packet_receive_buffers
>= critical_value
)
574 result
= STATE_CRITICAL
;
575 else if (check_warning_value
&& used_packet_receive_buffers
>= warning_value
)
576 result
= STATE_WARNING
;
578 if (check_critical_value
&& percent_used_packet_receive_buffers
>= critical_value
)
579 result
= STATE_CRITICAL
;
580 else if (check_warning_value
&& percent_used_packet_receive_buffers
>= warning_value
)
581 result
= STATE_WARNING
;
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
);
587 /* check SAP table entries */
588 } else if (vars_to_check
== SAPENTRIES
) {
591 my_tcp_connect(server_address
, server_port
, &sd
);
593 if (sap_number
== -1)
594 xasprintf(&send_buffer
, "S9\r\n");
596 xasprintf(&send_buffer
, "S9.%d\r\n", sap_number
);
597 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
598 if (result
!= STATE_OK
)
601 sap_entries
= atoi(recv_buffer
);
603 if (check_critical_value
&& sap_entries
>= critical_value
)
604 result
= STATE_CRITICAL
;
605 else if (check_warning_value
&& sap_entries
>= warning_value
)
606 result
= STATE_WARNING
;
608 if (sap_number
== -1)
609 xasprintf(&output_message
, _("%lu entries in SAP table"), sap_entries
);
611 xasprintf(&output_message
, _("%lu entries in SAP table for SAP type %d"), sap_entries
, sap_number
);
613 /* check KB purgeable space on volume */
614 } else if (vars_to_check
== VKP
) {
617 my_tcp_connect(server_address
, server_port
, &sd
);
619 xasprintf(&send_buffer
, "VKP%s\r\n", volume_name
);
620 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
621 if (result
!= STATE_OK
)
624 if (!strcmp(recv_buffer
, "-1\n")) {
625 xasprintf(&output_message
, _("CRITICAL - Volume '%s' does not exist!"), volume_name
);
626 result
= STATE_CRITICAL
;
628 purgeable_disk_space
= strtoul(recv_buffer
, NULL
, 10);
629 if (check_critical_value
&& purgeable_disk_space
>= critical_value
)
630 result
= STATE_CRITICAL
;
631 else if (check_warning_value
&& purgeable_disk_space
>= warning_value
)
632 result
= STATE_WARNING
;
633 xasprintf(&output_message
, _("%s%lu KB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;"), (result
== STATE_OK
) ? "" : _("Only "),
634 purgeable_disk_space
, volume_name
, volume_name
, purgeable_disk_space
, warning_value
, critical_value
);
636 /* check MB purgeable space on volume */
637 } else if (vars_to_check
== VMP
) {
639 xasprintf(&send_buffer
, "VMP%s\r\n", volume_name
);
640 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
641 if (result
!= STATE_OK
)
644 if (!strcmp(recv_buffer
, "-1\n")) {
645 xasprintf(&output_message
, _("CRITICAL - Volume '%s' does not exist!"), volume_name
);
646 result
= STATE_CRITICAL
;
648 purgeable_disk_space
= strtoul(recv_buffer
, NULL
, 10);
649 if (check_critical_value
&& purgeable_disk_space
>= critical_value
)
650 result
= STATE_CRITICAL
;
651 else if (check_warning_value
&& purgeable_disk_space
>= warning_value
)
652 result
= STATE_WARNING
;
653 xasprintf(&output_message
, _("%s%lu MB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;"), (result
== STATE_OK
) ? "" : _("Only "),
654 purgeable_disk_space
, volume_name
, volume_name
, purgeable_disk_space
, warning_value
, critical_value
);
657 /* check % purgeable space on volume */
658 } else if (vars_to_check
== VPP
) {
661 my_tcp_connect(server_address
, server_port
, &sd
);
663 xasprintf(&send_buffer
, "VKP%s\r\n", volume_name
);
664 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
665 if (result
!= STATE_OK
)
668 if (!strcmp(recv_buffer
, "-1\n")) {
670 xasprintf(&output_message
, _("CRITICAL - Volume '%s' does not exist!"), volume_name
);
671 result
= STATE_CRITICAL
;
675 purgeable_disk_space
= strtoul(recv_buffer
, NULL
, 10);
678 my_tcp_connect(server_address
, server_port
, &sd
);
680 xasprintf(&send_buffer
, "VKS%s\r\n", volume_name
);
681 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
682 if (result
!= STATE_OK
)
684 total_disk_space
= strtoul(recv_buffer
, NULL
, 10);
686 percent_purgeable_space
= (unsigned long)(((double)purgeable_disk_space
/ (double)total_disk_space
) * 100.0);
688 if (check_critical_value
&& percent_purgeable_space
>= critical_value
)
689 result
= STATE_CRITICAL
;
690 else if (check_warning_value
&& percent_purgeable_space
>= warning_value
)
691 result
= STATE_WARNING
;
692 purgeable_disk_space
/= 1024;
693 xasprintf(&output_message
, _("%lu MB (%lu%%) purgeable on volume %s|Purgeable%s=%lu;%lu;%lu;0;100"), purgeable_disk_space
,
694 percent_purgeable_space
, volume_name
, volume_name
, percent_purgeable_space
, warning_value
, critical_value
);
697 /* check KB not yet purgeable space on volume */
698 } else if (vars_to_check
== VKNP
) {
701 my_tcp_connect(server_address
, server_port
, &sd
);
703 xasprintf(&send_buffer
, "VKNP%s\r\n", volume_name
);
704 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
705 if (result
!= STATE_OK
)
708 if (!strcmp(recv_buffer
, "-1\n")) {
709 xasprintf(&output_message
, _("CRITICAL - Volume '%s' does not exist!"), volume_name
);
710 result
= STATE_CRITICAL
;
712 non_purgeable_disk_space
= strtoul(recv_buffer
, NULL
, 10);
713 if (check_critical_value
&& non_purgeable_disk_space
>= critical_value
)
714 result
= STATE_CRITICAL
;
715 else if (check_warning_value
&& non_purgeable_disk_space
>= warning_value
)
716 result
= STATE_WARNING
;
717 xasprintf(&output_message
, _("%s%lu KB not yet purgeable on volume %s"), (result
== STATE_OK
) ? "" : _("Only "),
718 non_purgeable_disk_space
, volume_name
);
721 /* check % not yet purgeable space on volume */
722 } else if (vars_to_check
== VPNP
) {
725 my_tcp_connect(server_address
, server_port
, &sd
);
727 xasprintf(&send_buffer
, "VKNP%s\r\n", volume_name
);
728 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
729 if (result
!= STATE_OK
)
732 if (!strcmp(recv_buffer
, "-1\n")) {
734 xasprintf(&output_message
, _("CRITICAL - Volume '%s' does not exist!"), volume_name
);
735 result
= STATE_CRITICAL
;
739 non_purgeable_disk_space
= strtoul(recv_buffer
, NULL
, 10);
742 my_tcp_connect(server_address
, server_port
, &sd
);
744 xasprintf(&send_buffer
, "VKS%s\r\n", volume_name
);
745 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
746 if (result
!= STATE_OK
)
748 total_disk_space
= strtoul(recv_buffer
, NULL
, 10);
750 percent_non_purgeable_space
= (unsigned long)(((double)non_purgeable_disk_space
/ (double)total_disk_space
) * 100.0);
752 if (check_critical_value
&& percent_non_purgeable_space
>= critical_value
)
753 result
= STATE_CRITICAL
;
754 else if (check_warning_value
&& percent_non_purgeable_space
>= warning_value
)
755 result
= STATE_WARNING
;
756 purgeable_disk_space
/= 1024;
757 xasprintf(&output_message
, _("%lu MB (%lu%%) not yet purgeable on volume %s"), non_purgeable_disk_space
,
758 percent_non_purgeable_space
, volume_name
);
761 /* check # of open files */
762 } else if (vars_to_check
== OFILES
) {
765 my_tcp_connect(server_address
, server_port
, &sd
);
767 xasprintf(&send_buffer
, "S18\r\n");
768 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
769 if (result
!= STATE_OK
)
772 open_files
= atoi(recv_buffer
);
774 if (check_critical_value
&& open_files
>= critical_value
)
775 result
= STATE_CRITICAL
;
776 else if (check_warning_value
&& open_files
>= warning_value
)
777 result
= STATE_WARNING
;
779 xasprintf(&output_message
, _("%lu open files|Openfiles=%lu;%lu;%lu;0,0"), open_files
, open_files
, warning_value
, critical_value
);
781 /* check # of abended threads (Netware > 5.x only) */
782 } else if (vars_to_check
== ABENDS
) {
785 my_tcp_connect(server_address
, server_port
, &sd
);
787 xasprintf(&send_buffer
, "S17\r\n");
788 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
789 if (result
!= STATE_OK
)
792 abended_threads
= atoi(recv_buffer
);
794 if (check_critical_value
&& abended_threads
>= critical_value
)
795 result
= STATE_CRITICAL
;
796 else if (check_warning_value
&& abended_threads
>= warning_value
)
797 result
= STATE_WARNING
;
799 xasprintf(&output_message
, _("%lu abended threads|Abends=%lu;%lu;%lu;;"), abended_threads
, abended_threads
, warning_value
,
802 /* check # of current service processes (Netware 5.x only) */
803 } else if (vars_to_check
== CSPROCS
) {
806 my_tcp_connect(server_address
, server_port
, &sd
);
808 xasprintf(&send_buffer
, "S20\r\n");
809 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
810 if (result
!= STATE_OK
)
813 max_service_processes
= atoi(recv_buffer
);
816 my_tcp_connect(server_address
, server_port
, &sd
);
818 xasprintf(&send_buffer
, "S21\r\n");
819 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
820 if (result
!= STATE_OK
)
823 current_service_processes
= atoi(recv_buffer
);
825 if (check_critical_value
&& current_service_processes
>= critical_value
)
826 result
= STATE_CRITICAL
;
827 else if (check_warning_value
&& current_service_processes
>= warning_value
)
828 result
= STATE_WARNING
;
830 xasprintf(&output_message
, _("%lu current service processes (%lu max)|Processes=%lu;%lu;%lu;0;%lu"), current_service_processes
,
831 max_service_processes
, current_service_processes
, warning_value
, critical_value
, max_service_processes
);
833 /* check # Timesync Status */
834 } else if (vars_to_check
== TSYNC
) {
837 my_tcp_connect(server_address
, server_port
, &sd
);
839 xasprintf(&send_buffer
, "S22\r\n");
840 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
841 if (result
!= STATE_OK
)
844 time_sync_status
= atoi(recv_buffer
);
846 if (time_sync_status
== 0) {
847 result
= STATE_CRITICAL
;
848 xasprintf(&output_message
, _("CRITICAL - Time not in sync with network!"));
850 xasprintf(&output_message
, _("OK - Time in sync with network!"));
853 /* check LRU sitting time in secondss */
854 } else if (vars_to_check
== LRUS
) {
857 my_tcp_connect(server_address
, server_port
, &sd
);
859 send_buffer
= strdup("S4\r\n");
860 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
861 if (result
!= STATE_OK
)
863 lru_time
= strtoul(recv_buffer
, NULL
, 10);
865 if (check_critical_value
&& lru_time
<= critical_value
)
866 result
= STATE_CRITICAL
;
867 else if (check_warning_value
&& lru_time
<= warning_value
)
868 result
= STATE_WARNING
;
869 xasprintf(&output_message
, _("LRU sitting time = %lu seconds"), lru_time
);
871 /* check % dirty cacheobuffers as a percentage of the total*/
872 } else if (vars_to_check
== DCB
) {
875 my_tcp_connect(server_address
, server_port
, &sd
);
877 send_buffer
= strdup("S6\r\n");
878 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
879 if (result
!= STATE_OK
)
881 dirty_cache_buffers
= atoi(recv_buffer
);
883 if (check_critical_value
&& dirty_cache_buffers
<= critical_value
)
884 result
= STATE_CRITICAL
;
885 else if (check_warning_value
&& dirty_cache_buffers
<= warning_value
)
886 result
= STATE_WARNING
;
887 xasprintf(&output_message
, _("Dirty cache buffers = %lu%% of the total|DCB=%lu;%lu;%lu;0;100"), dirty_cache_buffers
,
888 dirty_cache_buffers
, warning_value
, critical_value
);
890 /* check % total cache buffers as a percentage of the original*/
891 } else if (vars_to_check
== TCB
) {
894 my_tcp_connect(server_address
, server_port
, &sd
);
896 send_buffer
= strdup("S7\r\n");
897 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
898 if (result
!= STATE_OK
)
900 total_cache_buffers
= atoi(recv_buffer
);
902 if (check_critical_value
&& total_cache_buffers
<= critical_value
)
903 result
= STATE_CRITICAL
;
904 else if (check_warning_value
&& total_cache_buffers
<= warning_value
)
905 result
= STATE_WARNING
;
906 xasprintf(&output_message
, _("Total cache buffers = %lu%% of the original|TCB=%lu;%lu;%lu;0;100"), total_cache_buffers
,
907 total_cache_buffers
, warning_value
, critical_value
);
909 } else if (vars_to_check
== DSVER
) {
912 my_tcp_connect(server_address
, server_port
, &sd
);
914 xasprintf(&send_buffer
, "S13\r\n");
915 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
916 if (result
!= STATE_OK
)
919 recv_buffer
[strlen(recv_buffer
) - 1] = 0;
921 xasprintf(&output_message
, _("NDS Version %s"), recv_buffer
);
923 } else if (vars_to_check
== UPTIME
) {
926 my_tcp_connect(server_address
, server_port
, &sd
);
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
)
933 recv_buffer
[sizeof(recv_buffer
) - 1] = 0;
934 recv_buffer
[strlen(recv_buffer
) - 1] = 0;
936 xasprintf(&output_message
, _("Up %s"), recv_buffer
);
938 } else if (vars_to_check
== NLM
) {
941 my_tcp_connect(server_address
, server_port
, &sd
);
943 xasprintf(&send_buffer
, "S24:%s\r\n", nlm_name
);
944 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
945 if (result
!= STATE_OK
)
948 recv_buffer
[strlen(recv_buffer
) - 1] = 0;
949 if (strcmp(recv_buffer
, "-1")) {
950 xasprintf(&output_message
, _("Module %s version %s is loaded"), nlm_name
, recv_buffer
);
952 result
= STATE_CRITICAL
;
953 xasprintf(&output_message
, _("Module %s is not loaded"), nlm_name
);
955 } else if (vars_to_check
== NRMP
) {
957 xasprintf(&send_buffer
, "NRMP:%s\r\n", nrmp_name
);
958 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
959 if (result
!= STATE_OK
)
962 if (!strcmp(recv_buffer
, "-1\n")) {
963 xasprintf(&output_message
, _("CRITICAL - Value '%s' does not exist!"), nrmp_name
);
964 result
= STATE_CRITICAL
;
966 nrmp_value
= strtoul(recv_buffer
, NULL
, 10);
967 if (check_critical_value
&& nrmp_value
<= critical_value
)
968 result
= STATE_CRITICAL
;
969 else if (check_warning_value
&& nrmp_value
<= warning_value
)
970 result
= STATE_WARNING
;
971 xasprintf(&output_message
, _("%s is %lu|%s=%lu;%lu;%lu;;"), nrmp_name
, nrmp_value
, nrmp_name
, nrmp_value
, warning_value
,
975 } else if (vars_to_check
== NRMM
) {
977 xasprintf(&send_buffer
, "NRMM:%s\r\n", nrmm_name
);
978 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
979 if (result
!= STATE_OK
)
982 if (!strcmp(recv_buffer
, "-1\n")) {
983 xasprintf(&output_message
, _("CRITICAL - Value '%s' does not exist!"), nrmm_name
);
984 result
= STATE_CRITICAL
;
986 nrmm_value
= strtoul(recv_buffer
, NULL
, 10);
987 if (check_critical_value
&& nrmm_value
<= critical_value
)
988 result
= STATE_CRITICAL
;
989 else if (check_warning_value
&& nrmm_value
<= warning_value
)
990 result
= STATE_WARNING
;
991 xasprintf(&output_message
, _("%s is %lu|%s=%lu;%lu;%lu;;"), nrmm_name
, nrmm_value
, nrmm_name
, nrmm_value
, warning_value
,
995 } else if (vars_to_check
== NRMS
) {
997 xasprintf(&send_buffer
, "NRMS:%s\r\n", nrms_name
);
998 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
999 if (result
!= STATE_OK
)
1002 if (!strcmp(recv_buffer
, "-1\n")) {
1003 xasprintf(&output_message
, _("CRITICAL - Value '%s' does not exist!"), nrms_name
);
1004 result
= STATE_CRITICAL
;
1006 nrms_value
= strtoul(recv_buffer
, NULL
, 10);
1007 if (check_critical_value
&& nrms_value
>= critical_value
)
1008 result
= STATE_CRITICAL
;
1009 else if (check_warning_value
&& nrms_value
>= warning_value
)
1010 result
= STATE_WARNING
;
1011 xasprintf(&output_message
, _("%s is %lu|%s=%lu;%lu;%lu;;"), nrms_name
, nrms_value
, nrms_name
, nrms_value
, warning_value
,
1015 } else if (vars_to_check
== NSS1
) {
1017 xasprintf(&send_buffer
, "NSS1:%s\r\n", nss1_name
);
1018 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
1019 if (result
!= STATE_OK
)
1022 if (!strcmp(recv_buffer
, "-1\n")) {
1023 xasprintf(&output_message
, _("CRITICAL - Value '%s' does not exist!"), nss1_name
);
1024 result
= STATE_CRITICAL
;
1026 nss1_value
= strtoul(recv_buffer
, NULL
, 10);
1027 if (check_critical_value
&& nss1_value
>= critical_value
)
1028 result
= STATE_CRITICAL
;
1029 else if (check_warning_value
&& nss1_value
>= warning_value
)
1030 result
= STATE_WARNING
;
1031 xasprintf(&output_message
, _("%s is %lu|%s=%lu;%lu;%lu;;"), nss1_name
, nss1_value
, nss1_name
, nss1_value
, warning_value
,
1035 } else if (vars_to_check
== NSS2
) {
1037 xasprintf(&send_buffer
, "NSS2:%s\r\n", nss2_name
);
1038 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
1039 if (result
!= STATE_OK
)
1042 if (!strcmp(recv_buffer
, "-1\n")) {
1043 xasprintf(&output_message
, _("CRITICAL - Value '%s' does not exist!"), nss2_name
);
1044 result
= STATE_CRITICAL
;
1046 nss2_value
= strtoul(recv_buffer
, NULL
, 10);
1047 if (check_critical_value
&& nss2_value
>= critical_value
)
1048 result
= STATE_CRITICAL
;
1049 else if (check_warning_value
&& nss2_value
>= warning_value
)
1050 result
= STATE_WARNING
;
1051 xasprintf(&output_message
, _("%s is %lu|%s=%lu;%lu;%lu;;"), nss2_name
, nss2_value
, nss2_name
, nss2_value
, warning_value
,
1055 } else if (vars_to_check
== NSS3
) {
1057 xasprintf(&send_buffer
, "NSS3:%s\r\n", nss3_name
);
1058 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
1059 if (result
!= STATE_OK
)
1062 if (!strcmp(recv_buffer
, "-1\n")) {
1063 xasprintf(&output_message
, _("CRITICAL - Value '%s' does not exist!"), nss3_name
);
1064 result
= STATE_CRITICAL
;
1066 nss3_value
= strtoul(recv_buffer
, NULL
, 10);
1067 if (check_critical_value
&& nss3_value
>= critical_value
)
1068 result
= STATE_CRITICAL
;
1069 else if (check_warning_value
&& nss3_value
>= warning_value
)
1070 result
= STATE_WARNING
;
1071 xasprintf(&output_message
, _("%s is %lu|%s=%lu;%lu;%lu;;"), nss3_name
, nss3_value
, nss3_name
, nss3_value
, warning_value
,
1075 } else if (vars_to_check
== NSS4
) {
1077 xasprintf(&send_buffer
, "NSS4:%s\r\n", nss4_name
);
1078 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
1079 if (result
!= STATE_OK
)
1082 if (!strcmp(recv_buffer
, "-1\n")) {
1083 xasprintf(&output_message
, _("CRITICAL - Value '%s' does not exist!"), nss4_name
);
1084 result
= STATE_CRITICAL
;
1086 nss4_value
= strtoul(recv_buffer
, NULL
, 10);
1087 if (check_critical_value
&& nss4_value
>= critical_value
)
1088 result
= STATE_CRITICAL
;
1089 else if (check_warning_value
&& nss4_value
>= warning_value
)
1090 result
= STATE_WARNING
;
1091 xasprintf(&output_message
, _("%s is %lu|%s=%lu;%lu;%lu;;"), nss4_name
, nss4_value
, nss4_name
, nss4_value
, warning_value
,
1095 } else if (vars_to_check
== NSS5
) {
1097 xasprintf(&send_buffer
, "NSS5:%s\r\n", nss5_name
);
1098 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
1099 if (result
!= STATE_OK
)
1102 if (!strcmp(recv_buffer
, "-1\n")) {
1103 xasprintf(&output_message
, _("CRITICAL - Value '%s' does not exist!"), nss5_name
);
1104 result
= STATE_CRITICAL
;
1106 nss5_value
= strtoul(recv_buffer
, NULL
, 10);
1107 if (check_critical_value
&& nss5_value
>= critical_value
)
1108 result
= STATE_CRITICAL
;
1109 else if (check_warning_value
&& nss5_value
>= warning_value
)
1110 result
= STATE_WARNING
;
1111 xasprintf(&output_message
, _("%s is %lu|%s=%lu;%lu;%lu;;"), nss5_name
, nss5_value
, nss5_name
, nss5_value
, warning_value
,
1115 } else if (vars_to_check
== NSS6
) {
1117 xasprintf(&send_buffer
, "NSS6:%s\r\n", nss6_name
);
1118 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
1119 if (result
!= STATE_OK
)
1122 if (!strcmp(recv_buffer
, "-1\n")) {
1123 xasprintf(&output_message
, _("CRITICAL - Value '%s' does not exist!"), nss6_name
);
1124 result
= STATE_CRITICAL
;
1126 nss6_value
= strtoul(recv_buffer
, NULL
, 10);
1127 if (check_critical_value
&& nss6_value
>= critical_value
)
1128 result
= STATE_CRITICAL
;
1129 else if (check_warning_value
&& nss6_value
>= warning_value
)
1130 result
= STATE_WARNING
;
1131 xasprintf(&output_message
, _("%s is %lu|%s=%lu;%lu;%lu;;"), nss6_name
, nss6_value
, nss6_name
, nss6_value
, warning_value
,
1135 } else if (vars_to_check
== NSS7
) {
1137 xasprintf(&send_buffer
, "NSS7:%s\r\n", nss7_name
);
1138 result
= send_tcp_request(sd
, send_buffer
, recv_buffer
, sizeof(recv_buffer
));
1139 if (result
!= STATE_OK
)
1142 if (!strcmp(recv_buffer
, "-1\n")) {
1143 xasprintf(&output_message
, _("CRITICAL - Value '%s' does not exist!"), nss7_name
);
1144 result
= STATE_CRITICAL
;
1146 nss7_value
= strtoul(recv_buffer
, NULL
, 10);
1147 if (check_critical_value
&& nss7_value
>= critical_value
)
1148 result
= STATE_CRITICAL
;
1149 else if (check_warning_value
&& nss7_value
>= warning_value
)
1150 result
= STATE_WARNING
;
1151 xasprintf(&output_message
, _("%s is %lu|%s=%lu;%lu;%lu;;"), nss7_name
, nss7_value
, nss7_name
, nss7_value
, warning_value
,
1157 output_message
= strdup(_("Nothing to check!\n"));
1158 result
= STATE_UNKNOWN
;
1166 printf("%s%s\n", netware_version
, output_message
);
1171 /* process command-line arguments */
1172 int process_arguments(int argc
, char **argv
) {
1176 static struct option longopts
[] = {{"port", required_argument
, 0, 'p'}, {"timeout", required_argument
, 0, 't'},
1177 {"critical", required_argument
, 0, 'c'}, {"warning", required_argument
, 0, 'w'},
1178 {"variable", required_argument
, 0, 'v'}, {"hostname", required_argument
, 0, 'H'},
1179 {"osversion", no_argument
, 0, 'o'}, {"version", no_argument
, 0, 'V'},
1180 {"help", no_argument
, 0, 'h'}, {0, 0, 0, 0}};
1182 /* no options were supplied */
1186 /* backwards compatibility */
1187 if (!is_option(argv
[1])) {
1188 server_address
= argv
[1];
1194 for (c
= 1; c
< argc
; c
++) {
1195 if (strcmp("-to", argv
[c
]) == 0)
1196 strcpy(argv
[c
], "-t");
1197 else if (strcmp("-wv", argv
[c
]) == 0)
1198 strcpy(argv
[c
], "-w");
1199 else if (strcmp("-cv", argv
[c
]) == 0)
1200 strcpy(argv
[c
], "-c");
1204 c
= getopt_long(argc
, argv
, "+hoVH:t:c:w:p:v:", longopts
, &option
);
1206 if (c
== -1 || c
== EOF
|| c
== 1)
1210 case '?': /* print short usage statement if args not parsable */
1212 case 'h': /* help */
1214 exit(STATE_UNKNOWN
);
1215 case 'V': /* version */
1216 print_revision(progname
, NP_VERSION
);
1217 exit(STATE_UNKNOWN
);
1218 case 'H': /* hostname */
1219 server_address
= optarg
;
1221 case 'o': /* display nos version */
1222 check_netware_version
= true;
1224 case 'p': /* port */
1225 if (is_intnonneg(optarg
))
1226 server_port
= atoi(optarg
);
1228 die(STATE_UNKNOWN
, _("Server port an integer\n"));
1231 if (strlen(optarg
) < 3)
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);
1286 } else if (!strcmp(optarg
, "OFILES"))
1287 vars_to_check
= OFILES
;
1288 else if (strncmp(optarg
, "VKP", 3) == 0) {
1289 vars_to_check
= VKP
;
1290 volume_name
= strdup(optarg
+ 3);
1291 if (!strcmp(volume_name
, ""))
1292 volume_name
= strdup("SYS");
1293 } else if (strncmp(optarg
, "VMP", 3) == 0) {
1294 vars_to_check
= VMP
;
1295 volume_name
= strdup(optarg
+ 3);
1296 if (!strcmp(volume_name
, ""))
1297 volume_name
= strdup("SYS");
1298 } else if (strncmp(optarg
, "VMU", 3) == 0) {
1299 vars_to_check
= VMU
;
1300 volume_name
= strdup(optarg
+ 3);
1301 if (!strcmp(volume_name
, ""))
1302 volume_name
= strdup("SYS");
1303 } else if (strncmp(optarg
, "VPU", 3) == 0) {
1304 vars_to_check
= VPU
;
1305 volume_name
= strdup(optarg
+ 3);
1306 if (!strcmp(volume_name
, ""))
1307 volume_name
= strdup("SYS");
1308 } else if (strncmp(optarg
, "VPP", 3) == 0) {
1309 vars_to_check
= VPP
;
1310 volume_name
= strdup(optarg
+ 3);
1311 if (!strcmp(volume_name
, ""))
1312 volume_name
= strdup("SYS");
1313 } else if (strncmp(optarg
, "VKNP", 4) == 0) {
1314 vars_to_check
= VKNP
;
1315 volume_name
= strdup(optarg
+ 4);
1316 if (!strcmp(volume_name
, ""))
1317 volume_name
= strdup("SYS");
1318 } else if (strncmp(optarg
, "VPNP", 4) == 0) {
1319 vars_to_check
= VPNP
;
1320 volume_name
= strdup(optarg
+ 4);
1321 if (!strcmp(volume_name
, ""))
1322 volume_name
= strdup("SYS");
1323 } else if (!strcmp(optarg
, "ABENDS"))
1324 vars_to_check
= ABENDS
;
1325 else if (!strcmp(optarg
, "CSPROCS"))
1326 vars_to_check
= CSPROCS
;
1327 else if (!strcmp(optarg
, "TSYNC"))
1328 vars_to_check
= TSYNC
;
1329 else if (!strcmp(optarg
, "DSVER"))
1330 vars_to_check
= DSVER
;
1331 else if (!strcmp(optarg
, "UPTIME")) {
1332 vars_to_check
= UPTIME
;
1333 } else if (strncmp(optarg
, "NLM:", 4) == 0) {
1334 vars_to_check
= NLM
;
1335 nlm_name
= strdup(optarg
+ 4);
1336 } else if (strncmp(optarg
, "NRMP", 4) == 0) {
1337 vars_to_check
= NRMP
;
1338 nrmp_name
= strdup(optarg
+ 4);
1339 if (!strcmp(nrmp_name
, ""))
1340 nrmp_name
= strdup("AVAILABLE_MEMORY");
1341 } else if (strncmp(optarg
, "NRMM", 4) == 0) {
1342 vars_to_check
= NRMM
;
1343 nrmm_name
= strdup(optarg
+ 4);
1344 if (!strcmp(nrmm_name
, ""))
1345 nrmm_name
= strdup("AVAILABLE_CACHE_MEMORY");
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");
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");
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");
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");
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");
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");
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");
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");
1416 case 'w': /* warning threshold */
1417 warning_value
= strtoul(optarg
, NULL
, 10);
1418 check_warning_value
= true;
1420 case 'c': /* critical threshold */
1421 critical_value
= strtoul(optarg
, NULL
, 10);
1422 check_critical_value
= true;
1424 case 't': /* timeout */
1425 socket_timeout
= atoi(optarg
);
1426 if (socket_timeout
<= 0)
1434 void print_help(void) {
1436 xasprintf(&myport
, "%d", PORT
);
1438 print_revision(progname
, NP_VERSION
);
1440 printf("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n");
1441 printf(COPYRIGHT
, copyright
, email
);
1443 printf("%s\n", _("This plugin attempts to contact the MRTGEXT NLM running on a"));
1444 printf("%s\n", _("Novell server to gather the requested system information."));
1450 printf(UT_HELP_VRSN
);
1451 printf(UT_EXTRA_OPTS
);
1453 printf(UT_HOST_PORT
, 'p', myport
);
1455 printf(" %s\n", "-v, --variable=STRING");
1456 printf(" %s\n", _("Variable to check. Valid variables include:"));
1457 printf(" %s\n", _("LOAD1 = 1 minute average CPU load"));
1458 printf(" %s\n", _("LOAD5 = 5 minute average CPU load"));
1459 printf(" %s\n", _("LOAD15 = 15 minute average CPU load"));
1460 printf(" %s\n", _("CSPROCS = number of current service processes (NW 5.x only)"));
1461 printf(" %s\n", _("ABENDS = number of abended threads (NW 5.x only)"));
1462 printf(" %s\n", _("UPTIME = server uptime"));
1463 printf(" %s\n", _("LTCH = percent long term cache hits"));
1464 printf(" %s\n", _("CBUFF = current number of cache buffers"));
1465 printf(" %s\n", _("CDBUFF = current number of dirty cache buffers"));
1466 printf(" %s\n", _("DCB = dirty cache buffers as a percentage of the total"));
1467 printf(" %s\n", _("TCB = dirty cache buffers as a percentage of the original"));
1468 printf(" %s\n", _("OFILES = number of open files"));
1469 printf(" %s\n", _(" VMF<vol> = MB of free space on Volume <vol>"));
1470 printf(" %s\n", _(" VMU<vol> = MB used space on Volume <vol>"));
1471 printf(" %s\n", _(" VPU<vol> = percent used space on Volume <vol>"));
1472 printf(" %s\n", _(" VMP<vol> = MB of purgeable space on Volume <vol>"));
1473 printf(" %s\n", _(" VPF<vol> = percent free space on volume <vol>"));
1474 printf(" %s\n", _(" VKF<vol> = KB of free space on volume <vol>"));
1475 printf(" %s\n", _(" VPP<vol> = percent purgeable space on volume <vol>"));
1476 printf(" %s\n", _(" VKP<vol> = KB of purgeable space on volume <vol>"));
1477 printf(" %s\n", _(" VPNP<vol> = percent not yet purgeable space on volume <vol>"));
1478 printf(" %s\n", _(" VKNP<vol> = KB of not yet purgeable space on volume <vol>"));
1479 printf(" %s\n", _(" LRUM = LRU sitting time in minutes"));
1480 printf(" %s\n", _(" LRUS = LRU sitting time in seconds"));
1481 printf(" %s\n", _(" DSDB = check to see if DS Database is open"));
1482 printf(" %s\n", _(" DSVER = NDS version"));
1483 printf(" %s\n", _(" UPRB = used packet receive buffers"));
1484 printf(" %s\n", _(" PUPRB = percent (of max) used packet receive buffers"));
1485 printf(" %s\n", _(" SAPENTRIES = number of entries in the SAP table"));
1486 printf(" %s\n", _(" SAPENTRIES<n> = number of entries in the SAP table for SAP type <n>"));
1487 printf(" %s\n", _(" TSYNC = timesync status"));
1488 printf(" %s\n", _(" LOGINS = check to see if logins are enabled"));
1489 printf(" %s\n", _(" CONNS = number of currently licensed connections"));
1490 printf(" %s\n", _(" NRMH = NRM Summary Status"));
1491 printf(" %s\n", _(" NRMP<stat> = Returns the current value for a NRM health item"));
1492 printf(" %s\n", _(" NRMM<stat> = Returns the current memory stats from NRM"));
1493 printf(" %s\n", _(" NRMS<stat> = Returns the current Swapfile stats from NRM"));
1494 printf(" %s\n", _(" NSS1<stat> = Statistics from _Admin:Manage_NSS\\GeneralStats.xml"));
1495 printf(" %s\n", _(" NSS3<stat> = Statistics from _Admin:Manage_NSS\\NameCache.xml"));
1496 printf(" %s\n", _(" NSS4<stat> = Statistics from _Admin:Manage_NSS\\FileStats.xml"));
1497 printf(" %s\n", _(" NSS5<stat> = Statistics from _Admin:Manage_NSS\\ObjectCache.xml"));
1498 printf(" %s\n", _(" NSS6<stat> = Statistics from _Admin:Manage_NSS\\Thread.xml"));
1499 printf(" %s\n", _(" NSS7<stat> = Statistics from _Admin:Manage_NSS\\AuthorizationCache.xml"));
1500 printf(" %s\n", _(" NLM:<nlm> = check if NLM is loaded and report version"));
1501 printf(" %s\n", _(" (e.g. NLM:TSANDS.NLM)"));
1503 printf(" %s\n", "-w, --warning=INTEGER");
1504 printf(" %s\n", _("Threshold which will result in a warning status"));
1505 printf(" %s\n", "-c, --critical=INTEGER");
1506 printf(" %s\n", _("Threshold which will result in a critical status"));
1507 printf(" %s\n", "-o, --osversion");
1508 printf(" %s\n", _("Include server version string in results"));
1510 printf(UT_CONN_TIMEOUT
, DEFAULT_SOCKET_TIMEOUT
);
1513 printf("%s\n", _("Notes:"));
1514 printf(" %s\n", _("- This plugin requires that the MRTGEXT.NLM file from James Drews' MRTG"));
1515 printf(" %s\n", _(" extension for NetWare be loaded on the Novell servers you wish to check."));
1516 printf(" %s\n", _(" (available from http://www.engr.wisc.edu/~drews/mrtg/)"));
1517 printf(" %s\n", _("- Values for critical thresholds should be lower than warning thresholds"));
1518 printf(" %s\n", _(" when the following variables are checked: VPF, VKF, LTCH, CBUFF, DCB, "));
1519 printf(" %s\n", _(" TCB, LRUS and LRUM."));
1524 void print_usage(void) {
1525 printf("%s\n", _("Usage:"));
1526 printf("%s -H host [-p port] [-v variable] [-w warning] [-c critical] [-t timeout]\n", progname
);