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