[Nagiosplug-devel] Re: long names in devices whith check_disk
Orf, Tracy
orft at gknstl.com
Tue Jul 20 06:20:02 CEST 2004
I am running nagios plugins on HP-UX 11.11. As already noted, the
check_disk plugin on HP-UX doesn't work well with filesystem names
longer than about 20 characters. If anyone is interested in using the
1.3 version with HP-UX, I've attached my changes to check_disk.c that I
am using.
Replace the main while loop with this:
while (fgets (input_buffer, MAX_INPUT_BUFFER - 1,
child_process)) {
if (!index (input_buffer, '/'))
continue;
/* Fixes AIX /proc fs which lists - for size values */
if (strstr (input_buffer, "/proc ") == input_buffer)
continue;
/* Fixes HP-UX where long filesystem names cause the df
command
output to spread to two lines
*/
if (sscanf (input_buffer, "%s %f %f %f %d%% %s",
file_system,
&total_disk, &used_disk, &free_disk, &usp, mntp) ==
6 ||
sscanf (input_buffer, "%s %*s %f %f %f %d%% %s",
file_system,
&total_disk, &used_disk, &free_disk,
&usp, mntp) == 6 ||
sscanf (input_buffer, "%s %*s %f %f %f %d%% %s",
file_system,
&total_disk, &used_disk, &free_disk,
&usp, mntp) == 1) {
if (strcmp(exclude_device,file_system) == 0 ||
(strlen(mntp) > 0 &&
strcmp(exclude_device,mntp) == 0)) {
if (verbose>0)
printf ("ignoring %s.",
file_system);
continue;
}
/* filesystem info will be on the next line on
HP-UX
for long filesystem names */
if (strlen(mntp) == 0) {
if (fgets (input_buffer,
MAX_INPUT_BUFFER - 1,
child_process)) {
if (!(sscanf (input_buffer,
"%f %f %f %d%%
%s",
&total_disk,
&used_disk,
&free_disk,
&usp, mntp) == 5)) {
printf ("Unable to read
output:\n%s\n%s\n",
command_line,
input_buffer);
return result;
}
}
}
}
else {
printf ("Unable to read output:\n%s\n%s\n",
command_line, input_buffer);
return result;
}
disk_result = check_disk (usp, free_disk);
if (strcmp (file_system, "none") == 0)
strncpy (file_system, mntp, MAX_INPUT_BUFFER-1);
if (disk_result==STATE_OK && erronly && !verbose)
continue;
if (disk_result!=STATE_OK || verbose>=0)
asprintf (&output, "%s [%.0f kB (%d%%) free on
%s]", output,
free_disk, 100 - usp, display_mntp ?
mntp : file_system);
result = max_state (result, disk_result);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nagios-plugins.org/archive/devel/attachments/20040720/06b9c62d/attachment.html>
More information about the Devel
mailing list