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