Fix option description authpassword -> authpasswd
[monitoring-plugins.git] / plugins / check_nwstat.c
blobe7e8de05b8cee6bcae798b9b60266cdc495f7b9a
1 /*****************************************************************************
2 *
3 * Monitoring check_nwstat plugin
4 *
5 * License: GPL
6 * Copyright (c) 2000-2007 Monitoring Plugins Development Team
7 *
8 * Description:
9 *
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-2007";
34 const char *email = "devel@monitoring-plugins.org";
36 #include "common.h"
37 #include "netutils.h"
38 #include "utils.h"
40 enum checkvar {
41 NONE,
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 VMP, /* check MB purgeable space on volume */
50 VKF, /* check KB free space on volume */
51 LTCH, /* check long-term cache hit percentage */
52 CBUFF, /* check total cache buffers */
53 CDBUFF, /* check dirty cache buffers */
54 LRUM, /* check LRU sitting time in minutes */
55 DSDB, /* check to see if DS Database is open */
56 LOGINS, /* check to see if logins are enabled */
57 NRMH, /* check to see NRM Health Status */
58 PUPRB, /* check % of used packet receive buffers */
59 UPRB, /* check used packet receive buffers */
60 SAPENTRIES, /* check SAP entries */
61 OFILES, /* check number of open files */
62 VKP, /* check KB purgeable space on volume */
63 VPP, /* check % purgeable space on volume */
64 VKNP, /* check KB not yet purgeable space on volume */
65 VPNP, /* check % not yet purgeable space on volume */
66 ABENDS, /* check abended thread count */
67 CSPROCS, /* check number of current service processes */
68 TSYNC, /* check timesync status 0=no 1=yes in sync to the network */
69 LRUS, /* check LRU sitting time in seconds */
70 DCB, /* check dirty cache buffers as a percentage of the total */
71 TCB, /* check total cache buffers as a percentage of the original */
72 DSVER, /* check NDS version */
73 UPTIME, /* check server uptime */
74 NLM, /* check NLM loaded */
75 NRMP, /* check NRM Process Values */
76 NRMM, /* check NRM Memory Values */
77 NRMS, /* check NRM Values */
78 NSS1, /* check Statistics from _Admin:Manage_NSS\GeneralStats.xml */
79 NSS2, /* check Statistics from _Admin:Manage_NSS\BufferCache.xml */
80 NSS3, /* check statistics from _Admin:Manage_NSS\NameCache.xml */
81 NSS4, /* check statistics from _Admin:Manage_NSS\FileStats.xml */
82 NSS5, /* check statistics from _Admin:Manage_NSS\ObjectCache.xml */
83 NSS6, /* check statistics from _Admin:Manage_NSS\Thread.xml */
84 NSS7 /* check statistics from _Admin:Manage_NSS\AuthorizationCache.xml */
87 enum {
88 PORT = 9999
91 char *server_address=NULL;
92 char *volume_name=NULL;
93 char *nlm_name=NULL;
94 char *nrmp_name=NULL;
95 char *nrmm_name=NULL;
96 char *nrms_name=NULL;
97 char *nss1_name=NULL;
98 char *nss2_name=NULL;
99 char *nss3_name=NULL;
100 char *nss4_name=NULL;
101 char *nss5_name=NULL;
102 char *nss6_name=NULL;
103 char *nss7_name=NULL;
104 int server_port=PORT;
105 unsigned long warning_value=0L;
106 unsigned long critical_value=0L;
107 int check_warning_value=FALSE;
108 int check_critical_value=FALSE;
109 int check_netware_version=FALSE;
110 enum checkvar vars_to_check = NONE;
111 int sap_number=-1;
113 int process_arguments(int, char **);
114 void print_help(void);
115 void print_usage(void);
120 main(int argc, char **argv) {
121 int result = STATE_UNKNOWN;
122 int sd;
123 char *send_buffer=NULL;
124 char recv_buffer[MAX_INPUT_BUFFER];
125 char *output_message=NULL;
126 char *temp_buffer=NULL;
127 char *netware_version=NULL;
129 int time_sync_status=0;
130 int nrm_health_status=0;
131 unsigned long total_cache_buffers=0;
132 unsigned long dirty_cache_buffers=0;
133 unsigned long open_files=0;
134 unsigned long abended_threads=0;
135 unsigned long max_service_processes=0;
136 unsigned long current_service_processes=0;
137 unsigned long free_disk_space=0L;
138 unsigned long nrmp_value=0L;
139 unsigned long nrmm_value=0L;
140 unsigned long nrms_value=0L;
141 unsigned long nss1_value=0L;
142 unsigned long nss2_value=0L;
143 unsigned long nss3_value=0L;
144 unsigned long nss4_value=0L;
145 unsigned long nss5_value=0L;
146 unsigned long nss6_value=0L;
147 unsigned long nss7_value=0L;
148 unsigned long total_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);
167 textdomain (PACKAGE);
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==TRUE) {
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)
189 return result;
190 if (!strcmp(recv_buffer,"-1\n"))
191 netware_version = strdup("");
192 else {
193 recv_buffer[strlen(recv_buffer)-1]=0;
194 xasprintf (&netware_version,_("NetWare %s: "),recv_buffer);
196 } else
197 netware_version = strdup("");
200 /* check CPU load */
201 if (vars_to_check==LOAD1 || vars_to_check==LOAD5 || vars_to_check==LOAD15) {
203 switch(vars_to_check) {
204 case LOAD1:
205 temp_buffer = strdup ("1");
206 break;
207 case LOAD5:
208 temp_buffer = strdup ("5");
209 break;
210 default:
211 temp_buffer = strdup ("15");
212 break;
215 close(sd);
216 my_tcp_connect (server_address, server_port, &sd);
218 xasprintf (&send_buffer,"UTIL%s\r\n",temp_buffer);
219 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
220 if (result!=STATE_OK)
221 return result;
222 utilization=strtoul(recv_buffer,NULL,10);
224 close(sd);
225 my_tcp_connect (server_address, server_port, &sd);
227 send_buffer = strdup ("UPTIME\r\n");
228 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
229 if (result!=STATE_OK)
230 return result;
231 recv_buffer[strlen(recv_buffer)-1]=0;
232 sprintf(uptime,_("Up %s,"),recv_buffer);
234 if (check_critical_value==TRUE && utilization >= critical_value)
235 result=STATE_CRITICAL;
236 else if (check_warning_value==TRUE && utilization >= warning_value)
237 result=STATE_WARNING;
239 xasprintf (&output_message,
240 _("Load %s - %s %s-min load average = %lu%%|load%s=%lu;%lu;%lu;0;100"),
241 state_text(result),
242 uptime,
243 temp_buffer,
244 utilization,
245 temp_buffer,
246 utilization,
247 warning_value,
248 critical_value);
250 /* check number of user connections */
251 } else if (vars_to_check==CONNS) {
253 close(sd);
254 my_tcp_connect (server_address, server_port, &sd);
256 send_buffer = strdup ("CONNECT\r\n");
257 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
258 if (result!=STATE_OK)
259 return result;
260 current_connections=strtoul(recv_buffer,NULL,10);
262 if (check_critical_value==TRUE && current_connections >= critical_value)
263 result=STATE_CRITICAL;
264 else if (check_warning_value==TRUE && current_connections >= warning_value)
265 result=STATE_WARNING;
267 xasprintf (&output_message,
268 _("Conns %s - %lu current connections|Conns=%lu;%lu;%lu;;"),
269 state_text(result),
270 current_connections,
271 current_connections,
272 warning_value,
273 critical_value);
275 /* check % long term cache hits */
276 } else if (vars_to_check==LTCH) {
278 close(sd);
279 my_tcp_connect (server_address, server_port, &sd);
281 send_buffer = strdup ("S1\r\n");
282 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
283 if (result!=STATE_OK)
284 return result;
285 cache_hits=atoi(recv_buffer);
287 if (check_critical_value==TRUE && cache_hits <= critical_value)
288 result=STATE_CRITICAL;
289 else if (check_warning_value==TRUE && cache_hits <= warning_value)
290 result=STATE_WARNING;
292 xasprintf (&output_message,
293 _("%s: Long term cache hits = %lu%%"),
294 state_text(result),
295 cache_hits);
297 /* check cache buffers */
298 } else if (vars_to_check==CBUFF) {
300 close(sd);
301 my_tcp_connect (server_address, server_port, &sd);
303 send_buffer = strdup ("S2\r\n");
304 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
305 if (result!=STATE_OK)
306 return result;
307 cache_buffers=strtoul(recv_buffer,NULL,10);
309 if (check_critical_value==TRUE && cache_buffers <= critical_value)
310 result=STATE_CRITICAL;
311 else if (check_warning_value==TRUE && cache_buffers <= warning_value)
312 result=STATE_WARNING;
314 xasprintf (&output_message,
315 _("%s: Total cache buffers = %lu|Cachebuffers=%lu;%lu;%lu;;"),
316 state_text(result),
317 cache_buffers,
318 cache_buffers,
319 warning_value,
320 critical_value);
322 /* check dirty cache buffers */
323 } else if (vars_to_check==CDBUFF) {
325 close(sd);
326 my_tcp_connect (server_address, server_port, &sd);
328 send_buffer = strdup ("S3\r\n");
329 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
330 if (result!=STATE_OK)
331 return result;
332 cache_buffers=strtoul(recv_buffer,NULL,10);
334 if (check_critical_value==TRUE && cache_buffers >= critical_value)
335 result=STATE_CRITICAL;
336 else if (check_warning_value==TRUE && cache_buffers >= warning_value)
337 result=STATE_WARNING;
339 xasprintf (&output_message,
340 _("%s: Dirty cache buffers = %lu|Dirty-Cache-Buffers=%lu;%lu;%lu;;"),
341 state_text(result),
342 cache_buffers,
343 cache_buffers,
344 warning_value,
345 critical_value);
347 /* check LRU sitting time in minutes */
348 } else if (vars_to_check==LRUM) {
350 close(sd);
351 my_tcp_connect (server_address, server_port, &sd);
353 send_buffer = strdup ("S5\r\n");
354 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
355 if (result!=STATE_OK)
356 return result;
357 lru_time=strtoul(recv_buffer,NULL,10);
359 if (check_critical_value==TRUE && lru_time <= critical_value)
360 result=STATE_CRITICAL;
361 else if (check_warning_value==TRUE && lru_time <= warning_value)
362 result=STATE_WARNING;
364 xasprintf (&output_message,
365 _("%s: LRU sitting time = %lu minutes"),
366 state_text(result),
367 lru_time);
370 /* check KB free space on volume */
371 } else if (vars_to_check==VKF) {
373 close(sd);
374 my_tcp_connect (server_address, server_port, &sd);
376 xasprintf (&send_buffer,"VKF%s\r\n",volume_name);
377 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
378 if (result!=STATE_OK)
379 return result;
381 if (!strcmp(recv_buffer,"-1\n")) {
382 xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
383 result=STATE_CRITICAL;
384 } else {
385 free_disk_space=strtoul(recv_buffer,NULL,10);
386 if (check_critical_value==TRUE && free_disk_space <= critical_value)
387 result=STATE_CRITICAL;
388 else if (check_warning_value==TRUE && free_disk_space <= warning_value)
389 result=STATE_WARNING;
390 xasprintf (&output_message,
391 _("%s%lu KB free on volume %s|KBFree%s=%lu;%lu;%lu;;"),
392 (result==STATE_OK)?"":_("Only "),
393 free_disk_space,
394 volume_name,
395 volume_name,
396 free_disk_space,
397 warning_value,
398 critical_value);
401 /* check MB free space on volume */
402 } else if (vars_to_check==VMF) {
404 xasprintf (&send_buffer,"VMF%s\r\n",volume_name);
405 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
406 if (result!=STATE_OK)
407 return result;
409 if (!strcmp(recv_buffer,"-1\n")) {
410 xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
411 result=STATE_CRITICAL;
412 } else {
413 free_disk_space=strtoul(recv_buffer,NULL,10);
414 if (check_critical_value==TRUE && free_disk_space <= critical_value)
415 result=STATE_CRITICAL;
416 else if (check_warning_value==TRUE && free_disk_space <= warning_value)
417 result=STATE_WARNING;
418 xasprintf (&output_message,
419 _("%s%lu MB free on volume %s|MBFree%s=%lu;%lu;%lu;;"),
420 (result==STATE_OK)?"":_("Only "),
421 free_disk_space,
422 volume_name,
423 volume_name,
424 free_disk_space,
425 warning_value,
426 critical_value);
428 /* check MB used space on volume */
429 } else if (vars_to_check==VMU) {
431 xasprintf (&send_buffer,"VMU%s\r\n",volume_name);
432 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
433 if (result!=STATE_OK)
434 return result;
436 if (!strcmp(recv_buffer,"-1\n")) {
437 xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
438 result=STATE_CRITICAL;
439 } else {
440 free_disk_space=strtoul(recv_buffer,NULL,10);
441 if (check_critical_value==TRUE && free_disk_space <= critical_value)
442 result=STATE_CRITICAL;
443 else if (check_warning_value==TRUE && free_disk_space <= warning_value)
444 result=STATE_WARNING;
445 xasprintf (&output_message,
446 _("%s%lu MB used on volume %s|MBUsed%s=%lu;%lu;%lu;;"),
447 (result==STATE_OK)?"":_("Only "),
448 free_disk_space,
449 volume_name,
450 volume_name,
451 free_disk_space,
452 warning_value,
453 critical_value);
457 /* check % free space on volume */
458 } else if (vars_to_check==VPF) {
460 close(sd);
461 my_tcp_connect (server_address, server_port, &sd);
463 xasprintf (&send_buffer,"VKF%s\r\n",volume_name);
464 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
465 if (result!=STATE_OK)
466 return result;
468 if (!strcmp(recv_buffer,"-1\n")) {
470 xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
471 result=STATE_CRITICAL;
473 } else {
475 free_disk_space=strtoul(recv_buffer,NULL,10);
477 close(sd);
478 my_tcp_connect (server_address, server_port, &sd);
480 xasprintf (&send_buffer,"VKS%s\r\n",volume_name);
481 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
482 if (result!=STATE_OK)
483 return result;
484 total_disk_space=strtoul(recv_buffer,NULL,10);
486 percent_free_space=(unsigned long)(((double)free_disk_space/(double)total_disk_space)*100.0);
488 if (check_critical_value==TRUE && percent_free_space <= critical_value)
489 result=STATE_CRITICAL;
490 else if (check_warning_value==TRUE && percent_free_space <= warning_value)
491 result=STATE_WARNING;
492 free_disk_space/=1024;
493 total_disk_space/=1024;
494 xasprintf (&output_message,_("%lu MB (%lu%%) free on volume %s - total %lu MB|FreeMB%s=%lu;%lu;%lu;0;100"),
495 free_disk_space,
496 percent_free_space,
497 volume_name,
498 total_disk_space,
499 volume_name,
500 percent_free_space,
501 warning_value,
502 critical_value
506 /* check to see if DS Database is open or closed */
507 } else if (vars_to_check==DSDB) {
509 close(sd);
510 my_tcp_connect (server_address, server_port, &sd);
512 send_buffer = strdup ("S11\r\n");
513 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
514 if (result!=STATE_OK)
515 return result;
516 if (atoi(recv_buffer)==1)
517 result=STATE_OK;
518 else
519 result=STATE_WARNING;
521 close(sd);
522 my_tcp_connect (server_address, server_port, &sd);
524 send_buffer = strdup ("S13\r\n");
525 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
526 temp_buffer=strtok(recv_buffer,"\r\n");
528 xasprintf (&output_message,_("Directory Services Database is %s (DS version %s)"),(result==STATE_OK)?"open":"closed",temp_buffer);
530 /* check to see if logins are enabled */
531 } else if (vars_to_check==LOGINS) {
533 close(sd);
534 my_tcp_connect (server_address, server_port, &sd);
536 send_buffer = strdup ("S12\r\n");
537 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
538 if (result!=STATE_OK)
539 return result;
540 if (atoi(recv_buffer)==1)
541 result=STATE_OK;
542 else
543 result=STATE_WARNING;
545 xasprintf (&output_message,_("Logins are %s"),(result==STATE_OK)?_("enabled"):_("disabled"));
548 /* check NRM Health Status Summary*/
549 } else if (vars_to_check==NRMH) {
551 xasprintf (&send_buffer,"NRMH\r\n");
552 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
553 if (result!=STATE_OK)
554 return result;
556 nrm_health_status=atoi(recv_buffer);
558 if (nrm_health_status==2) {
559 result=STATE_OK;
560 xasprintf (&output_message,_("CRITICAL - NRM Status is bad!"));
562 else {
563 if (nrm_health_status==1) {
564 result=STATE_WARNING;
565 xasprintf (&output_message,_("Warning - NRM Status is suspect!"));
568 xasprintf (&output_message,_("OK - NRM Status is good!"));
573 /* check packet receive buffers */
574 } else if (vars_to_check==UPRB || vars_to_check==PUPRB) {
576 close(sd);
577 my_tcp_connect (server_address, server_port, &sd);
579 xasprintf (&send_buffer,"S15\r\n");
580 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
581 if (result!=STATE_OK)
582 return result;
584 used_packet_receive_buffers=atoi(recv_buffer);
586 close(sd);
587 my_tcp_connect (server_address, server_port, &sd);
589 xasprintf (&send_buffer,"S16\r\n");
590 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
591 if (result!=STATE_OK)
592 return result;
594 max_packet_receive_buffers=atoi(recv_buffer);
596 percent_used_packet_receive_buffers=(unsigned long)(((double)used_packet_receive_buffers/(double)max_packet_receive_buffers)*100.0);
598 if (vars_to_check==UPRB) {
599 if (check_critical_value==TRUE && used_packet_receive_buffers >= critical_value)
600 result=STATE_CRITICAL;
601 else if (check_warning_value==TRUE && used_packet_receive_buffers >= warning_value)
602 result=STATE_WARNING;
603 } else {
604 if (check_critical_value==TRUE && percent_used_packet_receive_buffers >= critical_value)
605 result=STATE_CRITICAL;
606 else if (check_warning_value==TRUE && percent_used_packet_receive_buffers >= warning_value)
607 result=STATE_WARNING;
610 xasprintf (&output_message,_("%lu of %lu (%lu%%) packet receive buffers used"),used_packet_receive_buffers,max_packet_receive_buffers,percent_used_packet_receive_buffers);
612 /* check SAP table entries */
613 } else if (vars_to_check==SAPENTRIES) {
615 close(sd);
616 my_tcp_connect (server_address, server_port, &sd);
618 if (sap_number==-1)
619 xasprintf (&send_buffer,"S9\r\n");
620 else
621 xasprintf (&send_buffer,"S9.%d\r\n",sap_number);
622 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
623 if (result!=STATE_OK)
624 return result;
626 sap_entries=atoi(recv_buffer);
628 if (check_critical_value==TRUE && sap_entries >= critical_value)
629 result=STATE_CRITICAL;
630 else if (check_warning_value==TRUE && sap_entries >= warning_value)
631 result=STATE_WARNING;
633 if (sap_number==-1)
634 xasprintf (&output_message,_("%lu entries in SAP table"),sap_entries);
635 else
636 xasprintf (&output_message,_("%lu entries in SAP table for SAP type %d"),sap_entries,sap_number);
638 /* check KB purgeable space on volume */
639 } else if (vars_to_check==VKP) {
641 close(sd);
642 my_tcp_connect (server_address, server_port, &sd);
644 xasprintf (&send_buffer,"VKP%s\r\n",volume_name);
645 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
646 if (result!=STATE_OK)
647 return result;
649 if (!strcmp(recv_buffer,"-1\n")) {
650 xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
651 result=STATE_CRITICAL;
652 } else {
653 purgeable_disk_space=strtoul(recv_buffer,NULL,10);
654 if (check_critical_value==TRUE && purgeable_disk_space >= critical_value)
655 result=STATE_CRITICAL;
656 else if (check_warning_value==TRUE && purgeable_disk_space >= warning_value)
657 result=STATE_WARNING;
658 xasprintf (&output_message,_("%s%lu KB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;"),
659 (result==STATE_OK)?"":_("Only "),
660 purgeable_disk_space,
661 volume_name,
662 volume_name,
663 purgeable_disk_space,
664 warning_value,
665 critical_value);
667 /* check MB purgeable space on volume */
668 } else if (vars_to_check==VMP) {
670 xasprintf (&send_buffer,"VMP%s\r\n",volume_name);
671 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
672 if (result!=STATE_OK)
673 return result;
675 if (!strcmp(recv_buffer,"-1\n")) {
676 xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
677 result=STATE_CRITICAL;
678 } else {
679 purgeable_disk_space=strtoul(recv_buffer,NULL,10);
680 if (check_critical_value==TRUE && purgeable_disk_space >= critical_value)
681 result=STATE_CRITICAL;
682 else if (check_warning_value==TRUE && purgeable_disk_space >= warning_value)
683 result=STATE_WARNING;
684 xasprintf (&output_message,_("%s%lu MB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;"),
685 (result==STATE_OK)?"":_("Only "),
686 purgeable_disk_space,
687 volume_name,
688 volume_name,
689 purgeable_disk_space,
690 warning_value,
691 critical_value);
694 /* check % purgeable space on volume */
695 } else if (vars_to_check==VPP) {
697 close(sd);
698 my_tcp_connect (server_address, server_port, &sd);
700 xasprintf (&send_buffer,"VKP%s\r\n",volume_name);
701 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
702 if (result!=STATE_OK)
703 return result;
705 if (!strcmp(recv_buffer,"-1\n")) {
707 xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
708 result=STATE_CRITICAL;
710 } else {
712 purgeable_disk_space=strtoul(recv_buffer,NULL,10);
714 close(sd);
715 my_tcp_connect (server_address, server_port, &sd);
717 xasprintf (&send_buffer,"VKS%s\r\n",volume_name);
718 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
719 if (result!=STATE_OK)
720 return result;
721 total_disk_space=strtoul(recv_buffer,NULL,10);
723 percent_purgeable_space=(unsigned long)(((double)purgeable_disk_space/(double)total_disk_space)*100.0);
725 if (check_critical_value==TRUE && percent_purgeable_space >= critical_value)
726 result=STATE_CRITICAL;
727 else if (check_warning_value==TRUE && percent_purgeable_space >= warning_value)
728 result=STATE_WARNING;
729 purgeable_disk_space/=1024;
730 xasprintf (&output_message,_("%lu MB (%lu%%) purgeable on volume %s|Purgeable%s=%lu;%lu;%lu;0;100"),
731 purgeable_disk_space,
732 percent_purgeable_space,
733 volume_name,
734 volume_name,
735 percent_purgeable_space,
736 warning_value,
737 critical_value
741 /* check KB not yet purgeable space on volume */
742 } else if (vars_to_check==VKNP) {
744 close(sd);
745 my_tcp_connect (server_address, server_port, &sd);
747 xasprintf (&send_buffer,"VKNP%s\r\n",volume_name);
748 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
749 if (result!=STATE_OK)
750 return result;
752 if (!strcmp(recv_buffer,"-1\n")) {
753 xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
754 result=STATE_CRITICAL;
755 } else {
756 non_purgeable_disk_space=strtoul(recv_buffer,NULL,10);
757 if (check_critical_value==TRUE && non_purgeable_disk_space >= critical_value)
758 result=STATE_CRITICAL;
759 else if (check_warning_value==TRUE && non_purgeable_disk_space >= warning_value)
760 result=STATE_WARNING;
761 xasprintf (&output_message,_("%s%lu KB not yet purgeable on volume %s"),(result==STATE_OK)?"":_("Only "),non_purgeable_disk_space,volume_name);
764 /* check % not yet purgeable space on volume */
765 } else if (vars_to_check==VPNP) {
767 close(sd);
768 my_tcp_connect (server_address, server_port, &sd);
770 xasprintf (&send_buffer,"VKNP%s\r\n",volume_name);
771 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
772 if (result!=STATE_OK)
773 return result;
775 if (!strcmp(recv_buffer,"-1\n")) {
777 xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
778 result=STATE_CRITICAL;
780 } else {
782 non_purgeable_disk_space=strtoul(recv_buffer,NULL,10);
784 close(sd);
785 my_tcp_connect (server_address, server_port, &sd);
787 xasprintf (&send_buffer,"VKS%s\r\n",volume_name);
788 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
789 if (result!=STATE_OK)
790 return result;
791 total_disk_space=strtoul(recv_buffer,NULL,10);
793 percent_non_purgeable_space=(unsigned long)(((double)non_purgeable_disk_space/(double)total_disk_space)*100.0);
795 if (check_critical_value==TRUE && percent_non_purgeable_space >= critical_value)
796 result=STATE_CRITICAL;
797 else if (check_warning_value==TRUE && percent_non_purgeable_space >= warning_value)
798 result=STATE_WARNING;
799 purgeable_disk_space/=1024;
800 xasprintf (&output_message,_("%lu MB (%lu%%) not yet purgeable on volume %s"),non_purgeable_disk_space,percent_non_purgeable_space,volume_name);
803 /* check # of open files */
804 } else if (vars_to_check==OFILES) {
806 close(sd);
807 my_tcp_connect (server_address, server_port, &sd);
809 xasprintf (&send_buffer,"S18\r\n");
810 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
811 if (result!=STATE_OK)
812 return result;
814 open_files=atoi(recv_buffer);
816 if (check_critical_value==TRUE && open_files >= critical_value)
817 result=STATE_CRITICAL;
818 else if (check_warning_value==TRUE && open_files >= warning_value)
819 result=STATE_WARNING;
821 xasprintf (&output_message,_("%lu open files|Openfiles=%lu;%lu;%lu;0,0"),
822 open_files,
823 open_files,
824 warning_value,
825 critical_value);
828 /* check # of abended threads (Netware > 5.x only) */
829 } else if (vars_to_check==ABENDS) {
831 close(sd);
832 my_tcp_connect (server_address, server_port, &sd);
834 xasprintf (&send_buffer,"S17\r\n");
835 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
836 if (result!=STATE_OK)
837 return result;
839 abended_threads=atoi(recv_buffer);
841 if (check_critical_value==TRUE && abended_threads >= critical_value)
842 result=STATE_CRITICAL;
843 else if (check_warning_value==TRUE && abended_threads >= warning_value)
844 result=STATE_WARNING;
846 xasprintf (&output_message,_("%lu abended threads|Abends=%lu;%lu;%lu;;"),
847 abended_threads,
848 abended_threads,
849 warning_value,
850 critical_value);
852 /* check # of current service processes (Netware 5.x only) */
853 } else if (vars_to_check==CSPROCS) {
855 close(sd);
856 my_tcp_connect (server_address, server_port, &sd);
858 xasprintf (&send_buffer,"S20\r\n");
859 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
860 if (result!=STATE_OK)
861 return result;
863 max_service_processes=atoi(recv_buffer);
865 close(sd);
866 my_tcp_connect (server_address, server_port, &sd);
868 xasprintf (&send_buffer,"S21\r\n");
869 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
870 if (result!=STATE_OK)
871 return result;
873 current_service_processes=atoi(recv_buffer);
875 if (check_critical_value==TRUE && current_service_processes >= critical_value)
876 result=STATE_CRITICAL;
877 else if (check_warning_value==TRUE && current_service_processes >= warning_value)
878 result=STATE_WARNING;
880 xasprintf (&output_message,
881 _("%lu current service processes (%lu max)|Processes=%lu;%lu;%lu;0;%lu"),
882 current_service_processes,
883 max_service_processes,
884 current_service_processes,
885 warning_value,
886 critical_value,
887 max_service_processes);
889 /* check # Timesync Status */
890 } else if (vars_to_check==TSYNC) {
892 close(sd);
893 my_tcp_connect (server_address, server_port, &sd);
895 xasprintf (&send_buffer,"S22\r\n");
896 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
897 if (result!=STATE_OK)
898 return result;
900 time_sync_status=atoi(recv_buffer);
902 if (time_sync_status==0) {
903 result=STATE_CRITICAL;
904 xasprintf (&output_message,_("CRITICAL - Time not in sync with network!"));
906 else {
907 xasprintf (&output_message,_("OK - Time in sync with network!"));
914 /* check LRU sitting time in secondss */
915 } else if (vars_to_check==LRUS) {
917 close(sd);
918 my_tcp_connect (server_address, server_port, &sd);
920 send_buffer = strdup ("S4\r\n");
921 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
922 if (result!=STATE_OK)
923 return result;
924 lru_time=strtoul(recv_buffer,NULL,10);
926 if (check_critical_value==TRUE && lru_time <= critical_value)
927 result=STATE_CRITICAL;
928 else if (check_warning_value==TRUE && lru_time <= warning_value)
929 result=STATE_WARNING;
930 xasprintf (&output_message,_("LRU sitting time = %lu seconds"),lru_time);
933 /* check % dirty cacheobuffers as a percentage of the total*/
934 } else if (vars_to_check==DCB) {
936 close(sd);
937 my_tcp_connect (server_address, server_port, &sd);
939 send_buffer = strdup ("S6\r\n");
940 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
941 if (result!=STATE_OK)
942 return result;
943 dirty_cache_buffers=atoi(recv_buffer);
945 if (check_critical_value==TRUE && dirty_cache_buffers <= critical_value)
946 result=STATE_CRITICAL;
947 else if (check_warning_value==TRUE && dirty_cache_buffers <= warning_value)
948 result=STATE_WARNING;
949 xasprintf (&output_message,_("Dirty cache buffers = %lu%% of the total|DCB=%lu;%lu;%lu;0;100"),
950 dirty_cache_buffers,
951 dirty_cache_buffers,
952 warning_value,
953 critical_value);
955 /* check % total cache buffers as a percentage of the original*/
956 } else if (vars_to_check==TCB) {
958 close(sd);
959 my_tcp_connect (server_address, server_port, &sd);
961 send_buffer = strdup ("S7\r\n");
962 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
963 if (result!=STATE_OK)
964 return result;
965 total_cache_buffers=atoi(recv_buffer);
967 if (check_critical_value==TRUE && total_cache_buffers <= critical_value)
968 result=STATE_CRITICAL;
969 else if (check_warning_value==TRUE && total_cache_buffers <= warning_value)
970 result=STATE_WARNING;
971 xasprintf (&output_message,_("Total cache buffers = %lu%% of the original|TCB=%lu;%lu;%lu;0;100"),
972 total_cache_buffers,
973 total_cache_buffers,
974 warning_value,
975 critical_value);
977 } else if (vars_to_check==DSVER) {
979 close(sd);
980 my_tcp_connect (server_address, server_port, &sd);
982 xasprintf (&send_buffer,"S13\r\n");
983 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
984 if (result!=STATE_OK)
985 return result;
987 recv_buffer[strlen(recv_buffer)-1]=0;
989 xasprintf (&output_message,_("NDS Version %s"),recv_buffer);
991 } else if (vars_to_check==UPTIME) {
993 close(sd);
994 my_tcp_connect (server_address, server_port, &sd);
996 xasprintf (&send_buffer,"UPTIME\r\n");
997 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
998 if (result!=STATE_OK)
999 return result;
1002 recv_buffer[sizeof(recv_buffer)-1]=0;
1003 recv_buffer[strlen(recv_buffer)-1]=0;
1005 xasprintf (&output_message,_("Up %s"),recv_buffer);
1007 } else if (vars_to_check==NLM) {
1009 close(sd);
1010 my_tcp_connect (server_address, server_port, &sd);
1012 xasprintf (&send_buffer,"S24:%s\r\n",nlm_name);
1013 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
1014 if (result!=STATE_OK)
1015 return result;
1017 recv_buffer[strlen(recv_buffer)-1]=0;
1018 if (strcmp(recv_buffer,"-1")) {
1019 xasprintf (&output_message,_("Module %s version %s is loaded"),nlm_name,recv_buffer);
1020 } else {
1021 result=STATE_CRITICAL;
1022 xasprintf (&output_message,_("Module %s is not loaded"),nlm_name);
1025 } else if (vars_to_check==NRMP) {
1027 xasprintf (&send_buffer,"NRMP:%s\r\n",nrmp_name);
1028 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
1029 if (result!=STATE_OK)
1030 return result;
1032 if (!strcmp(recv_buffer,"-1\n")) {
1033 xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nrmp_name);
1034 result=STATE_CRITICAL;
1035 } else {
1036 nrmp_value=strtoul(recv_buffer,NULL,10);
1037 if (check_critical_value==TRUE && nrmp_value <= critical_value)
1038 result=STATE_CRITICAL;
1039 else if (check_warning_value==TRUE && nrmp_value <= warning_value)
1040 result=STATE_WARNING;
1041 xasprintf (&output_message,
1042 _("%s is %lu|%s=%lu;%lu;%lu;;"),
1043 nrmp_name,
1044 nrmp_value,
1045 nrmp_name,
1046 nrmp_value,
1047 warning_value,
1048 critical_value);
1051 } else if (vars_to_check==NRMM) {
1053 xasprintf (&send_buffer,"NRMM:%s\r\n",nrmm_name);
1054 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
1055 if (result!=STATE_OK)
1056 return result;
1058 if (!strcmp(recv_buffer,"-1\n")) {
1059 xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nrmm_name);
1060 result=STATE_CRITICAL;
1061 } else {
1062 nrmm_value=strtoul(recv_buffer,NULL,10);
1063 if (check_critical_value==TRUE && nrmm_value <= critical_value)
1064 result=STATE_CRITICAL;
1065 else if (check_warning_value==TRUE && nrmm_value <= warning_value)
1066 result=STATE_WARNING;
1067 xasprintf (&output_message,
1068 _("%s is %lu|%s=%lu;%lu;%lu;;"),
1069 nrmm_name,
1070 nrmm_value,
1071 nrmm_name,
1072 nrmm_value,
1073 warning_value,
1074 critical_value);
1077 } else if (vars_to_check==NRMS) {
1079 xasprintf (&send_buffer,"NRMS:%s\r\n",nrms_name);
1080 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
1081 if (result!=STATE_OK)
1082 return result;
1084 if (!strcmp(recv_buffer,"-1\n")) {
1085 xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nrms_name);
1086 result=STATE_CRITICAL;
1087 } else {
1088 nrms_value=strtoul(recv_buffer,NULL,10);
1089 if (check_critical_value==TRUE && nrms_value >= critical_value)
1090 result=STATE_CRITICAL;
1091 else if (check_warning_value==TRUE && nrms_value >= warning_value)
1092 result=STATE_WARNING;
1093 xasprintf (&output_message,
1094 _("%s is %lu|%s=%lu;%lu;%lu;;"),
1095 nrms_name,
1096 nrms_value,
1097 nrms_name,
1098 nrms_value,
1099 warning_value,
1100 critical_value);
1103 } else if (vars_to_check==NSS1) {
1105 xasprintf (&send_buffer,"NSS1:%s\r\n",nss1_name);
1106 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
1107 if (result!=STATE_OK)
1108 return result;
1110 if (!strcmp(recv_buffer,"-1\n")) {
1111 xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss1_name);
1112 result=STATE_CRITICAL;
1113 } else {
1114 nss1_value=strtoul(recv_buffer,NULL,10);
1115 if (check_critical_value==TRUE && nss1_value >= critical_value)
1116 result=STATE_CRITICAL;
1117 else if (check_warning_value==TRUE && nss1_value >= warning_value)
1118 result=STATE_WARNING;
1119 xasprintf (&output_message,
1120 _("%s is %lu|%s=%lu;%lu;%lu;;"),
1121 nss1_name,
1122 nss1_value,
1123 nss1_name,
1124 nss1_value,
1125 warning_value,
1126 critical_value);
1129 } else if (vars_to_check==NSS2) {
1131 xasprintf (&send_buffer,"NSS2:%s\r\n",nss2_name);
1132 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
1133 if (result!=STATE_OK)
1134 return result;
1136 if (!strcmp(recv_buffer,"-1\n")) {
1137 xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss2_name);
1138 result=STATE_CRITICAL;
1139 } else {
1140 nss2_value=strtoul(recv_buffer,NULL,10);
1141 if (check_critical_value==TRUE && nss2_value >= critical_value)
1142 result=STATE_CRITICAL;
1143 else if (check_warning_value==TRUE && nss2_value >= warning_value)
1144 result=STATE_WARNING;
1145 xasprintf (&output_message,
1146 _("%s is %lu|%s=%lu;%lu;%lu;;"),
1147 nss2_name,
1148 nss2_value,
1149 nss2_name,
1150 nss2_value,
1151 warning_value,
1152 critical_value);
1155 } else if (vars_to_check==NSS3) {
1157 xasprintf (&send_buffer,"NSS3:%s\r\n",nss3_name);
1158 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
1159 if (result!=STATE_OK)
1160 return result;
1162 if (!strcmp(recv_buffer,"-1\n")) {
1163 xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss3_name);
1164 result=STATE_CRITICAL;
1165 } else {
1166 nss3_value=strtoul(recv_buffer,NULL,10);
1167 if (check_critical_value==TRUE && nss3_value >= critical_value)
1168 result=STATE_CRITICAL;
1169 else if (check_warning_value==TRUE && nss3_value >= warning_value)
1170 result=STATE_WARNING;
1171 xasprintf (&output_message,
1172 _("%s is %lu|%s=%lu;%lu;%lu;;"),
1173 nss3_name,
1174 nss3_value,
1175 nss3_name,
1176 nss3_value,
1177 warning_value,
1178 critical_value);
1181 } else if (vars_to_check==NSS4) {
1183 xasprintf (&send_buffer,"NSS4:%s\r\n",nss4_name);
1184 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
1185 if (result!=STATE_OK)
1186 return result;
1188 if (!strcmp(recv_buffer,"-1\n")) {
1189 xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss4_name);
1190 result=STATE_CRITICAL;
1191 } else {
1192 nss4_value=strtoul(recv_buffer,NULL,10);
1193 if (check_critical_value==TRUE && nss4_value >= critical_value)
1194 result=STATE_CRITICAL;
1195 else if (check_warning_value==TRUE && nss4_value >= warning_value)
1196 result=STATE_WARNING;
1197 xasprintf (&output_message,
1198 _("%s is %lu|%s=%lu;%lu;%lu;;"),
1199 nss4_name,
1200 nss4_value,
1201 nss4_name,
1202 nss4_value,
1203 warning_value,
1204 critical_value);
1207 } else if (vars_to_check==NSS5) {
1209 xasprintf (&send_buffer,"NSS5:%s\r\n",nss5_name);
1210 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
1211 if (result!=STATE_OK)
1212 return result;
1214 if (!strcmp(recv_buffer,"-1\n")) {
1215 xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss5_name);
1216 result=STATE_CRITICAL;
1217 } else {
1218 nss5_value=strtoul(recv_buffer,NULL,10);
1219 if (check_critical_value==TRUE && nss5_value >= critical_value)
1220 result=STATE_CRITICAL;
1221 else if (check_warning_value==TRUE && nss5_value >= warning_value)
1222 result=STATE_WARNING;
1223 xasprintf (&output_message,
1224 _("%s is %lu|%s=%lu;%lu;%lu;;"),
1225 nss5_name,
1226 nss5_value,
1227 nss5_name,
1228 nss5_value,
1229 warning_value,
1230 critical_value);
1233 } else if (vars_to_check==NSS6) {
1235 xasprintf (&send_buffer,"NSS6:%s\r\n",nss6_name);
1236 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
1237 if (result!=STATE_OK)
1238 return result;
1240 if (!strcmp(recv_buffer,"-1\n")) {
1241 xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss6_name);
1242 result=STATE_CRITICAL;
1243 } else {
1244 nss6_value=strtoul(recv_buffer,NULL,10);
1245 if (check_critical_value==TRUE && nss6_value >= critical_value)
1246 result=STATE_CRITICAL;
1247 else if (check_warning_value==TRUE && nss6_value >= warning_value)
1248 result=STATE_WARNING;
1249 xasprintf (&output_message,
1250 _("%s is %lu|%s=%lu;%lu;%lu;;"),
1251 nss6_name,
1252 nss6_value,
1253 nss6_name,
1254 nss6_value,
1255 warning_value,
1256 critical_value);
1259 } else if (vars_to_check==NSS7) {
1261 xasprintf (&send_buffer,"NSS7:%s\r\n",nss7_name);
1262 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
1263 if (result!=STATE_OK)
1264 return result;
1266 if (!strcmp(recv_buffer,"-1\n")) {
1267 xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss7_name);
1268 result=STATE_CRITICAL;
1269 } else {
1270 nss7_value=strtoul(recv_buffer,NULL,10);
1271 if (check_critical_value==TRUE && nss7_value >= critical_value)
1272 result=STATE_CRITICAL;
1273 else if (check_warning_value==TRUE && nss7_value >= warning_value)
1274 result=STATE_WARNING;
1275 xasprintf (&output_message,
1276 _("%s is %lu|%s=%lu;%lu;%lu;;"),
1277 nss7_name,
1278 nss7_value,
1279 nss7_name,
1280 nss7_value,
1281 warning_value,
1282 critical_value);
1287 else {
1289 output_message = strdup (_("Nothing to check!\n"));
1290 result=STATE_UNKNOWN;
1294 close (sd);
1296 /* reset timeout */
1297 alarm(0);
1299 printf("%s%s\n",netware_version,output_message);
1301 return result;
1306 /* process command-line arguments */
1307 int process_arguments(int argc, char **argv) {
1308 int c;
1310 int option = 0;
1311 static struct option longopts[] =
1313 {"port", required_argument,0,'p'},
1314 {"timeout", required_argument,0,'t'},
1315 {"critical", required_argument,0,'c'},
1316 {"warning", required_argument,0,'w'},
1317 {"variable", required_argument,0,'v'},
1318 {"hostname", required_argument,0,'H'},
1319 {"osversion",no_argument, 0,'o'},
1320 {"version", no_argument, 0,'V'},
1321 {"help", no_argument, 0,'h'},
1322 {0,0,0,0}
1325 /* no options were supplied */
1326 if (argc<2) return ERROR;
1328 /* backwards compatibility */
1329 if (! is_option(argv[1])) {
1330 server_address=argv[1];
1331 argv[1]=argv[0];
1332 argv=&argv[1];
1333 argc--;
1336 for (c=1;c<argc;c++) {
1337 if (strcmp("-to",argv[c])==0)
1338 strcpy(argv[c],"-t");
1339 else if (strcmp("-wv",argv[c])==0)
1340 strcpy(argv[c],"-w");
1341 else if (strcmp("-cv",argv[c])==0)
1342 strcpy(argv[c],"-c");
1345 while (1) {
1346 c = getopt_long(argc,argv,"+hoVH:t:c:w:p:v:",longopts,&option);
1348 if (c==-1||c==EOF||c==1)
1349 break;
1351 switch (c)
1353 case '?': /* print short usage statement if args not parsable */
1354 usage5 ();
1355 case 'h': /* help */
1356 print_help();
1357 exit(STATE_UNKNOWN);
1358 case 'V': /* version */
1359 print_revision(progname, NP_VERSION);
1360 exit(STATE_UNKNOWN);
1361 case 'H': /* hostname */
1362 server_address=optarg;
1363 break;
1364 case 'o': /* display nos version */
1365 check_netware_version=TRUE;
1366 break;
1367 case 'p': /* port */
1368 if (is_intnonneg(optarg))
1369 server_port=atoi(optarg);
1370 else
1371 die(STATE_UNKNOWN,_("Server port an integer\n"));
1372 break;
1373 case 'v':
1374 if (strlen(optarg)<3)
1375 return ERROR;
1376 if (!strcmp(optarg,"LOAD1"))
1377 vars_to_check=LOAD1;
1378 else if (!strcmp(optarg,"LOAD5"))
1379 vars_to_check=LOAD5;
1380 else if (!strcmp(optarg,"LOAD15"))
1381 vars_to_check=LOAD15;
1382 else if (!strcmp(optarg,"CONNS"))
1383 vars_to_check=CONNS;
1384 else if (!strcmp(optarg,"LTCH"))
1385 vars_to_check=LTCH;
1386 else if (!strcmp(optarg,"DCB"))
1387 vars_to_check=DCB;
1388 else if (!strcmp(optarg,"TCB"))
1389 vars_to_check=TCB;
1390 else if (!strcmp(optarg,"CBUFF"))
1391 vars_to_check=CBUFF;
1392 else if (!strcmp(optarg,"CDBUFF"))
1393 vars_to_check=CDBUFF;
1394 else if (!strcmp(optarg,"LRUM"))
1395 vars_to_check=LRUM;
1396 else if (!strcmp(optarg,"LRUS"))
1397 vars_to_check=LRUS;
1398 else if (strncmp(optarg,"VPF",3)==0) {
1399 vars_to_check=VPF;
1400 volume_name = strdup (optarg+3);
1401 if (!strcmp(volume_name,""))
1402 volume_name = strdup ("SYS");
1404 else if (strncmp(optarg,"VKF",3)==0) {
1405 vars_to_check=VKF;
1406 volume_name = strdup (optarg+3);
1407 if (!strcmp(volume_name,""))
1408 volume_name = strdup ("SYS");
1410 else if (strncmp(optarg,"VMF",3)==0) {
1411 vars_to_check=VMF;
1412 volume_name = strdup (optarg+3);
1413 if (!strcmp(volume_name,""))
1414 volume_name = strdup ("SYS");
1416 else if (!strcmp(optarg,"DSDB"))
1417 vars_to_check=DSDB;
1418 else if (!strcmp(optarg,"LOGINS"))
1419 vars_to_check=LOGINS;
1420 else if (!strcmp(optarg,"NRMH"))
1421 vars_to_check=NRMH;
1422 else if (!strcmp(optarg,"UPRB"))
1423 vars_to_check=UPRB;
1424 else if (!strcmp(optarg,"PUPRB"))
1425 vars_to_check=PUPRB;
1426 else if (!strncmp(optarg,"SAPENTRIES",10)) {
1427 vars_to_check=SAPENTRIES;
1428 if (strlen(optarg)>10)
1429 sap_number=atoi(optarg+10);
1430 else
1431 sap_number=-1;
1433 else if (!strcmp(optarg,"OFILES"))
1434 vars_to_check=OFILES;
1435 else if (strncmp(optarg,"VKP",3)==0) {
1436 vars_to_check=VKP;
1437 volume_name = strdup (optarg+3);
1438 if (!strcmp(volume_name,""))
1439 volume_name = strdup ("SYS");
1441 else if (strncmp(optarg,"VMP",3)==0) {
1442 vars_to_check=VMP;
1443 volume_name = strdup (optarg+3);
1444 if (!strcmp(volume_name,""))
1445 volume_name = strdup ("SYS");
1447 else if (strncmp(optarg,"VMU",3)==0) {
1448 vars_to_check=VMU;
1449 volume_name = strdup (optarg+3);
1450 if (!strcmp(volume_name,""))
1451 volume_name = strdup ("SYS");
1453 else if (strncmp(optarg,"VPP",3)==0) {
1454 vars_to_check=VPP;
1455 volume_name = strdup (optarg+3);
1456 if (!strcmp(volume_name,""))
1457 volume_name = strdup ("SYS");
1459 else if (strncmp(optarg,"VKNP",4)==0) {
1460 vars_to_check=VKNP;
1461 volume_name = strdup (optarg+4);
1462 if (!strcmp(volume_name,""))
1463 volume_name = strdup ("SYS");
1465 else if (strncmp(optarg,"VPNP",4)==0) {
1466 vars_to_check=VPNP;
1467 volume_name = strdup (optarg+4);
1468 if (!strcmp(volume_name,""))
1469 volume_name = strdup("SYS");
1471 else if (!strcmp(optarg,"ABENDS"))
1472 vars_to_check=ABENDS;
1473 else if (!strcmp(optarg,"CSPROCS"))
1474 vars_to_check=CSPROCS;
1475 else if (!strcmp(optarg,"TSYNC"))
1476 vars_to_check=TSYNC;
1477 else if (!strcmp(optarg,"DSVER"))
1478 vars_to_check=DSVER;
1479 else if (!strcmp(optarg,"UPTIME")) {
1480 vars_to_check=UPTIME;
1482 else if (strncmp(optarg,"NLM:",4)==0) {
1483 vars_to_check=NLM;
1484 nlm_name=strdup (optarg+4);
1486 else if (strncmp(optarg,"NRMP",4)==0) {
1487 vars_to_check=NRMP;
1488 nrmp_name = strdup (optarg+4);
1489 if (!strcmp(nrmp_name,""))
1490 nrmp_name = strdup ("AVAILABLE_MEMORY");
1492 else if (strncmp(optarg,"NRMM",4)==0) {
1493 vars_to_check=NRMM;
1494 nrmm_name = strdup (optarg+4);
1495 if (!strcmp(nrmm_name,""))
1496 nrmm_name = strdup ("AVAILABLE_CACHE_MEMORY");
1500 else if (strncmp(optarg,"NRMS",4)==0) {
1501 vars_to_check=NRMS;
1502 nrms_name = strdup (optarg+4);
1503 if (!strcmp(nrms_name,""))
1504 nrms_name = strdup ("USED_SWAP_SPACE");
1508 else if (strncmp(optarg,"NSS1",4)==0) {
1509 vars_to_check=NSS1;
1510 nss1_name = strdup (optarg+4);
1511 if (!strcmp(nss1_name,""))
1512 nss1_name = strdup ("CURRENTBUFFERCACHESIZE");
1516 else if (strncmp(optarg,"NSS2",4)==0) {
1517 vars_to_check=NSS2;
1518 nss2_name = strdup (optarg+4);
1519 if (!strcmp(nss2_name,""))
1520 nss2_name = strdup ("CACHEHITS");
1524 else if (strncmp(optarg,"NSS3",4)==0) {
1525 vars_to_check=NSS3;
1526 nss3_name = strdup (optarg+4);
1527 if (!strcmp(nss3_name,""))
1528 nss3_name = strdup ("CACHEGITPERCENT");
1532 else if (strncmp(optarg,"NSS4",4)==0) {
1533 vars_to_check=NSS4;
1534 nss4_name = strdup (optarg+4);
1535 if (!strcmp(nss4_name,""))
1536 nss4_name = strdup ("CURRENTOPENCOUNT");
1540 else if (strncmp(optarg,"NSS5",4)==0) {
1541 vars_to_check=NSS5;
1542 nss5_name = strdup (optarg+4);
1543 if (!strcmp(nss5_name,""))
1544 nss5_name = strdup ("CACHEMISSES");
1549 else if (strncmp(optarg,"NSS6",4)==0) {
1550 vars_to_check=NSS6;
1551 nss6_name = strdup (optarg+4);
1552 if (!strcmp(nss6_name,""))
1553 nss6_name = strdup ("PENDINGWORKSCOUNT");
1558 else if (strncmp(optarg,"NSS7",4)==0) {
1559 vars_to_check=NSS7;
1560 nss7_name = strdup (optarg+4);
1561 if (!strcmp(nss7_name,""))
1562 nss7_name = strdup ("CACHESIZE");
1567 else
1568 return ERROR;
1569 break;
1570 case 'w': /* warning threshold */
1571 warning_value=strtoul(optarg,NULL,10);
1572 check_warning_value=TRUE;
1573 break;
1574 case 'c': /* critical threshold */
1575 critical_value=strtoul(optarg,NULL,10);
1576 check_critical_value=TRUE;
1577 break;
1578 case 't': /* timeout */
1579 socket_timeout=atoi(optarg);
1580 if (socket_timeout<=0)
1581 return ERROR;
1586 return OK;
1591 void print_help(void)
1593 char *myport;
1594 xasprintf (&myport, "%d", PORT);
1596 print_revision (progname, NP_VERSION);
1598 printf ("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n");
1599 printf (COPYRIGHT, copyright, email);
1601 printf ("%s\n", _("This plugin attempts to contact the MRTGEXT NLM running on a"));
1602 printf ("%s\n", _("Novell server to gather the requested system information."));
1604 printf ("\n\n");
1606 print_usage();
1608 printf (UT_HELP_VRSN);
1609 printf (UT_EXTRA_OPTS);
1611 printf (UT_HOST_PORT, 'p', myport);
1613 printf (" %s\n", "-v, --variable=STRING");
1614 printf (" %s\n", _("Variable to check. Valid variables include:"));
1615 printf (" %s\n", _("LOAD1 = 1 minute average CPU load"));
1616 printf (" %s\n", _("LOAD5 = 5 minute average CPU load"));
1617 printf (" %s\n", _("LOAD15 = 15 minute average CPU load"));
1618 printf (" %s\n", _("CSPROCS = number of current service processes (NW 5.x only)"));
1619 printf (" %s\n", _("ABENDS = number of abended threads (NW 5.x only)"));
1620 printf (" %s\n", _("UPTIME = server uptime"));
1621 printf (" %s\n", _("LTCH = percent long term cache hits"));
1622 printf (" %s\n", _("CBUFF = current number of cache buffers"));
1623 printf (" %s\n", _("CDBUFF = current number of dirty cache buffers"));
1624 printf (" %s\n", _("DCB = dirty cache buffers as a percentage of the total"));
1625 printf (" %s\n", _("TCB = dirty cache buffers as a percentage of the original"));
1626 printf (" %s\n", _("OFILES = number of open files"));
1627 printf (" %s\n", _(" VMF<vol> = MB of free space on Volume <vol>"));
1628 printf (" %s\n", _(" VMU<vol> = MB used space on Volume <vol>"));
1629 printf (" %s\n", _(" VMP<vol> = MB of purgeable space on Volume <vol>"));
1630 printf (" %s\n", _(" VPF<vol> = percent free space on volume <vol>"));
1631 printf (" %s\n", _(" VKF<vol> = KB of free space on volume <vol>"));
1632 printf (" %s\n", _(" VPP<vol> = percent purgeable space on volume <vol>"));
1633 printf (" %s\n", _(" VKP<vol> = KB of purgeable space on volume <vol>"));
1634 printf (" %s\n", _(" VPNP<vol> = percent not yet purgeable space on volume <vol>"));
1635 printf (" %s\n", _(" VKNP<vol> = KB of not yet purgeable space on volume <vol>"));
1636 printf (" %s\n", _(" LRUM = LRU sitting time in minutes"));
1637 printf (" %s\n", _(" LRUS = LRU sitting time in seconds"));
1638 printf (" %s\n", _(" DSDB = check to see if DS Database is open"));
1639 printf (" %s\n", _(" DSVER = NDS version"));
1640 printf (" %s\n", _(" UPRB = used packet receive buffers"));
1641 printf (" %s\n", _(" PUPRB = percent (of max) used packet receive buffers"));
1642 printf (" %s\n", _(" SAPENTRIES = number of entries in the SAP table"));
1643 printf (" %s\n", _(" SAPENTRIES<n> = number of entries in the SAP table for SAP type <n>"));
1644 printf (" %s\n", _(" TSYNC = timesync status"));
1645 printf (" %s\n", _(" LOGINS = check to see if logins are enabled"));
1646 printf (" %s\n", _(" CONNS = number of currently licensed connections"));
1647 printf (" %s\n", _(" NRMH = NRM Summary Status"));
1648 printf (" %s\n", _(" NRMP<stat> = Returns the current value for a NRM health item"));
1649 printf (" %s\n", _(" NRMM<stat> = Returns the current memory stats from NRM"));
1650 printf (" %s\n", _(" NRMS<stat> = Returns the current Swapfile stats from NRM"));
1651 printf (" %s\n", _(" NSS1<stat> = Statistics from _Admin:Manage_NSS\\GeneralStats.xml"));
1652 printf (" %s\n", _(" NSS3<stat> = Statistics from _Admin:Manage_NSS\\NameCache.xml"));
1653 printf (" %s\n", _(" NSS4<stat> = Statistics from _Admin:Manage_NSS\\FileStats.xml"));
1654 printf (" %s\n", _(" NSS5<stat> = Statistics from _Admin:Manage_NSS\\ObjectCache.xml"));
1655 printf (" %s\n", _(" NSS6<stat> = Statistics from _Admin:Manage_NSS\\Thread.xml"));
1656 printf (" %s\n", _(" NSS7<stat> = Statistics from _Admin:Manage_NSS\\AuthorizationCache.xml"));
1657 printf (" %s\n", _(" NLM:<nlm> = check if NLM is loaded and report version"));
1658 printf (" %s\n", _(" (e.g. NLM:TSANDS.NLM)"));
1659 printf ("\n");
1660 printf (" %s\n", "-w, --warning=INTEGER");
1661 printf (" %s\n", _("Threshold which will result in a warning status"));
1662 printf (" %s\n", "-c, --critical=INTEGER");
1663 printf (" %s\n", _("Threshold which will result in a critical status"));
1664 printf (" %s\n", "-o, --osversion");
1665 printf (" %s\n", _("Include server version string in results"));
1667 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
1669 printf ("\n");
1670 printf ("%s\n", _("Notes:"));
1671 printf (" %s\n", _("- This plugin requres that the MRTGEXT.NLM file from James Drews' MRTG"));
1672 printf (" %s\n", _(" extension for NetWare be loaded on the Novell servers you wish to check."));
1673 printf (" %s\n", _(" (available from http://www.engr.wisc.edu/~drews/mrtg/)"));
1674 printf (" %s\n", _("- Values for critical thresholds should be lower than warning thresholds"));
1675 printf (" %s\n", _(" when the following variables are checked: VPF, VKF, LTCH, CBUFF, DCB, "));
1676 printf (" %s\n", _(" TCB, LRUS and LRUM."));
1678 printf (UT_SUPPORT);
1683 void print_usage(void)
1685 printf ("%s\n", _("Usage:"));
1686 printf ("%s -H host [-p port] [-v variable] [-w warning] [-c critical] [-t timeout]\n",progname);