1 /*****************************************************************************
3 * Monitoring check_nwstat plugin
6 * Copyright (c) 2000-2007 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-2007";
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 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 */
91 char *server_address
=NULL
;
92 char *volume_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
;
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
;
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
)
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("");
201 if (vars_to_check
==LOAD1
|| vars_to_check
==LOAD5
|| vars_to_check
==LOAD15
) {
203 switch(vars_to_check
) {
205 temp_buffer
= strdup ("1");
208 temp_buffer
= strdup ("5");
211 temp_buffer
= strdup ("15");
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
)
222 utilization
=strtoul(recv_buffer
,NULL
,10);
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
)
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"),
250 /* check number of user connections */
251 } else if (vars_to_check
==CONNS
) {
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
)
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;;"),
275 /* check % long term cache hits */
276 } else if (vars_to_check
==LTCH
) {
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
)
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%%"),
297 /* check cache buffers */
298 } else if (vars_to_check
==CBUFF
) {
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
)
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;;"),
322 /* check dirty cache buffers */
323 } else if (vars_to_check
==CDBUFF
) {
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
)
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;;"),
347 /* check LRU sitting time in minutes */
348 } else if (vars_to_check
==LRUM
) {
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
)
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"),
370 /* check KB free space on volume */
371 } else if (vars_to_check
==VKF
) {
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
)
381 if (!strcmp(recv_buffer
,"-1\n")) {
382 xasprintf (&output_message
,_("CRITICAL - Volume '%s' does not exist!"),volume_name
);
383 result
=STATE_CRITICAL
;
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 "),
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
)
409 if (!strcmp(recv_buffer
,"-1\n")) {
410 xasprintf (&output_message
,_("CRITICAL - Volume '%s' does not exist!"),volume_name
);
411 result
=STATE_CRITICAL
;
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 "),
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
)
436 if (!strcmp(recv_buffer
,"-1\n")) {
437 xasprintf (&output_message
,_("CRITICAL - Volume '%s' does not exist!"),volume_name
);
438 result
=STATE_CRITICAL
;
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 "),
457 /* check % free space on volume */
458 } else if (vars_to_check
==VPF
) {
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
)
468 if (!strcmp(recv_buffer
,"-1\n")) {
470 xasprintf (&output_message
,_("CRITICAL - Volume '%s' does not exist!"),volume_name
);
471 result
=STATE_CRITICAL
;
475 free_disk_space
=strtoul(recv_buffer
,NULL
,10);
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
)
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"),
506 /* check to see if DS Database is open or closed */
507 } else if (vars_to_check
==DSDB
) {
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
)
516 if (atoi(recv_buffer
)==1)
519 result
=STATE_WARNING
;
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
) {
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
)
540 if (atoi(recv_buffer
)==1)
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
)
556 nrm_health_status
=atoi(recv_buffer
);
558 if (nrm_health_status
==2) {
560 xasprintf (&output_message
,_("CRITICAL - NRM Status is bad!"));
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
) {
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
)
584 used_packet_receive_buffers
=atoi(recv_buffer
);
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
)
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
;
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
) {
616 my_tcp_connect (server_address
, server_port
, &sd
);
619 xasprintf (&send_buffer
,"S9\r\n");
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
)
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
;
634 xasprintf (&output_message
,_("%lu entries in SAP table"),sap_entries
);
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
) {
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
)
649 if (!strcmp(recv_buffer
,"-1\n")) {
650 xasprintf (&output_message
,_("CRITICAL - Volume '%s' does not exist!"),volume_name
);
651 result
=STATE_CRITICAL
;
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
,
663 purgeable_disk_space
,
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
)
675 if (!strcmp(recv_buffer
,"-1\n")) {
676 xasprintf (&output_message
,_("CRITICAL - Volume '%s' does not exist!"),volume_name
);
677 result
=STATE_CRITICAL
;
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
,
689 purgeable_disk_space
,
694 /* check % purgeable space on volume */
695 } else if (vars_to_check
==VPP
) {
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
)
705 if (!strcmp(recv_buffer
,"-1\n")) {
707 xasprintf (&output_message
,_("CRITICAL - Volume '%s' does not exist!"),volume_name
);
708 result
=STATE_CRITICAL
;
712 purgeable_disk_space
=strtoul(recv_buffer
,NULL
,10);
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
)
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
,
735 percent_purgeable_space
,
741 /* check KB not yet purgeable space on volume */
742 } else if (vars_to_check
==VKNP
) {
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
)
752 if (!strcmp(recv_buffer
,"-1\n")) {
753 xasprintf (&output_message
,_("CRITICAL - Volume '%s' does not exist!"),volume_name
);
754 result
=STATE_CRITICAL
;
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
) {
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
)
775 if (!strcmp(recv_buffer
,"-1\n")) {
777 xasprintf (&output_message
,_("CRITICAL - Volume '%s' does not exist!"),volume_name
);
778 result
=STATE_CRITICAL
;
782 non_purgeable_disk_space
=strtoul(recv_buffer
,NULL
,10);
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
)
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
) {
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
)
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"),
828 /* check # of abended threads (Netware > 5.x only) */
829 } else if (vars_to_check
==ABENDS
) {
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
)
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;;"),
852 /* check # of current service processes (Netware 5.x only) */
853 } else if (vars_to_check
==CSPROCS
) {
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
)
863 max_service_processes
=atoi(recv_buffer
);
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
)
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
,
887 max_service_processes
);
889 /* check # Timesync Status */
890 } else if (vars_to_check
==TSYNC
) {
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
)
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!"));
907 xasprintf (&output_message
,_("OK - Time in sync with network!"));
914 /* check LRU sitting time in secondss */
915 } else if (vars_to_check
==LRUS
) {
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
)
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
) {
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
)
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"),
955 /* check % total cache buffers as a percentage of the original*/
956 } else if (vars_to_check
==TCB
) {
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
)
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"),
977 } else if (vars_to_check
==DSVER
) {
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
)
987 recv_buffer
[strlen(recv_buffer
)-1]=0;
989 xasprintf (&output_message
,_("NDS Version %s"),recv_buffer
);
991 } else if (vars_to_check
==UPTIME
) {
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
)
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
) {
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
)
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
);
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
)
1032 if (!strcmp(recv_buffer
,"-1\n")) {
1033 xasprintf (&output_message
,_("CRITICAL - Value '%s' does not exist!"),nrmp_name
);
1034 result
=STATE_CRITICAL
;
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;;"),
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
)
1058 if (!strcmp(recv_buffer
,"-1\n")) {
1059 xasprintf (&output_message
,_("CRITICAL - Value '%s' does not exist!"),nrmm_name
);
1060 result
=STATE_CRITICAL
;
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;;"),
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
)
1084 if (!strcmp(recv_buffer
,"-1\n")) {
1085 xasprintf (&output_message
,_("CRITICAL - Value '%s' does not exist!"),nrms_name
);
1086 result
=STATE_CRITICAL
;
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;;"),
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
)
1110 if (!strcmp(recv_buffer
,"-1\n")) {
1111 xasprintf (&output_message
,_("CRITICAL - Value '%s' does not exist!"),nss1_name
);
1112 result
=STATE_CRITICAL
;
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;;"),
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
)
1136 if (!strcmp(recv_buffer
,"-1\n")) {
1137 xasprintf (&output_message
,_("CRITICAL - Value '%s' does not exist!"),nss2_name
);
1138 result
=STATE_CRITICAL
;
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;;"),
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
)
1162 if (!strcmp(recv_buffer
,"-1\n")) {
1163 xasprintf (&output_message
,_("CRITICAL - Value '%s' does not exist!"),nss3_name
);
1164 result
=STATE_CRITICAL
;
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;;"),
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
)
1188 if (!strcmp(recv_buffer
,"-1\n")) {
1189 xasprintf (&output_message
,_("CRITICAL - Value '%s' does not exist!"),nss4_name
);
1190 result
=STATE_CRITICAL
;
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;;"),
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
)
1214 if (!strcmp(recv_buffer
,"-1\n")) {
1215 xasprintf (&output_message
,_("CRITICAL - Value '%s' does not exist!"),nss5_name
);
1216 result
=STATE_CRITICAL
;
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;;"),
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
)
1240 if (!strcmp(recv_buffer
,"-1\n")) {
1241 xasprintf (&output_message
,_("CRITICAL - Value '%s' does not exist!"),nss6_name
);
1242 result
=STATE_CRITICAL
;
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;;"),
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
)
1266 if (!strcmp(recv_buffer
,"-1\n")) {
1267 xasprintf (&output_message
,_("CRITICAL - Value '%s' does not exist!"),nss7_name
);
1268 result
=STATE_CRITICAL
;
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;;"),
1289 output_message
= strdup (_("Nothing to check!\n"));
1290 result
=STATE_UNKNOWN
;
1299 printf("%s%s\n",netware_version
,output_message
);
1306 /* process command-line arguments */
1307 int process_arguments(int argc
, char **argv
) {
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'},
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];
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");
1346 c
= getopt_long(argc
,argv
,"+hoVH:t:c:w:p:v:",longopts
,&option
);
1348 if (c
==-1||c
==EOF
||c
==1)
1353 case '?': /* print short usage statement if args not parsable */
1355 case 'h': /* 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
;
1364 case 'o': /* display nos version */
1365 check_netware_version
=TRUE
;
1367 case 'p': /* port */
1368 if (is_intnonneg(optarg
))
1369 server_port
=atoi(optarg
);
1371 die(STATE_UNKNOWN
,_("Server port an integer\n"));
1374 if (strlen(optarg
)<3)
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"))
1386 else if (!strcmp(optarg
,"DCB"))
1388 else if (!strcmp(optarg
,"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"))
1396 else if (!strcmp(optarg
,"LRUS"))
1398 else if (strncmp(optarg
,"VPF",3)==0) {
1400 volume_name
= strdup (optarg
+3);
1401 if (!strcmp(volume_name
,""))
1402 volume_name
= strdup ("SYS");
1404 else if (strncmp(optarg
,"VKF",3)==0) {
1406 volume_name
= strdup (optarg
+3);
1407 if (!strcmp(volume_name
,""))
1408 volume_name
= strdup ("SYS");
1410 else if (strncmp(optarg
,"VMF",3)==0) {
1412 volume_name
= strdup (optarg
+3);
1413 if (!strcmp(volume_name
,""))
1414 volume_name
= strdup ("SYS");
1416 else if (!strcmp(optarg
,"DSDB"))
1418 else if (!strcmp(optarg
,"LOGINS"))
1419 vars_to_check
=LOGINS
;
1420 else if (!strcmp(optarg
,"NRMH"))
1422 else if (!strcmp(optarg
,"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);
1433 else if (!strcmp(optarg
,"OFILES"))
1434 vars_to_check
=OFILES
;
1435 else if (strncmp(optarg
,"VKP",3)==0) {
1437 volume_name
= strdup (optarg
+3);
1438 if (!strcmp(volume_name
,""))
1439 volume_name
= strdup ("SYS");
1441 else if (strncmp(optarg
,"VMP",3)==0) {
1443 volume_name
= strdup (optarg
+3);
1444 if (!strcmp(volume_name
,""))
1445 volume_name
= strdup ("SYS");
1447 else if (strncmp(optarg
,"VMU",3)==0) {
1449 volume_name
= strdup (optarg
+3);
1450 if (!strcmp(volume_name
,""))
1451 volume_name
= strdup ("SYS");
1453 else if (strncmp(optarg
,"VPP",3)==0) {
1455 volume_name
= strdup (optarg
+3);
1456 if (!strcmp(volume_name
,""))
1457 volume_name
= strdup ("SYS");
1459 else if (strncmp(optarg
,"VKNP",4)==0) {
1461 volume_name
= strdup (optarg
+4);
1462 if (!strcmp(volume_name
,""))
1463 volume_name
= strdup ("SYS");
1465 else if (strncmp(optarg
,"VPNP",4)==0) {
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) {
1484 nlm_name
=strdup (optarg
+4);
1486 else if (strncmp(optarg
,"NRMP",4)==0) {
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) {
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) {
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) {
1510 nss1_name
= strdup (optarg
+4);
1511 if (!strcmp(nss1_name
,""))
1512 nss1_name
= strdup ("CURRENTBUFFERCACHESIZE");
1516 else if (strncmp(optarg
,"NSS2",4)==0) {
1518 nss2_name
= strdup (optarg
+4);
1519 if (!strcmp(nss2_name
,""))
1520 nss2_name
= strdup ("CACHEHITS");
1524 else if (strncmp(optarg
,"NSS3",4)==0) {
1526 nss3_name
= strdup (optarg
+4);
1527 if (!strcmp(nss3_name
,""))
1528 nss3_name
= strdup ("CACHEGITPERCENT");
1532 else if (strncmp(optarg
,"NSS4",4)==0) {
1534 nss4_name
= strdup (optarg
+4);
1535 if (!strcmp(nss4_name
,""))
1536 nss4_name
= strdup ("CURRENTOPENCOUNT");
1540 else if (strncmp(optarg
,"NSS5",4)==0) {
1542 nss5_name
= strdup (optarg
+4);
1543 if (!strcmp(nss5_name
,""))
1544 nss5_name
= strdup ("CACHEMISSES");
1549 else if (strncmp(optarg
,"NSS6",4)==0) {
1551 nss6_name
= strdup (optarg
+4);
1552 if (!strcmp(nss6_name
,""))
1553 nss6_name
= strdup ("PENDINGWORKSCOUNT");
1558 else if (strncmp(optarg
,"NSS7",4)==0) {
1560 nss7_name
= strdup (optarg
+4);
1561 if (!strcmp(nss7_name
,""))
1562 nss7_name
= strdup ("CACHESIZE");
1570 case 'w': /* warning threshold */
1571 warning_value
=strtoul(optarg
,NULL
,10);
1572 check_warning_value
=TRUE
;
1574 case 'c': /* critical threshold */
1575 critical_value
=strtoul(optarg
,NULL
,10);
1576 check_critical_value
=TRUE
;
1578 case 't': /* timeout */
1579 socket_timeout
=atoi(optarg
);
1580 if (socket_timeout
<=0)
1591 void print_help(void)
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."));
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)"));
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
);
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
);