summaryrefslogtreecommitdiffstats
path: root/web/attachments/50888-check_nwstat.c.diff
blob: ec41c30aa7326602fa68bf20faea80fdbfce4825 (plain)
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
--- check_nwstat.old	2003-05-21 11:52:20.000000000 +0100
+++ check_nwstat.c	2003-05-21 13:18:21.000000000 +0100
@@ -24,7 +24,7 @@
  *****************************************************************************/
 
 const char *progname = "check_nwstat";
-#define REVISION "$Revision: 1.7 $"
+#define REVISION "$Revision: 1.8 $"
 #define COPYRIGHT "Copyright (c) 1999-2001 Ethan Galstad"
 
 #define SUMMARY "\
@@ -69,6 +69,7 @@
      DCB      = dirty cache buffers as a percentage of the total\n\
      TCB      = dirty cache buffers as a percentage of the original\n\
      UPTIME   = server uptime\n\
+     NLM:<nlm> = check if NLM is loaded and report version (e.g. \"NLM:TSANDS.NLM\")\n\
 -w, --warning=INTEGER\n\
   Threshold which will result in a warning status\n\
 -c, --critical=INTEGER\n\
@@ -127,11 +128,13 @@
 #define CHECK_TCB           26 /* check total cache buffers as a percentage of the original */
 #define CHECK_DSVER         27 /* check NDS version */
 #define CHECK_UPTIME        28 /* check server uptime */
+#define CHECK_NLM           29 /* check NLM loaded */
 
 #define PORT 9999
 
 char *server_address=NULL;
 char *volume_name=NULL;
+char *nlm_name=NULL;
 int server_port=PORT;
 unsigned long warning_value=0L;
 unsigned long critical_value=0L;
@@ -702,6 +705,20 @@
 
 	  	asprintf(&output_message,"Up %s",recv_buffer);
 
+        } else if (vars_to_check==CHECK_NLM) {
+ 	        asprintf(&send_buffer,"S24:%s\r\n",nlm_name);
+                result=process_tcp_request(server_address,server_port,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 {
 
 		output_message = strscpy(output_message,"Nothing to check!\n");
@@ -875,6 +892,10 @@
 					vars_to_check=CHECK_DSVER;
 				else if(!strcmp(optarg,"UPTIME"))
 					vars_to_check=CHECK_UPTIME;
+				else if(strncmp(optarg,"NLM:",4)==0) {
+				        vars_to_check=CHECK_NLM;
+					nlm_name=strscpy(nlm_name,optarg+4);
+                                }
 				else
 					return ERROR;
 				break;