summaryrefslogtreecommitdiffstats
path: root/web/attachments/131422-diff_check_nt
diff options
context:
space:
mode:
Diffstat (limited to 'web/attachments/131422-diff_check_nt')
-rw-r--r--web/attachments/131422-diff_check_nt230
1 files changed, 230 insertions, 0 deletions
diff --git a/web/attachments/131422-diff_check_nt b/web/attachments/131422-diff_check_nt
new file mode 100644
index 0000000..6d0865d
--- /dev/null
+++ b/web/attachments/131422-diff_check_nt
@@ -0,0 +1,230 @@
1--- check_nt.c.original 2005-03-05 04:45:05.000000000 -0500
2+++ check_nt.c 2005-04-23 08:35:43.000000000 -0400
3@@ -282,111 +282,74 @@
4 break;
5
6 case CHECK_COUNTER:
7-
8-
9- /*
10- CHECK_COUNTER has been modified to provide extensive perfdata information.
11- In order to do this, some modifications have been done to the code
12- and some constraints have been introduced.
13-
14- 1) For the sake of simplicity of the code, perfdata information will only be
15- provided when the "description" field is added.
16-
17- 2) If the counter you're going to measure is percent-based, the code will detect
18- the percent sign in its name and will attribute minimum (0%) and maximum (100%)
19- values automagically, as well the ¨%" sign to graph units.
20-
21- 3) OTOH, if the counter is "absolute", you'll have to provide the following
22- the counter unit - that is, the dimensions of the counter you're getting. Examples:
23- pages/s, packets transferred, etc.
24-
25- 4) If you want, you may provide the minimum and maximum values to expect. They aren't mandatory,
26- but once specified they MUST have the same order of magnitude and units of -w and -c; otherwise.
27- strange things will happen when you make graphs of your data.
28- */
29-
30- if (value_list == NULL)
31- output_message = strdup (_("No counter specified"));
32- else
33- {
34- preparelist (value_list); /* replace , between services with & to send the request */
35- isPercent = (strchr (value_list, '%') != NULL);
36-
37- strtok (value_list, "&"); /* burn the first parameters */
38- description = strtok (NULL, "&");
39- counter_unit = strtok (NULL, "&");
40- asprintf (&send_buffer, "%s&8&%s", req_password, value_list);
41- fetch_data (server_address, server_port, send_buffer);
42- counter_value = atof (recv_buffer);
43-
44-
45- if (description == NULL)
46- asprintf (&output_message, "%.f", counter_value);
47- else if (isPercent)
48- {
49- counter_unit = strdup ("%");
50- allRight = TRUE;
51- }
52-
53- if ((counter_unit != NULL) && (!allRight))
54- {
55- minval = strtok (NULL, "&");
56- maxval = strtok (NULL, "&");
57-
58- /* All parameters specified. Let's check the numbers */
59-
60- fminval = (minval != NULL) ? strtod (minval, &errcvt) : -1;
61- fmaxval = (minval != NULL) ? strtod (maxval, &errcvt) : -1;
62-
63- if ((fminval == 0) && (minval == errcvt))
64- output_message = strdup (_("Minimum value contains non-numbers"));
65- else
66- {
67- if ((fmaxval == 0) && (maxval == errcvt))
68- output_message = strdup (_("Maximum value contains non-numbers"));
69- else
70- allRight = TRUE; /* Everything is OK. */
71-
72- }
73- }
74- else if ((counter_unit == NULL) && (description != NULL))
75- output_message = strdup (_("No unit counter specified"));
76-
77- if (allRight)
78- {
79- /* Let's format the output string, finally... */
80- if (strstr(description, "%") == NULL) {
81- asprintf (&output_message, "%s = %.2f %s", description, counter_value, counter_unit);
82- } else {
83- /* has formatting, will segv if wrong */
84- asprintf (&output_message, description, counter_value);
85- }
86- asprintf (&output_message, "%s |", output_message);
87- asprintf (&output_message,"%s %s", output_message,
88- fperfdata (description, counter_value,
89- counter_unit, 1, warning_value, 1, critical_value,
90- (!(isPercent) && (minval != NULL)), fminval,
91- (!(isPercent) && (minval != NULL)), fmaxval));
92- }
93- }
94-
95- if (critical_value > warning_value)
96- { /* Normal thresholds */
97- if (check_critical_value == TRUE && counter_value >= critical_value)
98- return_code = STATE_CRITICAL;
99- else if (check_warning_value == TRUE && counter_value >= warning_value)
100- return_code = STATE_WARNING;
101- else
102- return_code = STATE_OK;
103- }
104- else
105- { /* inverse thresholds */
106- return_code = STATE_OK;
107- if (check_critical_value == TRUE && counter_value <= critical_value)
108- return_code = STATE_CRITICAL;
109- else if (check_warning_value == TRUE && counter_value <= warning_value)
110- return_code = STATE_WARNING;
111- }
112+ /*
113+ * Check_Counter has been rewriten for NC_Net now it processes the pref data in
114+ * a more consistent way to the Nagios plug-in development guidelines.
115+ * 1) if no Units of mesurement use a 0 (zero) for the UOM in the check
116+ * and the units will be omited from the output.
117+ * 2) it will do MIN without a MAX
118+ * 3) still processes custom min and max even if it is %
119+ * 4) % has a default of min 0, max 100
120+ * 5) -w and -c are no longer causing a seg fault. old code said to always
121+ * process both for perf data, but it should have checked that they were in use.
122+ * 6) the description is only a label for perf data not a formatter...
123+ ****************************************************************************/
124+ if (value_list == NULL)
125+ output_message = strdup (_("No counter specified"));
126+ else {
127+ preparelist (value_list); /* replace , between services with & to send the request */
128+
129+ temp_string = strtok (value_list, "&");
130+ isPercent = (strchr (temp_string, '%') != NULL);
131+ description = strtok (NULL, "&");
132+ counter_unit = strtok (NULL, "&");
133+ asprintf (&send_buffer, "%s&8&%s", req_password, value_list);
134+ fetch_data (server_address, server_port, send_buffer);
135+ counter_value = atof (recv_buffer);
136+ if (isPercent) counter_unit = strdup ("%");
137+ if ( description != NULL && counter_unit == NULL )
138+ counter_unit = strdup ( "0" );
139+ if ( counter_unit != NULL && description != NULL)
140+ {
141+ if ( counter_unit[0] == '0' ) counter_unit[0] = '\0';
142+ minval = strtok (NULL, "&");
143+ maxval = strtok (NULL, "&");
144+ if ( minval == NULL && isPercent ) asprintf(&minval,"0");
145+ if ( minval != NULL ) fminval = strtod ( minval, NULL ) ;
146+ if ( maxval == NULL && isPercent ) asprintf(&maxval,"100");
147+ if ( maxval != NULL ) fmaxval = strtod (maxval, NULL);
148+ allRight = TRUE;
149+ /* Let's format the output string, finally... */
150+ asprintf (&output_message, "%s = %.2f %s", description, counter_value, counter_unit);
151+ asprintf (&output_message,"%s | %s", output_message,
152+ fperfdata (description, counter_value,
153+ counter_unit, check_warning_value, warning_value,
154+ check_critical_value, critical_value,
155+ (minval != NULL), fminval,
156+ (maxval != NULL), fmaxval ));
157+ }
158+ else if (isPercent)
159+ asprintf(&output_message, "%s = %.2f %%",temp_string,counter_value);
160+ else
161+ asprintf(&output_message, "%s = %.2f",temp_string,counter_value);
162+ }
163+ if (critical_value > warning_value)
164+ { /* Normal thresholds */
165+ if (check_critical_value == TRUE && counter_value >= critical_value)
166+ return_code = STATE_CRITICAL;
167+ else if (check_warning_value == TRUE && counter_value >= warning_value)
168+ return_code = STATE_WARNING;
169+ else
170+ return_code = STATE_OK;
171+ }
172+ else
173+ { /* inverse thresholds */
174+ return_code = STATE_OK;
175+ if (check_critical_value == TRUE && counter_value <= critical_value)
176+ return_code = STATE_CRITICAL;
177+ else if (check_warning_value == TRUE && counter_value <= warning_value)
178+ return_code = STATE_WARNING;
179+ }
180 break;
181
182 case CHECK_FILEAGE:
183@@ -394,7 +357,7 @@
184 if (value_list==NULL)
185 output_message = strdup (_("No counter specified"));
186 else {
187- preparelist(value_list); /* replace , between services with & to send the request */
188+ preparelist(value_list); /* replace , between services with & to send the request */
189 asprintf(&send_buffer,"%s&9&%s", req_password,value_list);
190 fetch_data (server_address, server_port, send_buffer);
191 age_in_minutes = atoi(strtok(recv_buffer,"&"));
192@@ -672,13 +635,32 @@
193 printf (_("\
194 COUNTER = Check any performance counter of Windows NT/2000.\n\
195 Request a -l parameters with the following syntax:\n\
196- -l \"\\\\<performance object>\\\\counter\",\"<description>\n\
197- The <description> parameter is optional and \n\
198- is given to a printf output command which requires a float parameter.\n\
199- If <description> does not include \"%%\", it is used as a label.\n\
200+ -l \"\\\\<performance object>\\\\counter\"[,\"<Label>\"][,<UOM>][,<MIN>][,<MAX>]\n\
201+ The <label> parameter is optional and is used for performance data\n\
202+ If <performance object> includes \"%%\", it automaticlly considers %% performanc data.\n\
203+ label is the label for performance data\n\
204+ If the label is omited then the performance counter object will be used.\n\
205+ UOM - Unit of Measurment -if no UOM use a zero 0, \n\
206+ a zero tells check_nt to ignore the UOM in the output.\n\
207+ examples of UOM- s,us,ms,%%,B,KB,MB,TB,c \n\
208+ c- is for continous counter. \n\
209+ Min and Max are optional but are used by third party program (RRD) for graphing.\n\
210 Some examples:\n\
211- \"Paging file usage is %%.2f %%%%\"\n\
212- \"%%.f %%%% paging file used.\"\n"));
213+ -l \"\\Process(_Total)\\Thread Count\",\"Thread Count\",MB,0,1000 -w 5 -c 700\n\
214+ Thread Count = 534.00 MB | 'Thread Count'=534.000000MB;5.000000;700.000000;0.000000;1000.000000\n\
215+ -l \"\\Paging File(_Total)\\%% Usage\"\n\
216+ \\Paging File(_Total)\\%% Usage = 36.61 %%\n\
217+ -l \"\\paging file(_total)\\%% usage\"\n\
218+ \\paging File(_total)\\%% usage = 36.61 %%\n\
219+ -l \"\\paging file(_total)\\%% usage\",\"test1\"\n\
220+ test1 = 36.60 % | test1=36.599730%;;;0.000000;100.000000\n\
221+ -l \"\\paging file(_total)\\%% usage\",\"test1\",%%,20\n\
222+ test1 = 36.60 % | test1=36.599730%;;;20.000000;100.000000\n\
223+ -l \"\\Server\\Server Sessions\",\"test SS\",%%\n\
224+ test SS = 1.00 %% | 'test SS'=1.000000%%;;;\n\
225+ -l \"\\Server\\Server Sessions\",\"Server Sessions\",0,0,50 -w 20 -c 45\n\
226+ Server Sessions = 1.00 c | 'Server Sessions'=1.000000;20.000000;45.000000;0.000000;50.000000\n"));
227+
228 printf (_("Notes:\n\
229 - The NSClient service should be running on the server to get any information\n\
230 (http://nsclient.ready2run.nl).\n\