From ae at op5.se Wed Jun 1 00:49:31 2005 From: ae at op5.se (Andreas Ericsson) Date: Wed Jun 1 00:49:31 2005 Subject: [Nagiosplug-devel] -Wall clean patch Message-ID: <429D684D.6080007@op5.se> The attached patch makes the plugins compile cleanly on FC3 and Owl-current with -Wall applied. No logic has been changed, so I haven't tested it any more than a re-compile. How portable is -Wall btw? Perhaps it should always be turned on when available? -- Andreas Ericsson andreas.ericsson at op5.se OP5 AB www.op5.se Lead Developer -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: nagiosplug-Wall-clean.diff URL: From Matthias.Eble at kaufland.de Wed Jun 1 07:08:03 2005 From: Matthias.Eble at kaufland.de (Matthias.Eble at kaufland.de) Date: Wed Jun 1 07:08:03 2005 Subject: [Nagiosplug-devel] additional function for check_disk [Virus checked] In-Reply-To: <428A2F49.7010802@op5.se> Message-ID: nagiosplug-devel-admin at lists.sourceforge.net schrieb am 17.05.2005 19:52:09: > Matthias.Eble at kaufland.de wrote: > > Hi list, > > > > at the moment, check_disk returns a state != STATE_OK if any of the > > monitored filesystems has less than -w or -c freespace. > > > > In our case, this doesn't meet our needs, since our Oracle databases use > > more than just one filesystem to store their data. > > So if there are n data-volumes available, it doesn't matter if one or n-1 > > volumes get filled 100% as long as one volume remains beyond > > the warning level. > > > > I've got three approaches for solve this problem. > > > > First: > > Introduce an option like -g (--group) followed by a comma_seperated_list > > of partitions/lvols/mountpoints which are to group. > > > > Probably the cleanest solution, or possibly to add check_disk_group as > its own command. > So after analyzing the code of check_disk it looks like it would be the best way to add two values to the mount_entry struct in mountlist.h: State (STATE_OK,..) gid (group id) I couldn't find any file (except check_disk.c) which uses the mount_entry struct, so I like to know if a change like this matches nagiosplug's coding rules. I'm in doubt because it's located in the lib directory. Please be lenient toward me since this is my first contribution.. :) From ae at op5.se Wed Jun 1 07:26:33 2005 From: ae at op5.se (Andreas Ericsson) Date: Wed Jun 1 07:26:33 2005 Subject: [Nagiosplug-devel] Guidelines Message-ID: <429DC4E8.8080502@op5.se> I've been going through the plugin guidelines and noticed a couple of weird things and hints in them, for example; * "Print only one line of text" This should be changed to "Always make sure the first line of output contains something useful", as it's usually useful to (by default) print any error messages later on so the user sees them when running them from command-line. I'd be happy to print a queuing system for error messages so they can be printed at plugin exit. * "The plugins are copyrighted by their respective authors", and later on, "The copyright for the changes will then revert to the Nagios Plugin Development Team". This second statement is just pure BS anyway, as the signover of copyrights requires a fair amount of paperwork and cannot be automated by a statement on a webpage. If anything, you can force authors to make their changes GPL'd (the GPL already states this explicitly, but it's still a good idea to make it painfully obvious on the webpage). The code submitted to the project *IS* GPL, but may be copyrighted by others. If those others choose to change the copyright of their copy of the code, they cannot make those changes apply retroactively to the code-versions in the nagiosplug repository. * "Don't execute system commands without specifying their full path". The reason given (trojans earlier in the path) is fairly moot given that if someone can add files to any element of the path the game is most certainly lost. It's good for making sure idiots don't write code that wildly spawn external programs though. * "Validate all input" Considering the fact that not a single plugin does this today (unless you're thinking validate_arguments()), this is just a waste of web-space. The fact that the spopen()-enabled plugins run commands on a large array of hosts which produce vastly different output, this turns somewhat impossible. * "All network plugins should use DEFAULT_SOCKET_TIMEOUT to timeout". For many plugins, this is largely meaningless as most of them can calculate how long they will have to run at a maximum before they return CRITICAL anyway (check_tcp with -w and -c flags, check_ping, etc). Having them hung in kernel-space when they'll still return CRITICAL won't make anybody happier. This should be changed to "Use DEFAULT_SOCKET_TIMEOUT as default unless a value can be properly calculated". * "In addition to the reserved options" .... and what follows. I notice that there are no less than 4 of the 5 listed "standard" options that are supposed to denote username in one form or another. Please just drop this section entirely, or decide on ONE thing to use. the --url option, currently applying to a single plugin (check_http) isn't exactly what I would call "standard". In addition, it would be nice to see a section called "Don't waste return values just so you can (possibly inaccurately) recalculate them later". Another section, named "Use the appropriate function for the job" would also be nice as well as "Prefer ANSI C over non-standard functions". For reasons to this, take a look at the use of strstr() (which isn't an intrinsic function) being used as strchr() (which IS an intrinsic function) in too many of the plugins, as well as strpbrk(), strspn() and friends. All of those new sections could be bundled under "Optimization", which would then incorporate the "Allow sibling call optimizations" and "How To Make Life Easy For The Compiler". end rant; Sorry to those of you whom I'm sure took offense. None was actually intended. -- Andreas Ericsson andreas.ericsson at op5.se OP5 AB www.op5.se Lead Developer From sghosh at sghosh.org Wed Jun 1 07:26:34 2005 From: sghosh at sghosh.org (Subhendu Ghosh) Date: Wed Jun 1 07:26:34 2005 Subject: [Nagiosplug-devel] additional function for check_disk [Virus checked] In-Reply-To: References: Message-ID: On Wed, 1 Jun 2005 Matthias.Eble at kaufland.de wrote: > nagiosplug-devel-admin at lists.sourceforge.net schrieb am 17.05.2005 > 19:52:09: > >> Matthias.Eble at kaufland.de wrote: >>> Hi list, >>> >>> at the moment, check_disk returns a state != STATE_OK if any of the >>> monitored filesystems has less than -w or -c freespace. >>> >>> In our case, this doesn't meet our needs, since our Oracle databases > use >>> more than just one filesystem to store their data. >>> So if there are n data-volumes available, it doesn't matter if one or > n-1 >>> volumes get filled 100% as long as one volume remains beyond >>> the warning level. >>> >>> I've got three approaches for solve this problem. >>> >>> First: >>> Introduce an option like -g (--group) followed by a > comma_seperated_list >>> of partitions/lvols/mountpoints which are to group. >>> >> >> Probably the cleanest solution, or possibly to add check_disk_group as >> its own command. >> > > So after analyzing the code of check_disk it looks like it would be the > best way > to add two values to the mount_entry struct in mountlist.h: > State (STATE_OK,..) > gid (group id) > > > I couldn't find any file (except check_disk.c) which uses the mount_entry > struct, > so I like to know if a change like this matches nagiosplug's coding rules. > I'm in doubt because it's located in the lib directory. > > Please be lenient toward me since this is my first contribution.. :) > > a patch is always easier to accept as a contribution. -- -sg From noreply at sourceforge.net Wed Jun 1 07:30:43 2005 From: noreply at sourceforge.net (SourceForge.net) Date: Wed Jun 1 07:30:43 2005 Subject: [Nagiosplug-devel] [ nagiosplug-Patches-1145413 ] This patche allow to use unix sockets in nagios plugins. Message-ID: Patches item #1145413, was opened at 2005-02-21 08:20 Message generated for change (Comment added) made by sghosh You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397599&aid=1145413&group_id=29880 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Enhancement Group: None Status: Open Resolution: None Priority: 5 Submitted By: Alex Samorukov (samm2) Assigned to: Nobody/Anonymous (nobody) Summary: This patche allow to use unix sockets in nagios plugins. Initial Comment: With this patch user can specify unix socket as -H argument. This allow to check tcp services which are bind to unix sockets only. I use this for checking clamav-clamd. Alsi, i added check_clamd prototype to check status of the CLAMAV daemon (clamav.net). ---------------------------------------------------------------------- >Comment By: Subhendu Ghosh (sghosh) Date: 2005-06-01 10:29 Message: Logged In: YES user_id=46572 Can you take a shot at reworking the patch based on the current CVS - a bunch of changes went in a couple of weeks ago that breaks this patch. ---------------------------------------------------------------------- Comment By: Alex Samorukov (samm2) Date: 2005-03-11 05:04 Message: Logged In: YES user_id=891004 Hi. Will nagios-plugins use this code? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397599&aid=1145413&group_id=29880 From noreply at sourceforge.net Wed Jun 1 07:34:20 2005 From: noreply at sourceforge.net (SourceForge.net) Date: Wed Jun 1 07:34:20 2005 Subject: [Nagiosplug-devel] [ nagiosplug-Patches-1212395 ] check_snmp - don't read MIBS if not needed Message-ID: Patches item #1212395, was opened at 2005-05-31 23:41 Message generated for change (Settings changed) made by sghosh You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397599&aid=1212395&group_id=29880 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: John Sellens (jsellens) >Assigned to: Subhendu Ghosh (sghosh) Summary: check_snmp - don't read MIBS if not needed Initial Comment: One of the slowdowns in check_snmp is when snmpget reads all the MIB files. But it occurred to me today that if you call check_snmp with an OID (instead of an SNMP variable name), then we don't need to read any MIB files at all. Here's a patch. Thanks! John jsellens at syonex.com ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397599&aid=1212395&group_id=29880 From noreply at sourceforge.net Wed Jun 1 07:34:25 2005 From: noreply at sourceforge.net (SourceForge.net) Date: Wed Jun 1 07:34:25 2005 Subject: [Nagiosplug-devel] [ nagiosplug-Patches-925295 ] check_disk_smb: compare_levels_after_kMG_decoding Message-ID: Patches item #925295, was opened at 2004-03-29 08:36 Message generated for change (Settings changed) made by sghosh You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397599&aid=925295&group_id=29880 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: neil prockter (orangepeel) >Assigned to: Subhendu Ghosh (sghosh) Summary: check_disk_smb: compare_levels_after_kMG_decoding Initial Comment: Hi in order to avoid Argument "500M" isn't numeric in numeric gt (>) at ./check_disk_smb_experimental line 96. Argument "1000M" isn't numeric in numeric gt (>) at ./check_disk_smb_experimental line 96. type warnings from check_disk_smb I propose the following patch This moves the comparing of warn and crit to after the kMG have been decoded, using the _type variables to decide whether to compare Additionally allows mixing of kMG (e.g. -w 1000M -c 500k) Not sure if warn being percent and crit being actual should be considered, would need to examin the output to determine share size first Neil ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397599&aid=925295&group_id=29880 From noreply at sourceforge.net Wed Jun 1 07:34:26 2005 From: noreply at sourceforge.net (SourceForge.net) Date: Wed Jun 1 07:34:26 2005 Subject: [Nagiosplug-devel] [ nagiosplug-Patches-1183791 ] check_disk_smb: allow emtpy passwords Message-ID: Patches item #1183791, was opened at 2005-04-15 10:40 Message generated for change (Settings changed) made by sghosh You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397599&aid=1183791&group_id=29880 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Enhancement Group: None Status: Open Resolution: None Priority: 5 Submitted By: Bart Cortooms (bart) >Assigned to: Subhendu Ghosh (sghosh) Summary: check_disk_smb: allow emtpy passwords Initial Comment: This patch allows empty passwords to be used for logins, which is useful for shares which allow guest logins and don't require a password. This changes the default password from "guest" to an emtpy password. ---------------------------------------------------------------------- Comment By: M. Sean Finney (seanius) Date: 2005-04-17 18:23 Message: Logged In: YES user_id=226838 hi, i've committed this to CVS, along with changing the output of --help to reflect that the default behavior has now changed to use an empty password (hope no one objects to this, otherwise we'll have to revisit this) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397599&aid=1183791&group_id=29880 From Matthias.Eble at kaufland.de Wed Jun 1 07:40:29 2005 From: Matthias.Eble at kaufland.de (Matthias.Eble at kaufland.de) Date: Wed Jun 1 07:40:29 2005 Subject: Antwort: Re: Re: [Nagiosplug-devel] additional function for check_disk [Virus checked] In-Reply-To: Message-ID: nagiosplug-devel-admin at lists.sourceforge.net schrieb am 01.06.2005 16:24:00: > On Wed, 1 Jun 2005 Matthias.Eble at kaufland.de wrote: > > > nagiosplug-devel-admin at lists.sourceforge.net schrieb am 17.05.2005 > > 19:52:09: > > > >> Matthias.Eble at kaufland.de wrote: > >>> Hi list, > >>> > >>> at the moment, check_disk returns a state != STATE_OK if any of the > >>> monitored filesystems has less than -w or -c freespace. > >>> > >>> In our case, this doesn't meet our needs, since our Oracle databases > > use > >>> more than just one filesystem to store their data. > >>> So if there are n data-volumes available, it doesn't matter if one or > > n-1 > >>> volumes get filled 100% as long as one volume remains beyond > >>> the warning level. > >>> > >>> I've got three approaches for solve this problem. > >>> > >>> First: > >>> Introduce an option like -g (--group) followed by a > > comma_seperated_list > >>> of partitions/lvols/mountpoints which are to group. > >>> > >> > >> Probably the cleanest solution, or possibly to add check_disk_group as > >> its own command. > >> > > > > So after analyzing the code of check_disk it looks like it would be the > > best way > > to add two values to the mount_entry struct in mountlist.h: > > State (STATE_OK,..) > > gid (group id) > > > > > > I couldn't find any file (except check_disk.c) which uses the mount_entry > > struct, > > so I like to know if a change like this matches nagiosplug's coding rules. > > I'm in doubt because it's located in the lib directory. > > > > Please be lenient toward me since this is my first contribution.. :) > > > > > > a patch is always easier to accept as a contribution. > well, maybe I chose the wrong word... this will be my first contributed patch.. From sghosh at sghosh.org Wed Jun 1 08:26:36 2005 From: sghosh at sghosh.org (Subhendu Ghosh) Date: Wed Jun 1 08:26:36 2005 Subject: [Nagiosplug-devel] Guidelines In-Reply-To: <429DC4E8.8080502@op5.se> References: <429DC4E8.8080502@op5.se> Message-ID: On Wed, 1 Jun 2005, Andreas Ericsson wrote: > I've been going through the plugin guidelines and noticed a couple of weird > things and hints in them, for example; > > * "Print only one line of text" > This should be changed to "Always make sure the first line of output contains > something useful", as it's usually useful to (by default) print any error > messages later on so the user sees them when running them from command-line. > I'd be happy to print a queuing system for error messages so they can be > printed at plugin exit. > > * "The plugins are copyrighted by their respective authors", and later on, > "The copyright for the changes will then revert to the Nagios Plugin > Development Team". > This second statement is just pure BS anyway, as the signover of copyrights > requires a fair amount of paperwork and cannot be automated by a statement on > a webpage. If anything, you can force authors to make their changes GPL'd > (the GPL already states this explicitly, but it's still a good idea to make > it painfully obvious on the webpage). The code submitted to the project *IS* > GPL, but may be copyrighted by others. If those others choose to change the > copyright of their copy of the code, they cannot make those changes apply > retroactively to the code-versions in the nagiosplug repository. > > * "Don't execute system commands without specifying their full path". > The reason given (trojans earlier in the path) is fairly moot given that if > someone can add files to any element of the path the game is most certainly > lost. It's good for making sure idiots don't write code that wildly spawn > external programs though. > > * "Validate all input" > Considering the fact that not a single plugin does this today (unless you're > thinking validate_arguments()), this is just a waste of web-space. The fact > that the spopen()-enabled plugins run commands on a large array of hosts > which produce vastly different output, this turns somewhat impossible. > > * "All network plugins should use DEFAULT_SOCKET_TIMEOUT to timeout". > For many plugins, this is largely meaningless as most of them can calculate > how long they will have to run at a maximum before they return CRITICAL > anyway (check_tcp with -w and -c flags, check_ping, etc). Having them hung in > kernel-space when they'll still return CRITICAL won't make anybody happier. > This should be changed to "Use DEFAULT_SOCKET_TIMEOUT as default unless a > value can be properly calculated". > > * "In addition to the reserved options" .... and what follows. > I notice that there are no less than 4 of the 5 listed "standard" options > that are supposed to denote username in one form or another. Please just drop > this section entirely, or decide on ONE thing to use. the --url option, > currently applying to a single plugin (check_http) isn't exactly what I would > call "standard". > > > In addition, it would be nice to see a section called "Don't waste return > values just so you can (possibly inaccurately) recalculate them later". > Another section, named "Use the appropriate function for the job" would also > be nice as well as "Prefer ANSI C over non-standard functions". For reasons > to this, take a look at the use of strstr() (which isn't an intrinsic > function) being used as strchr() (which IS an intrinsic function) in too many > of the plugins, as well as strpbrk(), strspn() and friends. > All of those new sections could be bundled under "Optimization", which would > then incorporate the "Allow sibling call optimizations" and "How To Make Life > Easy For The Compiler". > > end rant; > > Sorry to those of you whom I'm sure took offense. None was actually intended. > > no offense - diff sgml ;) please -- -sg From noreply at sourceforge.net Wed Jun 1 08:30:30 2005 From: noreply at sourceforge.net (SourceForge.net) Date: Wed Jun 1 08:30:30 2005 Subject: [Nagiosplug-devel] [ nagiosplug-Patches-1183791 ] check_disk_smb: allow emtpy passwords Message-ID: Patches item #1183791, was opened at 2005-04-15 10:40 Message generated for change (Settings changed) made by sghosh You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397599&aid=1183791&group_id=29880 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Enhancement Group: None >Status: Pending Resolution: None Priority: 5 Submitted By: Bart Cortooms (bart) >Assigned to: M. Sean Finney (seanius) Summary: check_disk_smb: allow emtpy passwords Initial Comment: This patch allows empty passwords to be used for logins, which is useful for shares which allow guest logins and don't require a password. This changes the default password from "guest" to an emtpy password. ---------------------------------------------------------------------- Comment By: M. Sean Finney (seanius) Date: 2005-04-17 18:23 Message: Logged In: YES user_id=226838 hi, i've committed this to CVS, along with changing the output of --help to reflect that the default behavior has now changed to use an empty password (hope no one objects to this, otherwise we'll have to revisit this) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397599&aid=1183791&group_id=29880 From dan.hopkins at uk.easynet.net Wed Jun 1 08:56:10 2005 From: dan.hopkins at uk.easynet.net (Dan Hopkins) Date: Wed Jun 1 08:56:10 2005 Subject: [Nagiosplug-devel] Guidelines Message-ID: <13E80BCA327C4D43AC2EFCE6B06E53145D4CDF@exch0-tmshm.uk.easynet.corp> > From: Andreas Ericsson [mailto:ae at op5.se] > I've been going through the plugin guidelines and noticed a couple of > weird things and hints in them, for example; ... > * "In addition to the reserved options" .... and what follows. > I notice that there are no less than 4 of the 5 listed "standard" > options that are supposed to denote username in one form or another. > Please just drop this section entirely, or decide on ONE > thing to use. > the --url option, currently applying to a single plugin (check_http) > isn't exactly what I would call "standard". Also, perhaps trivial in the scheme of things, it'd be great if all plugins actually supported the options they claim to in their usage. Long options spring to mind (see check_http) Dan From noreply at sourceforge.net Wed Jun 1 12:43:14 2005 From: noreply at sourceforge.net (SourceForge.net) Date: Wed Jun 1 12:43:14 2005 Subject: [Nagiosplug-devel] [ nagiosplug-Patches-1212395 ] check_snmp - don't read MIBS if not needed Message-ID: Patches item #1212395, was opened at 2005-05-31 23:41 Message generated for change (Settings changed) made by sghosh You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397599&aid=1212395&group_id=29880 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None >Status: Pending Resolution: None Priority: 5 Submitted By: John Sellens (jsellens) Assigned to: Subhendu Ghosh (sghosh) Summary: check_snmp - don't read MIBS if not needed Initial Comment: One of the slowdowns in check_snmp is when snmpget reads all the MIB files. But it occurred to me today that if you call check_snmp with an OID (instead of an SNMP variable name), then we don't need to read any MIB files at all. Here's a patch. Thanks! John jsellens at syonex.com ---------------------------------------------------------------------- >Comment By: Subhendu Ghosh (sghosh) Date: 2005-06-01 15:41 Message: Logged In: YES user_id=46572 modified patch updated to cvs. thanks ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397599&aid=1212395&group_id=29880 From noreply at sourceforge.net Wed Jun 1 14:14:49 2005 From: noreply at sourceforge.net (SourceForge.net) Date: Wed Jun 1 14:14:49 2005 Subject: [Nagiosplug-devel] [ nagiosplug-Patches-1104536 ] Enhancements in check_snmp Message-ID: Patches item #1104536, was opened at 2005-01-18 10:27 Message generated for change (Comment added) made by sghosh You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397599&aid=1104536&group_id=29880 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Enhancement Group: None Status: Open Resolution: None Priority: 5 Submitted By: Friedrich Priewasser (friedl-faba) >Assigned to: Subhendu Ghosh (sghosh) Summary: Enhancements in check_snmp Initial Comment: I've made some enhancements in the check_snmp plugin. These are: Use of factors, so that the output will be divided/multiplied by this factor. Algebraic operations, allowing addition, multiplication ... of results and constants Generation of performance output for Nagios There are few additional files, which I needed for the algebric operations: queue.h / queue.c for stacks and queues calculator.h / calculator.c for the evaluation Therefore some changes in the Makefile are necessary. Regards, Friedrich -- Friedrich Priewasser Software Engineer Fabalabs Software GmbH Honauerstra?e 4 A-4020 Linz e-mail: mailto:friedrich.priewasser at fabalabs.org http://www.fabalabs.org ---------------------------------------------------------------------- >Comment By: Subhendu Ghosh (sghosh) Date: 2005-06-01 17:13 Message: Logged In: YES user_id=46572 will add this after migrating to net-snmp lib usage ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397599&aid=1104536&group_id=29880 From sabol at alderaan.gsfc.nasa.gov Wed Jun 1 15:51:54 2005 From: sabol at alderaan.gsfc.nasa.gov (Edward J. Sabol) Date: Wed Jun 1 15:51:54 2005 Subject: [Nagiosplug-devel] Re: check_procs ELAPSED [patch] In-Reply-To: <20050531205115.GA10841@seanius.net> (message from sean finney on Tue, 31 May 2005 16:51:15 -0400) References: <200505311933.j4VJXTI7024062@alderaan.gsfc.nasa.gov> <20050531205115.GA10841@seanius.net> Message-ID: <200506012249.j51MnmUS028135@alderaan.gsfc.nasa.gov> Sean Finney wrote: > the whole ps format autodetection is a real mess (i was just looking at > it last week), and should be rethought. my thinking is to remove much > of it from the configure.in script, and instead provide a way to > specify the options/format from the cmdline, but i probably won't be > getting to that any time in the near future because my TODO stack is > already nearly toppling over :) Hey Sean, I noticed your recent patch to check_procs.c that you committed to CVS, so I downloaded the daily HEAD tarball and tried to build it. Unfortunately, I encountered several syntax errors in check_procs.c as a result of your changes when I tried to compile it using gcc 2.95.3. I presume it compiles fine using newer versions of gcc, but I think it's a good idea to maintain compatibility with older gcc's. In that spirit, I propose the following the patch to check_procs.c: --- check_procs.c_HEAD Tue May 24 20:43:20 2005 +++ check_procs.c Wed Jun 1 18:34:54 2005 @@ -94,7 +94,7 @@ int procseconds = 0; float procpcpu = 0; char procstat[8]; - char procetime[MAX_INPUT_BUFFER]; + char procetime[MAX_INPUT_BUFFER] = { '\0' }; char *procargs; char *temp_string; @@ -108,12 +108,10 @@ int expected_cols = PS_COLS - 1; int warn = 0; /* number of processes in warn state */ int crit = 0; /* number of processes in crit state */ - procetime[0]='\0'; /* keep this clean because -vvv always prints it */ int i = 0; - int result = STATE_UNKNOWN; - //setlocale (LC_ALL, ""); + /* setlocale (LC_ALL, ""); */ bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); @@ -643,6 +641,9 @@ (minutes * 60) + seconds; + if (verbose >= 3 && metric == METRIC_ELAPSED) { + printf("seconds: %d\n", total); + } return total; } Sean, would you please consider committing this patch? Note that this patch restores the display of the converted etime to the super-verbose debug output. I found this rather useful when debugging my ELAPSED metric checks and I think it should be retained. However, as a compromise, I've changed the logic that it's only displayed when the ELAPSED metric is specified. That's really the only time it's all at all useful anyway. Sean, just out of curiosity, could you perhaps elaborate on why you commented out the setlocale() call? All the other Nagios plugins seem to do it. I'm sure you had a good reason... The only missing piece of the puzzle needed to get the ELAPSED metirc working on my Red Hat Linux 7.3 system was adding etime to the PS_COMMAND and tweaking the other ps-related variables in configure.in. For that, I propose the following patch: --- ./configure.in_HEAD Wed Jun 1 18:01:30 2005 +++ ./configure.in Wed Jun 1 17:53:00 2005 @@ -593,15 +593,15 @@ AC_PATH_PROG(PATH_TO_PS,ps) AC_MSG_CHECKING(for ps syntax) -dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo. +dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwwo. dnl so test for this first... -if ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \ - egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null +if ps axwwo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \ + egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +ELAPSED +COMMAND"] > /dev/null then - ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" - ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu comm args'" - ac_cv_ps_format="%s %d %d %d %d %d %f %s %n" - ac_cv_ps_cols=9 + ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]" + ac_cv_ps_command="$PATH_TO_PS axwwo 'stat uid pid ppid vsz rss pcpu etime comm args'" + ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n" + ac_cv_ps_cols=10 AC_MSG_RESULT([$ac_cv_ps_command]) dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo From seanius at seanius.net Wed Jun 1 21:26:08 2005 From: seanius at seanius.net (sean finney) Date: Wed Jun 1 21:26:08 2005 Subject: [Nagiosplug-devel] Re: check_procs ELAPSED [patch] In-Reply-To: <200506012249.j51MnmUS028135@alderaan.gsfc.nasa.gov> References: <200505311933.j4VJXTI7024062@alderaan.gsfc.nasa.gov> <20050531205115.GA10841@seanius.net> <200506012249.j51MnmUS028135@alderaan.gsfc.nasa.gov> Message-ID: <20050602042429.GA31070@seanius.net> hi edward, On Wed, Jun 01, 2005 at 06:49:48PM -0400, Edward J. Sabol wrote: > - char procetime[MAX_INPUT_BUFFER]; > + char procetime[MAX_INPUT_BUFFER] = { '\0' }; okay, that makes sense. > - //setlocale (LC_ALL, ""); > + /* setlocale (LC_ALL, ""); */ this was actually an oversight on my part, i commented it out while debugging something else. it should be uncommented and so i'll back that out. > + if (verbose >= 3 && metric == METRIC_ELAPSED) { > + printf("seconds: %d\n", total); > + } okay, if that's useful i'll put that back in too. i'll see about getting these changes in between now and friday. i'll take a look at the configure.in patch too when i have a chance. sean -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: Digital signature URL: From sabol at alderaan.gsfc.nasa.gov Thu Jun 2 06:55:08 2005 From: sabol at alderaan.gsfc.nasa.gov (Edward J. Sabol) Date: Thu Jun 2 06:55:08 2005 Subject: [Nagiosplug-devel] Re: -Wall clean patch In-Reply-To: <429D684D.6080007@op5.se> (message from Andreas Ericsson on Wed, 01 Jun 2005 09:48:29 +0200) References: <429D684D.6080007@op5.se> Message-ID: <200506021352.j52DqKnc029669@alderaan.gsfc.nasa.gov> > The attached patch makes the plugins compile cleanly on FC3 and > Owl-current with -Wall applied. No logic has been changed, so I haven't > tested it any more than a re-compile. [...] > diff -urN ../orig.nplg/plugins/check_nagios.c ./plugins/check_nagios.c > --- ../orig.nplg/plugins/check_nagios.c 2005-05-26 14:12:21.000000000 +0200 > +++ ./plugins/check_nagios.c 2005-06-01 07:28:00.000000000 +0200 > @@ -55,7 +55,6 @@ > int procrss = 0; > float procpcpu = 0; > char procstat[8]; > - char procetime[MAX_INPUT_BUFFER]; > char procprog[MAX_INPUT_BUFFER]; > char *procargs; > int pos, cols; Um, you need to keep procetime there, don't you? It may or may not be in PS_VARLIST, depending upon what configure does. If it is in PS_VARLIST, then the check_nagios.c plugin will no longer compile, unless I'm misunderstanding something. Otherwise, this looks very good. > How portable is -Wall btw? Perhaps it should always be turned on when > available? The Apache httpd_apreq developers added a configure switch for developers to use to turn on -Wall. Actually, it turns on a bunch of gcc warnings. Here's the list they use: -Werror -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations \ -Wwrite-strings -Wcast-qual -Wfloat-equal -Wshadow -Wpointer-arith \ -Wbad-function-cast -Wsign-compare -Waggregate-return -Wmissing-noreturn \ -Wmissing-format-attribute -Wpacked -Wredundant-decls -Wnested-externs \ -Wdisabled-optimization -Wno-long-long -Wendif-labels -Wcast-align From noreply at sourceforge.net Thu Jun 2 13:44:04 2005 From: noreply at sourceforge.net (SourceForge.net) Date: Thu Jun 2 13:44:04 2005 Subject: [Nagiosplug-devel] [ nagiosplug-Patches-1213786 ] Enable SNMP version 2c in check_snmp.c Message-ID: Patches item #1213786, was opened at 2005-06-02 13:42 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397599&aid=1213786&group_id=29880 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Enhancement Group: None Status: Open Resolution: None Priority: 5 Submitted By: Alan Hagge (ahagge) Assigned to: Nobody/Anonymous (nobody) Summary: Enable SNMP version 2c in check_snmp.c Initial Comment: This patch (against version 1.4) allows check_snmp.c to support SNMP version 2c. This is needed to support 64-bit counters in some equipment (such as ethernet switches) which roll their 32-bit counters too frequently. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397599&aid=1213786&group_id=29880 From seanius at seanius.net Fri Jun 3 06:47:16 2005 From: seanius at seanius.net (sean finney) Date: Fri Jun 3 06:47:16 2005 Subject: [Nagiosplug-devel] check_load arg parsing bugfix and cleanup In-Reply-To: <429B21A6.3050009@op5.se> References: <429742E4.4050504@op5.se> <20050527221720.GA26079@seanius.net> <4297CED6.700@op5.se> <20050529215408.GA18638@seanius.net> <429B21A6.3050009@op5.se> Message-ID: <20050603134441.GA15713@seanius.net> hey, On Mon, May 30, 2005 at 04:22:30PM +0200, Andreas Ericsson wrote: > Also for async safety reasons, but the plugins should only call > exit_code = np_runcmd(command, &chld_out, &chld_err, flags); > and never worry about anything else (the flags parameter is a new > addition which makes it possible for plugins decide if they want the > output->line array populated or not). cool. i see that as being a generally helpful parameter. > The output structure is fairly general and can be used for other things > as well (getting data from a network socket, reading files, etc. etc.) something that would be nice to see would be to have this extended to manage not just output, but also input. specifically, what comes to mind are the various check_tcp derived plugins where there's a specific order of send-recieve operations. or perhaps there's a need for a different datastructure to handle this? anyway, i'm going to hold off on the applying runcmd patches for the time being, as i won't have time to majorly audit this for the next 3 weeks or so. i'm definitely planning on re-visiting this then, if someone else hasn't already picked up the ball on this by then. sean -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: Digital signature URL: From seanius at seanius.net Fri Jun 3 06:59:29 2005 From: seanius at seanius.net (sean finney) Date: Fri Jun 3 06:59:29 2005 Subject: [Nagiosplug-devel] Re: check_procs ELAPSED [patch] In-Reply-To: <200506012249.j51MnmUS028135@alderaan.gsfc.nasa.gov> References: <200505311933.j4VJXTI7024062@alderaan.gsfc.nasa.gov> <20050531205115.GA10841@seanius.net> <200506012249.j51MnmUS028135@alderaan.gsfc.nasa.gov> Message-ID: <20050603135713.GB15713@seanius.net> hi ed, i've committed the first of the two patches, but have a question about the second: On Wed, Jun 01, 2005 at 06:49:48PM -0400, Edward J. Sabol wrote: > -dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo. > +dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwwo. why the two w's? sean -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: Digital signature URL: From sabol at alderaan.gsfc.nasa.gov Fri Jun 3 07:13:24 2005 From: sabol at alderaan.gsfc.nasa.gov (Edward J. Sabol) Date: Fri Jun 3 07:13:24 2005 Subject: [Nagiosplug-devel] Re: check_procs ELAPSED [patch] In-Reply-To: <20050603135713.GB15713@seanius.net> (message from sean finney on Fri, 3 Jun 2005 09:57:13 -0400) References: <200505311933.j4VJXTI7024062@alderaan.gsfc.nasa.gov> <20050531205115.GA10841@seanius.net> <200506012249.j51MnmUS028135@alderaan.gsfc.nasa.gov> <20050603135713.GB15713@seanius.net> Message-ID: <200506031412.j53ECLPi000529@alderaan.gsfc.nasa.gov> Sean Finney wrote: > i've committed the first of the two patches, but have a question about > the second: > On Wed, Jun 01, 2005 at 06:49:48PM -0400, Edward J. Sabol wrote: >> -dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo. >> +dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwwo. > > why the two w's? Yeah, I'm not actually all that sure about the configure.in patch. All I know is that it worked for me. I don't know how other OSes will cope. As for the two w's specificaly, when I added "etime" to the output, the `ps' command truncated the args even more. A second w causes the complete command arguments to be displayed. That just seemed like a good idea to me. Honestly, I think it should probably be in all of the `ps' commands, but I'll leave that to someone else. Later, Ed From ae at op5.se Fri Jun 3 08:18:30 2005 From: ae at op5.se (Andreas Ericsson) Date: Fri Jun 3 08:18:30 2005 Subject: [Nagiosplug-devel] check_load arg parsing bugfix and cleanup In-Reply-To: <20050603134441.GA15713@seanius.net> References: <429742E4.4050504@op5.se> <20050527221720.GA26079@seanius.net> <4297CED6.700@op5.se> <20050529215408.GA18638@seanius.net> <429B21A6.3050009@op5.se> <20050603134441.GA15713@seanius.net> Message-ID: <42A07463.3010108@op5.se> sean finney wrote: > hey, > > On Mon, May 30, 2005 at 04:22:30PM +0200, Andreas Ericsson wrote: > >>Also for async safety reasons, but the plugins should only call >>exit_code = np_runcmd(command, &chld_out, &chld_err, flags); >>and never worry about anything else (the flags parameter is a new >>addition which makes it possible for plugins decide if they want the >>output->line array populated or not). > > > cool. i see that as being a generally helpful parameter. > > >>The output structure is fairly general and can be used for other things >>as well (getting data from a network socket, reading files, etc. etc.) > > > something that would be nice to see would be to have this extended to > manage not just output, but also input. specifically, what comes to > mind are the various check_tcp derived plugins where there's a specific > order of send-recieve operations. or perhaps there's a need for a > different datastructure to handle this? > As typedefs are "free" wrt binary footprint, I'd say a structure of its own would be in place here. Something along the lines of; struct layer6_protocol { char *service_name; char *eol; unsigned short port; int protocol; struct net_event **event; } where event is a NULL-terminated list of a struct such as shown below. struct net_event { size_t flags; size_t len; char *data; } > anyway, i'm going to hold off on the applying runcmd patches for the > time being, as i won't have time to majorly audit this for the next > 3 weeks or so. i'm definitely planning on re-visiting this then, if > someone else hasn't already picked up the ball on this by then. > > > sean -- Andreas Ericsson andreas.ericsson at op5.se OP5 AB www.op5.se Lead Developer From jhmartin at toger.us Fri Jun 3 20:16:14 2005 From: jhmartin at toger.us (Jason Martin) Date: Fri Jun 3 20:16:14 2005 Subject: [Nagiosplug-devel] Guidelines In-Reply-To: <429DC4E8.8080502@op5.se> References: <429DC4E8.8080502@op5.se> Message-ID: <20050604031427.GB2653@zippy.toger.us> On Wed, Jun 01, 2005 at 04:23:36PM +0200, Andreas Ericsson wrote: > * "Print only one line of text" > This should be changed to "Always make sure the first line of output > contains something useful", as it's usually useful to (by default) print > any error messages later on so the user sees them when running them from > command-line. I'd be happy to print a queuing system for error messages > so they can be printed at plugin exit. So long as it is made obvious that Nagios will show only one line of text... > * "Validate all input" > Considering the fact that not a single plugin does this today (unless > you're thinking validate_arguments()), this is just a waste of This is still a good idea -- a widely distributed plugin should be very careful what it does, especially if it is going to be run through a semi-insecure mechanism such as NRPE. Not all the plugins do this, but they should. > In addition, it would be nice to see a section called "Don't waste > return values just so you can (possibly inaccurately) recalculate them > later". What do you mean by this? Overall it looks good. -Jason Martin -- I've got to sit down and work out where I stand. This message is PGP/MIME signed. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 211 bytes Desc: not available URL: From ae at op5.se Fri Jun 3 23:26:04 2005 From: ae at op5.se (Andreas Ericsson) Date: Fri Jun 3 23:26:04 2005 Subject: [Nagiosplug-devel] Guidelines In-Reply-To: <20050604031427.GB2653@zippy.toger.us> References: <429DC4E8.8080502@op5.se> <20050604031427.GB2653@zippy.toger.us> Message-ID: <42A14951.3040007@op5.se> Jason Martin wrote: > On Wed, Jun 01, 2005 at 04:23:36PM +0200, Andreas Ericsson wrote: >>* "Validate all input" >>Considering the fact that not a single plugin does this today (unless >>you're thinking validate_arguments()), this is just a waste of > > This is still a good idea -- a widely distributed plugin should > be very careful what it does, especially if it is going to be > run through a semi-insecure mechanism such as NRPE. Not all the > plugins do this, but they should. > Then call it "Write secure code" or something. Input validation is only a small part of that, and practically useless unless there's a data-mangling middle- or back-end of the plugin. > >>In addition, it would be nice to see a section called "Don't waste >>return values just so you can (possibly inaccurately) recalculate them >>later". > > What do you mean by this? > See the is_intnonneg() and the likes for this. It calculates the value and then throws it away, just to let the caller calculate them all over again. > Overall it looks good. > -Jason Martin > -- Andreas Ericsson andreas.ericsson at op5.se OP5 AB www.op5.se Lead Developer From ae at op5.se Sat Jun 4 00:44:04 2005 From: ae at op5.se (Andreas Ericsson) Date: Sat Jun 4 00:44:04 2005 Subject: [Nagiosplug-devel] asprintf() madness (example patch) Message-ID: <42A15BAF.2070707@op5.se> I'm hoping to start a discussion here rather than having this patch applied, so I haven't sent it to the tracker (although committing it is a good idea anyways). In some of the plugins, strings are concatenated with asprintf() just to be printed by printf() in the next statement. This is made even more horrible when considering asprintf() never guarantees it will successfully allocate memory. The perfdata and fperfdata also use sprintf, although can calculate the maximum length required to ensure boundary safety, so sprintf() (which is ansi C) would do just fine. The possibly wasted memory is a lot less than asprintf() uses for temporary storage. asprintf(foo, "%s%s", foo, bar); should be replaced by a concat2(str1, str2) function. If needed, concat3, concat4 and even concat_unlim could easily be written as well. What the hell is the meaning behind all the asprintf()'s when a good 250 or so of them can be replaced by simpler and more portable functions that can also exit properly when it runs out of memory? Validation of memory allocating calls is another matter that could be easily and transparently solved (with use of wrapper functions and transparency macros). -- Andreas Ericsson andreas.ericsson at op5.se OP5 AB www.op5.se Lead Developer From ae at op5.se Sat Jun 4 01:08:01 2005 From: ae at op5.se (Andreas Ericsson) Date: Sat Jun 4 01:08:01 2005 Subject: [Nagiosplug-devel] asprintf() madness (example patch) In-Reply-To: <42A15BAF.2070707@op5.se> References: <42A15BAF.2070707@op5.se> Message-ID: <42A1611F.2050305@op5.se> And here be the patch. ;) Andreas Ericsson wrote: > I'm hoping to start a discussion here rather than having this patch > applied, so I haven't sent it to the tracker (although committing it is > a good idea anyways). > > In some of the plugins, strings are concatenated with asprintf() just to > be printed by printf() in the next statement. This is made even more > horrible when considering asprintf() never guarantees it will > successfully allocate memory. > > The perfdata and fperfdata also use sprintf, although can calculate the > maximum length required to ensure boundary safety, so sprintf() (which > is ansi C) would do just fine. The possibly wasted memory is a lot less > than asprintf() uses for temporary storage. > > asprintf(foo, "%s%s", foo, bar); > should be replaced by a concat2(str1, str2) function. If needed, > concat3, concat4 and even concat_unlim could easily be written as well. > > What the hell is the meaning behind all the asprintf()'s when a good 250 > or so of them can be replaced by simpler and more portable functions > that can also exit properly when it runs out of memory? > > Validation of memory allocating calls is another matter that could be > easily and transparently solved (with use of wrapper functions and > transparency macros). > -- Andreas Ericsson andreas.ericsson at op5.se OP5 AB www.op5.se Lead Developer -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: nagiosplug-check_swap-asprintf-madness.diff URL: From noreply at sourceforge.net Sat Jun 4 10:45:14 2005 From: noreply at sourceforge.net (SourceForge.net) Date: Sat Jun 4 10:45:14 2005 Subject: [Nagiosplug-devel] [ nagiosplug-Feature Requests-1214888 ] IPMI hardware sensors support Message-ID: Feature Requests item #1214888, was opened at 2005-06-04 17:43 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397600&aid=1214888&group_id=29880 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Priority: 5 Submitted By: Chris Wilson (gcc) Assigned to: Nobody/Anonymous (nobody) Summary: IPMI hardware sensors support Initial Comment: Hi all, Please find attached a plugin to check IPMI hardware sensors, for example on Dell Poweredge 14xx and 18xx rackmount servers. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397600&aid=1214888&group_id=29880 From assis at partner-it.com.br Sat Jun 4 18:25:40 2005 From: assis at partner-it.com.br (Eduardo Assis) Date: Sat Jun 4 18:25:40 2005 Subject: [Nagiosplug-devel] list of plugins Message-ID: <20050531192116.20053.qmail@hm101.locaweb.com.br> Hi, I am in need of a list of plugins, and a description of each, could you please give me the list or a url pointing one for me? Thank you very much. Sorry by my poor english. Eduardo From jmhenril at gmail.com Sat Jun 4 18:25:41 2005 From: jmhenril at gmail.com (Johann Henriquez) Date: Sat Jun 4 18:25:41 2005 Subject: [Nagiosplug-devel] [Patch] check_inodes-freebsd.pl 1.1 (Nagios-Plugin 1.4) Message-ID: --- check_inodes-freebsd.pl Wed Jun 1 18:59:12 2005 +++ check_inodes-freebsd.pl Sat Jun 4 18:41:29 2005 @@ -4,7 +4,7 @@ # Designed on FreeBSD 4.6 (although this should not matter) # parses df output, splits, and then takes variables # df.pl -f mountpoint -w warningnumber -c critical number -# USE NUMBERS AND NOT PERCENTS FOR wanring and critical values +# USE NUMBERS AND NOT PERCENTS FOR warning and critical values # -h is help # -v is version # Mountpoints: @@ -15,7 +15,7 @@ use strict; use Getopt::Long; use vars qw($opt_V $opt_h $opt_w $opt_c $opt_f $verbose $PROGNAME); -use lib "/usr/local/libexec/nagios" ; +use lib "/usr/local/nagios/libexec" ; use utils qw($TIMEOUT %ERRORS &print_revision &support); my $df = "/bin/df"; @@ -91,15 +91,15 @@ my ($fs,$onek,$used,$avail,$capacity,$iused,$ifree,$ipercent,$mounted) = split; $ipercent =~ s/%//s; - if ($ipercent > $opt_w) { + if ($ipercent > $opt_c) { + $state = $ERRORS{'CRITICAL'}; + $answer = "CRITICAL: $ipercent percent inodes used on $opt_f\n"; + } elsif ($ipercent >= $opt_w) { $state = $ERRORS{'WARNING'}; - $answer = "WARNING: $ipercent percent inodes free on $opt_f\n"; - } elsif ($ipercent > $opt_w) { - $state = $ERRORS{'CRITCAL'}; - $answer = "CRITICAL: $ipercent percent inodes free on $opt_f\n"; + $answer = "WARNING: $ipercent percent inodes used on $opt_f\n"; } elsif ($ipercent < $opt_w) { $state = $ERRORS{'OK'}; - $answer = "OK: $ipercent percent inodes free on $opt_f\n"; + $answer = "OK: $ipercent percent inodes used on $opt_f\n"; } } @@ -109,8 +109,8 @@ exit $state; sub print_usage () { - print "Usage: $PROGNAME [-w ] [-c ]\n"; - print "Example: $PROGNAME /dev/ad0s1a -w 50 -c 75\n"; + print "Usage: $PROGNAME -f [-w ] [-c ]\n"; + print "Example: $PROGNAME -f /usr -w 50 -c 75\n"; } sub print_help () { -- regards, Johann Henriquez Lucero From noreply at sourceforge.net Sun Jun 5 00:44:02 2005 From: noreply at sourceforge.net (SourceForge.net) Date: Sun Jun 5 00:44:02 2005 Subject: [Nagiosplug-devel] [ nagiosplug-Bugs-1215064 ] Documentation: Which plugins are available? Message-ID: Bugs item #1215064, was opened at 2005-06-05 07:43 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1215064&group_id=29880 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Peer Janssen (peerjanssen) Assigned to: Nobody/Anonymous (nobody) Summary: Documentation: Which plugins are available? Initial Comment: I'm trying to find documentation about which plugins are available. I spend some time browsing the web documentation and found much useful information -- wetting my appetite for this seemingly very nice framework --, but there seems to be no info about the available plugins, neither on the nagios site, nor on the nagios plugin site. Of course I could download the plugin package and take a look into whatever I would find in there. But a public list on the website would be nicer in order to make an informed decision ("executive summary" type) and, of course, for propaganda purposes. You may consider this a documentation bug or a wishlist item, whatever you prefer. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1215064&group_id=29880 From noreply at sourceforge.net Sun Jun 5 10:45:09 2005 From: noreply at sourceforge.net (SourceForge.net) Date: Sun Jun 5 10:45:09 2005 Subject: [Nagiosplug-devel] [ nagiosplug-Patches-1211624 ] check_tcp cleanup (take 1) Message-ID: Patches item #1211624, was opened at 2005-05-30 17:52 Message generated for change (Comment added) made by seanius You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397599&aid=1211624&group_id=29880 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Enhancement Group: None >Status: Closed >Resolution: Accepted Priority: 5 Submitted By: Andreas Ericsson (ageric) >Assigned to: M. Sean Finney (seanius) Summary: check_tcp cleanup (take 1) Initial Comment: Cleanup and optimization patch for check_tcp. It also removes some redundant code and fixes a potential SIGSEGV in the matching of server_expect against returned output. Note that further cleaning up should be done for this plugin and parts of it should simply be redesigned, but that's for another rainy day. ---------------------------------------------------------------------- Comment By: M. Sean Finney (seanius) Date: 2005-06-05 13:44 Message: Logged In: YES user_id=226838 this patch has been committed to the nagiosplug CVS repository. thank you for your contribution. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397599&aid=1211624&group_id=29880 From seanius at seanius.net Sun Jun 5 10:46:10 2005 From: seanius at seanius.net (sean finney) Date: Sun Jun 5 10:46:10 2005 Subject: [Nagiosplug-devel] check_tcp cleanup and optimization In-Reply-To: <429B8AF4.5070708@op5.se> References: <429B8AF4.5070708@op5.se> Message-ID: <20050605174459.GA11812@seanius.net> On Mon, May 30, 2005 at 11:51:48PM +0200, Andreas Ericsson wrote: > Attached is a cleanup and optimization patch for check_tcp. It also > removes some redundant code and fixes a potential SIGSEGV in the > matching of server_expect against returned output and makes sure it > doesn't print perfdata that appears to be OK when the server responded > weirdly. i've just applied the patch. there was a missing semicolon around line 72, but otherwise it looks good. sean -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: Digital signature URL: From noreply at sourceforge.net Sun Jun 5 10:52:13 2005 From: noreply at sourceforge.net (SourceForge.net) Date: Sun Jun 5 10:52:13 2005 Subject: [Nagiosplug-devel] [ nagiosplug-Bugs-1215064 ] Documentation: Which plugins are available? Message-ID: Bugs item #1215064, was opened at 2005-06-05 03:43 Message generated for change (Comment added) made by seanius You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1215064&group_id=29880 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Peer Janssen (peerjanssen) Assigned to: Nobody/Anonymous (nobody) Summary: Documentation: Which plugins are available? Initial Comment: I'm trying to find documentation about which plugins are available. I spend some time browsing the web documentation and found much useful information -- wetting my appetite for this seemingly very nice framework --, but there seems to be no info about the available plugins, neither on the nagios site, nor on the nagios plugin site. Of course I could download the plugin package and take a look into whatever I would find in there. But a public list on the website would be nicer in order to make an informed decision ("executive summary" type) and, of course, for propaganda purposes. You may consider this a documentation bug or a wishlist item, whatever you prefer. ---------------------------------------------------------------------- >Comment By: M. Sean Finney (seanius) Date: 2005-06-05 13:50 Message: Logged In: YES user_id=226838 i don't think there is a single authoritative list of plugins available, but i think it would be a very useful thing to have. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1215064&group_id=29880 From noreply at sourceforge.net Tue Jun 7 10:45:17 2005 From: noreply at sourceforge.net (SourceForge.net) Date: Tue Jun 7 10:45:17 2005 Subject: [Nagiosplug-devel] [ nagiosplug-Patches-1216576 ] Two check_hpjd fixes Message-ID: Patches item #1216576, was opened at 2005-06-07 17:44 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397599&aid=1216576&group_id=29880 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Bugfix Group: None Status: Open Resolution: None Priority: 5 Submitted By: Richard Brodie (leogah) Assigned to: Nobody/Anonymous (nobody) Summary: Two check_hpjd fixes Initial Comment: This patch fixes two problems in the check_hpjd plugin. Firstly, the OIDs for Paper Out and Paper Jam have been transposed. Both the HP MIB and reality seem to have them the other way. Secondly, some of the newer HP printers have a multiline status LCD (and send newline characters in the status text). ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397599&aid=1216576&group_id=29880 From greg.panula at lexisnexis.com Wed Jun 8 10:40:49 2005 From: greg.panula at lexisnexis.com (G. Panula) Date: Wed Jun 8 10:40:49 2005 Subject: [Nagiosplug-devel] check_file_age.pl patch Message-ID: <42A6C9AF.9020700@lexisnexis.com> Minor tweak that adds a switch(-n), if one doesn't want an error condition for "file not found". Attached text file has patch. greg -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: check_file_age-patch.txt URL: From awarkentin at dataarmor.net Wed Jun 8 10:40:53 2005 From: awarkentin at dataarmor.net (Andrey Warkentin) Date: Wed Jun 8 10:40:53 2005 Subject: [Nagiosplug-devel] Patch against check_disk_smb - fixes incorrect invocation of smclient. Message-ID: Hello, Here is a patch that fixes the check_disk_smb plugin from nagios-plugins-1.4 to correctly call smbclient. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: check_disk_smb.smbclient-args-patch Type: application/octet-stream Size: 1868 bytes Desc: not available URL: From awarkentin at dataarmor.net Wed Jun 8 10:40:55 2005 From: awarkentin at dataarmor.net (Andrey Warkentin) Date: Wed Jun 8 10:40:55 2005 Subject: [Nagiosplug-devel] RE: Patch against check_disk_smb - fixes incorrect invocation of smclient. Message-ID: Hello again. Here is a much better version that will work both with Samba 2.x.x and Samba 3.x.x. :-). -----Original Message----- From: Andrey Warkentin Sent: Wednesday, June 08, 2005 11:35 AM To: 'nagiosplug-devel at lists.sourceforge.net'; 'sghosh at users.sourceforge.net' Subject: Patch against check_disk_smb - fixes incorrect invocation of smclient. Hello, Here is a patch that fixes the check_disk_smb plugin from nagios-plugins-1.4 to correctly call smbclient. << File: check_disk_smb.smbclient-args-patch >> -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: check_disk_smb.smbclient-args-patch Type: application/octet-stream Size: 3008 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: check_disk_smb Type: application/octet-stream Size: 8377 bytes Desc: not available URL: From sghosh at sghosh.org Wed Jun 8 10:44:55 2005 From: sghosh at sghosh.org (Subhendu Ghosh) Date: Wed Jun 8 10:44:55 2005 Subject: [Nagiosplug-devel] RE: Patch against check_disk_smb - fixes incorrect invocation of smclient. In-Reply-To: References: Message-ID: Can you also post this on the tracker. Thanks. -sg > Hello again. > Here is a much better version that will work both with Samba 2.x.x and > Samba 3.x.x. :-). > -----Original Message----- > From: Andrey Warkentin > Sent: Wednesday, June 08, 2005 11:35 AM > To: 'nagiosplug-devel at lists.sourceforge.net'; > 'sghosh at users.sourceforge.net' > Subject: Patch against check_disk_smb - fixes incorrect invocation of > smclient. > Hello, > Here is a patch that fixes the check_disk_smb plugin from > nagios-plugins-1.4 to correctly call smbclient. > << File: check_disk_smb.smbclient-args-patch >> > -- From gavin at openfusion.com.au Wed Jun 8 17:41:17 2005 From: gavin at openfusion.com.au (Gavin Carr) Date: Wed Jun 8 17:41:17 2005 Subject: [Nagiosplug-devel] OF nagios plugins Message-ID: <20050609003703.GD1036@openfusion.com.au> Hi all, We've written a few perl nagios plugins that are available here: http://www.openfusion.com.au/labs/nagios/ in case they're of use to anyone else. They include: - check_yum/check_up2date, to check for outstanding updates - check_kernel_version, to check we're running the latest available linux kernel (RPMs only) - check_inodes, a check_disk workalike - check_linux_raid, a generalised version of contrib/check_linux_raid.pl - check_qmailq - based on contrib/check_qmailq.pl Feedback welcome. Cheers, Gavin From pla at softflare.com Wed Jun 8 18:24:03 2005 From: pla at softflare.com (Paul L. Allen) Date: Wed Jun 8 18:24:03 2005 Subject: [Nagiosplug-devel] Re: OF nagios plugins In-Reply-To: <20050609003703.GD1036@openfusion.com.au> References: <20050609003703.GD1036@openfusion.com.au> Message-ID: <20050609011652.31415.qmail@mullet.softflare.net> Gavin Carr writes: > - check_linux_raid, a generalised version of contrib/check_linux_raid.pl I had to hack that myself to deal with various things that /proc/mdstat did in more recent versions of Red Hat. It's late now (and I have applied several glasses of de-stressing fluid) so when I get time I'll check what you've done and see if I've done anything you've missed and try to merge it in. If that's too hard I'll send you mine and let you try to merge it in. :) > - check_qmailq - based on contrib/check_qmailq.pl At one point check_mailq added support for checking qmail queues. If it worked properly it would be better to use that rather than having a separate plugin to check qmail queues. Check_mailq added -W and -C options for checks on preprocessed messages as reported by qmail-qstat. Unfortunately, the way it used GetOpt::Long caused meant that -W and -C caused an error about about a conflict with -w and -W and a conflict with -c and -C with some versions of Getopt::Long. Even more unfortunately, I believe a patch was submitted to "fix" the problem by removing the -W and -C options. A better fix is to change -W and -C to (say) -p and -q. An even better fix is to add the line "use Getopt::Long::Configure('bundling') (which is how check_ntp manages to work with upper- and lower-case options with versions of Getopt::Long that check_qmailq barfs on). Another point with check_mailq is that the authors clearly tested it on a qmail installation that has Bruce Guenther's unofficial and unsanctioned qmail patches. In particular, the installation had the patch that allows unprivileged users to run qmail-qstat (technically, it replaces the qmail-qstat shell script with a script that connects to a privileged daemon). Installations that do not have the qmail-qstat patch will fail to work with check_mailq unless you setuid root on qmail-qstat or do some sudo magic. This is undocumented in the plugin, so if you don't have the patch (or haven't applied it because you don't want ordinary users to see the output of qmail-qstat) then check_mailq will fail and you won't know why it fails for you even though it apparently worked for the authors. If those problems are fixed then check_mailq is a better way of doing it. If only because it means somebody else is maintaining it and you don't have to. :) -- Paul Allen Softflare Support From gavin at openfusion.com.au Wed Jun 8 18:40:33 2005 From: gavin at openfusion.com.au (Gavin Carr) Date: Wed Jun 8 18:40:33 2005 Subject: [Nagiosplug-devel] Re: OF nagios plugins In-Reply-To: <20050609011652.31415.qmail@mullet.softflare.net> References: <20050609003703.GD1036@openfusion.com.au> <20050609011652.31415.qmail@mullet.softflare.net> Message-ID: <20050609013836.GA3392@openfusion.com.au> On Thu, Jun 09, 2005 at 02:16:52AM +0100, Paul L. Allen wrote: > Gavin Carr writes: > > - check_linux_raid, a generalised version of contrib/check_linux_raid.pl > > I had to hack that myself to deal with various things that /proc/mdstat > did in more recent versions of Red Hat. It's late now (and I have applied > several glasses of de-stressing fluid) so when I get time I'll check what > you've done and see if I've done anything you've missed and try to merge > it in. If that's too hard I'll send you mine and let you try to merge it > in. :) The main thing I was after was the ability to check _all_ raid devices, not to have to test them individually. The contrib one couldn't do that. > > - check_qmailq - based on contrib/check_qmailq.pl > > At one point check_mailq added support for checking qmail queues. If it > worked properly it would be better to use that rather than having a > separate plugin to check qmail queues. Check_mailq added -W and -C > options for checks on preprocessed messages as reported by qmail-qstat. > Unfortunately, the way it used GetOpt::Long caused meant that -W and -C > caused an error about about a conflict with -w and -W and a conflict with > -c and -C with some versions of Getopt::Long. Even more unfortunately, I > believe a patch was submitted to "fix" the problem by removing the -W and > -C options. A better fix is to change -W and -C to (say) -p and -q. An > even better fix is to add the line "use Getopt::Long::Configure('bundling') > (which is how check_ntp manages to work with upper- and lower-case options > with versions of Getopt::Long that check_qmailq barfs on). > > Another point with check_mailq is that the authors clearly tested it on a > qmail installation that has Bruce Guenther's unofficial and unsanctioned > qmail patches. In particular, the installation had the patch that allows > unprivileged users to run qmail-qstat (technically, it replaces the > qmail-qstat shell script with a script that connects to a privileged > daemon). Installations that do not have the qmail-qstat patch will fail to > work with check_mailq unless you setuid root on qmail-qstat or do some sudo > magic. This is undocumented in the plugin, so if you don't have the patch > (or haven't applied it because you don't want ordinary users to see the > output of qmail-qstat) then check_mailq will fail and you won't know why it > fails for you even though it apparently worked for the authors. Yeah, I tried check_mailq first, but couldn't get it to work. The problem I hit was that I'm typically using DAG's nagios-plugins RPM package, and that doesn't set $PATH_TO_QMAIL_QSTAT in utils.pm, which check_mailq requires. I gave up on it when I couldn't figure out a way to fix that on multiple machines cleanly. Hardcoded paths in libaries (except maybe as defaults) are way dumb! How about adding an etc/nagios/plugins.cfg for such things, so that sites can override site-local settings like that? > If those problems are fixed then check_mailq is a better way of doing it. > If only because it means somebody else is maintaining it and you don't have > to. :) Absolutely. :-) Cheers, Gavin From sghosh at sghosh.org Wed Jun 8 18:56:42 2005 From: sghosh at sghosh.org (Subhendu Ghosh) Date: Wed Jun 8 18:56:42 2005 Subject: [Nagiosplug-devel] Re: OF nagios plugins In-Reply-To: <20050609013836.GA3392@openfusion.com.au> References: <20050609003703.GD1036@openfusion.com.au> <20050609011652.31415.qmail@mullet.softflare.net> <20050609013836.GA3392@openfusion.com.au> Message-ID: On Thu, 9 Jun 2005, Gavin Carr wrote: > > Yeah, I tried check_mailq first, but couldn't get it to work. The problem > I hit was that I'm typically using DAG's nagios-plugins RPM package, and > that doesn't set $PATH_TO_QMAIL_QSTAT in utils.pm, which check_mailq requires. > I gave up on it when I couldn't figure out a way to fix that on multiple > machines cleanly. Hardcoded paths in libaries (except maybe as defaults) are > way dumb! How about adding an etc/nagios/plugins.cfg for such things, so > that sites can override site-local settings like that? > Having always done it the old-fashioned way, I never really thought about the rpms and the configure runtime-default-paths. It would be useful to add this to the general feature set as we look at transforming utils.pm into more of library of objects. -- -sg From gavin at openfusion.com.au Wed Jun 8 19:15:56 2005 From: gavin at openfusion.com.au (Gavin Carr) Date: Wed Jun 8 19:15:56 2005 Subject: [Nagiosplug-devel] Re: OF nagios plugins In-Reply-To: References: <20050609003703.GD1036@openfusion.com.au> <20050609011652.31415.qmail@mullet.softflare.net> <20050609013836.GA3392@openfusion.com.au> Message-ID: <20050609021112.GF3392@openfusion.com.au> On Wed, Jun 08, 2005 at 09:50:30PM -0400, Subhendu Ghosh wrote: > >Yeah, I tried check_mailq first, but couldn't get it to work. The problem > >I hit was that I'm typically using DAG's nagios-plugins RPM package, and > >that doesn't set $PATH_TO_QMAIL_QSTAT in utils.pm, which check_mailq > >requires. > >I gave up on it when I couldn't figure out a way to fix that on multiple > >machines cleanly. Hardcoded paths in libaries (except maybe as defaults) > >are > >way dumb! How about adding an etc/nagios/plugins.cfg for such things, so > >that sites can override site-local settings like that? > > > > Having always done it the old-fashioned way, I never really thought about > the rpms and the configure runtime-default-paths. Yeah, certainly separating out the runtime paths into a configuration file would be a good thing. > It would be useful to add this to the general feature set as we look at > transforming utils.pm into more of library of objects. Is this a TODO, or is something underway? Any info on what's planned? I'd be happy to help out if you're looking for any assistance. Cheers, Gavin From pla at softflare.com Wed Jun 8 19:32:40 2005 From: pla at softflare.com (Paul L. Allen) Date: Wed Jun 8 19:32:40 2005 Subject: [Nagiosplug-devel] Re: OF nagios plugins In-Reply-To: <20050609013836.GA3392@openfusion.com.au> References: <20050609003703.GD1036@openfusion.com.au> <20050609011652.31415.qmail@mullet.softflare.net> <20050609013836.GA3392@openfusion.com.au> Message-ID: <20050609022940.14659.qmail@mullet.softflare.net> Gavin Carr writes: > The main thing I was after was the ability to check _all_ raid devices, > not to have to test them individually. The contrib one couldn't do that. Ummm, I don't remember the contrib one having that problem. But it was a long time ago that I hacked it into something that worked for me. The things I remember were it didn't recognize some of the resynching states and didn't recognize some down states. If I remember correctly (it is now very, very late and I am completely de-stressed). > Yeah, I tried check_mailq first, but couldn't get it to work. The problem > I hit was that I'm typically using DAG's nagios-plugins RPM package, and > that doesn't set $PATH_TO_QMAIL_QSTAT in utils.pm, Yeah, I had that problem too, but I didn't do a full 1.4 install, just grabbed the plugin, so figured it was because I'd cheated. Actually, I think it also needs the path to the various utilities that qmail-qstat invokes (as I said, it's very late here, but I'm fairly sure that without that path it falls over, at least on any Red Hat release I've used it on). > I gave up on it when I couldn't figure out a way to fix that on multiple > machines cleanly. Hack utils.pm, copy over the hacked version after installing the plugins. That's what I do. It's not ideal, but it's not a major pain. > Hardcoded paths in libaries (except maybe as defaults) are > way dumb! It's not dumb if the makefile is smart enough to figure out the correct paths needed for each plugin. In that case it's much easier because the makefile only has to twiddle utils.pm instead of many plugins. > How about adding an etc/nagios/plugins.cfg for such things, so > that sites can override site-local settings like that? I don't see the point. That just adds extra overheads. If you can edit plugins.cfg to change paths you can edit utils.pm. Yeah, if you're building the plugins on different distros you might have to alter utils.pm on a per-distro basis, but the same would be true of plugins.cfg. The only way plugins.cfg would be useful is if any entries in it over-rode utils.pm. Then you could happily copy utils.pm everywhere and use plugins.cfg to over-ride it. But I still think having configure/Makefile do it automatically is a cleaner method because you're going to have to run those anyway if you're dealing with a different-from-normal distro/architecture. The real issue here is that some of the qmail stuff in check_mailq works only on the systems the authors have tested it on. No disrespect meant - until about a month ago I didn't know of the Bruce Guenther patch that made qmail-qstat usable by unprivileged users and none of our servers have it. If you don't have that then the pathing stuff, and the suexec or sudo stuff, becomes necessary. -- Paul Allen Softflare Support From sghosh at sghosh.org Wed Jun 8 19:59:50 2005 From: sghosh at sghosh.org (Subhendu Ghosh) Date: Wed Jun 8 19:59:50 2005 Subject: [Nagiosplug-devel] Re: OF nagios plugins In-Reply-To: <20050609021112.GF3392@openfusion.com.au> References: <20050609003703.GD1036@openfusion.com.au> <20050609011652.31415.qmail@mullet.softflare.net> <20050609013836.GA3392@openfusion.com.au> <20050609021112.GF3392@openfusion.com.au> Message-ID: On Thu, 9 Jun 2005, Gavin Carr wrote: > On Wed, Jun 08, 2005 at 09:50:30PM -0400, Subhendu Ghosh wrote: >>> Yeah, I tried check_mailq first, but couldn't get it to work. The problem >>> I hit was that I'm typically using DAG's nagios-plugins RPM package, and >>> that doesn't set $PATH_TO_QMAIL_QSTAT in utils.pm, which check_mailq >>> requires. >>> I gave up on it when I couldn't figure out a way to fix that on multiple >>> machines cleanly. Hardcoded paths in libaries (except maybe as defaults) >>> are >>> way dumb! How about adding an etc/nagios/plugins.cfg for such things, so >>> that sites can override site-local settings like that? >>> >> >> Having always done it the old-fashioned way, I never really thought about >> the rpms and the configure runtime-default-paths. > > Yeah, certainly separating out the runtime paths into a configuration > file would be a good thing. > >> It would be useful to add this to the general feature set as we look at >> transforming utils.pm into more of library of objects. > > Is this a TODO, or is something underway? Any info on what's planned? I'd > be happy to help out if you're looking for any assistance. > This is a TODO. If you want to take a stab at defining a class - perhaps Nagios::PUtil (Nagios is a registered CPAN namespace) and creating an autoload function that looks to see if the "etc/nagios/plugins.cfg" exists with defined values and over-write the values in utils.pm -- -sg From noreply at sourceforge.net Wed Jun 8 21:57:27 2005 From: noreply at sourceforge.net (SourceForge.net) Date: Wed Jun 8 21:57:27 2005 Subject: [Nagiosplug-devel] [ nagiosplug-Patches-1217379 ] Make check_disk_smb work with both Samba 2.x.x and Samba 3.x Message-ID: Patches item #1217379, was opened at 2005-06-09 06:55 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397599&aid=1217379&group_id=29880 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Bugfix Group: None Status: Open Resolution: None Priority: 5 Submitted By: Andrey Warkentin (sfcoder) Assigned to: Nobody/Anonymous (nobody) Summary: Make check_disk_smb work with both Samba 2.x.x and Samba 3.x Initial Comment: (As mailed to the dev list and to sghosh) Summary of problem: In Samba 3.x.x, smbclient takes server/share as a UNC path, unlike Samba 2.x.x. Summary of solution: Detect version and act accordingly. The solution has been tested with a Samba 2.x installation and with a Samba 3.x installation. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397599&aid=1217379&group_id=29880 From ae at op5.se Thu Jun 9 02:15:53 2005 From: ae at op5.se (Andreas Ericsson) Date: Thu Jun 9 02:15:53 2005 Subject: [Nagiosplug-devel] Re: OF nagios plugins In-Reply-To: <20050609011652.31415.qmail@mullet.softflare.net> References: <20050609003703.GD1036@openfusion.com.au> <20050609011652.31415.qmail@mullet.softflare.net> Message-ID: <42A807E6.5040001@op5.se> Paul L. Allen wrote: > Gavin Carr writes: > >> - check_linux_raid, a generalised version of contrib/check_linux_raid.pl > > > I had to hack that myself to deal with various things that /proc/mdstat > did in more recent versions of Red Hat. It's late now (and I have applied > several glasses of de-stressing fluid) so when I get time I'll check what > you've done and see if I've done anything you've missed and try to merge > it in. If that's too hard I'll send you mine and let you try to merge it > in. :) > >> - check_qmailq - based on contrib/check_qmailq.pl > > > At one point check_mailq added support for checking qmail queues. If it > worked properly it would be better to use that rather than having a > separate plugin to check qmail queues. Check_mailq added -W and -C > options for checks on preprocessed messages as reported by qmail-qstat. > Unfortunately, the way it used GetOpt::Long caused meant that -W and -C > caused an error about about a conflict with -w and -W -W is also reserved by POSIX for implementation extensions, according to the getopt(3) man page. Plugins using it are broken. > unprivileged users to run qmail-qstat (technically, it replaces the > qmail-qstat shell script with a script that connects to a privileged > daemon). Installations that do not have the qmail-qstat patch will fail to > work with check_mailq unless you setuid root on qmail-qstat or do some sudo > magic. sudo magic then, or suid the script interpreter. On most sane distributions scripts can't have +s. > This is undocumented in the plugin, so if you don't have the patch > (or haven't applied it because you don't want ordinary users to see the > output of qmail-qstat) then check_mailq will fail and you won't know why it > fails for you even though it apparently worked for the authors. > If those problems are fixed then check_mailq is a better way of doing it. > If only because it means somebody else is maintaining it and you don't have > to. :) And also to not double the efforts. Code duplication is a fairly stupid way of keeping people busy without accomplishing all that much. -- Andreas Ericsson andreas.ericsson at op5.se OP5 AB www.op5.se Lead Developer From gavin at openfusion.com.au Thu Jun 9 05:20:22 2005 From: gavin at openfusion.com.au (Gavin Carr) Date: Thu Jun 9 05:20:22 2005 Subject: [Nagiosplug-devel] Re: OF nagios plugins In-Reply-To: <20050609022940.14659.qmail@mullet.softflare.net> References: <20050609003703.GD1036@openfusion.com.au> <20050609011652.31415.qmail@mullet.softflare.net> <20050609013836.GA3392@openfusion.com.au> <20050609022940.14659.qmail@mullet.softflare.net> Message-ID: <20050609121615.GE4013@openfusion.com.au> On Thu, Jun 09, 2005 at 03:29:40AM +0100, Paul L. Allen wrote: > >I gave up on it when I couldn't figure out a way to fix that on multiple > >machines cleanly. > > Hack utils.pm, copy over the hacked version after installing the plugins. > That's what I do. It's not ideal, but it's not a major pain. Depends how many machines you're talking. And then a new version of nagios plugins is released, and all your customisations get wiped out. Hmmmm. > >Hardcoded paths in libaries (except maybe as defaults) are > >way dumb! > > It's not dumb if the makefile is smart enough to figure out the correct > paths needed for each plugin. In that case it's much easier because the > makefile only has to twiddle utils.pm instead of many plugins. Two problems with this: one, the smartest makefile in the world is still running at build time, not at install time. So with packages it captures the settings for the packager's system, not the installed system. Two, utils.pm is a library, so as above it gets upgraded with new versions and my customisations get wiped out. Sure such things should be abstracted, but into a config file of some kind that is explicitly not automatically upgraded. > >How about adding an etc/nagios/plugins.cfg for such things, so > >that sites can override site-local settings like that? > > I don't see the point. That just adds extra overheads. If you can edit > plugins.cfg to change paths you can edit utils.pm. Yeah, if you're > building the plugins on different distros you might have to alter utils.pm > on a per-distro basis, but the same would be true of plugins.cfg. The only > way plugins.cfg would be useful is if any entries in it over-rode utils.pm. > Then you could happily copy utils.pm everywhere and use plugins.cfg to > over-ride it. But I still think having configure/Makefile do it > automatically is a cleaner method because you're going to have to run those > anyway if you're dealing with a different-from-normal distro/architecture. Another part of the problem here is that for non-core things like qmail there often is no 'normal'. It might be installed in /usr, /usr/local, or in /var/qmail. You can try and define sensible defaults when building a package, but the installer must have the ability to override them. Cheers, Gavin From ae at op5.se Thu Jun 9 05:38:49 2005 From: ae at op5.se (Andreas Ericsson) Date: Thu Jun 9 05:38:49 2005 Subject: [Nagiosplug-devel] Re: OF nagios plugins In-Reply-To: <20050609121615.GE4013@openfusion.com.au> References: <20050609003703.GD1036@openfusion.com.au> <20050609011652.31415.qmail@mullet.softflare.net> <20050609013836.GA3392@openfusion.com.au> <20050609022940.14659.qmail@mullet.softflare.net> <20050609121615.GE4013@openfusion.com.au> Message-ID: <42A837A0.1050308@op5.se> Gavin Carr wrote: > On Thu, Jun 09, 2005 at 03:29:40AM +0100, Paul L. Allen wrote: > >>>I gave up on it when I couldn't figure out a way to fix that on multiple >>>machines cleanly. >> >>Hack utils.pm, copy over the hacked version after installing the plugins. >>That's what I do. It's not ideal, but it's not a major pain. > > > Depends how many machines you're talking. And then a new version of > nagios plugins is released, and all your customisations get wiped out. > Hmmmm. > man sed. If you're going to upgrade the plugin package you'll probably have it scripted anyway. I recommend sed 4.0.9 or later, as it supports in-place editing (-i flag) and makes such things a lot easier. > >>>Hardcoded paths in libaries (except maybe as defaults) are >>>way dumb! >> >>It's not dumb if the makefile is smart enough to figure out the correct >>paths needed for each plugin. In that case it's much easier because the >>makefile only has to twiddle utils.pm instead of many plugins. > > > Two problems with this: one, the smartest makefile in the world is still > running at build time, not at install time. So with packages it captures > the settings for the packager's system, not the installed system. > Performance would drop to around 50% if each plugin needs to look for the programs it's supposed to execute. Feel free to fork the nagiosplug project yourself if you don't like it. > Two, utils.pm is a library, so as above it gets upgraded with new versions > and my customisations get wiped out. Sure such things should be abstracted, > but into a config file of some kind that is explicitly not automatically > upgraded. > utils.pm is a bloody textfile. It might change, but variable names will not. man sed. Besides, what's the point of upgrading if things are already working fine? If you're just upgrading without needing/wanting any new features (or to get rid of bugs, obviously), you really should get yourself a hobby. > >>>How about adding an etc/nagios/plugins.cfg for such things, so >>>that sites can override site-local settings like that? >> >>I don't see the point. That just adds extra overheads. If you can edit >>plugins.cfg to change paths you can edit utils.pm. Yeah, if you're >>building the plugins on different distros you might have to alter utils.pm >>on a per-distro basis, but the same would be true of plugins.cfg. The only >>way plugins.cfg would be useful is if any entries in it over-rode utils.pm. >>Then you could happily copy utils.pm everywhere and use plugins.cfg to >>over-ride it. But I still think having configure/Makefile do it >>automatically is a cleaner method because you're going to have to run those >>anyway if you're dealing with a different-from-normal distro/architecture. > > > Another part of the problem here is that for non-core things like qmail > there often is no 'normal'. It might be installed in /usr, /usr/local, > or in /var/qmail. You can try and define sensible defaults when building > a package, but the installer must have the ability to override them. > I'm not sure, but I think you can. Try PATH_TO_QSTAT=/some/path ./configure (bash-like shell). configure.in will tell you if this should or shouldn't work. -- Andreas Ericsson andreas.ericsson at op5.se OP5 AB www.op5.se Lead Developer From gavin at openfusion.com.au Thu Jun 9 06:13:59 2005 From: gavin at openfusion.com.au (Gavin Carr) Date: Thu Jun 9 06:13:59 2005 Subject: [Nagiosplug-devel] Re: OF nagios plugins In-Reply-To: <42A837A0.1050308@op5.se> References: <20050609003703.GD1036@openfusion.com.au> <20050609011652.31415.qmail@mullet.softflare.net> <20050609013836.GA3392@openfusion.com.au> <20050609022940.14659.qmail@mullet.softflare.net> <20050609121615.GE4013@openfusion.com.au> <42A837A0.1050308@op5.se> Message-ID: <20050609130926.GG4013@openfusion.com.au> On Thu, Jun 09, 2005 at 02:35:44PM +0200, Andreas Ericsson wrote: > >>Hack utils.pm, copy over the hacked version after installing the plugins. > >>That's what I do. It's not ideal, but it's not a major pain. > > > >Depends how many machines you're talking. And then a new version of > >nagios plugins is released, and all your customisations get wiped out. > >Hmmmm. > > man sed. If you're going to upgrade the plugin package you'll probably > have it scripted anyway. I recommend sed 4.0.9 or later, as it supports > in-place editing (-i flag) and makes such things a lot easier. Sure, or perl, or patch for that matter. But all you're doing is automating a fix that shouldn't be required in the first place. There's a reason that the /etc tree exists - it's to separate configs from code. Check it out sometime. > >>It's not dumb if the makefile is smart enough to figure out the correct > >>paths needed for each plugin. In that case it's much easier because the > >>makefile only has to twiddle utils.pm instead of many plugins. > > > >Two problems with this: one, the smartest makefile in the world is still > >running at build time, not at install time. So with packages it captures > >the settings for the packager's system, not the installed system. > > Performance would drop to around 50% if each plugin needs to look for > the programs it's supposed to execute. Feel free to fork the nagiosplug > project yourself if you don't like it. No one's suggesting plugins do dynamic searches. I'm suggesting that the settings should live somewhere else than in a library. > >Two, utils.pm is a library, so as above it gets upgraded with new versions > >and my customisations get wiped out. Sure such things should be abstracted, > >but into a config file of some kind that is explicitly not automatically > >upgraded. > > utils.pm is a bloody textfile. It might change, but variable names will > not. man sed. Besides, what's the point of upgrading if things are > already working fine? If you're just upgrading without needing/wanting > any new features (or to get rid of bugs, obviously), you really should > get yourself a hobby. Wow, powerful argument - "I know, if upgrading breaks things, maybe don't upgrade." Wish I'd thought of that. -G From pla at softflare.com Thu Jun 9 06:41:25 2005 From: pla at softflare.com (Paul L. Allen) Date: Thu Jun 9 06:41:25 2005 Subject: [Nagiosplug-devel] Re: OF nagios plugins In-Reply-To: <20050609121615.GE4013@openfusion.com.au> References: <20050609003703.GD1036@openfusion.com.au> <20050609011652.31415.qmail@mullet.softflare.net> <20050609013836.GA3392@openfusion.com.au> <20050609022940.14659.qmail@mullet.softflare.net> <20050609121615.GE4013@openfusion.com.au> Message-ID: <20050609133842.30167.qmail@mullet.softflare.net> Gavin Carr writes: > On Thu, Jun 09, 2005 at 03:29:40AM +0100, Paul L. Allen wrote: >> Hack utils.pm, copy over the hacked version after installing the plugins. >> That's what I do. It's not ideal, but it's not a major pain. > > Depends how many machines you're talking. And then a new version of > nagios plugins is released, and all your customisations get wiped out. > Hmmmm. Hmmm indeed. Further on you talk about building on one machine and then copying the plugins to other machine. If you do it that way then instead of "build, copy" it becomes "build, hack utils.pm, copy." If you do a build and install on each machine then first you have to copy the tarball around anyway, so it's not that much harder to copy a hacked utils.pm around, and even easier if you have a tool that does these things for you. The most sensible way of doing it if you do a build and install on each machine is to first unpack the tarball, make your changes to utils.pm then repackage it with a variation on the tarball name to indicate it's a local modification. >> It's not dumb if the makefile is smart enough to figure out the correct >> paths needed for each plugin. In that case it's much easier because the >> makefile only has to twiddle utils.pm instead of many plugins. > > Two problems with this: one, the smartest makefile in the world is still > running at build time, not at install time. So with packages it captures > the settings for the packager's system, not the installed system. Some of us have to cope with different CPUs and different versions of OS and libraries. There's always a chance that the compiled code from an Intel 686 will have problems on AMD or Celeron. It's more than likely that code compiled on RHEL4 will not run on RH 7.3 because the libraries have changed (doing it the other way around should work because of the compatibility libraries in RHEL4). Unless you have a homogeneous set of machines one or other of those problems will eventually bite you. > Two, utils.pm is a library, so as above it gets upgraded with new versions > and my customisations get wiped out. Sure such things should be > abstracted, but into a config file of some kind that is explicitly not > automatically upgraded. That is a sensible reason for having an external config file if you have machines where the location of, say, qmail differs from box to box. -- Paul Allen Softflare Support From pla at softflare.com Thu Jun 9 07:44:16 2005 From: pla at softflare.com (Paul L. Allen) Date: Thu Jun 9 07:44:16 2005 Subject: [Nagiosplug-devel] Re: OF nagios plugins In-Reply-To: <42A807E6.5040001@op5.se> References: <20050609003703.GD1036@openfusion.com.au> <20050609011652.31415.qmail@mullet.softflare.net> <42A807E6.5040001@op5.se> Message-ID: <20050609144002.15480.qmail@mullet.softflare.net> Andreas Ericsson writes: > -W is also reserved by POSIX for implementation extensions, according to > the getopt(3) man page. Plugins using it are broken. In which case -W should be added to the list of reserved options in the Plugin Developer Guidelines. -- Paul Allen Softflare Support From ae at op5.se Thu Jun 9 09:43:48 2005 From: ae at op5.se (Andreas Ericsson) Date: Thu Jun 9 09:43:48 2005 Subject: [Nagiosplug-devel] Re: OF nagios plugins In-Reply-To: <20050609144002.15480.qmail@mullet.softflare.net> References: <20050609003703.GD1036@openfusion.com.au> <20050609011652.31415.qmail@mullet.softflare.net> <42A807E6.5040001@op5.se> <20050609144002.15480.qmail@mullet.softflare.net> Message-ID: <42A8710C.4060402@op5.se> Paul L. Allen wrote: > Andreas Ericsson writes: > >> -W is also reserved by POSIX for implementation extensions, according >> to the getopt(3) man page. Plugins using it are broken. > > > In which case -W should be added to the list of reserved options in the > Plugin Developer Guidelines. Why? I would have thought it fairly obvious that plugins should adhere to ANSI, POSIX, SUS and UNIX *prior* to whatever the guidelines says. Perhaps I'm wrong. Either way, feel free to patch. ;) -- Andreas Ericsson andreas.ericsson at op5.se OP5 AB www.op5.se Lead Developer From pla at softflare.com Thu Jun 9 10:05:59 2005 From: pla at softflare.com (Paul L. Allen) Date: Thu Jun 9 10:05:59 2005 Subject: [Nagiosplug-devel] Re: OF nagios plugins In-Reply-To: <42A8710C.4060402@op5.se> References: <20050609003703.GD1036@openfusion.com.au> <20050609011652.31415.qmail@mullet.softflare.net> <42A807E6.5040001@op5.se> <20050609144002.15480.qmail@mullet.softflare.net> <42A8710C.4060402@op5.se> Message-ID: <20050609170239.25988.qmail@mullet.softflare.net> Andreas Ericsson writes: > Paul L. Allen wrote: >> In which case -W should be added to the list of reserved options in the >> Plugin Developer Guidelines. > > Why? I would have thought it fairly obvious that plugins should adhere to > ANSI, POSIX, SUS and UNIX *prior* to whatever the guidelines says. Not everyone knows all of those things in as much detail as you do. I'd expect most people here were surprised to learn of POSIX's -W. Even if the number of people who already knew of -W is a lot higher than I thought, one day somebody who doesn't know of -W's POSIX usage will write a plugin that follows everything in the guidelines but happens to use -W because it's not mentioned as reserved. The plugin will be submitted, then you'll point out that -W is reserved for POSIX, then a patch may eventually be submitted, then the developers will say the patch has been committed, then somebody will ask what's wrong with -W and if it is reserved by POSIX why don't the guidelines mention it, then you'll say it's obvious, then... It may be redundant information to the few people who have read every line of source code in Linux but it cuts down on potential list traffic if the guidelines mention it. In the end it's up to the core developers to decide whether or not -W and any others like it, should be mentioned. -- Paul Allen Softflare Support From ae at op5.se Thu Jun 9 10:09:27 2005 From: ae at op5.se (Andreas Ericsson) Date: Thu Jun 9 10:09:27 2005 Subject: [Nagiosplug-devel] Re: OF nagios plugins In-Reply-To: <20050609130926.GG4013@openfusion.com.au> References: <20050609003703.GD1036@openfusion.com.au> <20050609011652.31415.qmail@mullet.softflare.net> <20050609013836.GA3392@openfusion.com.au> <20050609022940.14659.qmail@mullet.softflare.net> <20050609121615.GE4013@openfusion.com.au> <42A837A0.1050308@op5.se> <20050609130926.GG4013@openfusion.com.au> Message-ID: <42A876BB.9020203@op5.se> Gavin Carr wrote: > On Thu, Jun 09, 2005 at 02:35:44PM +0200, Andreas Ericsson wrote: > >>>>Hack utils.pm, copy over the hacked version after installing the plugins. >>>>That's what I do. It's not ideal, but it's not a major pain. >>> >>>Depends how many machines you're talking. And then a new version of >>>nagios plugins is released, and all your customisations get wiped out. >>>Hmmmm. >> >>man sed. If you're going to upgrade the plugin package you'll probably >>have it scripted anyway. I recommend sed 4.0.9 or later, as it supports >>in-place editing (-i flag) and makes such things a lot easier. > > > Sure, or perl, or patch for that matter. But all you're doing is automating > a fix that shouldn't be required in the first place. There's a reason that > the /etc tree exists - it's to separate configs from code. Check it out > sometime. > Now you're being just a tad silly. Seeing as you're the first to bring this up I'd say you should either submit a patch and hope the maintainers accepts it, fork the plugins so you can do whatever you want, or just calmly accept that what one person wants ten others would hate, and none would work to implement. > >>>>It's not dumb if the makefile is smart enough to figure out the correct >>>>paths needed for each plugin. In that case it's much easier because the >>>>makefile only has to twiddle utils.pm instead of many plugins. >>> >>>Two problems with this: one, the smartest makefile in the world is still >>>running at build time, not at install time. So with packages it captures >>>the settings for the packager's system, not the installed system. >> >>Performance would drop to around 50% if each plugin needs to look for >>the programs it's supposed to execute. Feel free to fork the nagiosplug >>project yourself if you don't like it. > > > No one's suggesting plugins do dynamic searches. I'm suggesting that the > settings should live somewhere else than in a library. > The difference of looking for it in a text-file as opposed to doing a path-wide search is not that large actually. If there are many external commands the pathwide search would be faster. And again, utils.pm is not a library, it's a perl-style configuration file. -- Andreas Ericsson andreas.ericsson at op5.se OP5 AB www.op5.se Lead Developer From ae at op5.se Thu Jun 9 10:18:07 2005 From: ae at op5.se (Andreas Ericsson) Date: Thu Jun 9 10:18:07 2005 Subject: [Nagiosplug-devel] Re: OF nagios plugins In-Reply-To: <20050609170239.25988.qmail@mullet.softflare.net> References: <20050609003703.GD1036@openfusion.com.au> <20050609011652.31415.qmail@mullet.softflare.net> <42A807E6.5040001@op5.se> <20050609144002.15480.qmail@mullet.softflare.net> <42A8710C.4060402@op5.se> <20050609170239.25988.qmail@mullet.softflare.net> Message-ID: <42A878A2.60203@op5.se> Paul L. Allen wrote: > Andreas Ericsson writes: > >> Paul L. Allen wrote: > > >>> In which case -W should be added to the list of reserved options in the >>> Plugin Developer Guidelines. >> >> >> Why? I would have thought it fairly obvious that plugins should adhere >> to ANSI, POSIX, SUS and UNIX *prior* to whatever the guidelines says. > > > Not everyone knows all of those things in as much detail as you do. I'd > expect most people here were surprised to learn of POSIX's -W. > Even if the number of people who already knew of -W is a lot higher than I > thought, one day somebody who doesn't know of -W's POSIX usage will write > a plugin that follows everything in the guidelines but happens to use -W > because it's not mentioned as reserved. The plugin will be submitted, > then you'll point out that -W is reserved for POSIX, then a patch may > eventually be submitted, then the developers will say the patch has been > committed, then somebody will ask what's wrong with -W and if it is > reserved by POSIX why don't the guidelines mention it, then you'll say > it's obvious, then... It may be redundant information to the few people > who have read every line of source code in Linux but it cuts down on > potential list traffic if the guidelines mention it. > In the end it's up to the core developers to decide whether or not -W > and any others like it, should be mentioned. True. I'll see what I can do to get it in there. -- Andreas Ericsson andreas.ericsson at op5.se OP5 AB www.op5.se Lead Developer From ae at op5.se Fri Jun 10 03:20:38 2005 From: ae at op5.se (Andreas Ericsson) Date: Fri Jun 10 03:20:38 2005 Subject: [Nagiosplug-devel] Obsoleted contrib and tarballs files Message-ID: <42A968A4.2010503@op5.se> Just a heads up.. I've been doing a "shallow audit" of the contrib and tarballs stuff in the nagiosplug CVS. In the tarballs directory, the following files are obsolete; berger-ping.tar.gz, There's already 2 ping programs, do we need another? check_memory.tar.gz (won't work on recent platforms, and can easily be replaced by forking check_swap() and using it for memory checks). check_spread.tar, won't compile, poorly documented, no build instructions. check_traffic-0.91b.tar.gz, I've improved greatly on this and intend to submit a patch to make it one of the standard plugins. radius.tar.gz, the same files are distributed with the radiusclient distribution. In the contrib directory; check_logins (obsoleted by the near-identical check_users) check_procl, check_procr; the same functionality can be obtained by check_procs. check_pop3.pl - check_tcp provides better functionality check_nwstat.pl - check_nwstat provides better functionality check_ftpget.pl - highly insecure (I can hack up a C version in about 10 minutes if anyone's actually interested, without using local files). check_dl_size.pl - see check_ftpget.pl. somewhat obsoleted by check_http. check_rbl.c, rblcheck* - abusive and cause for black-listing (which is funny, since they check for blacklisted domains) check_mem.pl - easily obsoleted by a fork of check_swap (or __progname logic). check_timeout.c - should really be in nagios/testing of the nagios core distribution, or dropped completely. check_mysql.c, check_mysql.pl, check_mysqlslave.pl - obsoleted by plugins/check_mysql.c (which is cleaner and has more features). There are most certainly more, but I grew disgusted and gave up. -- Andreas Ericsson andreas.ericsson at op5.se OP5 AB www.op5.se Lead Developer From elliott at commscope.com Fri Jun 10 05:19:53 2005 From: elliott at commscope.com (elliott at commscope.com) Date: Fri Jun 10 05:19:53 2005 Subject: [Nagiosplug-devel] Proxy Plugin in Perl In-Reply-To: <20050610031356.6BCB4892E2@sc8-sf-spam1.sourceforge.net> Message-ID: Hi All, I have been in the process of developing a proxy plugin in perl that communicates with a fairly extensible agent that I wrote (also in perl) that runs commands on remote hosts, caches the results and replies to the nagios servers requests. Currently I do alot on solaris 2.8 and 2.9, but it would be easily extensible to others. Any interest? -------------- next part -------------- An HTML attachment was scrubbed... URL: From ae at op5.se Fri Jun 10 06:24:15 2005 From: ae at op5.se (Andreas Ericsson) Date: Fri Jun 10 06:24:15 2005 Subject: [Nagiosplug-devel] np_runcmd framework Message-ID: <42A99342.9080905@op5.se> Ahoy. I've completed the np_runcmd framework and tested it on Linux (FC3 and Owl-current) and FreeBSD. It seems to work splendidly, providing a slight speedup for some things and quite a bit smaller code. Also included in this patch is a major cleanup and overhaul for check_hpjd. I haven't been able to test it as I don't have a hpjd printer, but the theory behind it is sound and I'm confident it will work as expected. It reduces the LOC count by about 100 lines (25%) and uses more portable and easier to parse snmpget syntax. As I don't have cvs commit access I was forced to fork this off into a repository of my own (hence all the $Id: $ updates in the diff). I will keep working on that repository and see what possibilities there are for backsyncing with the official project. Sorry about that, but my work-description includes fixing and improving on the plugins and the number of patches I had to keep track of quickly turned out to be unmanagable without an SCM where I could commit things occasionally. I'll add this to the tracker as well (*sigh*). -- Andreas Ericsson andreas.ericsson at op5.se OP5 AB www.op5.se Lead Developer -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: nagiosplug-runcmd.diff URL: From ae at op5.se Fri Jun 10 06:33:50 2005 From: ae at op5.se (Andreas Ericsson) Date: Fri Jun 10 06:33:50 2005 Subject: [Nagiosplug-devel] np_runcmd framework In-Reply-To: <42A99342.9080905@op5.se> References: <42A99342.9080905@op5.se> Message-ID: <42A99562.6030300@op5.se> Just a thought; This patch requires the nagiosplug-common_h-sanity.diff I sent in a week or so ago. One of the problems of maintaining and testing with a separate CVS repository, I suppose. Cheers. Andreas Ericsson wrote: > Ahoy. > > I've completed the np_runcmd framework and tested it on Linux (FC3 and > Owl-current) and FreeBSD. It seems to work splendidly, providing a > slight speedup for some things and quite a bit smaller code. > > Also included in this patch is a major cleanup and overhaul for > check_hpjd. I haven't been able to test it as I don't have a hpjd > printer, but the theory behind it is sound and I'm confident it will > work as expected. It reduces the LOC count by about 100 lines (25%) and > uses more portable and easier to parse snmpget syntax. > > As I don't have cvs commit access I was forced to fork this off into a > repository of my own (hence all the $Id: $ updates in the diff). I will > keep working on that repository and see what possibilities there are for > backsyncing with the official project. Sorry about that, but my > work-description includes fixing and improving on the plugins and the > number of patches I had to keep track of quickly turned out to be > unmanagable without an SCM where I could commit things occasionally. > > I'll add this to the tracker as well (*sigh*). > > > ------------------------------------------------------------------------ > > diff -urN ../nplg/plugins/check_by_ssh.c ./plugins/check_by_ssh.c > --- ../nplg/plugins/check_by_ssh.c 2005-01-05 21:53:11.000000000 +0100 > +++ ./plugins/check_by_ssh.c 2005-06-10 15:01:26.000000000 +0200 > @@ -14,19 +14,19 @@ > along with this program; if not, write to the Free Software > Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. > > - $Id: check_by_ssh.c,v 1.35 2004/12/25 12:09:19 opensides Exp $ > + $Id: check_by_ssh.c,v 1.3 2005/06/06 11:37:06 exon Exp $ > > *****************************************************************************/ > > const char *progname = "check_by_ssh"; > -const char *revision = "$Revision: 1.35 $"; > +const char *revision = "$Revision: 1.3 $"; > const char *copyright = "2000-2004"; > const char *email = "nagiosplug-devel at lists.sourceforge.net"; > > #include "common.h" > #include "netutils.h" > #include "utils.h" > -#include "popen.h" > +#include "runcmd.h" > > int process_arguments (int, char **); > int validate_arguments (void); > @@ -49,15 +49,15 @@ > main (int argc, char **argv) > { > > - char input_buffer[MAX_INPUT_BUFFER]; > char *result_text; > char *status_text; > - char *output; > + char *msg; > char *eol = NULL; > int cresult; > int result = STATE_UNKNOWN; > time_t local_time; > FILE *fp = NULL; > + struct output chld_out, chld_err; > > remotecmd = strdup (""); > comm = strdup (SSH_COMMAND); > @@ -82,48 +82,22 @@ > if (verbose) > printf ("%s\n", comm); > > - child_process = spopen (comm); > - > - if (child_process == NULL) { > - printf (_("Could not open pipe: %s\n"), comm); > - return STATE_UNKNOWN; > - } > - > - > - /* open STDERR for spopen */ > - child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); > - if (child_stderr == NULL) { > - printf (_("Could not open stderr for %s\n"), SSH_COMMAND); > - } > - > + result = np_runcmd(comm, &chld_out, &chld_err, 0); > > /* build up results from remote command in result_text */ > - while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) > - asprintf (&result_text, "%s%s", result_text, input_buffer); > + if(skip_lines && skip_lines < chld_out.lines) > + result_text = chld_out.line[skip_lines]; > + else > + result_text = chld_out.line[0]; > > /* WARNING if output found on stderr */ > - while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) { > - if (skip_lines > 0) { > - if (input_buffer[strlen(input_buffer)-1] == '\n') { > - skip_lines--; > - } > - } else { > - printf ("%s", input_buffer); > - result = STATE_WARNING; > - } > + if(chld_err.buflen) { > + printf("%s\n", chld_err.line[0]); > + return STATE_WARNING; > } > - (void) fclose (child_stderr); > - if (result == STATE_WARNING) > - return result; > - > - > - /* close the pipe */ > - result = spclose (child_process); > - > > /* process output */ > if (passive) { > - > if (!(fp = fopen (outputfile, "a"))) { > printf (_("SSH WARNING: could not open %s\n"), outputfile); > exit (STATE_UNKNOWN); > @@ -137,19 +111,19 @@ > printf ("%s", result_text); > return result; > } > - asprintf (&output, "%s", result_text); > + asprintf (&msg, "%s", result_text); > result_text = strnl (status_text); > - eol = strpbrk (output, "\r\n"); > + eol = strpbrk (msg, "\r\n"); > if (eol != NULL) > eol[0] = 0; > if (service[commands] && status_text > - && sscanf (status_text, "STATUS CODE: %d", &cresult) == 1) { > + && sscanf (status_text, "STATUS CODE: %d", &cresult) == 1) > + { > fprintf (fp, "[%d] PROCESS_SERVICE_CHECK_RESULT;%s;%s;%d;%s\n", > - (int) local_time, host_shortname, service[commands++], cresult, > - output); > + (int) local_time, host_shortname, service[commands++], > + cresult, msg); > } > } > - > } > > > @@ -206,7 +180,7 @@ > > while (1) { > c = getopt_long (argc, argv, "Vvh1246ft:H:O:p:i:u:l:C:S:n:s:", longopts, > - &option); > + &option); > > if (c == -1 || c == EOF) > break; > @@ -244,25 +218,27 @@ > passive = TRUE; > break; > case 's': /* description of service to check */ > - service = realloc (service, (++services) * sizeof(char *)); > p1 = optarg; > + service = realloc (service, (++services) * sizeof(char *)); > while ((p2 = index (p1, ':'))) { > *p2 = '\0'; > - asprintf (&service[services-1], "%s", p1); > + service[services - 1] = p1; > service = realloc (service, (++services) * sizeof(char *)); > p1 = p2 + 1; > } > - asprintf (&service[services-1], "%s", p1); > + service[services - 1] = p1; > break; > case 'n': /* short name of host in nagios configuration */ > host_shortname = optarg; > break; > + > case 'u': > c = 'l'; > case 'l': /* login name */ > case 'i': /* identity */ > asprintf (&comm, "%s -%c %s", comm, c, optarg); > break; > + > case '1': /* Pass these switches directly to ssh */ > case '2': /* 1 to force version 1, 2 to force version 2 */ > case '4': /* -4 for IPv4 */ > diff -urN ../nplg/plugins/check_dig.c ./plugins/check_dig.c > --- ../nplg/plugins/check_dig.c 2005-01-28 15:00:58.000000000 +0100 > +++ ./plugins/check_dig.c 2005-06-10 15:01:26.000000000 +0200 > @@ -14,29 +14,33 @@ > along with this program; if not, write to the Free Software > Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. > > - $Id: check_dig.c,v 1.40 2005/01/26 21:21:01 tonvoon Exp $ > + $Id: check_dig.c,v 1.3 2005/06/06 11:37:06 exon Exp $ > > *****************************************************************************/ > > +/* Hackers note: > + * There are typecasts to (char *) from _("foo bar") in this file. > + * They prevent compiler warnings. Never (ever), permute strings obtained > + * that are typecast from (const char *) (which happens when --disable-nls) > + * because on some architectures those strings are in non-writable memory */ > + > const char *progname = "check_dig"; > -const char *revision = "$Revision: 1.40 $"; > +const char *revision = "$Revision: 1.3 $"; > const char *copyright = "2002-2004"; > const char *email = "nagiosplug-devel at lists.sourceforge.net"; > > #include "common.h" > #include "netutils.h" > #include "utils.h" > -#include "popen.h" > +#include "runcmd.h" > > int process_arguments (int, char **); > int validate_arguments (void); > void print_help (void); > void print_usage (void); > > -enum { > - UNDEFINED = 0, > - DEFAULT_PORT = 53 > -}; > +#define UNDEFINED 0 > +#define DEFAULT_PORT 53 > > char *query_address = NULL; > char *record_type = "A"; > @@ -51,16 +55,15 @@ > int > main (int argc, char **argv) > { > - char input_buffer[MAX_INPUT_BUFFER]; > char *command_line; > - char *output; > + output chld_out, chld_err; > + char *msg = NULL; > + size_t i; > char *t; > long microsec; > double elapsed_time; > int result = STATE_UNKNOWN; > > - output = strdup (""); > - > setlocale (LC_ALL, ""); > bindtextdomain (PACKAGE, LOCALEDIR); > textdomain (PACKAGE); > @@ -89,100 +92,75 @@ > } > > /* run the command */ > - child_process = spopen (command_line); > - if (child_process == NULL) { > - printf (_("Could not open pipe: %s\n"), command_line); > - return STATE_UNKNOWN; > + if((result = np_runcmd(command_line, &chld_out, &chld_err, 0)) != 0) { > + result = STATE_WARNING; > + msg = (char *)_("dig returned an error status"); > } > > - child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); > - if (child_stderr == NULL) > - printf (_("Could not open stderr for %s\n"), command_line); > - > - while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) { > - > + for(i = 0; i < chld_out.lines; i++) { > /* the server is responding, we just got the host name... */ > - if (strstr (input_buffer, ";; ANSWER SECTION:")) { > + if (strstr (chld_out.line[i], ";; ANSWER SECTION:")) { > > /* loop through the whole 'ANSWER SECTION' */ > - do { > + for(; i < chld_out.lines; i++) { > /* get the host address */ > - if (!fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) > - break; > - > - if (strpbrk (input_buffer, "\r\n")) > - input_buffer[strcspn (input_buffer, "\r\n")] = '\0'; > + if (verbose) > + printf ("%s\n", chld_out.line[i]); > > - if (verbose && !strstr (input_buffer, ";; ")) > - printf ("%s\n", input_buffer); > - > - if (expected_address==NULL && strstr (input_buffer, query_address) != NULL) { > - output = strdup(input_buffer); > + if (strstr (chld_out.line[i], (expected_address == NULL ? query_address : expected_address)) != NULL) { > + msg = chld_out.line[i]; > result = STATE_OK; > - } > - else if (expected_address != NULL && strstr (input_buffer, expected_address) != NULL) { > - output = strdup(input_buffer); > - result = STATE_OK; > - } > > - /* Translate output TAB -> SPACE */ > - t = output; > - while ((t = index(t, '\t')) != NULL) > - *t = ' '; > - > - } while (!strstr (input_buffer, ";; ")); > + /* Translate output TAB -> SPACE */ > + t = msg; > + while ((t = strchr(t, '\t')) != NULL) *t = ' '; > + break; > + } > + } > > if (result == STATE_UNKNOWN) { > - asprintf (&output, _("Server not found in ANSWER SECTION")); > - result = STATE_WARNING; > - } > - } > - > - } > - > - if (result == STATE_UNKNOWN) { > - asprintf (&output, _("No ANSWER SECTION found")); > - } > + msg = (char *)_("Server not found in ANSWER SECTION"); > + result = STATE_WARNING; > + } > > - while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) { > - /* If we get anything on STDERR, at least set warning */ > - result = max_state (result, STATE_WARNING); > - printf ("%s", input_buffer); > - if (strlen (output) == 0) > - output = strdup (1 + index (input_buffer, ':')); > + /* we found the answer section, so break out of the loop */ > + break; > + } > } > > - (void) fclose (child_stderr); > + if (result == STATE_UNKNOWN) > + msg = (char *)_("No ANSWER SECTION found"); > > - /* close the pipe */ > - if (spclose (child_process)) { > - result = max_state (result, STATE_WARNING); > - if (strlen (output) == 0) > - asprintf (&output, _("dig returned an error status")); > + /* If we get anything on STDERR, at least set warning */ > + if(chld_err.buflen > 0) { > + result = max_state(result, STATE_WARNING); > + if(!msg) for(i = 0; i < chld_err.lines; i++) { > + msg = strchr(chld_err.line[0], ':'); > + if(msg) { > + msg++; > + break; > + } > + } > } > > microsec = deltime (tv); > elapsed_time = (double)microsec / 1.0e6; > > - if (output == NULL || strlen (output) == 0) > - asprintf (&output, _(" Probably a non-existent host/domain")); > - > if (critical_interval > UNDEFINED && elapsed_time > critical_interval) > result = STATE_CRITICAL; > > else if (warning_interval > UNDEFINED && elapsed_time > warning_interval) > result = STATE_WARNING; > > - asprintf (&output, _("%.3f seconds response time (%s)"), elapsed_time, output); > - > - printf ("DNS %s - %s|%s\n", > - state_text (result), output, > + printf ("DNS %s - %.3f seconds response time (%s)|%s\n", > + state_text (result), elapsed_time, > + msg ? msg : _("Probably a non-existent host/domain"), > fperfdata("time", elapsed_time, "s", > - (warning_interval>UNDEFINED?TRUE:FALSE), > - warning_interval, > - (critical_interval>UNDEFINED?TRUE:FALSE), > - critical_interval, > - TRUE, 0, FALSE, 0)); > + (warning_interval>UNDEFINED?TRUE:FALSE), > + warning_interval, > + (critical_interval>UNDEFINED?TRUE:FALSE), > + critical_interval, > + TRUE, 0, FALSE, 0)); > return result; > } > > @@ -359,6 +337,6 @@ > { > printf ("\ > Usage: %s -H host -l lookup [-p ] [-T ]\n\ > - [-w ] [-c ] [-t ]\n\ > - [-a ] [-v]\n", progname); > + [-w ] [-c ] [-t ]\n\ > + [-a ] [-v]\n", progname); > } > diff -urN ../nplg/plugins/check_dns.c ./plugins/check_dns.c > --- ../nplg/plugins/check_dns.c 2005-01-05 21:53:12.000000000 +0100 > +++ ./plugins/check_dns.c 2005-06-10 15:01:26.000000000 +0200 > @@ -17,19 +17,19 @@ > LIMITATION: nslookup on Solaris 7 can return output over 2 lines, which will not > be picked up by this plugin > > - $Id: check_dns.c,v 1.47 2004/12/30 00:41:39 opensides Exp $ > + $Id: check_dns.c,v 1.3 2005/06/06 11:37:06 exon Exp $ > > ******************************************************************************/ > > const char *progname = "check_dns"; > -const char *revision = "$Revision: 1.47 $"; > +const char *revision = "$Revision: 1.3 $"; > const char *copyright = "2000-2004"; > const char *email = "nagiosplug-devel at lists.sourceforge.net"; > > #include "common.h" > -#include "popen.h" > #include "utils.h" > #include "netutils.h" > +#include "runcmd.h" > > int process_arguments (int, char **); > int validate_arguments (void); > @@ -51,8 +51,8 @@ > { > char *command_line = NULL; > char input_buffer[MAX_INPUT_BUFFER]; > - char *output = NULL; > char *address = NULL; > + char *msg = NULL; > char *temp_buffer = NULL; > int non_authoritative = FALSE; > int result = STATE_UNKNOWN; > @@ -61,6 +61,8 @@ > struct timeval tv; > int multi_address; > int parse_address = FALSE; /* This flag scans for Address: but only after Name: */ > + output chld_out, chld_err; > + size_t i; > > setlocale (LC_ALL, ""); > bindtextdomain (PACKAGE, LOCALEDIR); > @@ -85,37 +87,31 @@ > printf ("%s\n", command_line); > > /* run the command */ > - child_process = spopen (command_line); > - if (child_process == NULL) { > - printf (_("Could not open pipe: %s\n"), command_line); > - return STATE_UNKNOWN; > + if((np_runcmd(command_line, &chld_out, &chld_err, 0)) != 0) { > + msg = (char *)_("nslookup returned error status"); > + result = STATE_WARNING; > } > > - child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); > - if (child_stderr == NULL) > - printf (_("Could not open stderr for %s\n"), command_line); > - > /* scan stdout */ > - while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) { > - > + for(i = 0; i < chld_out.lines; i++) { > if (verbose) > - printf ("%s", input_buffer); > + printf ("%s", chld_out.line[i]); > > - if (strstr (input_buffer, ".in-addr.arpa")) { > - if ((temp_buffer = strstr (input_buffer, "name = "))) > + if (strstr (chld_out.line[i], ".in-addr.arpa")) { > + if ((temp_buffer = strstr (chld_out.line[i], "name = "))) > address = strdup (temp_buffer + 7); > else { > - output = strdup (_("Warning plugin error")); > + msg = (char *)_("Warning plugin error"); > result = STATE_WARNING; > } > } > > /* the server is responding, we just got the host name... */ > - if (strstr (input_buffer, "Name:")) > + if (strstr (chld_out.line[i], "Name:")) > parse_address = TRUE; > - else if (parse_address == TRUE && (strstr (input_buffer, "Address:") || > - strstr (input_buffer, "Addresses:"))) { > - temp_buffer = index (input_buffer, ':'); > + else if (parse_address == TRUE && (strstr (chld_out.line[i], "Address:") || > + strstr (chld_out.line[i], "Addresses:"))) { > + temp_buffer = index (chld_out.line[i], ':'); > temp_buffer++; > > /* Strip leading spaces */ > @@ -135,59 +131,47 @@ > asprintf(&address, "%s,%s", address, temp_buffer); > } > > - else if (strstr (input_buffer, _("Non-authoritative answer:"))) { > + else if (strstr (chld_out.line[i], _("Non-authoritative answer:"))) { > non_authoritative = TRUE; > } > > - result = error_scan (input_buffer); > + result = error_scan (chld_out.line[i]); > if (result != STATE_OK) { > - output = strdup (1 + index (input_buffer, ':')); > - strip (output); > + msg = strchr (chld_out.line[i], ':'); > + if(msg) msg++; > break; > } > - > } > > /* scan stderr */ > - while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) { > - > + for(i = 0; i < chld_err.lines; i++) { > if (verbose) > - printf ("%s", input_buffer); > + printf ("%s", chld_err.line[i]); > > - if (error_scan (input_buffer) != STATE_OK) { > - result = max_state (result, error_scan (input_buffer)); > - output = strdup (1 + index (input_buffer, ':')); > - strip (output); > + if (error_scan (chld_err.line[i]) != STATE_OK) { > + result = max_state (result, error_scan (chld_err.line[i])); > + msg = strchr(input_buffer, ':'); > + if(msg) msg++; > } > } > > - /* close stderr */ > - (void) fclose (child_stderr); > - > - /* close stdout */ > - if (spclose (child_process)) { > - result = max_state (result, STATE_WARNING); > - if (output == NULL || !strcmp (output, "")) > - output = strdup (_("nslookup returned error status")); > - } > - > - /* If we got here, we should have an address string, > - and we can segfault if we do not */ > + /* If we got here, we should have an address string, > + * and we can segfault if we do not */ > if (address==NULL || strlen(address)==0) > die (STATE_CRITICAL, > - _("DNS CRITICAL - '%s' output parsing exited with no address\n"), > + _("DNS CRITICAL - '%s' msg parsing exited with no address\n"), > NSLOOKUP_COMMAND); > > /* compare to expected address */ > if (result == STATE_OK && match_expected_address && strcmp(address, expected_address)) { > result = STATE_CRITICAL; > - asprintf(&output, _("expected %s but got %s"), expected_address, address); > + asprintf(&msg, _("expected %s but got %s"), expected_address, address); > } > > /* check if authoritative */ > if (result == STATE_OK && expect_authority && non_authoritative) { > result = STATE_CRITICAL; > - asprintf(&output, _("server %s is not authoritative for %s"), dns_server, query_address); > + asprintf(&msg, _("server %s is not authoritative for %s"), dns_server, query_address); > } > > microsec = deltime (tv); > @@ -206,13 +190,13 @@ > } > else if (result == STATE_WARNING) > printf (_("DNS WARNING - %s\n"), > - !strcmp (output, "") ? _(" Probably a non-existent host/domain") : output); > + !strcmp (msg, "") ? _(" Probably a non-existent host/domain") : msg); > else if (result == STATE_CRITICAL) > printf (_("DNS CRITICAL - %s\n"), > - !strcmp (output, "") ? _(" Probably a non-existent host/domain") : output); > + !strcmp (msg, "") ? _(" Probably a non-existent host/domain") : msg); > else > printf (_("DNS UNKNOW - %s\n"), > - !strcmp (output, "") ? _(" Probably a non-existent host/domain") : output); > + !strcmp (msg, "") ? _(" Probably a non-existent host/domain") : msg); > > return result; > } > diff -urN ../nplg/plugins/check_fping.c ./plugins/check_fping.c > --- ../nplg/plugins/check_fping.c 2005-01-05 21:53:13.000000000 +0100 > +++ ./plugins/check_fping.c 2005-06-10 15:01:26.000000000 +0200 > @@ -14,26 +14,24 @@ > along with this program; if not, write to the Free Software > Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. > > - $Id: check_fping.c,v 1.24 2004/12/25 23:17:44 opensides Exp $ > + $Id: check_fping.c,v 1.2 2005/06/05 21:55:26 exon Exp $ > > ******************************************************************************/ > > const char *progname = "check_fping"; > -const char *revision = "$Revision: 1.24 $"; > +const char *revision = "$Revision: 1.2 $"; > const char *copyright = "2000-2004"; > const char *email = "nagiosplug-devel at lists.sourceforge.net"; > > #include "common.h" > -#include "popen.h" > #include "netutils.h" > #include "utils.h" > +#include "runcmd.h" > > -enum { > - PACKET_COUNT = 1, > - PACKET_SIZE = 56, > - PL = 0, > - RTA = 1 > -}; > +#define PACKET_COUNT 1 > +#define PACKET_SIZE 56 > +#define PL 0 > +#define RTA 1 > > int textscan (char *buf); > int process_arguments (int, char **); > @@ -59,11 +57,11 @@ > { > /* normaly should be int result = STATE_UNKNOWN; */ > > - int status = STATE_UNKNOWN; > + int result = STATE_UNKNOWN; > char *server = NULL; > char *command_line = NULL; > - char *input_buffer = NULL; > - input_buffer = malloc (MAX_INPUT_BUFFER); > + output chld_out, chld_err; > + size_t i; > > setlocale (LC_ALL, ""); > bindtextdomain (PACKAGE, LOCALEDIR); > @@ -79,43 +77,21 @@ > packet_size, packet_count, server); > > if (verbose) > - printf ("%s\n", command_line); > + printf ("command_line: %s\n", command_line); > > /* run the command */ > - child_process = spopen (command_line); > - if (child_process == NULL) { > - printf (_("Could not open pipe: %s\n"), command_line); > - return STATE_UNKNOWN; > - } > - > - child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); > - if (child_stderr == NULL) { > - printf (_("Could not open stderr for %s\n"), command_line); > - } > + if((np_runcmd(command_line, &chld_out, &chld_err, 0)) || chld_err.buflen) > + result = STATE_WARNING; > > - while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) { > - if (verbose) > - printf ("%s", input_buffer); > - status = max_state (status, textscan (input_buffer)); > - } > - > - /* If we get anything on STDERR, at least set warning */ > - while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) { > - status = max_state (status, STATE_WARNING); > - if (verbose) > - printf ("%s", input_buffer); > - status = max_state (status, textscan (input_buffer)); > - } > - (void) fclose (child_stderr); > + for(i = 0; i < chld_out.lines; i++) > + result = max_state (result, textscan (chld_out.line[i])); > > - /* close the pipe */ > - if (spclose (child_process)) > - /* need to use max_state not max */ > - status = max_state (status, STATE_WARNING); > + printf ("FPING %s - %s\n", state_text (result), server_name); > > - printf ("FPING %s - %s\n", state_text (status), server_name); > + if (verbose) for(i = 0; i < chld_out.lines; i++) > + printf ("%s", chld_out.line[i]); > > - return status; > + return result; > } > > > @@ -127,7 +103,7 @@ > char *losstr = NULL; > double loss; > double rta; > - int status = STATE_UNKNOWN; > + int result = STATE_UNKNOWN; > > if (strstr (buf, "not found")) { > die (STATE_CRITICAL, _("FPING UNKNOW - %s not found\n"), server_name); > @@ -143,7 +119,7 @@ > > } > else if (strstr (buf, "is alive")) { > - status = STATE_OK; > + result = STATE_OK; > > } > else if (strstr (buf, "xmt/rcv/%loss") && strstr (buf, "min/avg/max")) { > @@ -156,18 +132,18 @@ > loss = strtod (losstr, NULL); > rta = strtod (rtastr, NULL); > if (cpl_p == TRUE && loss > cpl) > - status = STATE_CRITICAL; > + result = STATE_CRITICAL; > else if (crta_p == TRUE && rta > crta) > - status = STATE_CRITICAL; > + result = STATE_CRITICAL; > else if (wpl_p == TRUE && loss > wpl) > - status = STATE_WARNING; > + result = STATE_WARNING; > else if (wrta_p == TRUE && rta > wrta) > - status = STATE_WARNING; > + result = STATE_WARNING; > else > - status = STATE_OK; > - die (status, > + result = STATE_OK; > + die (result, > _("FPING %s - %s (loss=%.0f%%, rta=%f ms)|%s %s\n"), > - state_text (status), server_name, loss, rta, > + state_text (result), server_name, loss, rta, > perfdata ("loss", (long int)loss, "%", wpl_p, wpl, cpl_p, cpl, TRUE, 0, TRUE, 100), > fperfdata ("rta", rta/1.0e3, "s", wrta_p, wrta/1.0e3, crta_p, crta/1.0e3, TRUE, 0, FALSE, 0)); > > @@ -179,24 +155,24 @@ > losstr = 1 + strstr (losstr, "/"); > loss = strtod (losstr, NULL); > if (atoi(losstr) == 100) > - status = STATE_CRITICAL; > + result = STATE_CRITICAL; > else if (cpl_p == TRUE && loss > cpl) > - status = STATE_CRITICAL; > + result = STATE_CRITICAL; > else if (wpl_p == TRUE && loss > wpl) > - status = STATE_WARNING; > + result = STATE_WARNING; > else > - status = STATE_OK; > + result = STATE_OK; > /* loss=%.0f%%;%d;%d;0;100 */ > - die (status, _("FPING %s - %s (loss=%.0f%% )|%s\n"), > - state_text (status), server_name, loss , > + die (result, _("FPING %s - %s (loss=%.0f%% )|%s\n"), > + state_text (result), server_name, loss , > perfdata ("loss", (long int)loss, "%", wpl_p, wpl, cpl_p, cpl, TRUE, 0, TRUE, 100)); > > } > else { > - status = max_state (status, STATE_WARNING); > + result = max_state (result, STATE_WARNING); > } > > - return status; > + return result; > } > > > diff -urN ../nplg/plugins/check_game.c ./plugins/check_game.c > --- ../nplg/plugins/check_game.c 2005-01-05 21:53:13.000000000 +0100 > +++ ./plugins/check_game.c 2005-06-10 15:01:26.000000000 +0200 > @@ -14,17 +14,17 @@ > * along with this program; if not, write to the Free Software > * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. > * > -* $Id: check_game.c,v 1.22 2004/12/25 23:17:44 opensides Exp $ > +* $Id: check_game.c,v 1.2 2005/06/05 21:55:26 exon Exp $ > *****************************************************************************/ > > const char *progname = "check_game"; > -const char *revision = "$Revision: 1.22 $"; > +const char *revision = "$Revision: 1.2 $"; > const char *copyright = "2002-2004"; > const char *email = "nagiosplug-devel at lists.sourceforge.net"; > > #include "common.h" > -#include "popen.h" > #include "utils.h" > +#include "runcmd.h" > > int process_arguments (int, char **); > int validate_arguments (void); > @@ -57,9 +57,9 @@ > char *command_line; > int result = STATE_UNKNOWN; > FILE *fp; > - char input_buffer[MAX_INPUT_BUFFER]; > char *p, *ret[QSTAT_MAX_RETURN_ARGS]; > - int i; > + size_t i = 0; > + output chld_out; > > setlocale (LC_ALL, ""); > bindtextdomain (PACKAGE, LOCALEDIR); > @@ -80,17 +80,9 @@ > if (verbose > 0) > printf ("%s\n", command_line); > > - /* run the command */ > - fp = spopen (command_line); > - if (fp == NULL) { > - printf (_("Could not open pipe: %s\n"), command_line); > - return STATE_UNKNOWN; > - } > - > - fgets (input_buffer, MAX_INPUT_BUFFER - 1, fp); /* Only interested in the first line */ > - > - /* strip the newline character from the end of the input */ > - input_buffer[strlen (input_buffer) - 1] = 0; > + /* run the command. historically, this plugin ignores output on stderr, > + * as well as return status of the qstat program */ > + (void)np_runcmd(command_line, &chld_out, NULL, 0); > > /* sanity check */ > /* was thinking about running qstat without any options, capturing the > @@ -102,18 +94,13 @@ > In the end, I figured I'd simply let an error occur & then trap it > */ > > - if (!strncmp (input_buffer, "unknown option", 14)) { > + if (!strncmp (chld_out.line[0], "unknown option", 14)) { > printf (_("CRITICAL - Host type parameter incorrect!\n")); > result = STATE_CRITICAL; > return result; > } > > - /* initialize the returned data buffer */ > - for (i = 0; i < QSTAT_MAX_RETURN_ARGS; i++) > - ret[i] = strdup(""); > - > - i = 0; > - p = (char *) strtok (input_buffer, QSTAT_DATA_DELIMITER); > + p = (char *) strtok (chld_out.line[0], QSTAT_DATA_DELIMITER); > while (p != NULL) { > ret[i] = p; > p = (char *) strtok (NULL, QSTAT_DATA_DELIMITER); > @@ -141,17 +128,14 @@ > ret[qstat_game_field], > ret[qstat_map_field], > ret[qstat_ping_field], > - perfdata ("players", atol(ret[qstat_game_players]), "", > + perfdata ("players", atol(ret[qstat_game_players]), "", > FALSE, 0, FALSE, 0, > TRUE, 0, TRUE, atol(ret[qstat_game_players_max])), > - fperfdata ("ping", strtod(ret[qstat_ping_field], NULL), "", > + fperfdata ("ping", strtod(ret[qstat_ping_field], NULL), "", > FALSE, 0, FALSE, 0, > TRUE, 0, FALSE, 0)); > } > > - /* close the pipe */ > - spclose (fp); > - > return result; > } > > diff -urN ../nplg/plugins/check_hpjd.c ./plugins/check_hpjd.c > --- ../nplg/plugins/check_hpjd.c 2005-01-05 21:53:13.000000000 +0100 > +++ ./plugins/check_hpjd.c 2005-06-10 15:01:26.000000000 +0200 > @@ -14,24 +14,22 @@ > * along with this program; if not, write to the Free Software > * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. > * > -* $Id: check_hpjd.c,v 1.31 2004/12/25 23:17:44 opensides Exp $ > +* $Id: check_hpjd.c,v 1.4 2005/06/06 11:37:06 exon Exp $ > *****************************************************************************/ > > const char *progname = "check_hpjd"; > -const char *revision = "$Revision: 1.31 $"; > +const char *revision = "$Revision: 1.4 $"; > const char *copyright = "2000-2004"; > const char *email = "nagiosplug-devel at lists.sourceforge.net"; > > #include "common.h" > -#include "popen.h" > #include "utils.h" > #include "netutils.h" > +#include "runcmd.h" > > #define DEFAULT_COMMUNITY "public" > > - > -const char *option_summary = "-H host [-C community]\n"; > - > +/* this macro is only avavilable from main() */ > #define HPJD_LINE_STATUS ".1.3.6.1.4.1.11.2.3.9.1.1.2.1" > #define HPJD_PAPER_STATUS ".1.3.6.1.4.1.11.2.3.9.1.1.2.2" > #define HPJD_INTERVENTION_REQUIRED ".1.3.6.1.4.1.11.2.3.9.1.1.2.3" > @@ -44,42 +42,50 @@ > #define HPJD_GD_DOOR_OPEN ".1.3.6.1.4.1.11.2.3.9.1.1.2.17" > #define HPJD_GD_PAPER_OUTPUT ".1.3.6.1.4.1.11.2.3.9.1.1.2.19" > #define HPJD_GD_STATUS_DISPLAY ".1.3.6.1.4.1.11.2.3.9.1.1.3" > +#define SNMP_VARS 12 > > #define ONLINE 0 > #define OFFLINE 1 > > -int process_arguments (int, char **); > -int validate_arguments (void); > -void print_help (void); > +/* make it compile without warnings when internationalization is disabled */ > +#ifndef ENABLE_NLS > +# ifdef _ > +# undef _ > +# endif > +# define _(x) x > +#endif > + > +static int process_arguments (int, char **); > +static int validate_arguments (void); > +static void print_help (void); > void print_usage (void); > > -char *community = NULL; > -char *address = NULL; > +static char *community = NULL; > +static char *address = NULL; > + > > int > main (int argc, char **argv) > { > char command_line[1024]; > - int result = STATE_UNKNOWN; > - int line; > - char input_buffer[MAX_INPUT_BUFFER]; > - char query_string[512]; > - char *errmsg; > - char *temp_buffer; > - int line_status = ONLINE; > - int paper_status = 0; > - int intervention_required = 0; > - int peripheral_error = 0; > - int paper_jam = 0; > - int paper_out = 0; > - int toner_low = 0; > - int page_punt = 0; > - int memory_out = 0; > - int door_open = 0; > - int paper_output = 0; > - char display_message[MAX_INPUT_BUFFER]; > - > - errmsg = malloc(MAX_INPUT_BUFFER); > + int result = STATE_OK; > + size_t i, val = 0; > + int errorflag = 0; /* bitflag error tracker */ > + output chld_out, chld_err; > + char *errmsg_strings[11]; > + > + /* populate the the error message array */ > + errmsg_strings[0] = _("Printer Offline"); > + errmsg_strings[1] = _("Unknown Paper Error"); > + errmsg_strings[2] = _("Intervention Required"); > + errmsg_strings[3] = _("Peripheral Error"); > + errmsg_strings[4] = _("Paper Jam"); > + errmsg_strings[5] = _("Out of Paper"); > + errmsg_strings[6] = _("Toner Low"); > + errmsg_strings[7] = _("Data too Slow for Engine"); > + errmsg_strings[8] = _("Insufficient Memory"); > + errmsg_strings[9] = _("A Door is Open"); > + errmsg_strings[10] = _("Output Tray is Full"); > > setlocale (LC_ALL, ""); > bindtextdomain (PACKAGE, LOCALEDIR); > @@ -88,206 +94,99 @@ > if (process_arguments (argc, argv) == ERROR) > usage4 (_("Could not parse arguments")); > > - /* removed ' 2>1' at end of command 10/27/1999 - EG */ > - /* create the query string */ > - sprintf > - (query_string, > - "%s.0 %s.0 %s.0 %s.0 %s.0 %s.0 %s.0 %s.0 %s.0 %s.0 %s.0 %s.0", > - HPJD_LINE_STATUS, > - HPJD_PAPER_STATUS, > - HPJD_INTERVENTION_REQUIRED, > - HPJD_GD_PERIPHERAL_ERROR, > - HPJD_GD_PAPER_JAM, > - HPJD_GD_PAPER_OUT, > - HPJD_GD_TONER_LOW, > - HPJD_GD_PAGE_PUNT, > - HPJD_GD_MEMORY_OUT, > - HPJD_GD_DOOR_OPEN, HPJD_GD_PAPER_OUTPUT, HPJD_GD_STATUS_DISPLAY); > - > - /* get the command to run */ > - sprintf (command_line, "%s -OQa -m : -v 1 -c %s %s %s", PATH_TO_SNMPGET, community, > - address, query_string); > + /* create the command-line. Get status display line first, so we can > + * match line status against powersave as we parse it */ > + sprintf (command_line, "%s -Oqv -m : -v 1 -c %s %s " > + "%s.0 %s.0 %s.0 %s.0 %s.0 %s.0 %s.0 %s.0 %s.0 %s.0 %s.0 %s.0", > + PATH_TO_SNMPGET, community, address, > + HPJD_GD_STATUS_DISPLAY, > + HPJD_LINE_STATUS, > + HPJD_PAPER_STATUS, > + HPJD_INTERVENTION_REQUIRED, > + HPJD_GD_PERIPHERAL_ERROR, > + HPJD_GD_PAPER_JAM, > + HPJD_GD_PAPER_OUT, > + HPJD_GD_TONER_LOW, > + HPJD_GD_PAGE_PUNT, > + HPJD_GD_MEMORY_OUT, > + HPJD_GD_DOOR_OPEN, > + HPJD_GD_PAPER_OUTPUT); > > /* run the command */ > - child_process = spopen (command_line); > - if (child_process == NULL) { > - printf (_("Could not open pipe: %s\n"), command_line); > - return STATE_UNKNOWN; > - } > - > - child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); > - if (child_stderr == NULL) { > - printf (_("Could not open stderr for %s\n"), command_line); > - } > - > - result = STATE_OK; > - > - line = 0; > - while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) { > + if((np_runcmd(command_line, &chld_out, &chld_err, 0)) || chld_err.buflen) > + result = STATE_WARNING; > > - /* strip the newline character from the end of the input */ > - if (input_buffer[strlen (input_buffer) - 1] == '\n') > - input_buffer[strlen (input_buffer) - 1] = 0; > - > - line++; > - > - temp_buffer = strtok (input_buffer, "="); > - temp_buffer = strtok (NULL, "="); > - > - if (temp_buffer == NULL) { > - > - result = STATE_UNKNOWN; > - strcpy (errmsg, input_buffer); > - > - } else { > - > - switch (line) { > - > - case 1: /* 1st line should contain the line status */ > - line_status = atoi (temp_buffer); > - break; > - case 2: /* 2nd line should contain the paper status */ > - paper_status = atoi (temp_buffer); > - break; > - case 3: /* 3rd line should be intervention required */ > - intervention_required = atoi (temp_buffer); > - break; > - case 4: /* 4th line should be peripheral error */ > - peripheral_error = atoi (temp_buffer); > - break; > - case 5: /* 5th line should contain the paper jam status */ > - paper_jam = atoi (temp_buffer); > - break; > - case 6: /* 6th line should contain the paper out status */ > - paper_out = atoi (temp_buffer); > - break; > - case 7: /* 7th line should contain the toner low status */ > - toner_low = atoi (temp_buffer); > - break; > - case 8: /* did data come too slow for engine */ > - page_punt = atoi (temp_buffer); > - break; > - case 9: /* did we run out of memory */ > - memory_out = atoi (temp_buffer); > - break; > - case 10: /* is there a door open */ > - door_open = atoi (temp_buffer); > - break; > - case 11: /* is output tray full */ > - paper_output = atoi (temp_buffer); > - break; > - case 12: /* display panel message */ > - strcpy (display_message, temp_buffer + 1); > - break; > - default: > - break; > - } > - > - } > - > - /* break out of the read loop if we encounter an error */ > - if (result != STATE_OK) > - break; > - } > + /* if there was none or not enough output, display an error and exit */ > + if (chld_out.buflen == 0 || chld_out.lines != SNMP_VARS - 1) { > + if(chld_err.buflen) printf("%s : ", chld_err.line[0]); > > - /* WARNING if output found on stderr */ > - if (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) { > - result = max_state (result, STATE_WARNING); > - /* remove CRLF */ > - if (input_buffer[strlen (input_buffer) - 1] == '\n') > - input_buffer[strlen (input_buffer) - 1] = 0; > - sprintf (errmsg, "%s", input_buffer ); > + if(chld_out.buflen == 0) > + printf (_("No data returned from %s\n"), address ); > + else > + printf(_("Not enough data returned from %s\n"), address); > > - } > - > - /* close stderr */ > - (void) fclose (child_stderr); > - > - /* close the pipe */ > - if (spclose (child_process)) > - result = max_state (result, STATE_WARNING); > - > - /* if there wasn't any output, display an error */ > - if (line == 0) { > - > - /* might not be the problem, but most likely is. */ > - result = STATE_UNKNOWN ; > - asprintf (&errmsg, "%s : Timeout from host %s\n", errmsg, address ); > - > + return STATE_UNKNOWN; > } > > - /* if we had no read errors, check the printer status results... */ > - if (result == STATE_OK) { > + for(i = 1; i < chld_out.lines; i++) { > + /* move to next if there's no error tag */ > + if(!(val = (size_t)strtol(chld_out.line[i], NULL, 0))) > + continue; > + > + /* tag the error */ > + errorflag |= 1 << i; > + > + /* this switch statement is only for additional exception handling */ > + switch (i) { > + case 1: /* line status */ > + /* clear this flag if it's powersaving (we know it's set if > + * we get here, so use xor and save 2 instructions) */ > + if(!strstr(chld_out.line[0], "POWERSAVE ON")) > + errorflag ^= 1 << i; > + break; > > - if (paper_jam) { > - result = STATE_WARNING; > - strcpy (errmsg, _("Paper Jam")); > - } > - else if (paper_out) { > - result = STATE_WARNING; > - strcpy (errmsg, _("Out of Paper")); > - } > - else if (line_status == OFFLINE) { > - if (strcmp (errmsg, "POWERSAVE ON") != 0) { > - result = STATE_WARNING; > - strcpy (errmsg, _("Printer Offline")); > - } > - } > - else if (peripheral_error) { > - result = STATE_WARNING; > - strcpy (errmsg, _("Peripheral Error")); > - } > - else if (intervention_required) { > - result = STATE_WARNING; > - strcpy (errmsg, _("Intervention Required")); > - } > - else if (toner_low) { > - result = STATE_WARNING; > - strcpy (errmsg, _("Toner Low")); > - } > - else if (memory_out) { > - result = STATE_WARNING; > - strcpy (errmsg, _("Insufficient Memory")); > - } > - else if (door_open) { > - result = STATE_WARNING; > - strcpy (errmsg, _("A Door is Open")); > - } > - else if (paper_output) { > - result = STATE_WARNING; > - strcpy (errmsg, _("Output Tray is Full")); > - } > - else if (page_punt) { > - result = STATE_WARNING; > - strcpy (errmsg, _("Data too Slow for Engine")); > - } > - else if (paper_status) { > - result = STATE_WARNING; > - strcpy (errmsg, _("Unknown Paper Error")); > + case 2: /* paper status */ > + case 3: /* intervention required */ > + case 4: /* peripheral error */ > + case 5: /* paper jam */ > + case 6: /* paper out */ > + case 7: /* toner low */ > + case 8: /* data came too slow for engine */ > + case 9: /* out of memory */ > + case 10: /* door open */ > + case 11: /* output tray full */ > + break; > } > } > > - if (result == STATE_OK) > - printf (_("Printer ok - (%s)\n"), display_message); > - > - else if (result == STATE_UNKNOWN) { > + /* if some error occurred, print a starting line and all the errors */ > + if(errorflag) { > + printf ("%s (%s)", chld_err.buflen != 0 ? chld_err.buf : "", > + chld_out.line[0]); > > - printf ("%s\n", errmsg); > + for(i = 0; i < SNMP_VARS; i++) { /* loop the error flags */ > + if((errorflag >> i) & 1) /* only print if flag is set */ > + printf(" :: %s", errmsg_strings[i++]); > + } > > - /* if printer could not be reached, escalate to critical */ > - if (strstr (errmsg, "Timeout")) > - result = STATE_CRITICAL; > + return STATE_CRITICAL; > } > > - else if (result == STATE_WARNING) > - printf ("%s (%s)\n", errmsg, display_message); > + /* set WARNING if output on stderr */ > + if (chld_err.buflen) { > + printf("WARNING - Printer seems ok, but %s printed to stderr (%s)", > + PATH_TO_SNMPGET, chld_err.line[0]); > + return STATE_WARNING; > + } > > - return result; > + /* all is well if we end up here */ > + printf (_("Printer ok - (%s)\n"), chld_out.line[0]); > + return STATE_OK; > } > > > /* process command-line arguments */ > -int > +static int > process_arguments (int argc, char **argv) > { > int c; > @@ -296,9 +195,6 @@ > static struct option longopts[] = { > {"hostname", required_argument, 0, 'H'}, > {"community", required_argument, 0, 'C'}, > -/* {"critical", required_argument,0,'c'}, */ > -/* {"warning", required_argument,0,'w'}, */ > -/* {"port", required_argument,0,'P'}, */ > {"version", no_argument, 0, 'V'}, > {"help", no_argument, 0, 'h'}, > {0, 0, 0, 0} > @@ -307,7 +203,6 @@ > if (argc < 2) > return ERROR; > > - > while (1) { > c = getopt_long (argc, argv, "+hVH:C:", longopts, &option); > > @@ -317,7 +212,7 @@ > switch (c) { > case 'H': /* hostname */ > if (is_host (optarg)) { > - address = strscpy(address, optarg) ; > + address = strdup(optarg) ; > } > else { > usage2 (_("Invalid hostname/address"), optarg); > @@ -346,26 +241,26 @@ > usage2 (_("Invalid hostname/address"), argv[c]); > } > } > - > + > if (community == NULL) { > if (argv[c] != NULL ) > community = argv[c]; > else > - community = strdup (DEFAULT_COMMUNITY); > + community = DEFAULT_COMMUNITY; > } > > return validate_arguments (); > } > > > -int > +static int > validate_arguments (void) > { > return OK; > } > > > -void > +static void > print_help (void) > { > print_revision (progname, revision); > @@ -389,7 +284,6 @@ > } > > > - > void > print_usage (void) > { > diff -urN ../nplg/plugins/check_load.c ./plugins/check_load.c > --- ../nplg/plugins/check_load.c 2005-05-30 17:44:13.000000000 +0200 > +++ ./plugins/check_load.c 2005-06-10 15:01:26.000000000 +0200 > @@ -14,18 +14,18 @@ > along with this program; if not, write to the Free Software > Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. > > - $Id: check_load.c,v 1.28 2005/05/28 01:21:54 seanius Exp $ > + $Id: check_load.c,v 1.3 2005/06/05 21:55:26 exon Exp $ > > ******************************************************************************/ > > const char *progname = "check_load"; > -const char *revision = "$Revision: 1.28 $"; > +const char *revision = "$Revision: 1.3 $"; > const char *copyright = "1999-2004"; > const char *email = "nagiosplug-devel at lists.sourceforge.net"; > > #include "common.h" > #include "utils.h" > -#include "popen.h" > +#include "runcmd.h" > > #ifdef HAVE_SYS_LOADAVG_H > #include > @@ -47,12 +47,8 @@ > /* strictly for pretty-print usage in loops */ > static const int nums[3] = { 1, 5, 15 }; > > -/* provide some fairly sane defaults */ > double wload[3] = { 0.0, 0.0, 0.0 }; > double cload[3] = { 0.0, 0.0, 0.0 }; > -#define la1 la[0] > -#define la5 la[1] > -#define la15 la[2] > > char *status_line; > > @@ -86,14 +82,16 @@ > main (int argc, char **argv) > { > int result; > - int i; > + size_t i; /* size_t so we can match against chld_out.lines if need be */ > > double la[3] = { 0.0, 0.0, 0.0 }; /* NetBSD complains about unitialized arrays */ > #ifndef HAVE_GETLOADAVG > - char input_buffer[MAX_INPUT_BUFFER]; > # ifdef HAVE_PROC_LOADAVG > + char input_buffer[MAX_INPUT_BUFFER]; > FILE *fp; > char *str, *next; > +# else > + output chld_out, chld_err; > # endif > #endif > > @@ -126,23 +124,11 @@ > > fclose (fp); > # else > - child_process = spopen (PATH_TO_UPTIME); > - if (child_process == NULL) { > - printf (_("Error opening %s\n"), PATH_TO_UPTIME); > - return STATE_UNKNOWN; > - } > - child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); > - if (child_stderr == NULL) { > - printf (_("Could not open stderr for %s\n"), PATH_TO_UPTIME); > - } > - fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process); > - sscanf (input_buffer, "%*[^l]load average: %f, %f, %f", &la1, &la5, &la15); > + if((result = np_runcmd(PATH_TO_UPTIME, &chld_out, &chld_err, 0)) || chld_err.buflen) > + die(STATE_UNKNOWN, _("Error code %d returned in %s\n"), > + result, PATH_TO_UPTIME); > > - result = spclose (child_process); > - if (result) { > - printf (_("Error code %d returned in %s\n"), result, PATH_TO_UPTIME); > - return STATE_UNKNOWN; > - } > + sscanf (chld_out.buf, "%*[^l]load average: %f, %f, %f", &la[0], &la[1], &la[2]); > # endif > #endif > > @@ -162,17 +148,17 @@ > /* we got this far, so assume OK until we've measured */ > result = STATE_OK; > > - asprintf(&status_line, _("load average: %.2f, %.2f, %.2f"), la1, la5, la15); > - > for(i = 0; i < 3; i++) { > if(la[i] > cload[i]) { > result = STATE_CRITICAL; > break; > } > - else if(la[i] > wload[i]) result = STATE_WARNING; > + > + if(la[i] > wload[i]) result = STATE_WARNING; > } > > - printf("%s - %s|", state_text(result), status_line); > + printf(_("%s - load average: %.2f, %.2f, %.2f|"), > + state_text(result), la[0], la[1], la[2]); > for(i = 0; i < 3; i++) > printf("load%d=%.3f;%.3f;%.3f;0; ", nums[i], la[i], wload[i], cload[i]); > > @@ -248,14 +234,13 @@ > int i = 0; > > /* match cload first, as it will give the most friendly error message > - * if user hasn't given the -c switch properly */ > + * if user hasn't given the -c switch properly. Don't make sure wload[i] > + * < cload[i] as it prevents users from forcing a critical state */ > for(i = 0; i < 3; i++) { > - if(cload[i] < 0) > + if(cload[i] == 0.0) > die (STATE_UNKNOWN, _("Critical threshold for %d-minute load average is not specified\n"), nums[i]); > - if(wload[i] < 0) > + if(wload[i] == 0.0) > die (STATE_UNKNOWN, _("Warning threshold for %d-minute load average is not specified\n"), nums[i]); > - if(wload[i] > cload[i]) > - die (STATE_UNKNOWN, _("Parameter inconsistency: %d-minute \"warning load\" is greater than \"critical load\"\n"), nums[i]); > } > > return OK; > diff -urN ../nplg/plugins/check_nagios.c ./plugins/check_nagios.c > --- ../nplg/plugins/check_nagios.c 2005-05-26 14:12:21.000000000 +0200 > +++ ./plugins/check_nagios.c 2005-06-10 15:01:26.000000000 +0200 > @@ -14,17 +14,17 @@ > along with this program; if not, write to the Free Software > Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. > > - $Id: check_nagios.c,v 1.26 2005/05/25 00:43:20 seanius Exp $ > + $Id: check_nagios.c,v 1.3 2005/06/06 11:37:06 exon Exp $ > > ******************************************************************************/ > > const char *progname = "check_nagios"; > -const char *revision = "$Revision: 1.26 $"; > +const char *revision = "$Revision: 1.3 $"; > const char *copyright = "1999-2004"; > const char *email = "nagiosplug-devel at lists.sourceforge.net"; > > #include "common.h" > -#include "popen.h" > +#include "runcmd.h" > #include "utils.h" > > int process_arguments (int, char **); > @@ -55,6 +55,8 @@ > int procrss = 0; > float procpcpu = 0; > char procstat[8]; > + /* procetime is unused in most configurations, but may be in PS_VAR_LIST > + * so it must be here in spite of it producing compiler warnings */ > char procetime[MAX_INPUT_BUFFER]; > char procprog[MAX_INPUT_BUFFER]; > char *procargs; > @@ -62,6 +64,8 @@ > int expected_cols = PS_COLS - 1; > const char *zombie = "Z"; > char *temp_string; > + output chld_out, chld_err; > + size_t i; > > setlocale (LC_ALL, ""); > bindtextdomain (PACKAGE, LOCALEDIR); > @@ -99,40 +103,30 @@ > printf(_("command: %s\n"), PS_COMMAND); > > /* run the command to check for the Nagios process.. */ > - child_process = spopen (PS_COMMAND); > - if (child_process == NULL) { > - printf (_("Could not open pipe: %s\n"), PS_COMMAND); > - return STATE_UNKNOWN; > - } > - > - child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); > - if (child_stderr == NULL) { > - printf (_("Could not open stderr for %s\n"), PS_COMMAND); > - } > - > - fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process); > + if((result = np_runcmd(PS_COMMAND, &chld_out, &chld_err, 0)) != 0) > + result = STATE_WARNING; > > /* count the number of matching Nagios processes... */ > - while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) { > - cols = sscanf (input_buffer, PS_FORMAT, PS_VARLIST); > - /* Zombie processes do not give a procprog command */ > - if ( cols == (expected_cols - 1) && strstr(procstat, zombie) ) { > - cols = expected_cols; > - /* Set some value for procargs for the strip command further below > - Seen to be a problem on some Solaris 7 and 8 systems */ > - input_buffer[pos] = '\n'; > - input_buffer[pos+1] = 0x0; > - } > + for(i = 0; i < chld_out.lines; i++) { > + cols = sscanf (chld_out.line[i], PS_FORMAT, PS_VARLIST); > + /* Zombie processes do not give a procprog command */ > + if ( cols == (expected_cols - 1) && strstr(procstat, zombie) ) { > + cols = expected_cols; > + /* Set some value for procargs for the strip command further below > + * Seen to be a problem on some Solaris 7 and 8 systems */ > + chld_out.line[i][pos] = '\n'; > + chld_out.line[i][pos+1] = 0x0; > + } > if ( cols >= expected_cols ) { > - asprintf (&procargs, "%s", input_buffer + pos); > + asprintf (&procargs, "%s", chld_out.line[i] + pos); > strip (procargs); > - > + > /* Some ps return full pathname for command. This removes path */ > - temp_string = strtok ((char *)procprog, "/"); > - while (temp_string) { > - strcpy(procprog, temp_string); > - temp_string = strtok (NULL, "/"); > - } > + temp_string = strtok ((char *)procprog, "/"); > + while (temp_string) { > + strcpy(procprog, temp_string); > + temp_string = strtok (NULL, "/"); > + } > > /* May get empty procargs */ > if (!strstr(procargs, argv[0]) && strstr(procargs, process_string) && strcmp(procargs,"")) { > @@ -145,14 +139,7 @@ > } > > /* If we get anything on stderr, at least set warning */ > - while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) > - result = max_state (result, STATE_WARNING); > - > - /* close stderr */ > - (void) fclose (child_stderr); > - > - /* close the pipe */ > - if (spclose (child_process)) > + if(chld_err.buflen) > result = max_state (result, STATE_WARNING); > > /* reset the alarm handler */ > diff -urN ../nplg/plugins/check_ping.c ./plugins/check_ping.c > --- ../nplg/plugins/check_ping.c 2005-05-26 14:12:21.000000000 +0200 > +++ ./plugins/check_ping.c 2005-06-10 15:01:26.000000000 +0200 > @@ -14,18 +14,18 @@ > along with this program; if not, write to the Free Software > Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. > > - $Id: check_ping.c,v 1.44 2005/05/25 14:25:55 sghosh Exp $ > + $Id: check_ping.c,v 1.2 2005/06/05 21:55:26 exon Exp $ > > ******************************************************************************/ > > const char *progname = "check_ping"; > -const char *revision = "$Revision: 1.44 $"; > +const char *revision = "$Revision: 1.2 $"; > const char *copyright = "2000-2004"; > const char *email = "nagiosplug-devel at lists.sourceforge.net"; > > #include "common.h" > #include "netutils.h" > -#include "popen.h" > +#include "runcmd.h" > #include "utils.h" > > #define WARN_DUPLICATES "DUPLICATES FOUND! " > @@ -40,7 +40,7 @@ > int get_threshold (char *, float *, int *); > int validate_arguments (void); > int run_ping (const char *cmd, const char *addr); > -int error_scan (char buf[MAX_INPUT_BUFFER], const char *addr); > +int error_scan (const char *buf, const char *addr); > void print_usage (void); > void print_help (void); > > @@ -58,7 +58,7 @@ > float rta = UNKNOWN_TRIP_TIME; > int pl = UNKNOWN_PACKET_LOSS; > > -char *warn_text; > +char *warn_text = NULL; > > > > @@ -95,10 +95,8 @@ > if (is_inet6_addr(addresses[i]) && address_family != AF_INET) > rawcmd = strdup(PING6_COMMAND); > else > - rawcmd = strdup(PING_COMMAND); > -#else > - rawcmd = strdup(PING_COMMAND); > #endif > + rawcmd = strdup(PING_COMMAND); > > /* does the host address of number of packets argument come first? */ > #ifdef PING_PACKETS_FIRST > @@ -119,8 +117,7 @@ > > if (pl == UNKNOWN_PACKET_LOSS || rta < 0.0) { > printf ("%s\n", cmd); > - die (STATE_UNKNOWN, > - _("CRITICAL - Could not interpret output from ping command\n")); > + die (STATE_UNKNOWN, _("CRITICAL - Could not interpret output from ping command\n")); > } > > if (pl >= cpl || rta >= crta || rta < 0) > @@ -136,11 +133,11 @@ > if (display_html == TRUE) > printf ("", CGIURL, addresses[i]); > if (pl == 100) > - printf (_("PING %s - %sPacket loss = %d%%"), state_text (this_result), warn_text, > - pl); > + printf (_("PING %s - %sPacket loss = %d%%"), > + state_text(this_result), warn_text ? warn_text : " ", pl); > else > printf (_("PING %s - %sPacket loss = %d%%, RTA = %2.2f ms"), > - state_text (this_result), warn_text, pl, rta); > + state_text (this_result), warn_text ? warn_text : " ", pl, rta); > if (display_html == TRUE) > printf (""); > printf ("\n"); > @@ -399,42 +396,42 @@ > int > run_ping (const char *cmd, const char *addr) > { > - char buf[MAX_INPUT_BUFFER]; > int result = STATE_UNKNOWN; > - > - if ((child_process = spopen (cmd)) == NULL) > - die (STATE_UNKNOWN, _("Could not open pipe: %s\n"), cmd); > - > - child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); > - if (child_stderr == NULL) > - printf (_("Cannot open stderr for %s\n"), cmd); > - > - while (fgets (buf, MAX_INPUT_BUFFER - 1, child_process)) { > - > - result = max_state (result, error_scan (buf, addr)); > - > - /* get the percent loss statistics */ > - if(sscanf(buf,"%*d packets transmitted, %*d packets received, +%*d errors, %d%% packet loss",&pl)==1 || > - sscanf(buf,"%*d packets transmitted, %*d packets received, %d%% packet loss",&pl)==1 || > - sscanf(buf,"%*d packets transmitted, %*d packets received, %d%% loss, time",&pl)==1 || > - sscanf(buf,"%*d packets transmitted, %*d received, %d%% loss, time", &pl)==1 || > - sscanf(buf,"%*d packets transmitted, %*d received, %d%% packet loss, time", &pl)==1 || > - sscanf(buf,"%*d packets transmitted, %*d received, +%*d errors, %d%% packet loss", &pl) == 1 || > - sscanf(buf,"%*d packets transmitted %*d received, +%*d errors, %d%% packet loss", &pl) == 1 > - ) > + output chld_out, chld_err; > + char *p; > + size_t mult = 1, i; > + > + if((result = np_runcmd(cmd, &chld_out, &chld_err, 0)) != 0) > + result = STATE_WARNING; > + > + for(i = 0; i < chld_out.lines; i++) { > + /* get the packet loss. Find the % sign and count backwards */ > + if((p = memchr(chld_out.line[i], '%', chld_out.lens[i]))) { > + p--; > + pl = 0; > + while(p != chld_out.line[i] && isdigit(*p)) { > + pl += *p - '0' * mult; > + mult *= 10; > + p--; > + } > continue; > - > + } > /* get the round trip average */ > - else > - if(sscanf(buf,"round-trip min/avg/max = %*f/%f/%*f",&rta)==1 || > - sscanf(buf,"round-trip min/avg/max/mdev = %*f/%f/%*f/%*f",&rta)==1 || > - sscanf(buf,"round-trip min/avg/max/sdev = %*f/%f/%*f/%*f",&rta)==1 || > - sscanf(buf,"round-trip min/avg/max/stddev = %*f/%f/%*f/%*f",&rta)==1 || > - sscanf(buf,"round-trip min/avg/max/std-dev = %*f/%f/%*f/%*f",&rta)==1 || > - sscanf(buf,"round-trip (ms) min/avg/max = %*f/%f/%*f",&rta)==1 || > - sscanf(buf,"round-trip (ms) min/avg/max/stddev = %*f/%f/%*f/%*f",&rta)==1 || > - sscanf(buf,"rtt min/avg/max/mdev = %*f/%f/%*f/%*f ms",&rta)==1) > - continue; > + else { > + if(sscanf(chld_out.line[i], "round-trip min/avg/max = %*f/%f/%*f", &rta) == 1 || > + sscanf(chld_out.line[i], "round-trip min/avg/max/mdev = %*f/%f/%*f/%*f", &rta) == 1 || > + sscanf(chld_out.line[i], "round-trip min/avg/max/sdev = %*f/%f/%*f/%*f", &rta) == 1 || > + sscanf(chld_out.line[i], "round-trip min/avg/max/stddev = %*f/%f/%*f/%*f", &rta) == 1 || > + sscanf(chld_out.line[i], "round-trip min/avg/max/std-dev = %*f/%f/%*f/%*f", &rta) == 1 || > + sscanf(chld_out.line[i], "round-trip (ms) min/avg/max = %*f/%f/%*f", &rta) == 1 || > + sscanf(chld_out.line[i], "round-trip (ms) min/avg/max/stddev = %*f/%f/%*f/%*f", &rta) == 1 || > + sscanf(chld_out.line[i], "rtt min/avg/max/mdev = %*f/%f/%*f/%*f ms", &rta) == 1) > + { > + continue; > + } > + > + result = max_state (result, error_scan (chld_out.line[i], addr)); > + } > } > > /* this is needed because there is no rta if all packets are lost */ > @@ -442,19 +439,10 @@ > rta = crta; > > /* check stderr, setting at least WARNING if there is output here */ > - while (fgets (buf, MAX_INPUT_BUFFER - 1, child_stderr)) > - if (! strstr(buf,"WARNING - no SO_TIMESTAMP support, falling back to SIOCGSTAMP")) > - result = max_state (STATE_WARNING, error_scan (buf, addr)); > - > - (void) fclose (child_stderr); > - > - > - /* close the pipe - WARNING if status is set */ > - if (spclose (child_process)) > - result = max_state (result, STATE_WARNING); > - > - if (warn_text == NULL) > - warn_text = strdup(""); > + if(chld_err.buflen > 0) { > + if (! strstr(chld_err.line[0], "WARNING - no SO_TIMESTAMP support, falling back to SIOCGSTAMP")) > + result = max_state (STATE_WARNING, error_scan (chld_err.line[0], addr)); > + } > > return result; > } > @@ -462,7 +450,7 @@ > > > int > -error_scan (char buf[MAX_INPUT_BUFFER], const char *addr) > +error_scan (const char *buf, const char *addr) > { > if (strstr (buf, "Network is unreachable")) > die (STATE_CRITICAL, _("CRITICAL - Network unreachable (%s)"), addr); > diff -urN ../nplg/plugins/check_procs.c ./plugins/check_procs.c > --- ../nplg/plugins/check_procs.c 2005-06-03 19:35:45.000000000 +0200 > +++ ./plugins/check_procs.c 2005-06-10 15:01:26.000000000 +0200 > @@ -14,17 +14,17 @@ > along with this program; if not, write to the Free Software > Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. > > - $Id: check_procs.c,v 1.45 2005/06/03 13:53:43 seanius Exp $ > + $Id: check_procs.c,v 1.3 2005/06/06 11:37:06 exon Exp $ > > ******************************************************************************/ > > const char *progname = "check_procs"; > -const char *revision = "$Revision: 1.45 $"; > +const char *revision = "$Revision: 1.3 $"; > const char *copyright = "2000-2004"; > const char *email = "nagiosplug-devel at lists.sourceforge.net"; > > #include "common.h" > -#include "popen.h" > +#include "runcmd.h" > #include "utils.h" > > #include > @@ -96,7 +96,7 @@ > char procstat[8]; > char procetime[MAX_INPUT_BUFFER] = { '\0' }; > char *procargs; > - char *temp_string; > + output chld_out, chld_err; > > const char *zombie = "Z"; > > @@ -118,7 +118,7 @@ > input_buffer = malloc (MAX_INPUT_BUFFER); > procprog = malloc (MAX_INPUT_BUFFER); > > - asprintf (&metric_name, "PROCS"); > + metric_name = "PROCS"; > metric = METRIC_PROCS; > > if (process_arguments (argc, argv) == ERROR) > @@ -136,27 +136,15 @@ > if (verbose >= 2) > printf (_("CMD: %s\n"), PS_COMMAND); > > - child_process = spopen (PS_COMMAND); > - if (child_process == NULL) { > - printf (_("Could not open pipe: %s\n"), PS_COMMAND); > - return STATE_UNKNOWN; > - } > - > - child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); > - if (child_stderr == NULL) > - printf (_("Could not open stderr for %s\n"), PS_COMMAND); > - > - /* flush first line */ > - fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process); > - while ( input_buffer[strlen(input_buffer)-1] != '\n' ) > - fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process); > - > - while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) { > - asprintf (&input_line, "%s", input_buffer); > - while ( input_buffer[strlen(input_buffer)-1] != '\n' ) { > - fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process); > - asprintf (&input_line, "%s%s", input_line, input_buffer); > - } > + result = np_runcmd(PS_COMMAND, &chld_out, &chld_err, 0); > + if(result) { > + printf (_("System call returned nonzero status\n")); > + result = max_state (result, STATE_WARNING); > + } > + > + /* start parsing on second line */ > + for(i = 1; i < chld_out.lines; i++) { > + input_line = chld_out.line[i]; > > if (verbose >= 3) > printf ("%s", input_line); > @@ -177,8 +165,7 @@ > > /* Some ps return full pathname for command. This removes path */ > #ifdef HAVE_BASENAME > - temp_string = strdup(procprog); > - procprog = basename(temp_string); > + procprog = strdup(basename(procprog)); > #endif /* HAVE_BASENAME */ > > /* we need to convert the elapsed time to seconds */ > @@ -248,27 +235,17 @@ > } > > /* If we get anything on STDERR, at least set warning */ > - while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) { > - if (verbose) > - printf ("STDERR: %s", input_buffer); > + if(chld_err.buflen > 0) { > result = max_state (result, STATE_WARNING); > printf (_("System call sent warnings to stderr\n")); > } > - > - (void) fclose (child_stderr); > - > - /* close the pipe */ > - if (spclose (child_process)) { > - printf (_("System call returned nonzero status\n")); > - result = max_state (result, STATE_WARNING); > - } > > if (found == 0) { /* no process lines parsed so return STATE_UNKNOWN */ > printf (_("Unable to read output\n")); > return result; > } > > - if ( result == STATE_UNKNOWN ) > + if ( result == STATE_UNKNOWN ) > result = STATE_OK; > > /* Needed if procs found, but none match filter */ > @@ -459,7 +436,7 @@ > } > usage4 (_("PCPU must be a float!")); > case 'm': > - asprintf (&metric_name, "%s", optarg); > + metric_name = optarg; > if ( strcmp(optarg, "PROCS") == 0) { > metric = METRIC_PROCS; > break; > @@ -494,7 +471,7 @@ > if (cmax == -1 && argv[c]) > cmax = atoi (argv[c++]); > if (statopts == NULL && argv[c]) { > - asprintf (&statopts, "%s", argv[c++]); > + statopts = argv[c++]; > asprintf (&fmt, _("%s%sSTATE = %s"), (fmt ? fmt : ""), (options ? ", " : ""), statopts); > options |= STAT; > } > diff -urN ../nplg/plugins/check_snmp.c ./plugins/check_snmp.c > --- ../nplg/plugins/check_snmp.c 2005-06-03 12:07:28.000000000 +0200 > +++ ./plugins/check_snmp.c 2005-06-10 15:01:26.000000000 +0200 > @@ -14,18 +14,18 @@ > along with this program; if not, write to the Free Software > Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. > > - $Id: check_snmp.c,v 1.57 2005/06/01 19:41:01 sghosh Exp $ > + $Id: check_snmp.c,v 1.2 2005/06/05 21:55:26 exon Exp $ > > ******************************************************************************/ > > const char *progname = "check_snmp"; > -const char *revision = "$Revision: 1.57 $"; > +const char *revision = "$Revision: 1.2 $"; > const char *copyright = "1999-2004"; > const char *email = "nagiosplug-devel at lists.sourceforge.net"; > > #include "common.h" > #include "utils.h" > -#include "popen.h" > +#include "runcmd.h" > > #define DEFAULT_COMMUNITY "public" > #define DEFAULT_PORT "161" > @@ -136,11 +136,12 @@ > char *command_line = NULL; > char *response = NULL; > char *outbuff; > - char *output; > + char *msg; > char *ptr = NULL; > char *p2 = NULL; > char *show = NULL; > char type[8]; > + output chld_out, chld_err; > > setlocale (LC_ALL, ""); > bindtextdomain (PACKAGE, LOCALEDIR); > @@ -157,7 +158,7 @@ > units = strdup (""); > port = strdup (DEFAULT_PORT); > outbuff = strdup (""); > - output = strdup (""); > + msg = strdup (""); > delimiter = strdup (" = "); > output_delim = strdup (DEFAULT_OUTPUT_DELIMITER); > /* miblist = strdup (DEFAULT_MIBLIST); */ > @@ -168,41 +169,25 @@ > usage4 (_("Could not parse arguments")); > > /* create the command line to execute */ > - if(usesnmpgetnext == TRUE) { > - asprintf(&command_line, "%s -t %d -r %d -m %s -v %s %s %s:%s %s", > - PATH_TO_SNMPGETNEXT, timeout_interval, retries, miblist, proto, > - authpriv, server_address, port, oid); > - }else{ > - > - asprintf (&command_line, "%s -t %d -r %d -m %s -v %s %s %s:%s %s", > - PATH_TO_SNMPGET, timeout_interval, retries, miblist, proto, > - authpriv, server_address, port, oid); > - } > - > + asprintf(&command_line, "%s -t %d -r %d -m %s -v %s %s %s:%s %s", > + usesnmpgetnext == TRUE ? PATH_TO_SNMPGETNEXT : PATH_TO_SNMPGET, > + timeout_interval, retries, miblist, proto, > + authpriv, server_address, port, oid); > + > if (verbose) > printf ("%s\n", command_line); > - > > /* run the command */ > - child_process = spopen (command_line); > - if (child_process == NULL) { > - printf (_("Could not open pipe: %s\n"), command_line); > - exit (STATE_UNKNOWN); > - } > - > - child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); > - if (child_stderr == NULL) { > - printf (_("Could not open stderr for %s\n"), command_line); > - } > + if((np_runcmd(command_line, &chld_out, &chld_err, 0)) != 0 || chld_err.buflen) > + result = STATE_WARNING; > > - while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) > - asprintf (&output, "%s%s", output, input_buffer); > + for(i = 0; (size_t)i < chld_out.lines; i++) > + asprintf (&msg, "%s%s", msg, input_buffer); > > if (verbose) > - printf ("%s\n", output); > - > - ptr = output; > + printf ("%s\n", msg); > > + ptr = msg; > strcat(perfstr, "| "); > while (ptr) { > char *foo; > @@ -261,18 +246,11 @@ > iresult = STATE_DEPENDENT; > > /* Process this block for integer comparisons */ > - if (eval_method[i] & CRIT_GT || > - eval_method[i] & CRIT_LT || > - eval_method[i] & CRIT_GE || > - eval_method[i] & CRIT_LE || > - eval_method[i] & CRIT_EQ || > - eval_method[i] & CRIT_NE || > - eval_method[i] & WARN_GT || > - eval_method[i] & WARN_LT || > - eval_method[i] & WARN_GE || > - eval_method[i] & WARN_LE || > - eval_method[i] & WARN_EQ || > - eval_method[i] & WARN_NE) { > + if (eval_method[i] & (CRIT_GT | CRIT_LT | CRIT_GE | > + CRIT_LE | CRIT_EQ | CRIT_NE | > + WARN_GT | WARN_LT | WARN_GE | > + WARN_LE | WARN_EQ | WARN_NE)) > + { > p2 = strpbrk (p2, "0123456789"); > if (p2 == NULL) > die (STATE_UNKNOWN,_("No valid data returned")); > @@ -350,20 +328,6 @@ > label, > command_line); > > - /* WARNING if output found on stderr */ > - if (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) > - result = max_state (result, STATE_WARNING); > - > - /* close stderr */ > - (void) fclose (child_stderr); > - > - /* close the pipe */ > - if (spclose (child_process)) > - result = max_state (result, STATE_WARNING); > - > -/* if (nunits == 1 || i == 1) */ > -/* printf ("%s %s -%s %s\n", label, state_text (result), outbuff, units); */ > -/* else */ > printf ("%s %s -%s %s \n", label, state_text (result), outbuff, perfstr); > > return result; > diff -urN ../nplg/plugins/check_swap.c ./plugins/check_swap.c > --- ../nplg/plugins/check_swap.c 2005-01-24 08:29:54.000000000 +0100 > +++ ./plugins/check_swap.c 2005-06-10 15:01:26.000000000 +0200 > @@ -21,18 +21,18 @@ > * > * Copyright (c) 2000 Karl DeBisschop (kdebisschop at users.sourceforge.net) > * > - * $Id: check_swap.c,v 1.47 2005/01/19 21:14:47 tonvoon Exp $ > + * $Id: check_swap.c,v 1.4 2005/06/06 11:37:06 exon Exp $ > * > *****************************************************************************/ > > const char *progname = "check_swap"; > -const char *revision = "$Revision: 1.47 $"; > +const char *revision = "$Revision: 1.4 $"; > const char *copyright = "2000-2004"; > const char *email = "nagiosplug-devel at lists.sourceforge.net"; > > #include "common.h" > -#include "popen.h" > #include "utils.h" > +#include "runcmd.h" > > int check_swap (int usp, float free_swap); > int process_arguments (int argc, char **argv); > @@ -64,6 +64,8 @@ > char *temp_buffer; > char *swap_command; > char *swap_format; > + output chld_out, chld_err; > + size_t i = 0; > # else > # ifdef HAVE_DECL_SWAPCTL > int i=0, nswaps=0, swapctl_res=0; > @@ -79,14 +81,13 @@ > # endif > #endif > char str[32]; > - char *status, *tmp_status; > + char *status; > > setlocale (LC_ALL, ""); > bindtextdomain (PACKAGE, LOCALEDIR); > textdomain (PACKAGE); > > status = strdup (""); > - tmp_status = strdup (""); > perf = strdup (""); > > if (process_arguments (argc, argv) == ERROR) > @@ -146,15 +147,9 @@ > if (verbose >= 3) > printf (_("Format: %s\n"), swap_format); > > - child_process = spopen (swap_command); > - if (child_process == NULL) { > - printf (_("Could not open pipe: %s\n"), swap_command); > - return STATE_UNKNOWN; > - } > - > - child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); > - if (child_stderr == NULL) > - printf (_("Could not open stderr for %s\n"), swap_command); > + /* run the command. set WARNING if non-zero return or output on stderr */ > + if((np_runcmd(swap_command, &chld_out, &chld_err, 0)) || chld_err.buflen) > + result = STATE_WARNING; > > sprintf (str, "%s", ""); > /* read 1st line */ > @@ -210,17 +205,6 @@ > # ifdef _AIX > } > # endif > - > - /* If we get anything on STDERR, at least set warning */ > - while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) > - result = max_state (result, STATE_WARNING); > - > - /* close stderr */ > - (void) fclose (child_stderr); > - > - /* close the pipe */ > - if (spclose (child_process)) > - result = max_state (result, STATE_WARNING); > # else > # ifdef CHECK_SWAP_SWAPCTL_SVR4 > > @@ -314,16 +298,19 @@ > percent_used = 100 * ((double) used_swap) / ((double) total_swap); > result = max_state (result, check_swap (percent_used, free_swap)); > /* broken into two steps because of funkiness with builtin asprintf */ > - asprintf (&tmp_status, _(" %d%% free (%.0f MB out of %.0f MB)"), > - (100 - percent_used), free_swap, total_swap); > - asprintf (&status, "%s%s", tmp_status, status); > - > - asprintf (&perf, "%s", perfdata ("swap", (long) free_swap, "MB", > - TRUE, (long) max (warn_size/1024, warn_percent/100.0*total_swap), > - TRUE, (long) max (crit_size/1024, crit_percent/100.0*total_swap), > - TRUE, 0, > - TRUE, (long) total_swap)); > - printf ("SWAP %s:%s |%s\n", state_text (result), status, perf); > + /* the breaking was removed because it was stupid. There's no reason > + * to concatenate a string using asprintf() just to print it to stdout > + * in the next statement. */ > + printf (_("SWAP %s - %d%% free (%.0f MB out of %.0f MB) %s|"), > + state_text (result), > + (100 - percent_used), free_swap, total_swap, status); > + > + puts (perfdata ("swap", (long) free_swap, "MB", > + TRUE, (long) max (warn_size/1024, warn_percent/100.0*total_swap), > + TRUE, (long) max (crit_size/1024, crit_percent/100.0*total_swap), > + TRUE, 0, > + TRUE, (long) total_swap)); > + > return result; > } > > @@ -383,7 +370,7 @@ > } > else if (strstr (optarg, ",") && > strstr (optarg, "%") && > - sscanf (optarg, "%.0f,%d%%", &warn_size, &warn_percent) == 2) { > + sscanf (optarg, "%f,%d%%", &warn_size, &warn_percent) == 2) { > break; > } > else if (strstr (optarg, "%") && > @@ -400,7 +387,7 @@ > } > else if (strstr (optarg, ",") && > strstr (optarg, "%") && > - sscanf (optarg, "%.0f,%d%%", &crit_size, &crit_percent) == 2) { > + sscanf (optarg, "%f,%d%%", &crit_size, &crit_percent) == 2) { > break; > } > else if (strstr (optarg, "%") && > diff -urN ../nplg/plugins/check_users.c ./plugins/check_users.c > --- ../nplg/plugins/check_users.c 2005-01-05 21:53:22.000000000 +0100 > +++ ./plugins/check_users.c 2005-06-10 15:01:26.000000000 +0200 > @@ -14,17 +14,17 @@ > along with this program; if not, write to the Free Software > Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. > > - $Id: check_users.c,v 1.19 2004/12/25 23:17:44 opensides Exp $ > + $Id: check_users.c,v 1.2 2005/06/05 21:55:26 exon Exp $ > > *****************************************************************************/ > > const char *progname = "check_users"; > -const char *revision = "$Revision: 1.19 $"; > +const char *revision = "$Revision: 1.2 $"; > const char *copyright = "2000-2004"; > const char *email = "nagiosplug-devel at lists.sourceforge.net"; > > #include "common.h" > -#include "popen.h" > +#include "runcmd.h" > #include "utils.h" > > #define possibly_set(a,b) ((a) == 0 ? (b) : 0) > @@ -41,52 +41,28 @@ > { > int users = -1; > int result = STATE_UNKNOWN; > - char input_buffer[MAX_INPUT_BUFFER]; > - char *perf; > + output chld_out, chld_err; > + size_t i; > > setlocale (LC_ALL, ""); > bindtextdomain (PACKAGE, LOCALEDIR); > textdomain (PACKAGE); > > - perf = strdup(""); > - > if (process_arguments (argc, argv) == ERROR) > usage4 (_("Could not parse arguments")); > > /* run the command */ > - child_process = spopen (WHO_COMMAND); > - if (child_process == NULL) { > - printf (_("Could not open pipe: %s\n"), WHO_COMMAND); > - return STATE_UNKNOWN; > - } > - > - child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); > - if (child_stderr == NULL) > - printf (_("Could not open stderr for %s\n"), WHO_COMMAND); > - > - users = 0; > - > - while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) { > - > - /* increment 'users' on all lines except total user count */ > - if (input_buffer[0] != '#') { > - users++; > - continue; > - } > - > - /* get total logged in users */ > - if (sscanf (input_buffer, _("# users=%d"), &users) == 1) > - break; > - > - } > + result = np_runcmd(WHO_COMMAND, &chld_out, &chld_err, 0); > + if(result != 0) > + result = STATE_UNKNOWN; > + > + /* one user is listed per line, except when it begins with '#' */ > + users = chld_out.lines; > + for(i = 0; i < chld_out.lines; i++) > + if (chld_out.line[0][0] == '#') users--; > > /* check STDERR */ > - if (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) > - result = possibly_set (result, STATE_UNKNOWN); > - (void) fclose (child_stderr); > - > - /* close the pipe */ > - if (spclose (child_process)) > + if(chld_err.buflen > 0) > result = possibly_set (result, STATE_UNKNOWN); > > /* else check the user count against warning and critical thresholds */ > @@ -98,16 +74,12 @@ > result = STATE_OK; > > if (result == STATE_UNKNOWN) > - printf (_("Unable to read output\n")); > - else { > - asprintf(&perf, "%s", perfdata ("users", users, "", > - TRUE, wusers, > - TRUE, cusers, > - TRUE, 0, > - FALSE, 0)); > - printf (_("USERS %s - %d users currently logged in |%s\n"), state_text (result), > - users, perf); > - } > + die (STATE_UNKNOWN, _("Unable to read output\n")); > + > + printf (_("USERS %s - %d users currently logged in |%s\n"), > + state_text (result), users, > + perfdata("users", users, "", > + TRUE, wusers, TRUE, cusers, TRUE, 0, FALSE, 0)); > > return result; > } > @@ -129,8 +101,10 @@ > {0, 0, 0, 0} > }; > > - if (argc < 2) > - usage ("\n"); > + if (argc < 2) { > + print_usage (); > + exit(STATE_UNKNOWN); > + } > > while (1) { > c = getopt_long (argc, argv, "+hVvc:w:", longopts, &option); > diff -urN ../nplg/plugins/foo ./plugins/foo > --- ../nplg/plugins/foo 1970-01-01 01:00:00.000000000 +0100 > +++ ./plugins/foo 2005-06-10 15:05:25.000000000 +0200 > @@ -0,0 +1,12 @@ > +$Id: check_by_ssh.c,v 1.35 2004/12/25 12:09:19 opensides Exp $ > +$Id: check_dig.c,v 1.40 2005/01/26 21:21:01 tonvoon Exp $ > +$Id: check_dns.c,v 1.47 2004/12/30 00:41:39 opensides Exp $ > +$Id: check_fping.c,v 1.24 2004/12/25 23:17:44 opensides Exp $ > +$Id: check_load.c,v 1.28 2005/05/28 01:21:54 seanius Exp $ > +$Id: check_nagios.c,v 1.26 2005/05/25 00:43:20 seanius Exp $ > +$Id: check_ping.c,v 1.44 2005/05/25 14:25:55 sghosh Exp $ > +$Id: check_procs.c,v 1.45 2005/06/03 13:53:43 seanius Exp $ > +$Id: check_snmp.c,v 1.57 2005/06/01 19:41:01 sghosh Exp $ > +$Id: check_users.c,v 1.19 2004/12/25 23:17:44 opensides Exp $ > +$Id: negate.c,v 1.24 2004/12/25 23:17:44 opensides Exp $ > +$Id: urlize.c,v 1.17 2004/12/25 23:17:44 opensides Exp $ > diff -urN ../nplg/plugins/Makefile.am ./plugins/Makefile.am > --- ../nplg/plugins/Makefile.am 2005-02-15 09:28:36.000000000 +0100 > +++ ./plugins/Makefile.am 2005-06-10 15:01:26.000000000 +0200 > @@ -24,7 +24,8 @@ > check_nagios check_by_ssh check_dns check_nt check_ide_smart \ > check_procs > > -EXTRA_DIST = t utils.c netutils.c popen.c utils.h netutils.h popen.h common.h \ > +EXTRA_DIST = t common.h utils.c utils.h netutils.c netutils.h \ > + runcmd.c runcmd.h \ > getaddrinfo.c getaddrinfo.h gethostbyname.c gethostbyname.h > > PLUGINHDRS = common.h > @@ -46,85 +47,85 @@ > # the actual targets > > check_dhcp_LDADD = $(NETLIBS) > -check_dig_LDADD = $(NETLIBS) popen.o > -check_disk_LDADD = $(BASEOBJS) popen.o > -check_dns_LDADD = $(NETLIBS) popen.o > +check_dig_LDADD = $(NETLIBS) runcmd.o > +check_disk_LDADD = $(BASEOBJS) runcmd.o > +check_dns_LDADD = $(NETLIBS) runcmd.o > check_dummy_LDADD = $(BASEOBJS) > -check_fping_LDADD = $(NETLIBS) popen.o > -check_game_LDADD = $(BASEOBJS) popen.o > +check_fping_LDADD = $(NETLIBS) runcmd.o > +check_game_LDADD = $(BASEOBJS) runcmd.o > check_http_LDADD = $(NETLIBS) $(SSLLIBS) > -check_hpjd_LDADD = $(NETLIBS) popen.o > +check_hpjd_LDADD = $(NETLIBS) runcmd.o > check_icmp_LDADD = $(SOCKETLIBS) > check_ldap_LDADD = $(NETLIBS) $(LDAPLIBS) > -check_load_LDADD = $(BASEOBJS) popen.o > +check_load_LDADD = $(BASEOBJS) runcmd.o > check_mrtg_LDADD = $(BASEOBJS) > check_mrtgtraf_LDADD = $(BASEOBJS) > check_mysql_LDADD = $(NETLIBS) $(MYSQLLIBS) > -check_nagios_LDADD = $(BASEOBJS) popen.o > +check_nagios_LDADD = $(BASEOBJS) runcmd.o > check_nt_LDADD = $(NETLIBS) > check_nwstat_LDADD = $(NETLIBS) > check_overcr_LDADD = $(NETLIBS) > check_pgsql_LDADD = $(NETLIBS) $(PGLIBS) > -check_ping_LDADD = $(NETLIBS) popen.o > -check_procs_LDADD = $(BASEOBJS) popen.o > +check_ping_LDADD = $(NETLIBS) runcmd.o > +check_procs_LDADD = $(BASEOBJS) runcmd.o > check_radius_LDADD = $(NETLIBS) $(RADIUSLIBS) > check_real_LDADD = $(NETLIBS) > -check_snmp_LDADD = $(BASEOBJS) popen.o > +check_snmp_LDADD = $(BASEOBJS) runcmd.o > check_smtp_LDADD = $(NETLIBS) $(SSLLIBS) > check_ssh_LDADD = $(NETLIBS) > -check_swap_LDADD = $(BASEOBJS) popen.o > +check_swap_LDADD = $(BASEOBJS) runcmd.o > check_tcp_LDADD = $(NETLIBS) $(SSLLIBS) > check_time_LDADD = $(NETLIBS) > check_udp_LDADD = $(NETLIBS) > check_ups_LDADD = $(NETLIBS) > -check_users_LDADD = $(BASEOBJS) popen.o > -check_by_ssh_LDADD = $(NETLIBS) popen.o > +check_users_LDADD = $(BASEOBJS) runcmd.o > +check_by_ssh_LDADD = $(NETLIBS) runcmd.o > check_ide_smart_LDADD = $(BASEOBJS) > -negate_LDADD = $(BASEOBJS) popen.o > -urlize_LDADD = $(BASEOBJS) popen.o > +negate_LDADD = $(BASEOBJS) runcmd.o > +urlize_LDADD = $(BASEOBJS) runcmd.o > > check_dhcp_DEPENDENCIES = check_dhcp.c $(NETOBJS) $(DEPLIBS) > -check_dig_DEPENDENCIES = check_dig.c $(NETOBJS) popen.o $(DEPLIBS) > -check_disk_DEPENDENCIES = check_disk.c $(BASEOBJS) popen.o $(DEPLIBS) > -check_dns_DEPENDENCIES = check_dns.c $(NETOBJS) popen.o $(DEPLIBS) > +check_dig_DEPENDENCIES = check_dig.c $(NETOBJS) runcmd.o $(DEPLIBS) > +check_disk_DEPENDENCIES = check_disk.c $(BASEOBJS) runcmd.o $(DEPLIBS) > +check_dns_DEPENDENCIES = check_dns.c $(NETOBJS) runcmd.o $(DEPLIBS) > check_dummy_DEPENDENCIES = check_dummy.c $(DEPLIBS) > -check_fping_DEPENDENCIES = check_fping.c $(NETOBJS) popen.o $(DEPLIBS) > +check_fping_DEPENDENCIES = check_fping.c $(NETOBJS) runcmd.o $(DEPLIBS) > check_game_DEPENDENCIES = check_game.c $(DEPLIBS) > check_http_DEPENDENCIES = check_http.c $(NETOBJS) $(DEPLIBS) > -check_hpjd_DEPENDENCIES = check_hpjd.c $(NETOBJS) popen.o $(DEPLIBS) > +check_hpjd_DEPENDENCIES = check_hpjd.c $(NETOBJS) runcmd.o $(DEPLIBS) > check_icmp_DEPENDENCIES = check_icmp.c > check_ide_smart_DEPENDENCIES = check_ide_smart.c $(BASEOBJS) $(DEPLIBS) > check_ldap_DEPENDENCIES = check_ldap.c $(NETOBJS) $(DEPLIBS) > -check_load_DEPENDENCIES = check_load.c $(BASEOBJS) popen.o $(DEPLIBS) > +check_load_DEPENDENCIES = check_load.c $(BASEOBJS) runcmd.o $(DEPLIBS) > check_mrtg_DEPENDENCIES = check_mrtg.c $(DEPLIBS) > check_mrtgtraf_DEPENDENCIES = check_mrtgtraf.c $(DEPLIBS) > check_mysql_DEPENDENCIES = check_mysql.c $(NETOBJS) $(DEPLIBS) > -check_nagios_DEPENDENCIES = check_nagios.c $(BASEOBJS) popen.o $(DEPLIBS) > +check_nagios_DEPENDENCIES = check_nagios.c $(BASEOBJS) runcmd.o $(DEPLIBS) > check_nt_DEPENDENCIES = check_nt.c $(NETOBJS) $(DEPLIBS) > check_nwstat_DEPENDENCIES = check_nwstat.c $(NETOBJS) $(DEPLIBS) > check_overcr_DEPENDENCIES = check_overcr.c $(NETOBJS) $(DEPLIBS) > check_pgsql_DEPENDENCIES = check_pgsql.c $(NETOBJS) $(DEPLIBS) > -check_ping_DEPENDENCIES = check_ping.c $(NETOBJS) popen.o $(DEPLIBS) > -check_procs_DEPENDENCIES = check_procs.c $(BASEOBJS) popen.o $(DEPLIBS) > +check_ping_DEPENDENCIES = check_ping.c $(NETOBJS) runcmd.o $(DEPLIBS) > +check_procs_DEPENDENCIES = check_procs.c $(BASEOBJS) runcmd.o $(DEPLIBS) > check_radius_DEPENDENCIES = check_radius.c $(NETOBJS) $(DEPLIBS) > check_real_DEPENDENCIES = check_real.c $(NETOBJS) $(DEPLIBS) > -check_snmp_DEPENDENCIES = check_snmp.c $(BASEOBJS) popen.o $(DEPLIBS) > +check_snmp_DEPENDENCIES = check_snmp.c $(BASEOBJS) runcmd.o $(DEPLIBS) > check_smtp_DEPENDENCIES = check_smtp.c $(NETOBJS) $(DEPLIBS) > check_ssh_DEPENDENCIES = check_ssh.c $(NETOBJS) $(DEPLIBS) > -check_swap_DEPENDENCIES = check_swap.c $(BASEOBJS) popen.o $(DEPLIBS) > +check_swap_DEPENDENCIES = check_swap.c $(BASEOBJS) runcmd.o $(DEPLIBS) > check_tcp_DEPENDENCIES = check_tcp.c $(NETOBJS) $(DEPLIBS) > check_time_DEPENDENCIES = check_time.c $(NETOBJS) $(DEPLIBS) > check_udp_DEPENDENCIES = check_udp.c $(NETOBJS) $(DEPLIBS) > check_ups_DEPENDENCIES = check_ups.c $(NETOBJS) $(DEPLIBS) > -check_users_DEPENDENCIES = check_users.c $(BASEOBJS) popen.o $(DEPLIBS) > -check_by_ssh_DEPENDENCIES = check_by_ssh.c $(NETOBJS) popen.o $(DEPLIBS) > -negate_DEPENDENCIES = negate.c $(BASEOBJS) popen.o $(DEPLIBS) > -urlize_DEPENDENCIES = urlize.c $(BASEOBJS) popen.o $(DEPLIBS) > +check_users_DEPENDENCIES = check_users.c $(BASEOBJS) runcmd.o $(DEPLIBS) > +check_by_ssh_DEPENDENCIES = check_by_ssh.c $(NETOBJS) runcmd.o $(DEPLIBS) > +negate_DEPENDENCIES = negate.c $(BASEOBJS) runcmd.o $(DEPLIBS) > +urlize_DEPENDENCIES = urlize.c $(BASEOBJS) runcmd.o $(DEPLIBS) > > ############################################################################## > # secondary dependencies > > -popen.o: popen.c popen.h $(PLUGINHDRS) > +runcmd.o: runcmd.c runcmd.h $(PLUGINHDRS) > > utils.o: utils.c utils.h $(PLUGINHDRS) > > diff -urN ../nplg/plugins/negate.c ./plugins/negate.c > --- ../nplg/plugins/negate.c 2005-01-05 21:53:22.000000000 +0100 > +++ ./plugins/negate.c 2005-06-10 15:01:26.000000000 +0200 > @@ -14,7 +14,7 @@ > along with this program; if not, write to the Free Software > Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. > > - $Id: negate.c,v 1.24 2004/12/25 23:17:44 opensides Exp $ > + $Id: negate.c,v 1.2 2005/06/05 21:55:26 exon Exp $ > > @@-
> > @@ -54,7 +54,7 @@ > ******************************************************************************/ > > const char *progname = "negate"; > -const char *revision = "$Revision: 1.24 $"; > +const char *revision = "$Revision: 1.2 $"; > const char *copyright = "2002-2004"; > const char *email = "nagiosplug-devel at lists.sourceforge.net"; > > @@ -62,7 +62,7 @@ > > #include "common.h" > #include "utils.h" > -#include "popen.h" > +#include "runcmd.h" > > char *command_line; > > @@ -76,8 +76,9 @@ > int > main (int argc, char **argv) > { > - int found = 0, result = STATE_UNKNOWN; > - char *buf; > + int result = STATE_UNKNOWN; > + output chld_out, chld_err; > + size_t i; > > setlocale (LC_ALL, ""); > bindtextdomain (PACKAGE, LOCALEDIR); > @@ -92,43 +93,26 @@ > > (void) alarm ((unsigned) timeout_interval); > > - child_process = spopen (command_line); > - if (child_process == NULL) > - die (STATE_UNKNOWN, _("Could not open pipe: %s\n"), command_line); > - > - child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); > - > - if (child_stderr == NULL) { > - printf (_("Could not open stderr for %s\n"), command_line); > - } > - > - buf = malloc(MAX_INPUT_BUFFER); > - while (fgets (buf, MAX_INPUT_BUFFER - 1, child_process)) { > - found++; > - printf ("%s", buf); > - } > - > - if (!found) > + result = np_runcmd(command_line, &chld_out, &chld_err, 0); > + if (!chld_out.buflen) > die (STATE_UNKNOWN, > _("%s problem - No data received from host\nCMD: %s\n"),\ > argv[0], command_line); > > - /* close the pipe */ > - result = spclose (child_process); > + for(i = 0; i < chld_out.lines; i++) > + printf("%s", chld_out.line[i]); > > /* WARNING if output found on stderr */ > - if (fgets (buf, MAX_INPUT_BUFFER - 1, child_stderr)) > + if (chld_err.buflen != 0) > result = max_state (result, STATE_WARNING); > > - /* close stderr */ > - (void) fclose (child_stderr); > - > if (result == STATE_OK) > exit (STATE_CRITICAL); > - else if (result == STATE_CRITICAL) > + > + if (result == STATE_CRITICAL) > exit (EXIT_SUCCESS); > - else > - exit (result); > + > + exit (result); > } > > /****************************************************************************** > diff -urN ../nplg/plugins/runcmd.c ./plugins/runcmd.c > --- ../nplg/plugins/runcmd.c 1970-01-01 01:00:00.000000000 +0100 > +++ ./plugins/runcmd.c 2005-06-10 15:01:26.000000000 +0200 > @@ -0,0 +1,339 @@ > +/* > + * $Id: runcmd.c,v 1.1 2005/06/05 21:55:26 exon Exp $ > + * > + * A simple interface to executing programs from other programs, using an > + * optimized and safe popen()-like implementation. It is considered safe > + * in that no shell needs to be spawned and the environment passed to the > + * execve()'d program is essentially empty. > + * > + * > + * The code in this file is a derivative of popen.c which in turn was taken > + * from "Advanced Programming for the Unix Environment" by W. Richard Stevens. > + * > + * Care has been taken to make sure the functions are async-safe. The one > + * function which isn't is np_runcmd_init() which it doesn't make sense to > + * call twice anyway, so the api as a whole should be considered async-safe. > + * > + */ > + > +/** includes **/ > +#include "runcmd.h" > +#ifdef HAVE_SYS_WAIT_H > +# include > +#endif > + > +/** macros **/ > +#ifndef WEXITSTATUS > +# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) > +#endif > + > +#ifndef WIFEXITED > +# define WIFEXITED(stat_val) (((stat_val) & 255) == 0) > +#endif > + > +/* 4.3BSD Reno doesn't define SIG_ERR */ > +#if defined(SIG_IGN) && !defined(SIG_ERR) > +# define SIG_ERR ((Sigfunc *)-1) > +#endif > + > +/* This variable must be global, since there's no way the caller > + * can forcibly slay a dead or ungainly running program otherwise. > + * Multithreading apps and plugins can initialize it (via NP_RUNCMD_INIT) > + * in an async safe manner PRIOR to calling np_runcmd() for the first time. > + * > + * The check for initialized values is atomic and can > + * occur in any number of threads simultaneously. */ > +static pid_t *np_pids = NULL; > + > +/* If OPEN_MAX isn't defined, we try the sysconf syscall first. > + * If that fails, we fall back to an educated guess which is accurate > + * on Linux and some other systems. There's no guarantee that our guess is > + * adequate and the program will die with SIGSEGV if it isn't and the > + * upper boundary is breached. */ > +#ifdef OPEN_MAX > +# define maxfd OPEN_MAX > +#else > +# ifndef _SC_OPEN_MAX /* sysconf macro unavailable, so guess */ > +# define maxfd 256 > +# else > +static int maxfd = 0; > +# endif /* _SC_OPEN_MAX */ > +#endif /* OPEN_MAX */ > + > + > +/** prototypes **/ > +static int np_runcmd_open(const char *, int *, int *) > + __attribute__((__nonnull__(1, 2, 3))); > + > +static int np_fetch_output(int, output *, int) > + __attribute__((__nonnull__(2))); > + > +static int np_runcmd_close(int); > + > +/* imported from utils.h */ > +extern void die (int, const char *, ...) > + __attribute__((__noreturn__,__format__(__printf__, 2, 3))); > + > + > +/* this function is NOT async-safe. It is exported so multithreaded > + * plugins (or other apps) can call it prior to running any commands > + * through this api and thus achieve async-safeness throughout the api */ > +void np_runcmd_init(void) > +{ > +#if !defined(OPEN_MAX) && defined(_SC_OPEN_MAX) > + if(!maxfd) { > + if((maxfd = sysconf(_SC_OPEN_MAX)) < 0) { > + /* possibly log or emit a warning here, since there's no > + * guarantee that our guess at maxfd will be adequate */ > + maxfd = 256; > + } > + } > +#endif > + > + if(!np_pids) np_pids = calloc(maxfd, sizeof(pid_t)); > +} > + > + > +/* Start running a command */ > +static int > +np_runcmd_open(const char *cmdstring, int *pfd, int *pfderr) > +{ > + char *env[2]; > + char *cmd = NULL; > + char **argv = NULL; > + char *str; > + int argc; > + size_t cmdlen; > + pid_t pid; > +#ifdef RLIMIT_CORE > + struct rlimit limit; > +#endif > + > + int i = 0; > + > + if(!np_pids) NP_RUNCMD_INIT; > + > + env[0] = strdup("LC_ALL=C"); > + env[1] = '\0'; > + > + /* if no command was passed, return with no error */ > + if (cmdstring == NULL) > + return -1; > + > + /* make copy of command string so strtok() doesn't silently modify it */ > + /* (the calling program may want to access it later) */ > + cmdlen = strlen(cmdstring); > + cmd = malloc(cmdlen + 1); > + if (cmd == NULL) return -1; > + memcpy(cmd, cmdstring, cmdlen); > + > + /* This is not a shell, so we don't handle "???" */ > + if (strstr (cmdstring, "\"")) return -1; > + > + /* allow single quotes, but only if non-whitesapce doesn't occur on both sides */ > + if (strstr (cmdstring, " ' ") || strstr (cmdstring, "'''")) > + return -1; > + > + /* each arg must be whitespace-separated, so args can be a maximum > + * of (len / 2) + 1. We add 1 extra to the mix for NULL termination */ > + argc = (cmdlen >> 1) + 2; > + argv = calloc(sizeof(char *), argc); > + > + if (argv == NULL) { > + printf (_("Could not malloc argv array in popen()\n")); > + return -1; > + } > + > + /* get command arguments (stupidly, but fairly quickly) */ > + while (cmd) { > + str = cmd; > + str += strspn (str, " \t\r\n"); /* trim any leading whitespace */ > + > + if (strstr (str, "'") == str) { /* handle SIMPLE quoted strings */ > + str++; > + if (!strstr (str, "'")) return -1; /* balanced? */ > + cmd = 1 + strstr (str, "'"); > + str[strcspn (str, "'")] = 0; > + } > + else { > + if (strpbrk (str, " \t\r\n")) { > + cmd = 1 + strpbrk (str, " \t\r\n"); > + str[strcspn (str, " \t\r\n")] = 0; > + } > + else { > + cmd = NULL; > + } > + } > + > + if (cmd && strlen (cmd) == strspn (cmd, " \t\r\n")) > + cmd = NULL; > + > + argv[i++] = str; > + } > + > + if (pipe(pfd) < 0 || pipe(pfderr) < 0 || (pid = fork()) < 0) > + return -1; /* errno set by the failing function */ > + > + /* child runs exceve() and _exit. */ > + if (pid == 0) { > +#ifdef RLIMIT_CORE > + /* the program we execve shouldn't leave core files */ > + getrlimit (RLIMIT_CORE, &limit); > + limit.rlim_cur = 0; > + setrlimit (RLIMIT_CORE, &limit); > +#endif > + close (pfd[0]); > + if (pfd[1] != STDOUT_FILENO) { > + dup2 (pfd[1], STDOUT_FILENO); > + close (pfd[1]); > + } > + close (pfderr[0]); > + if (pfderr[1] != STDERR_FILENO) { > + dup2 (pfderr[1], STDERR_FILENO); > + close (pfderr[1]); > + } > + > + /* close all descriptors in np_pids[] > + * This is executed in a separate address space (pure child), > + * so we don't have to worry about async safety */ > + for (i = 0; i < maxfd; i++) > + if(np_pids[i] > 0) > + close (i); > + > + execve (argv[0], argv, env); > + _exit (0); > + } > + > + /* parent picks up execution here */ > + /* close childs descriptors in our address space */ > + close(pfd[1]); > + close(pfderr[1]); > + > + /* tag our file's entry in the pid-list and return it */ > + np_pids[pfd[0]] = pid; > + > + return pfd[0]; > +} > + > + > +static int > +np_runcmd_close(int fd) > +{ > + int status; > + pid_t pid; > + > + /* make sure this fd was opened by popen() */ > + if(fd < 0 || fd > maxfd || !np_pids || (pid = np_pids[fd]) == 0) > + return -1; > + > + np_pids[fd] = 0; > + if (close (fd) == -1) return -1; > + > + /* EINTR is ok (sort of), everything else is bad */ > + while (waitpid (pid, &status, 0) < 0) > + if (errno != EINTR) return -1; > + > + /* return child's termination status */ > + return (WIFEXITED(status)) ? WEXITSTATUS(status) : -1; > +} > + > + > +void > +popen_timeout_alarm_handler (int signo) > +{ > + size_t i; > + > + if (signo == SIGALRM) > + puts(_("CRITICAL - Plugin timed out while executing system call\n")); > + > + if(np_pids) for(i = 0; i < maxfd; i++) { > + if(np_pids[i] != 0) kill(np_pids[i], SIGKILL); > + } > + > + exit (STATE_CRITICAL); > +} > + > + > +static int > +np_fetch_output(int fd, output *op, int flags) > +{ > + size_t len = 0, i = 0; > + size_t rsf = 6, ary_size = 0; /* rsf = right shift factor, dec'ed uncond once */ > + char *buf = NULL; > + int ret; > + char tmpbuf[4096]; > + > + op->buf = NULL; > + op->buflen = 0; > + while((ret = read(fd, tmpbuf, sizeof(tmpbuf))) > 0) { > + len = (size_t)ret; > + op->buf = realloc(op->buf, op->buflen + len + 1); > + memcpy(op->buf + op->buflen, tmpbuf, len); > + op->buflen += len; > + i++; > + } > + > + if(ret < 0) { > + printf("read() returned %d: %s\n", ret, strerror(errno)); > + return ret; > + } > + > + if(!op->buf || !op->buflen) return 0; > + > + /* some plugins may want to keep output unbroken */ > + if(flags & RUNCMD_NO_ARRAYS) > + return op->buflen; > + > + /* and some may want both (*sigh*) */ > + if(flags & RUNCMD_NO_ASSOC) { > + buf = malloc(op->buflen); > + memcpy(buf, op->buf, op->buflen); > + } > + else buf = op->buf; > + > + op->line = NULL; > + op->lens = NULL; > + len = i = 0; > + while(i < op->buflen) { > + /* make sure we have enough memory */ > + if(len >= ary_size) { > + ary_size = op->buflen >> --rsf; > + op->line = realloc(op->line, ary_size * sizeof(char *)); > + op->lens = realloc(op->lens, ary_size * sizeof(size_t)); > + } > + > + /* set the pointer to the string */ > + op->line[len] = &buf[i]; > + > + /* hop to next newline or end of buffer */ > + while(buf[i] != '\n' && i < op->buflen) i++; > + buf[i] = '\0'; > + > + /* calculate the string length using pointer difference */ > + op->lens[len] = (size_t)&buf[i] - (size_t)op->line[len]; > + > + len++; > + i++; > + } > + > + return len; > +} > + > + > +int > +np_runcmd(const char *cmd, output *out, output *err, int flags) > +{ > + int fd, pfd_out[2], pfd_err[2]; > + > + /* initialize the structs */ > + if(out) memset(out, 0, sizeof(output)); > + if(err) memset(err, 0, sizeof(output)); > + > + if((fd = np_runcmd_open(cmd, pfd_out, pfd_err)) == -1) > + die (STATE_UNKNOWN, _("Could not open pipe: %s\n"), cmd); > + > + if(out) out->lines = np_fetch_output(pfd_out[0], out, flags); > + if(err) err->lines = np_fetch_output(pfd_err[0], err, flags); > + > + return np_runcmd_close(fd); > +} > diff -urN ../nplg/plugins/runcmd.h ./plugins/runcmd.h > --- ../nplg/plugins/runcmd.h 1970-01-01 01:00:00.000000000 +0100 > +++ ./plugins/runcmd.h 2005-06-10 15:01:26.000000000 +0200 > @@ -0,0 +1,39 @@ > +/* > + * $Id: runcmd.h,v 1.1 2005/06/05 21:55:26 exon Exp $ > + * > + * Author: Andreas Ericsson > + * > + * Copyright: GNU GPL v2 or any later version. > + * > + */ > + > +#ifndef NAGIOSPLUG_RUNCMD_H > +#define NAGIOSPLUG_RUNCMD_H > + > +#include "common.h" > + > +/** types **/ > +struct output { > + char *buf; /* output buffer */ > + size_t buflen; /* output buffer content length */ > + char **line; /* array of lines (points to buf) */ > + size_t *lens; /* string lengths */ > + size_t lines; /* lines of output */ > +}; > + > +typedef struct output output; > + > +/** prototypes **/ > +int np_runcmd(const char *, output *, output *, int); > +void popen_timeout_alarm_handler(int) > + __attribute__((__noreturn__)); > + > +/* only multi-threaded plugins need to bother with this */ > +void np_runcmd_init(void); > +#define NP_RUNCMD_INIT np_runcmd_init() > + > +/* possible flags for np_runcmd()'s fourth argument */ > +#define RUNCMD_NO_ARRAYS 0x01 /* don't populate arrays at all */ > +#define RUNCMD_NO_ASSOC 0x02 /* output.line won't point to buf */ > + > +#endif /* NAGIOSPLUG_RUNCMD_H */ > diff -urN ../nplg/plugins/urlize.c ./plugins/urlize.c > --- ../nplg/plugins/urlize.c 2005-01-05 21:53:23.000000000 +0100 > +++ ./plugins/urlize.c 2005-06-10 15:01:26.000000000 +0200 > @@ -14,18 +14,18 @@ > along with this program; if not, write to the Free Software > Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. > > - $Id: urlize.c,v 1.17 2004/12/25 23:17:44 opensides Exp $ > + $Id: urlize.c,v 1.2 2005/06/05 21:55:26 exon Exp $ > > ******************************************************************************/ > > const char *progname = "urlize"; > -const char *revision = "$Revision: 1.17 $"; > +const char *revision = "$Revision: 1.2 $"; > const char *copyright = "2000-2004"; > const char *email = "nagiosplug-devel at lists.sourceforge.net"; > > #include "common.h" > #include "utils.h" > -#include "popen.h" > +#include "runcmd.h" > > void print_help (void); > void print_usage (void); > @@ -33,10 +33,11 @@ > int > main (int argc, char **argv) > { > - int found = 0, result = STATE_UNKNOWN; > + int result = STATE_UNKNOWN; > char *url = NULL; > char *cmd; > - char *buf; > + output chld_out, chld_err; > + size_t i; > > int c; > int option = 0; > @@ -67,55 +68,37 @@ > exit (EXIT_SUCCESS); > break; > case 'u': > - url = strdup (argv[optind]); > + url = optarg; > break; > case '?': > default: > - usage2 (_("Unknown argument"), optarg); > + usage3 (_("Unknown argument"), c); > } > } > > - if (url == NULL) > - url = strdup (argv[optind++]); > + if (url == NULL && optind < argc - 1) > + url = argv[optind++]; > > cmd = strdup (argv[optind++]); > for (c = optind; c < argc; c++) { > asprintf (&cmd, "%s %s", cmd, argv[c]); > } > > - child_process = spopen (cmd); > - if (child_process == NULL) { > - printf (_("Could not open pipe: %s\n"), cmd); > - exit (STATE_UNKNOWN); > - } > - > - child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); > - if (child_stderr == NULL) { > - printf (_("Could not open stderr for %s\n"), cmd); > - } > + result = np_runcmd(cmd, &chld_out, &chld_err, 0); > + printf ("", url); > > - buf = malloc(MAX_INPUT_BUFFER); > - printf ("", argv[1]); > - while (fgets (buf, MAX_INPUT_BUFFER - 1, child_process)) { > - found++; > - printf ("%s", buf); > - } > - > - if (!found) > + if (!chld_out.lines) > die (STATE_UNKNOWN, > _("%s UNKNOWN - No data received from host\nCMD: %s\n"), > argv[0], cmd); > > - /* close the pipe */ > - result = spclose (child_process); > + for(i = 0; i < chld_out.lines; i++) > + printf("%s", chld_out.line[i]); > > /* WARNING if output found on stderr */ > - if (fgets (buf, MAX_INPUT_BUFFER - 1, child_stderr)) > + if (chld_err.buflen) > result = max_state (result, STATE_WARNING); > > - /* close stderr */ > - (void) fclose (child_stderr); > - > printf ("\n"); > return result; > } -- Andreas Ericsson andreas.ericsson at op5.se OP5 AB www.op5.se Lead Developer From noreply at sourceforge.net Fri Jun 10 06:50:22 2005 From: noreply at sourceforge.net (SourceForge.net) Date: Fri Jun 10 06:50:22 2005 Subject: [Nagiosplug-devel] [ nagiosplug-Patches-1218232 ] np_runcmd framework Message-ID: Patches item #1218232, was opened at 2005-06-10 15:47 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397599&aid=1218232&group_id=29880 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Enhancement Group: None Status: Open Resolution: None Priority: 5 Submitted By: Andreas Ericsson (ageric) Assigned to: Nobody/Anonymous (nobody) Summary: np_runcmd framework Initial Comment: Ahoy. I've completed the np_runcmd framework and tested it on Linux (FC3 and Owl-current) and FreeBSD. It seems to work splendidly, providing a slight speedup for some things and quite a bit smaller code. Also included in this patch is a major cleanup and overhaul for check_hpjd. I haven't been able to test it as I don't have a hpjd printer, but the theory behind it is sound and I'm confident it will work as expected. It reduces the LOC count by about 100 lines (25%) and uses more portable and easier to parse snmpget syntax. As I don't have cvs commit access I was forced to fork this off into a repository of my own (hence all the $Id: $ updates in the diff). I will keep working on that repository and see what possibilities there are for backsyncing with the official project. Sorry about that, but my work-description includes fixing and improving on the plugins and the number of patches I had to keep track of quickly turned out to be unmanagable without an SCM where I could commit things occasionally. This was also submitted to the nagiosplug-devel list. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397599&aid=1218232&group_id=29880 From noreply at sourceforge.net Fri Jun 10 06:52:20 2005 From: noreply at sourceforge.net (SourceForge.net) Date: Fri Jun 10 06:52:20 2005 Subject: [Nagiosplug-devel] [ nagiosplug-Patches-1218235 ] unicast support for check_dhcp Message-ID: Patches item #1218235, was opened at 2005-06-10 15:49 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397599&aid=1218235&group_id=29880 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Enhancement Group: None Status: Open Resolution: None Priority: 5 Submitted By: Andreas Ericsson (ageric) Assigned to: Nobody/Anonymous (nobody) Summary: unicast support for check_dhcp Initial Comment: Heiti Ernits, an employee at Boras Kommun has added unicast support to the check_dchp plugin. I reworked it a bit to be more general and removed the hardcoded stuff. I also added detection of ones own IP-address to use for the return route. It gives check_dhcp the ability to mimic a dhcp-relay server, which use unicast when talking to the server and therefore can be used to query dhcp-servers on separate and even remote subnets. There are routing rules ofcourse. Querying a dhcp-server with ip 192.168.0.4 on subnet A from 192.168.0.3 on subnet B won't work, as the dhcp-server then will redirect its responses to a host on the same subnet (which may or may not exist) rather than the correct server. Sane networks probably won't suffer from it, and it may be possible to work around it (although I can't imagine how). Apply with patch -p1 < nagiosplug-check_dhcp-unicast.diff ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397599&aid=1218235&group_id=29880 From ae at op5.se Fri Jun 10 06:53:55 2005 From: ae at op5.se (Andreas Ericsson) Date: Fri Jun 10 06:53:55 2005 Subject: [Nagiosplug-devel] check_dhcp unicast patch Message-ID: <42A99A5E.3030109@op5.se> Ahoy. First off, sorry for the last patch, which was slightly on the large side. I should have compressed it, probably. Heiti Ernits, an employee at Boras Kommun has added unicast support to the check_dchp plugin. I reworked it a bit to be more general and removed the hardcoded stuff. I also added detection of ones own IP-address to use for the return route. It gives check_dhcp the ability to mimic a dhcp-relay server, which use unicast when talking to the server and therefore can be used to query dhcp-servers on separate and even remote subnets. There are routing rules ofcourse. Querying a dhcp-server with ip 192.168.0.4 on subnet A from 192.168.0.3 on subnet B won't work, as the dhcp-server then will redirect its responses to a host on the same subnet (which may or may not exist) rather than the correct server. Sane networks probably won't suffer from it, and it may be possible to work around it (although I can't imagine how). Apply with patch -p1 < nagiosplug-check_dhcp-unicast.diff -- Andreas Ericsson andreas.ericsson at op5.se OP5 AB www.op5.se Lead Developer -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: nagiosplug-check_dhcp-unicast.diff URL: From noreply at sourceforge.net Fri Jun 10 12:36:33 2005 From: noreply at sourceforge.net (SourceForge.net) Date: Fri Jun 10 12:36:33 2005 Subject: [Nagiosplug-devel] [ nagiosplug-Bugs-1218438 ] check_radius.c: In function `main': Message-ID: Bugs item #1218438, was opened at 2005-06-10 15:34 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1218438&group_id=29880 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Compilation Group: None Status: Open Resolution: None Priority: 5 Submitted By: S?bastien Guay (sebasguay) Assigned to: Nobody/Anonymous (nobody) Summary: check_radius.c: In function `main': Initial Comment: When trying to compile on slackware I got the following check_radius.c: In function `main': check_radius.c:126: error: too few arguments to function `rc_avpair_add' check_radius.c:127: error: too few arguments to function `rc_avpair_add' check_radius.c:128: error: too few arguments to function `rc_avpair_add' check_radius.c:129: error: too few arguments to function `rc_avpair_add' check_radius.c:139: error: too few arguments to function `rc_avpair_add' check_radius.c:145: error: too few arguments to function `rc_send_server' make[2]: *** [check_radius.o] Error 1 make[2]: Leaving directory `/usr/local/src/nagios-plugins-1.4/plugins' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/usr/local/src/nagios-plugins-1.4' make: *** [all] Error 2 I uninstalled the package ppp-2.4.2-i486-2 and redo a make and all was fine. After I reinstalled ppp-2.4.2-i486-2. ppp-2.4.2-i486-2 has a file radiusclient.h. S?bas ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1218438&group_id=29880 From seanius at seanius.net Fri Jun 10 13:09:45 2005 From: seanius at seanius.net (sean finney) Date: Fri Jun 10 13:09:45 2005 Subject: [Nagiosplug-devel] discussion of general plugin framework Message-ID: <20050610200639.GA11058@seanius.net> hey folks, this is an issue we've been slowly circling around, and the tether between us and the issue is getting smaller and smaller, so i might as well bring it out in the open for a full discussion. so what do we want out of this not-quite-existing API? here's a brain dump of what i can think of: functionality: - common way to run commands and get output, with the options to - seperate and/or ignore stderr - grab all output into large blob - grab all output split line by line - not grab output but pass handles to fd's (or fd-containing structs) - common way to perform network based operations, with options to - connect via various protocols - specify input - expect output - match output against strings or regular expressions - specify an arbitrarily complex pattern of input/ouput events in a connection - snmp related stuff: - provide as easy of an interface as possible for issueing snmp based checks - support v2c BULK requests - support v3 authentication - provide resulting OID arcs as data objects - provide a way to issue callback funcs on larger oid arcs? - provide a means to specify index, name, and values for members of tables. - common CLI options - general - common CLI options - wrapper to getopt to specify plugin-specific options language support: - C: development headers and dynamic libraries - Perl: Nagios::Plugin class/namespace? - shell/python/other? documentation: - relevant API-related updates to the developer guidelines - list of deprecated functions, cmdline options - an authoritative list of the official and unofficial plugins? of the stuff that i've mentioned, much of the work is already done in some form or another. i'm sure i've missed some things, and i've probably injected some subjective opinions into others. so please consider this is more of a discussion to get a final idea of the big picture, and feel free to amend the above list appropriately... sean -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: Digital signature URL: From ae at op5.se Fri Jun 10 16:59:12 2005 From: ae at op5.se (Andreas Ericsson) Date: Fri Jun 10 16:59:12 2005 Subject: [Nagiosplug-devel] discussion of general plugin framework In-Reply-To: <20050610200639.GA11058@seanius.net> References: <20050610200639.GA11058@seanius.net> Message-ID: <42AA28CA.4010404@op5.se> sean finney wrote: > hey folks, > > this is an issue we've been slowly circling around, and the tether > between us and the issue is getting smaller and smaller, so i might > as well bring it out in the open for a full discussion. > > so what do we want out of this not-quite-existing API? here's a brain > dump of what i can think of: > > functionality: > - common way to run commands and get output, with the options to > - seperate and/or ignore stderr > - grab all output into large blob > - grab all output split line by line > - not grab output but pass handles to fd's (or > fd-containing structs) This is more or less completed. It could do with some cross-platform testing though. > - common way to perform network based operations, with options to > - connect via various protocols > - specify input > - expect output This sounds a bit like check_tcp so far. > - match output against strings or regular expressions > - specify an arbitrarily complex pattern of input/ouput > events in a connection This sounds a bit like next generation check_tcp (check_net?). I'm not entirely sure that an exchange protocol like this is completely useful. Most of the common protocols have implementations that doesn't adhere strictly to standard. When such implementations are encountered it would probably be better to fork the generic plugin and do exception handling in separate code. Otherwise there's the risk of making just one large plugin which consists primarily of a long series of if() else if(). > - snmp related stuff: > - provide as easy of an interface as possible for > issueing snmp based checks > - support v2c BULK requests > - support v3 authentication > - provide resulting OID arcs as data objects > - provide a way to issue callback funcs on larger oid arcs? This last one is fairly easy. The mutt (or net-snmp for that matter) way of registering hooks for certain criteria works splendidly. It does however require a matching structure of some sort. Borrowing from PHP or some other high-level script language is most likely the best way to go (a struct for all variable types, with a flag telling which one to use). > - provide a means to specify index, name, and values for > members of tables. > - common CLI options > - general > - common CLI options > - wrapper to getopt to specify plugin-specific options > A long time ago I wrote a getopt() replacement which has the slight benefit of parsing options in a serial manner (that is, the first argument specified in the parser-list is fetched first from the command line). It also supported obscuring of sensitive arguments which could be useful and was fairly cheap to implement. I could look into it again if there's interest. It could quite easily be modded to auto-generate help output from the provided struct. > language support: > - C: development headers and dynamic libraries > - Perl: Nagios::Plugin class/namespace? > - shell/python/other? > C++? I don't write anything in it personally (except the occasional nmap patch, which is always reworked before submission :) ), but it might not be a bad idea to add a couple of #ifdef __cplusplus extern "C" { #endif statements to some of the header files planned for inclusion. > documentation: > - relevant API-related updates to the developer guidelines > - list of deprecated functions, cmdline options > - an authoritative list of the official and unofficial plugins? > Brief list of what's reserved. For example, some people don't know that POSIX has reserved types ending with _t (socklen_t, size_t, time_t etc), or that -W is a POSIX reserved command-line option (actually reserved for local implementation, but that's just standardese for "standardized to be used in some random way"). Recommend ansi89 functions over their BSD counterpart when such exists (memset() vs bzero(), memcpy() vs bcopy()). Compile a list if necessary, and use the "poison" pragma on them if compiling with a decently recent gcc version. > > of the stuff that i've mentioned, much of the work is already done in > some form or another. i'm sure i've missed some things, and i've > probably injected some subjective opinions into others. so please > consider this is more of a discussion to get a final idea of the big > picture, and feel free to amend the above list appropriately... > Userdata functions: - provide functions to actually parse (as opposed to validate) user-input. For example; char *byte_size_suffix[] = { "kb", "mb", "gb", "tb", "pb", NULL }; if(suffix) for(i = 0; byte_size_suffix[i]; i++) { if(!strcmp(suffix, byte_size_suffix[i]) value <<= (10 * i); } Another thing that might be good to decide on is what standards to require in the development environment used for building the plugins. Being portable is all good and well, but it can't be allowed to stop development. A test-harness is always nice and more or less required. I know someone submitted such a one to the tracker a while back, but I haven't had the time to look at it. -- Andreas Ericsson andreas.ericsson at op5.se OP5 AB www.op5.se Lead Developer From noreply at sourceforge.net Sun Jun 12 07:41:59 2005 From: noreply at sourceforge.net (SourceForge.net) Date: Sun Jun 12 07:41:59 2005 Subject: [Nagiosplug-devel] [ nagiosplug-Patches-1185704 ] New Testing Infrastructure Message-ID: Patches item #1185704, was opened at 2005-04-19 17:31 Message generated for change (Comment added) made by illumino You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397599&aid=1185704&group_id=29880 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Enhancement Group: None Status: Open Resolution: None Priority: 5 Submitted By: Peter Bray (illumino) Assigned to: Nobody/Anonymous (nobody) Summary: New Testing Infrastructure Initial Comment: The attched gzip'd tar archive contains a complete replacement for the Nagios Plugins 1.4.0 testing infrastructure and all currently written test harnesses. I hope that it will meet with the approval of the Nagios Plugins Team and replace the existing infrastructure. I have provided documentation of the key functions of the infrastructure in the perl module NPTest.pm and the test harnesses themselves should provide plenty of working examples for further assisting a test harness developer. I hope this infrastructure will ease & encourage the development of test harnesses for all of the Nagios Plugins. Reasoning behind the redevelopment: * I have always had trouble with the existing infrastructure, it never seemed to create the "Cache.pm", and the testing would not function until I had manually created it. * The test harnesses themselves were out of date with respect to the Nagios Plugins 1.4.0 test results. * It was not possible to debug the existing test harness during execution, as the values returned by the execution of the plug-in were never shown to the user. Making updating of out-of-date regexps more time consuming. * Test harnesses themselves were not directly executable. Although I did manage to work around this. Attributes of the new infrastructure: * A single perl module provides the bulk of the logic. The Cache and Helper Modules are no longer required. Aside: I considered rolling all of test.pl into the module, so that could be with "perl -MNPTest -e RunAll ..." but that is not in the current implementation, but its trivial. * The workhorse function "checkCmd" supports * debugging * flexible exit status testing * graceful handling of exceptions * makes each test case more concise and easier to read * All test harnesses are directly executable. * All test harnesses are self contained. They no longer rely on the wrapper to provide test parameters. This could be seen as a negative, but not having to update the wrapper every time a new test parameter is added will simplify development. * The new test parameter cache is much more flexible, including support for default values, environment variable overrides and even scoped parameters should the need arise. I hope these attributes and the corrections to the existing test harnesses will make the contribution a worth while addition to the Nagios Plugins code base. Peter Bray Sydney, Australia LEGAL STUFF: The submission is made "AS IS" with without express or implied warranty. The contribution may be used, redistributed and/or modified under the same terms as the Nagios Plugins release. ---------------------------------------------------------------------- >Comment By: Peter Bray (illumino) Date: 2005-06-13 00:35 Message: Logged In: YES user_id=426773 13th June : What (if anything) can I do to have this submission evaluated by the Nagios Plugins Team? ---------------------------------------------------------------------- Comment By: Peter Bray (illumino) Date: 2005-04-19 19:11 Message: Logged In: YES user_id=426773 Sorry, but I forgot the test.pl rewrite in the orginal archive submission Peter ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397599&aid=1185704&group_id=29880 From noreply at sourceforge.net Mon Jun 13 02:00:16 2005 From: noreply at sourceforge.net (SourceForge.net) Date: Mon Jun 13 02:00:16 2005 Subject: [Nagiosplug-devel] [ nagiosplug-Bugs-1219557 ] Service fails to start with error Message-ID: Bugs item #1219557, was opened at 2005-06-13 08:57 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1219557&group_id=29880 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Boris (dragon_sdc) Assigned to: Nobody/Anonymous (nobody) Summary: Service fails to start with error Initial Comment: Hello, I am having a problem staring NSClient on one of our Win 2003 servers. I am successfully running it on several others. When I try and start it I get "Error 1067 The process terminated unexpectedely". The event log shows the following (I have cut out all the binary data, as the last event log entry had way too much, although I can add it if necessary): --- Event Type: Error Event Source: Application Error Event Category: (100) Event ID: 1000 Date: 13/06/2005 Time: 09:36:58 User: N/A Computer: xxx Description: Faulting application pNSClient.exe, version 2.0.1.0, faulting module unknown, version 0.0.0.0, fault address 0x0084241d. For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp. --- Event Type: Information Event Source: NSClient Event Category: None Event ID: 1 Date: 13/06/2005 Time: 09:36:58 User: N/A Computer: xxx Description: NSClient is now responding to queries. --- Event Type: Error Event Source: NSClient Event Category: None Event ID: 2 Date: 13/06/2005 Time: 09:36:58 User: N/A Computer: xxx Description: NSClient CollectData: Call to retrieve counter value for failed, returning status code 4294967295. --- Event Type: Information Event Source: DrWatson Event Category: None Event ID: 4097 Date: 13/06/2005 Time: 09:36:59 User: N/A Computer: xxx Description: The application, C:\Program Files\NSClient\pNSClient.exe, generated an application error The error occurred on 06/13/2005 @ 09:36:59.174 The exception generated was c0000005 at address 0084241D () For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1219557&group_id=29880 From keith at midnighthax.com Wed Jun 15 11:29:47 2005 From: keith at midnighthax.com (Keith Edmunds) Date: Wed Jun 15 11:29:47 2005 Subject: [Nagiosplug-devel] check_sensor with performance info Message-ID: <42AFD655.4020109@midnighthax.com> I've written a check_sensor plugin that will check one individual sensors as output by the 'sensors' command, part of lm_sensors. It also returns performance information. It's test quality, but I've been using it successfully to monitor and plot voltages, temperatures and fan speeds here. I'm happy to make this available to others to continue testing, or to make it available to the project as a whole. Please contact me if you'd like a copy (note: I do not monitor this mailing list). Regards, Keith From bhuffman at incyte.com Wed Jun 15 11:29:50 2005 From: bhuffman at incyte.com (Brian Huffman) Date: Wed Jun 15 11:29:50 2005 Subject: [Nagiosplug-devel] Nagios plugins 1.4 stable or CVS? Message-ID: All, What would be the recommendation for running Nagios plugins 1.4 on Solaris and linux clients in a production environment? Are the CVS plugins stable enough? Or should I stick w/ 1.4? I'm under the impression that there are fixes for Solaris problems in CVS that might make it the better choice. Are others running CVS plugins in a production environment? Thanks, Brian -------------- next part -------------- An HTML attachment was scrubbed... URL: From ae at op5.se Wed Jun 15 12:56:43 2005 From: ae at op5.se (Andreas Ericsson) Date: Wed Jun 15 12:56:43 2005 Subject: [Nagiosplug-devel] Nagios plugins 1.4 stable or CVS? In-Reply-To: References: Message-ID: <42B08794.2020203@op5.se> Brian Huffman wrote: > All, > > > > What would be the recommendation for running Nagios plugins 1.4 on > Solaris and linux clients in a production environment? Are the CVS > plugins stable enough? Or should I stick w/ 1.4? Oddly enough, the CVS code is much more stable than the 1.4 release. At least on i386 Linux, *BSD, HP-UX and Tru64. I don't know about solaris. > I'm under the > impression that there are fixes for Solaris problems in CVS that might > make it the better choice. > Indeed. > > Are others running CVS plugins in a production environment? > Yes, but with a moderate amount of fixes. I grew tired of juggling an ever-growing set of patches at my end and forked the code. Most of it is still the same, but I've chopped out a couple of bugs and added some features (an experimental framework for running commands, among other things). I'll put it up for download if you're interested. -- Andreas Ericsson andreas.ericsson at op5.se OP5 AB www.op5.se Lead Developer From seanius at seanius.net Wed Jun 15 13:19:11 2005 From: seanius at seanius.net (sean finney) Date: Wed Jun 15 13:19:11 2005 Subject: [Nagiosplug-devel] Nagios plugins 1.4 stable or CVS? In-Reply-To: <42B08794.2020203@op5.se> References: <42B08794.2020203@op5.se> Message-ID: <20050615201606.GA8516@seanius.net> On Wed, Jun 15, 2005 at 09:55:00PM +0200, Andreas Ericsson wrote: > >What would be the recommendation for running Nagios plugins 1.4 on > >Solaris and linux clients in a production environment? Are the CVS > >plugins stable enough? Or should I stick w/ 1.4? > > Oddly enough, the CVS code is much more stable than the 1.4 release. At > least on i386 Linux, *BSD, HP-UX and Tru64. I don't know about solaris. this is mostly true, i'd say. i think the majority of things that have gone into cvs since 1.4 has come out have not been new features but bug fixes. ton: perhaps it's time to do a 1.4.1 release? > >Are others running CVS plugins in a production environment? what i tend to do is run the bulk of the 'official' plugins (as provided by my distribution's nagios-plugins package), and if i stumble across a particular problem that's fixed in cvs, i compile it, plop it in /usr/local, and modify my config to use that one instead. as andreas mentioned, there are going to be some big changes in the not-too-distant-future that may make this less the case, but for the meantime if you're already compiling the whole plugin suite from source i wouldn't worry about using the nagios stuff from CVS HEAD. sean -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: Digital signature URL: From seanius at seanius.net Wed Jun 15 13:34:13 2005 From: seanius at seanius.net (sean finney) Date: Wed Jun 15 13:34:13 2005 Subject: [Nagiosplug-devel] discussion of general plugin framework In-Reply-To: <42AA28CA.4010404@op5.se> References: <20050610200639.GA11058@seanius.net> <42AA28CA.4010404@op5.se> Message-ID: <20050615203227.GB8516@seanius.net> hey andreas, On Sat, Jun 11, 2005 at 01:56:58AM +0200, Andreas Ericsson wrote: > >functionality: > > - common way to run commands and get output, with the options to > > - seperate and/or ignore stderr > > - grab all output into large blob > > - grab all output split line by line > > - not grab output but pass handles to fd's (or > > fd-containing structs) > > This is more or less completed. It could do with some cross-platform > testing though. yes. like i said, many of the things i mentioned are already done to a certain extent. what i'm getting at is more of the 'big picture', and the glue that will bring it all together. > > - common way to perform network based operations, with options to > > - connect via various protocols > > - specify input > > - expect output > > This sounds a bit like check_tcp so far. > > > - match output against strings or regular expressions > > - specify an arbitrarily complex pattern of input/ouput > > events in a connection > > This sounds a bit like next generation check_tcp (check_net?). I'm not i think it would be an enhancement to check_tcp, check_udp, and any other simple network-based plugin. also, i think i forgot to mention: - better support for reading/sending/expecting binary data. > entirely sure that an exchange protocol like this is completely useful. > Most of the common protocols have implementations that doesn't adhere > strictly to standard. When such implementations are encountered it would > probably be better to fork the generic plugin and do exception handling > in separate code. Otherwise there's the risk of making just one large > plugin which consists primarily of a long series of if() else if(). yeah, this may be true. this would be way more effort than it were worth if any kind of decision making logic had to be incorporated, and it would be better to fork it off into a seperate plugin. the question is whether or not it's worth the effort to define a datatype and write the functions to support the arbitrary send/expect stuff for the simple cases. i'm thinking it may not be, or at least that it would be just as much code to do it that way as with some normal if/else statements. > > - provide a means to specify index, name, and values for > > members of tables. > > - common CLI options > > - general > > - common CLI options > > - wrapper to getopt to specify plugin-specific options > > > > A long time ago I wrote a getopt() replacement which has the slight > benefit of parsing options in a serial manner (that is, the first > argument specified in the parser-list is fetched first from the command > line). It also supported obscuring of sensitive arguments which could be > useful and was fairly cheap to implement. I could look into it again if > there's interest. It could quite easily be modded to auto-generate help > output from the provided struct. i ran across that patch in the tracker a bit back, though i haven't taken a close look at it. i'd argue against the merits of commandline obfuscation though, as there's still a theoretical opening to get the cmdline arguments and in most cases there's a better way to provide said credentials. > >language support: > > - C: development headers and dynamic libraries > > C++? I don't write anything in it personally (except the occasional nmap sure... why not? :) > Brief list of what's reserved. For example, some people don't know that > POSIX has reserved types ending with _t (socklen_t, size_t, time_t etc), > or that -W is a POSIX reserved command-line option (actually reserved > for local implementation, but that's just standardese for "standardized > to be used in some random way"). > Recommend ansi89 functions over their BSD counterpart when such exists > (memset() vs bzero(), memcpy() vs bcopy()). Compile a list if necessary, > and use the "poison" pragma on them if compiling with a decently recent > gcc version. all good points. > Userdata functions: > - provide functions to actually parse (as opposed to validate) > user-input. For example; > > char *byte_size_suffix[] = { "kb", "mb", "gb", "tb", "pb", NULL }; > if(suffix) for(i = 0; byte_size_suffix[i]; i++) { > if(!strcmp(suffix, byte_size_suffix[i]) value <<= (10 * i); > } this would be a very nice macro/function to have laying around. > Another thing that might be good to decide on is what standards to > require in the development environment used for building the plugins. > Being portable is all good and well, but it can't be allowed to stop > development. i don't think it has any time recently. granted it's kind of hard to bugfix on an AIX system when you don't have one readily available, but i don't think that would keep us from releasing. of course, a list of tested environments and recommended/supported toolchains couldn't hurt. sean -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: Digital signature URL: From ae at op5.se Wed Jun 15 15:08:22 2005 From: ae at op5.se (Andreas Ericsson) Date: Wed Jun 15 15:08:22 2005 Subject: [Nagiosplug-devel] discussion of general plugin framework In-Reply-To: <20050615203227.GB8516@seanius.net> References: <20050610200639.GA11058@seanius.net> <42AA28CA.4010404@op5.se> <20050615203227.GB8516@seanius.net> Message-ID: <42B0A6A4.1030609@op5.se> sean finney wrote: > hey andreas, > > On Sat, Jun 11, 2005 at 01:56:58AM +0200, Andreas Ericsson wrote: > >>> - common way to perform network based operations, with options to >>> - connect via various protocols >>> - specify input >>> - expect output >> >>This sounds a bit like check_tcp so far. >> >> >>> - match output against strings or regular expressions >>> - specify an arbitrarily complex pattern of input/ouput >>> events in a connection >> >>This sounds a bit like next generation check_tcp (check_net?). I'm not > > > i think it would be an enhancement to check_tcp, check_udp, and any > other simple network-based plugin. also, i think i forgot to mention: > > - better support for reading/sending/expecting binary data. > This is fairly simple after all; Just slap on a len variable. If it's zero but the pointer to the data is non-null, use strlen() to evaluate it. Otherwise use len. > >>entirely sure that an exchange protocol like this is completely useful. >>Most of the common protocols have implementations that doesn't adhere >>strictly to standard. When such implementations are encountered it would >>probably be better to fork the generic plugin and do exception handling >>in separate code. Otherwise there's the risk of making just one large >>plugin which consists primarily of a long series of if() else if(). > > > yeah, this may be true. this would be way more effort than it were > worth if any kind of decision making logic had to be incorporated, > and it would be better to fork it off into a seperate plugin. the > question is whether or not it's worth the effort to define a datatype > and write the functions to support the arbitrary send/expect stuff > for the simple cases. process_tcp_request() already exists. It's stupid and obsolescent, but it's there. > i'm thinking it may not be, or at least that > it would be just as much code to do it that way as with some normal > if/else statements. > > > >>> - provide a means to specify index, name, and values for >>> members of tables. >>> - common CLI options >>> - general >>> - common CLI options >>> - wrapper to getopt to specify plugin-specific options >>> >> >>A long time ago I wrote a getopt() replacement which has the slight >>benefit of parsing options in a serial manner (that is, the first >>argument specified in the parser-list is fetched first from the command >>line). It also supported obscuring of sensitive arguments which could be >>useful and was fairly cheap to implement. I could look into it again if >>there's interest. It could quite easily be modded to auto-generate help >>output from the provided struct. > > > i ran across that patch in the tracker a bit back, though i haven't taken > a close look at it. i'd argue against the merits of commandline > obfuscation though, as there's still a theoretical opening to get > the cmdline arguments and in most cases there's a better way to provide > said credentials. > Indeed. That was just some intellectual masturbation (although not very satisfying). The ability to parse command arguments in an order decided by the programmer might be fairly useful though. It would also get rid of the various differences of getopt_long on various systems and wouldn't increase loc count (getopt.c is already there). > >>Brief list of what's reserved. For example, some people don't know that >>POSIX has reserved types ending with _t (socklen_t, size_t, time_t etc), >>or that -W is a POSIX reserved command-line option (actually reserved >>for local implementation, but that's just standardese for "standardized >>to be used in some random way"). >>Recommend ansi89 functions over their BSD counterpart when such exists >>(memset() vs bzero(), memcpy() vs bcopy()). Compile a list if necessary, >>and use the "poison" pragma on them if compiling with a decently recent >>gcc version. > > > all good points. > > >>Userdata functions: >> - provide functions to actually parse (as opposed to validate) >> user-input. For example; >> >>char *byte_size_suffix[] = { "kb", "mb", "gb", "tb", "pb", NULL }; >>if(suffix) for(i = 0; byte_size_suffix[i]; i++) { >> if(!strcmp(suffix, byte_size_suffix[i]) value <<= (10 * i); >>} > > > this would be a very nice macro/function to have laying around. > There should be more functions like this. Gathering a single command-line argument is a 4-5 lines of code today. It should be 1 (+ possibly 1 to deal with failures). > >>Another thing that might be good to decide on is what standards to >>require in the development environment used for building the plugins. >>Being portable is all good and well, but it can't be allowed to stop >>development. > > > i don't think it has any time recently. getopt_long(), asprintf(). The decisions to use both those were taken knowing that it would mean bringing in a lot of code from the outside. asprintf() is also heavily abused (I've ranted about this earlier). In about 90% of the cases I've seen so far, a simple restructuring and possibly a call to die() every now and then has sufficed to get rid of a whole host of them (don't get me started on the uses it's put to in the perfdata functions). > granted it's kind of hard > to bugfix on an AIX system when you don't have one readily available, This is actually a problem I think it would be fairly easy to fix. When I was doing a lot of work with check_icmp I called for help from people who wanted to use it. I got access (root, even) at no less than 8 different platforms. It was for a limited time ofcourse, but I don't think it would be terribly difficult to do something similar prior to releases. At least not if root-access isn't strictly needed. Also, HP has a developer program that lets people sign up for accounts on a lot of different platforms and architectures. I've made heavy use of that on occasion, and I've begged Sun and Apple to do something similar (to no avail). > but i don't think that would keep us from releasing. of course, a list > of tested environments and recommended/supported toolchains couldn't hurt. > -- Andreas Ericsson andreas.ericsson at op5.se OP5 AB www.op5.se Lead Developer From sivakumar.nellurandi at cingular.com Mon Jun 20 10:32:29 2005 From: sivakumar.nellurandi at cingular.com (Nellurandi, Sivakumar) Date: Mon Jun 20 10:32:29 2005 Subject: [Nagiosplug-devel] check_swap in SUN OS Message-ID: Hi, I am finding some difficulties for having the check_swap plugin worked in SUN Solaris operating system. Can you please provide me the working version source code of the check_swap plugin? Problem description We have a question on the usage of check_swap plugin (version 1.4) on Solaris. The following is an extract from the print_help() function in check_swap.c printf (_("\n\ On Solaris, if -a specified, uses swap -l, otherwise uses swap -s.\n\ Will be discrepencies because swap -s counts allocated swap and includes\n\ real memory\n")); printf (_("\n\ On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s.\n")); The above print statements clearly state that omitting the "-a" argument to the plugin uses "swap -s" command on Solaris and "lsps -s" command on AIX. The following is again an extract from check_swap.c file which executes the "lsps -s" command for AIX /* These override the command used if a summary (and thus ! allswaps) is required */ /* The summary flag returns more accurate information about swap usage on these OSes */ # ifdef _AIX if (!allswaps) { asprintf(&swap_command, "%s", "/usr/sbin/lsps -s"); asprintf(&swap_format, "%s", "%f%*s %f"); conv_factor = 1; } # endif But in the code we did not find a similar execution of "swap -s" command for Solaris. Could you point out where the execution of "swap -s" command takes place. Here is the output of the plugin on Solaris 2.6 with & without the "-a" option. $ ./check_swap -a -w 10% -c 5% SWAP CRITICAL: 3% free (6 MB out of 200 MB) |swap=5MB;20;10;0;200 $ ./check_swap -w 10% -c 5% SWAP CRITICAL: 3% free (6 MB out of 200 MB) |swap=5MB;20;10;0;200 $ /usr/sbin/swap -l swapfile dev swaplo blocks free /dev/dsk/c0t3d0s1 32,25 8 410248 11312 As you can see, the output of the plugin is always in sync with "swap -l" command. We have observed the same behavior on Solaris 2.8 and Solaris 9 also. Thanks in advance for any help. Siva -------------- next part -------------- An HTML attachment was scrubbed... URL: From noreply at sourceforge.net Wed Jun 22 04:57:05 2005 From: noreply at sourceforge.net (SourceForge.net) Date: Wed Jun 22 04:57:05 2005 Subject: [Nagiosplug-devel] [ nagiosplug-Bugs-1225470 ] check_swap performance info incorrect Message-ID: Bugs item #1225470, was opened at 2005-06-22 11:55 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1225470&group_id=29880 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Keith Edmunds (backseat) Assigned to: Nobody/Anonymous (nobody) Summary: check_swap performance info incorrect Initial Comment: If check_swap is invoked with percentage aguments the performance data is incorrect: ------------------------------------------------------------------- $ ./check_swap -V check_swap (nagios-plugins 1.4) 1.47 $ ./check_swap -w 30% -c 20% SWAP OK: 94% free (894 MB out of 954 MB) |swap=893MB;286;190;0;953 ------------------------------------------------------------------- In the performance data section is: value=893 warn=286 crit=190 min=0 max=953 The value is above both the warn and crit values, which in this case is correct (ie, not an error). It would be better if the performance data were presented in percentage terms if the input is in percentage terms. One solution would be to express the warning and critical values as an @range (alarm if within range) with a lower value of zero. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1225470&group_id=29880 From Matt.Goli at fwpubs.com Thu Jun 23 19:18:12 2005 From: Matt.Goli at fwpubs.com (Goli, Matt) Date: Thu Jun 23 19:18:12 2005 Subject: [Nagiosplug-devel] Check_smtp plug-in suggestion Message-ID: <03A472EB8A2D624CBF1565E4E6DEF3A8692A@lart1wi1.krause.com> I am currently using version 1.9.2.2 of the check_smtp plug-in, and I would like to request that the plug-in have an option for sending the SMTP command "STARTTLS" prior to sending the "MAIL FROM:" command to the SMTP server. With our Exchange 2003 SMTP server, it causes an Event Log entry to occur every time the check is run against the Exchange SMTP server. Event log entry from Windows 2003, Exchange 2003 SMTP Server: Event Type: Error Event Source: MSExchangeTransport Event Category: SMTP Protocol Event ID: 7010 Date: 6/20/2005 Time: 3:57:15 PM User: N/A Computer: EXCH2 Description: This is an SMTP protocol log for virtual server ID 1, connection #980. The client at "172.29.1.252" sent a "mail" command, and the SMTP server responded with "505 5.7.3 Must issue a STARTTLS command first ". The full command sent was "mail FROM: ". This will probably cause the connection to fail. If there are any questions, or if I can be of more assistance, please feel free to contact me. Thank you, -- Matt Goli Network Engineer F+W Publications, Inc. (715) 445-4612 x 547 From seanius at seanius.net Sat Jun 25 16:50:00 2005 From: seanius at seanius.net (sean finney) Date: Sat Jun 25 16:50:00 2005 Subject: [Nagiosplug-devel] Check_smtp plug-in suggestion In-Reply-To: <03A472EB8A2D624CBF1565E4E6DEF3A8692A@lart1wi1.krause.com> References: <03A472EB8A2D624CBF1565E4E6DEF3A8692A@lart1wi1.krause.com> Message-ID: <20050625234832.GA5330@seanius.net> hi matt, On Mon, Jun 20, 2005 at 08:47:27PM -0500, Goli, Matt wrote: > I am currently using version 1.9.2.2 of the check_smtp plug-in, and I > would like to request that the plug-in have an option for sending the > SMTP command "STARTTLS" prior to sending the "MAIL FROM:" command to the > SMTP server. With our Exchange 2003 SMTP server, it causes an Event Log > entry to occur every time the check is run against the Exchange SMTP > server. try with the latest version of check_smtp out of CVS, i believe this should work against exchange. sean -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: Digital signature URL: From seanius at seanius.net Sat Jun 25 16:53:54 2005 From: seanius at seanius.net (sean finney) Date: Sat Jun 25 16:53:54 2005 Subject: [Nagiosplug-devel] check_swap in SUN OS In-Reply-To: References: Message-ID: <20050625235253.GB5330@seanius.net> hi siva, On Mon, Jun 20, 2005 at 10:13:57AM -0700, Nellurandi, Sivakumar wrote: > I am finding some difficulties for having the check_swap plugin worked > in SUN Solaris operating system. Can you please provide me the working > version source code of the check_swap plugin? sorry for the late reply, i've been afk for the last week or two, and i don't think anyone else here seems to have much to say about check_swap it seems. > printf (_("\n\ > On Solaris, if -a specified, uses swap -l, otherwise uses swap -s.\n\ > Will be discrepencies because swap -s counts allocated swap and > includes\n\ > real memory\n")); > printf (_("\n\ > On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s.\n")); > > The above print statements clearly state that omitting the "-a" argument > to the plugin uses "swap -s" command on Solaris and "lsps -s" command on > AIX. > But in the code we did not find a similar execution of "swap -s" command > for Solaris. Could you point out where the execution of "swap -s" > command takes place. my guess is that this usage information is outdated, and that swap -s is not executed at all, because iirc the solaris check_swap heavily (or perhaps exclusively) favors usage of the swapctl library routines instead of executing the cmdline program. sean -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: Digital signature URL: From seanius at seanius.net Sat Jun 25 18:16:01 2005 From: seanius at seanius.net (sean finney) Date: Sat Jun 25 18:16:01 2005 Subject: [Nagiosplug-devel] discussion of general plugin framework In-Reply-To: <42B0A6A4.1030609@op5.se> References: <20050610200639.GA11058@seanius.net> <42AA28CA.4010404@op5.se> <20050615203227.GB8516@seanius.net> <42B0A6A4.1030609@op5.se> Message-ID: <20050626011420.GA6245@seanius.net> hey, back at the keyboard now... On Thu, Jun 16, 2005 at 12:07:32AM +0200, Andreas Ericsson wrote: > > - better support for reading/sending/expecting binary data. > > This is fairly simple after all; Just slap on a len variable. If it's > zero but the pointer to the data is non-null, use strlen() to evaluate > it. Otherwise use len. right. > There should be more functions like this. Gathering a single > command-line argument is a 4-5 lines of code today. It should be 1 (+ > possibly 1 to deal with failures). dealing with failures could also have some kind of common and overloadable approach too, now that you mention it. > asprintf() is also heavily abused (I've ranted about this earlier). In yes, and i agree that it should be weaned out as much as possible. > This is actually a problem I think it would be fairly easy to fix. When > I was doing a lot of work with check_icmp I called for help from people > who wanted to use it. I got access (root, even) at no less than 8 > different platforms. It was for a limited time ofcourse, but I don't such access would be very helpful. i reached a stopping point with check_swap on AIX because i lost my access to the last AIX system i could login on, and got tired of debugging via email with the one person who was willing to test my source code... sean -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: Digital signature URL: From seanius at seanius.net Sat Jun 25 18:26:06 2005 From: seanius at seanius.net (sean finney) Date: Sat Jun 25 18:26:06 2005 Subject: [Nagiosplug-devel] asprintf() madness (example patch) In-Reply-To: <42A1611F.2050305@op5.se> References: <42A15BAF.2070707@op5.se> <42A1611F.2050305@op5.se> Message-ID: <20050626012426.GA6375@seanius.net> On Sat, Jun 04, 2005 at 10:06:55AM +0200, Andreas Ericsson wrote: > And here be the patch. ;) i've applied it to CVS, minus the comments sean -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: Digital signature URL: From seanius at seanius.net Sun Jun 26 09:29:20 2005 From: seanius at seanius.net (sean finney) Date: Sun Jun 26 09:29:20 2005 Subject: [Nagiosplug-devel] Obsoleted contrib and tarballs files In-Reply-To: <42A968A4.2010503@op5.se> References: <42A968A4.2010503@op5.se> Message-ID: <20050626162720.GA14990@seanius.net> hey, On Fri, Jun 10, 2005 at 12:17:08PM +0200, Andreas Ericsson wrote: > I've been doing a "shallow audit" of the contrib and tarballs stuff in > the nagiosplug CVS. > > In the tarballs directory, the following files are obsolete; > berger-ping.tar.gz, There's already 2 ping programs, do we need another? removed from cvs > check_memory.tar.gz (won't work on recent platforms, and can easily be > replaced by forking check_swap() and using it for memory checks). removed from cvs. > check_spread.tar, won't compile, poorly documented, no build instructions. removed from cvs. > check_traffic-0.91b.tar.gz, I've improved greatly on this and intend to > submit a patch to make it one of the standard plugins. i'll leave this until that happens then. > radius.tar.gz, the same files are distributed with the radiusclient > distribution. removed from cvs. > In the contrib directory; > check_logins (obsoleted by the near-identical check_users) > check_procl, check_procr; the same functionality can be obtained by > check_procs. > check_pop3.pl - check_tcp provides better functionality > check_nwstat.pl - check_nwstat provides better functionality > check_ftpget.pl - highly insecure (I can hack up a C version in about 10 > minutes if anyone's actually interested, without using local files). > check_dl_size.pl - see check_ftpget.pl. somewhat obsoleted by check_http. all of these removed from cvs. > check_rbl.c, rblcheck* - abusive and cause for black-listing (which is > funny, since they check for blacklisted domains) abusive because of the typical frequency, or what? > check_mem.pl - easily obsoleted by a fork of check_swap (or __progname > logic). then i'll leave this around until then. > check_timeout.c - should really be in nagios/testing of the nagios core > distribution, or dropped completely. don't know enough about what this one does. > check_mysql.c, check_mysql.pl, check_mysqlslave.pl - obsoleted by > plugins/check_mysql.c (which is cleaner and has more features). removed from cvs. thanks, sean -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: Digital signature URL: From ae at op5.se Sun Jun 26 13:35:15 2005 From: ae at op5.se (Andreas Ericsson) Date: Sun Jun 26 13:35:15 2005 Subject: [Nagiosplug-devel] Obsoleted contrib and tarballs files In-Reply-To: <20050626162720.GA14990@seanius.net> References: <42A968A4.2010503@op5.se> <20050626162720.GA14990@seanius.net> Message-ID: <42BF1119.3030302@op5.se> sean finney wrote: > hey, > > On Fri, Jun 10, 2005 at 12:17:08PM +0200, Andreas Ericsson wrote: > >>check_rbl.c, rblcheck* - abusive and cause for black-listing (which is >>funny, since they check for blacklisted domains) > > > abusive because of the typical frequency, or what? > Yes. I'm not completely positive how it works, but being run with a 15 minute interval makes it stop working after about 3 hours. It also pollutes the black-lists. > >>check_mem.pl - easily obsoleted by a fork of check_swap (or __progname >>logic). > > > then i'll leave this around until then. > > >>check_timeout.c - should really be in nagios/testing of the nagios core >>distribution, or dropped completely. > > > don't know enough about what this one does. > It times out. It can't do any competent work and is designed only to test Nagios' capability of slaying misbehaving plugins. I have a few other plugins which are equally useless for end users, so I'll submit them to the core project or perhaps build a small tarball of my own. It should only be used by very few very devoted beta-testers, so it's probably best to keep them separated from anything resembling "live" plugins. -- Andreas Ericsson andreas.ericsson at op5.se OP5 AB www.op5.se Lead Developer From srunschke at abit.de Mon Jun 27 02:09:13 2005 From: srunschke at abit.de (srunschke at abit.de) Date: Mon Jun 27 02:09:13 2005 Subject: [Nagiosplug-devel] [Virus scanned] Message-ID: Greetings, I have a fairly strange problem with both check_dig and check_dns, both from v1.4. It is reporting WARNING messages when it shouldn't and I cannot get any clue why those pop up at all. An example run from the commandline: [nagios at nagios libexec]$ ./check_dig -H 10.1.1.1 -l sourceforge.net -w 2 -c 5 DNS WARNING - 0.005 seconds response time (sourceforge.net. 1394 IN A 66.35.250.203)|time=0.004595s;2.000000;5.000000;0.000000 While the warning and critical threshholds are noted correctly in the perf data output, check_dig _always_ goes into WARNING as soon as the response is 0.005s or greater - which is unwanted behaviour of course, since I set warning to 2 sec and critical to 5 sec. I already took a peek into the code, but I couldn't find any error - to me it looks like it should work smooth, but then I'm not a big C crack ;) I'm in dire need of help, the other admins are going to lynch me soon ;) sash -------------------------------------------------- Sascha Runschke Netzwerk Administration IT-Services ABIT AG Robert-Bosch-Str. 1 40668 Meerbusch Tel.:+49 (0) 2150.9153.226 Mobil:+49 (0) 173.5419665 mailto:SRunschke at abit.de http://www.abit.net http://www.abit-epos.net http://www.my-academy.net -------------------------------------------------- Der Inhalt dieser Email sowie die Anh?nge sind ausschlie?lich f?r den bezeichneten Adressaten bestimmt. Wenn Sie nicht der vorgesehene Adressat dieser Email oder dessen Vertreter sein sollten, so beachten Sie bitte, da? jede Form der Kenntnisnahme, Ver?ffentlichung, Vervielf?ltigung oder Weitergabe des Inhalts dieser Email unzul?ssig ist. Wir m?chten Sie au?erdem darauf hinweisen, da? die Kommunikation per Email ?ber das Internet unsicher ist, da fuer unberechtigte Dritte grunds?tzlich die M?glichkeit der Kenntnisnahme und Manipulation besteht. Wenn Sie diese Nachricht versehentlich erhalten, informieren Sie bitte den Absender und l?schen diese Nachricht mit den Anh?ngen. Herzlichen Dank The information and any attachments contained in this email are intended solely for the addressee. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any form of disclosure, reproduction, distribution or any action taken or refrained from in reliance on it, is prohibited and may be unlawful. We also like to inform you that communication via email over the internet is insecure because third parties may have the possibility to access and manipulate emails. If you have received the message in error, please advise the sender and delete the message and any attachments. Thank you very much. From noreply at sourceforge.net Mon Jun 27 06:10:32 2005 From: noreply at sourceforge.net (SourceForge.net) Date: Mon Jun 27 06:10:32 2005 Subject: [Nagiosplug-devel] [ nagiosplug-Patches-1216576 ] Two check_hpjd fixes Message-ID: Patches item #1216576, was opened at 2005-06-07 13:44 Message generated for change (Comment added) made by seanius You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397599&aid=1216576&group_id=29880 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Bugfix Group: None >Status: Closed >Resolution: Fixed Priority: 5 Submitted By: Richard Brodie (leogah) >Assigned to: M. Sean Finney (seanius) Summary: Two check_hpjd fixes Initial Comment: This patch fixes two problems in the check_hpjd plugin. Firstly, the OIDs for Paper Out and Paper Jam have been transposed. Both the HP MIB and reality seem to have them the other way. Secondly, some of the newer HP printers have a multiline status LCD (and send newline characters in the status text). ---------------------------------------------------------------------- >Comment By: M. Sean Finney (seanius) Date: 2005-06-27 09:08 Message: Logged In: YES user_id=226838 thanks for the patch! ---------------------------------------------------------------------- Comment By: M. Sean Finney (seanius) Date: 2005-06-27 09:08 Message: Logged In: YES user_id=226838 this patch has been committed to the nagiosplug CVS repository. thank you for your contribution. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397599&aid=1216576&group_id=29880 From nagios at nagios.org Mon Jun 27 15:32:01 2005 From: nagios at nagios.org (Ethan Galstad) Date: Mon Jun 27 15:32:01 2005 Subject: [Nagiosplug-devel] Obsoleted contrib and tarballs files In-Reply-To: <42BF1119.3030302@op5.se> References: <20050626162720.GA14990@seanius.net> Message-ID: <42C037E2.12509.152FDE9@localhost> On 26 Jun 2005 at 22:33, Andreas Ericsson wrote: > sean finney wrote: > > hey, > > > > On Fri, Jun 10, 2005 at 12:17:08PM +0200, Andreas Ericsson wrote: > > > >>check_rbl.c, rblcheck* - abusive and cause for black-listing (which > >>is funny, since they check for blacklisted domains) > > > > > > abusive because of the typical frequency, or what? > > > > Yes. I'm not completely positive how it works, but being run with a 15 > minute interval makes it stop working after about 3 hours. It also > pollutes the black-lists. > > > > >>check_mem.pl - easily obsoleted by a fork of check_swap (or > >>__progname logic). > > > > > > then i'll leave this around until then. > > > > > >>check_timeout.c - should really be in nagios/testing of the nagios > >>core distribution, or dropped completely. > > > > > > don't know enough about what this one does. > > > > It times out. It can't do any competent work and is designed only to > test Nagios' capability of slaying misbehaving plugins. I have a few > other plugins which are equally useless for end users, so I'll submit > them to the core project or perhaps build a small tarball of my own. > It should only be used by very few very devoted beta-testers, so it's > probably best to keep them separated from anything resembling "live" > plugins. > Timing out can be useful, and not just for debugging purposes. This should definitely stay in the plugin distribution - I'm not planning on taking any plugins back into the main Nagios distribution. If its still there, check_dummy should stay as well. Also, it seems like there should be more input from plugin developers and users before a whole swath of plugins gets nuked from the CVS repository. Unless the complete functionality of some of the deceased plugins is implemented by the remaining survivors, why should they be removed? Sure, check_ftpget.pl and check_dl_size.pl (for example) may be insecure or inefficient, but so what if those are the things you need to monitor as an admin? I'm sure there was a valid reason that someone submitted the check_rbl.c plugin and related friends. If someone needs the functionality those plugins provide, why should we nuke them? Just my two cents. Ethan Galstad, Nagios Developer --- Email: nagios at nagios.org Website: http://www.nagios.org From seanius at seanius.net Mon Jun 27 16:56:24 2005 From: seanius at seanius.net (sean finney) Date: Mon Jun 27 16:56:24 2005 Subject: [Nagiosplug-devel] Obsoleted contrib and tarballs files In-Reply-To: <42C037E2.12509.152FDE9@localhost> References: <20050626162720.GA14990@seanius.net> <42C037E2.12509.152FDE9@localhost> Message-ID: <20050627235500.GA31390@seanius.net> hi ethan, On Mon, Jun 27, 2005 at 05:31:14PM -0500, Ethan Galstad wrote: > Timing out can be useful, and not just for debugging purposes. This > should definitely stay in the plugin distribution - I'm not planning > on taking any plugins back into the main Nagios distribution. If its > still there, check_dummy should stay as well. i agree, but it would probably be more appropriate to segregate these debugging plugins into a seperate location other than 'contrib' or the main plugins directory. > Also, it seems like there should be more input from plugin developers > and users before a whole swath of plugins gets nuked from the CVS > repository. Unless the complete functionality of some of the perhaps that was a bit heavy handed of me. however, these were all 'contrib' plugins, and i guess i take a slightly different attitude towards these vs. the 'official' plugins. also, when i signed on the nagiosplug team, the initial area where i was going to focus my efforts was bug-fixing and code cleaning, to which i feel this is an extension. i was basically operating on the assumption that these are buggy and not frequently used plugins and no tears would be shed about their disappearance. it is worth pointing out that if someone wants it back, it can always be resurrected from the attic (or in some cases preferably re-written). also, i do agree that there should be more communication. between the plugin group and the nagios core as well, for that matter--the current discussion of developing a more robust plugin api, is a good example. however the lists have been fairly quiet as of late... > should they be removed? Sure, check_ftpget.pl and check_dl_size.pl > (for example) may be insecure or inefficient, but so what if those > are the things you need to monitor as an admin? I'm sure there was a in that case, the version from the official 1.4 release could still be used. and of course the nagiosplug developers would appreciate hearing from said admins with either a comment like 'wtf? i need this plugin!', or more preferably a new version of the plugin. > valid reason that someone submitted the check_rbl.c plugin and > related friends. If someone needs the functionality those plugins > provide, why should we nuke them? Just my two cents. about the check_rbl.c, this is perhaps true. i don't know enough about what it's doing wrt the rbls (and how what it does differs from an equivalent check_dns), but do know enough to be concerned about providing what might turn into a headache for rbl server admins when the number of nagios installations running check_rbl every 5 minutes slowly starts to grow. perhaps something could be done on our end to discourage that behavior and still provide the desired functionality--like have check_rbl require a --not-abusive option that has to be passed to function, and if not passed exits with a warning telling them to make sure not to check too frequently or whatever and use the option. an idea, anyway. perhaps someone with more knowledge of the plugin can comment? sean -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: Digital signature URL: From noreply at sourceforge.net Mon Jun 27 17:02:01 2005 From: noreply at sourceforge.net (SourceForge.net) Date: Mon Jun 27 17:02:01 2005 Subject: [Nagiosplug-devel] [ nagiosplug-Bugs-1122262 ] checki_fping Message-ID: Bugs item #1122262, was opened at 2005-02-14 05:11 Message generated for change (Settings changed) made by seanius You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1122262&group_id=29880 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Argument proccessing Group: Release (specify) >Status: Closed >Resolution: Invalid Priority: 5 Submitted By: Chancellor Sy (i_m_chance) Assigned to: Nobody/Anonymous (nobody) Summary: checki_fping Initial Comment: Hi, When i run check_fping The output is it only checks Here is a sample output [root at apserv libexec]# ./check_fping -v -H 133.88.30.173 133.88.6.4 /usr/local/sbin/fping -b 56 -c 1 133.88.30.173 133.88.30.173 : [0], 84 bytes, 0.19 ms (0.19 avg, 0% loss) 133.88.30.173 : xmt/rcv/%loss = 1/1/0%, min/avg/max = 0.19/0.19/0.19 FPING OK - 133.88.30.173 (loss=0%, rta=0.190000 ms)|loss=0%;;;0;100 rta=0.000190s;;;0.000000 Your answer is very much appreciated. Regards Chancellor Sy ---------------------------------------------------------------------- >Comment By: M. Sean Finney (seanius) Date: 2005-06-27 20:00 Message: Logged In: YES user_id=226838 closing this bug... ---------------------------------------------------------------------- Comment By: Subhendu Ghosh (sghosh) Date: 2005-05-25 14:36 Message: Logged In: YES user_id=46572 Check_fping only supports one hostname ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1122262&group_id=29880 From noreply at sourceforge.net Mon Jun 27 17:30:46 2005 From: noreply at sourceforge.net (SourceForge.net) Date: Mon Jun 27 17:30:46 2005 Subject: [Nagiosplug-devel] [ nagiosplug-Bugs-1123292 ] check_swap: invalid scanf specification in argument parse Message-ID: Bugs item #1123292, was opened at 2005-02-15 13:17 Message generated for change (Comment added) made by seanius You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1123292&group_id=29880 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Argument proccessing Group: Release (specify) >Status: Closed >Resolution: Fixed Priority: 5 Submitted By: Steve Greenland (vmole) >Assigned to: M. Sean Finney (seanius) Summary: check_swap: invalid scanf specification in argument parse Initial Comment: Parsing the values of -w and -c (may) use the scanf() fmt string "%.0f, %d%%". However, precision specifiers are invalid in scanf() processing. I suppose the intent is to trim off any trailing fraction, but that can't be done in scanf(). Instead, read the whole value, and then use floor(3). ---------------------------------------------------------------------- >Comment By: M. Sean Finney (seanius) Date: 2005-06-27 20:27 Message: Logged In: YES user_id=226838 thanks for pointing this out. i've updated the update the plugin to use floor and the configure/makefile.am to test for -lm which many systems need for floor. ---------------------------------------------------------------------- Comment By: M. Sean Finney (seanius) Date: 2005-06-27 20:27 Message: Logged In: YES user_id=226838 this problem is now fixed in cvs. thank you for your report. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1123292&group_id=29880 From noreply at sourceforge.net Mon Jun 27 19:07:31 2005 From: noreply at sourceforge.net (SourceForge.net) Date: Mon Jun 27 19:07:31 2005 Subject: [Nagiosplug-devel] [ nagiosplug-Bugs-1218438 ] check_radius.c: In function `main': Message-ID: Bugs item #1218438, was opened at 2005-06-10 15:34 Message generated for change (Comment added) made by seanius You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1218438&group_id=29880 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Compilation Group: None Status: Open Resolution: None Priority: 5 Submitted By: S?bastien Guay (sebasguay) >Assigned to: M. Sean Finney (seanius) Summary: check_radius.c: In function `main': Initial Comment: When trying to compile on slackware I got the following check_radius.c: In function `main': check_radius.c:126: error: too few arguments to function `rc_avpair_add' check_radius.c:127: error: too few arguments to function `rc_avpair_add' check_radius.c:128: error: too few arguments to function `rc_avpair_add' check_radius.c:129: error: too few arguments to function `rc_avpair_add' check_radius.c:139: error: too few arguments to function `rc_avpair_add' check_radius.c:145: error: too few arguments to function `rc_send_server' make[2]: *** [check_radius.o] Error 1 make[2]: Leaving directory `/usr/local/src/nagios-plugins-1.4/plugins' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/usr/local/src/nagios-plugins-1.4' make: *** [all] Error 2 I uninstalled the package ppp-2.4.2-i486-2 and redo a make and all was fine. After I reinstalled ppp-2.4.2-i486-2. ppp-2.4.2-i486-2 has a file radiusclient.h. S?bas ---------------------------------------------------------------------- >Comment By: M. Sean Finney (seanius) Date: 2005-06-27 22:06 Message: Logged In: YES user_id=226838 hi sebastien, this looks like a problem with slackware or the slackware package of ppp then. where is the radiusclient.h provided by your libradius package (or whatever the slackware equivalent is that provides radiusclient.h)? i'm not sure why installing ppp would plop an include file used to build ppp in a compiler accessible directory in the first place, but unless you can provide a convincing reason why this is a problem with the nagios plugins, i'm going to close out the bug in a week's time. thanks, sean ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1218438&group_id=29880 From noreply at sourceforge.net Mon Jun 27 19:13:16 2005 From: noreply at sourceforge.net (SourceForge.net) Date: Mon Jun 27 19:13:16 2005 Subject: [Nagiosplug-devel] [ nagiosplug-Bugs-1219557 ] Service fails to start with error Message-ID: Bugs item #1219557, was opened at 2005-06-13 04:57 Message generated for change (Settings changed) made by seanius You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1219557&group_id=29880 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None >Status: Closed >Resolution: Invalid Priority: 5 Submitted By: Boris (dragon_sdc) Assigned to: Nobody/Anonymous (nobody) Summary: Service fails to start with error Initial Comment: Hello, I am having a problem staring NSClient on one of our Win 2003 servers. I am successfully running it on several others. When I try and start it I get "Error 1067 The process terminated unexpectedely". The event log shows the following (I have cut out all the binary data, as the last event log entry had way too much, although I can add it if necessary): --- Event Type: Error Event Source: Application Error Event Category: (100) Event ID: 1000 Date: 13/06/2005 Time: 09:36:58 User: N/A Computer: xxx Description: Faulting application pNSClient.exe, version 2.0.1.0, faulting module unknown, version 0.0.0.0, fault address 0x0084241d. For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp. --- Event Type: Information Event Source: NSClient Event Category: None Event ID: 1 Date: 13/06/2005 Time: 09:36:58 User: N/A Computer: xxx Description: NSClient is now responding to queries. --- Event Type: Error Event Source: NSClient Event Category: None Event ID: 2 Date: 13/06/2005 Time: 09:36:58 User: N/A Computer: xxx Description: NSClient CollectData: Call to retrieve counter value for failed, returning status code 4294967295. --- Event Type: Information Event Source: DrWatson Event Category: None Event ID: 4097 Date: 13/06/2005 Time: 09:36:59 User: N/A Computer: xxx Description: The application, C:\Program Files\NSClient\pNSClient.exe, generated an application error The error occurred on 06/13/2005 @ 09:36:59.174 The exception generated was c0000005 at address 0084241D () For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp. ---------------------------------------------------------------------- >Comment By: M. Sean Finney (seanius) Date: 2005-06-27 22:11 Message: Logged In: YES user_id=226838 hi, this doesn't look like a problem with the nagios plugins, but instead looks like a problem with the program nsclient (which is not part of the nagios-plugins project). looking through our source and documentation, i found the following link, which might be helpful: http://nsclient.ready2run.nl/ ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1219557&group_id=29880 From noreply at sourceforge.net Mon Jun 27 19:25:59 2005 From: noreply at sourceforge.net (SourceForge.net) Date: Mon Jun 27 19:25:59 2005 Subject: [Nagiosplug-devel] [ nagiosplug-Bugs-1144727 ] check_disk fails on Solaris with large available space Message-ID: Bugs item #1144727, was opened at 2005-02-20 05:44 Message generated for change (Comment added) made by seanius You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1144727&group_id=29880 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: John-David Childs (diskmuncher) >Assigned to: M. Sean Finney (seanius) Summary: check_disk fails on Solaris with large available space Initial Comment: check_disk returns a CRITICAL on Solaris (test 5.7 and 5.9) if a checked_filesystem actually has > 1TB of free space. This does NOT happen on Linux. Verifying functionality on IRIX. controldev [10:21am] plugins 69% df -k Filesystem kbytes used avail capacity Mounted on /proc 0 0 0 0% /proc /dev/dsk/c0t0d0s0 9075677 6666149 2318772 75% / fd 0 0 0 0% /dev/fd /dev/dsk/c0t0d0s4 482455 138924 295286 32% /var swap 1757696 79080 1678616 5% /tmp /dev/dsk/c0t0d0s6 6196234 6161 6128111 1% /ewrt /dev/dsk/c0t1d0s0 20652353 13923398 6522432 69% /bronze /dev/dsk/c0t1d0s1 20652353 4633312 15812518 23% /tools /dev/dsk/c0t1d0s4 29281179 23773695 5214673 83% /home opsnas1:/vol/home 1767421352 653768396 1113652956 37% /mnt controldev [10:23am] plugins 70% ./check_disk -w 10% -c 5% -e DISK CRITICAL - free space: /mnt 9007199254740993 MB (521854746624%);| /=6598MB;7975;8418;0;8862 /var=183MB;423;447;0;471 /tmp=77MB;1544;1630;0;1716 /ewrt=67MB;5445;5748;0;6051 /bronze=13799MB;18151;19159;0;20168 /tools=4727MB;18151;19159;0;20168 /home=23502MB;25734;27164;0;28594 /mnt=2735598MB;1553397;1639697;0;1725997 ---------------------------------------------------------------------- >Comment By: M. Sean Finney (seanius) Date: 2005-06-27 22:23 Message: Logged In: YES user_id=226838 hi john, have you had the chance to look into this more? unfortunately i don't have access to a solaris system with > 1TB storage so my powers to debug are a bit diminished. i suspect some number may be truncated somewhere, either in check_disk.c (most likely) or fsusage.c (harder to read, but also less likely the source). ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1144727&group_id=29880 From noreply at sourceforge.net Mon Jun 27 19:29:00 2005 From: noreply at sourceforge.net (SourceForge.net) Date: Mon Jun 27 19:29:00 2005 Subject: [Nagiosplug-devel] [ nagiosplug-Bugs-1164325 ] Warning threshold must be float or float triplet!" at check_ Message-ID: Bugs item #1164325, was opened at 2005-03-16 04:44 Message generated for change (Comment added) made by seanius You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1164325&group_id=29880 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None >Status: Closed >Resolution: Fixed Priority: 5 Submitted By: Wilfried Brunken (df7be) >Assigned to: M. Sean Finney (seanius) Summary: Warning threshold must be float or float triplet!" at check_ Initial Comment: No output generated, because of this Can the configure Script automatically find the problem ? (or documentation "INSTALL.UNIX" adding ?) The Workaround to fix the Problem was: - add the Line "setlocale(LC_NUMERIC, "POSIX");" in plugins/check_load.c - ./configure --disable-nls - Short Test: cd plugins ./check_load -w 1,1,1 -c 2,2,2 Needed "--disable-nls" at following OS: RedHat AS 3 ( gcc-3.2.3-49 ) SuSe-LINUX 9.x ( gcc-3.3.4-11 on 9.2 ) NOT SuSe 8.2 !! AIX 5.1 (not 4.3) ! ( C for AIX Compiler, Version 6 ) I found the Information visiting the following site: http://article.gmane.org/gmane.network.nagios.plugins.d evel/2473 1. Recompile the plugins using: ./configure --disable-nls I have not tested this, but I believe this should work. After the 'textdomain' call at the start of the plugin source code, add the line: setlocale(LC_NUMERIC, "POSIX"); Eg, with your problem plugin check_load. Edit plugins/check_load.c: -------------------check_load.c------------------- int main (int argc, char **argv) { int result = STATE_UNKNOWN; #if HAVE_GETLOADAVG==1 double la[3] = { 0.0, 0.0, 0.0 }; /* NetBSD complains about unitialized arrays */ #else # if HAVE_PROC_LOADAVG==1 FILE *fp; char input_buffer[MAX_INPUT_BUFFER]; char *tmp_ptr; # else char input_buffer[MAX_INPUT_BUFFER]; # endif #endif float la1, la5, la15; setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); setlocale(LC_NUMERIC, "POSIX"); <--- HERE!! -------------------check_load.c------------------- ---------------------------------------------------------------------- >Comment By: M. Sean Finney (seanius) Date: 2005-06-27 22:27 Message: Logged In: YES user_id=226838 thanks! ---------------------------------------------------------------------- Comment By: M. Sean Finney (seanius) Date: 2005-06-27 22:27 Message: Logged In: YES user_id=226838 this problem is now fixed in cvs. thank you for your report. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1164325&group_id=29880 From noreply at sourceforge.net Mon Jun 27 19:31:31 2005 From: noreply at sourceforge.net (SourceForge.net) Date: Mon Jun 27 19:31:31 2005 Subject: [Nagiosplug-devel] [ nagiosplug-Bugs-1185616 ] Hp Laserjet check Message-ID: Bugs item #1185616, was opened at 2005-04-18 23:21 Message generated for change (Comment added) made by seanius You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1185616&group_id=29880 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: David Andrew (fatherosam) >Assigned to: M. Sean Finney (seanius) Summary: Hp Laserjet check Initial Comment: I have written a quick and nasty HP Laserjet checker. Un fortunatly I am not a programmer and it is a bit quick and dirty. Just wondering if anyone thinks it is useful. ---------------------------------------------------------------------- >Comment By: M. Sean Finney (seanius) Date: 2005-06-27 22:29 Message: Logged In: YES user_id=226838 are you sure the current version of check_hpjd (in cvs) doesn't provide this ability, looking at the source code, i see the MIBS for these defined... ---------------------------------------------------------------------- Comment By: Aaron Kent Moore (mooreak) Date: 2005-04-20 09:45 Message: Logged In: YES user_id=867794 I would be interested in seeing it added to the plugins. It would be handy to be able to check the paper and toner status when someone calls about their printer not working. ---------------------------------------------------------------------- Comment By: David Andrew (fatherosam) Date: 2005-04-19 18:20 Message: Logged In: YES user_id=926258 I found check_hpjd only reported on the Jet Direct Card, this reports on the printer. Toner levels and paper out and service error messages etc. While check_hpjd only reported on the HP Net card in the printer. ---------------------------------------------------------------------- Comment By: Subhendu Ghosh (sghosh) Date: 2005-04-19 14:46 Message: Logged In: YES user_id=46572 Whats wrong with check_hpjd (HP JetDirect)? ---------------------------------------------------------------------- Comment By: Subhendu Ghosh (sghosh) Date: 2005-04-18 23:43 Message: Logged In: YES user_id=46572 Whats wrong with check_hpjd (HP JetDirect)? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1185616&group_id=29880 From seanius at seanius.net Mon Jun 27 21:17:14 2005 From: seanius at seanius.net (sean finney) Date: Mon Jun 27 21:17:14 2005 Subject: [Nagiosplug-devel] check_dhcp unicast patch In-Reply-To: <42A99A5E.3030109@op5.se> References: <42A99A5E.3030109@op5.se> Message-ID: <20050628041546.GA1351@seanius.net> hi, continuing on making my way through a backlog of mail... On Fri, Jun 10, 2005 at 03:49:18PM +0200, Andreas Ericsson wrote: > Ahoy. First off, sorry for the last patch, which was slightly on the > large side. I should have compressed it, probably. > > Apply with patch -p1 < nagiosplug-check_dhcp-unicast.diff the applies, but the plugin then fails to compile. looks like a missing '\n\' in the usage function. however, after i apply the patch, i can't seem to get the plugin to work. i get a bunch of messages on the dhcp server like: dhcpd: parse_option_buffer: option boot-size (126) larger than buffer. dhcpd: parse_option_buffer: option boot-size (126) larger than buffer. dhcpd: parse_option_buffer: option #130 (48) larger than buffer. dhcpd: parse_option_buffer: option #130 (48) larger than buffer. which seem to vary with what option and size they report, so i'm thinking maybe uninitialized memory or improperly set field in the dhcp options. though... now that i've tried with the cvs version, i get the same error. any ideas? sean -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: Digital signature URL: From ae at op5.se Tue Jun 28 00:52:32 2005 From: ae at op5.se (Andreas Ericsson) Date: Tue Jun 28 00:52:32 2005 Subject: [Nagiosplug-devel] Obsoleted contrib and tarballs files In-Reply-To: <42C037E2.12509.152FDE9@localhost> References: <20050626162720.GA14990@seanius.net> <42C037E2.12509.152FDE9@localhost> Message-ID: <42C10145.90408@op5.se> Ethan Galstad wrote: > On 26 Jun 2005 at 22:33, Andreas Ericsson wrote: > > >>sean finney wrote: >> >>>hey, >>> >>>On Fri, Jun 10, 2005 at 12:17:08PM +0200, Andreas Ericsson wrote: >>> >>> >>>>check_rbl.c, rblcheck* - abusive and cause for black-listing (which >>>>is funny, since they check for blacklisted domains) >>> >>> >>>abusive because of the typical frequency, or what? >>> >> >>Yes. I'm not completely positive how it works, but being run with a 15 >>minute interval makes it stop working after about 3 hours. It also >>pollutes the black-lists. >> >> >>>>check_mem.pl - easily obsoleted by a fork of check_swap (or >>>>__progname logic). >>> >>> >>>then i'll leave this around until then. >>> >>> >>> >>>>check_timeout.c - should really be in nagios/testing of the nagios >>>>core distribution, or dropped completely. >>> >>> >>>don't know enough about what this one does. >>> >> >>It times out. It can't do any competent work and is designed only to >>test Nagios' capability of slaying misbehaving plugins. I have a few >>other plugins which are equally useless for end users, so I'll submit >>them to the core project or perhaps build a small tarball of my own. >>It should only be used by very few very devoted beta-testers, so it's >>probably best to keep them separated from anything resembling "live" >>plugins. >> > > > Timing out can be useful, and not just for debugging purposes. This > should definitely stay in the plugin distribution - I'm not planning > on taking any plugins back into the main Nagios distribution. I'll set up a different testing release then. Distributing it with the sane plugins that aren't exclusively for testing doesn't make much sense if you ask me, as only core testers will be able to make any use of it at all. > If its still there, check_dummy should stay as well. > check_dummy has real uses (forcing stale passive checks to be something without using much load) and such, so that's a bit different. > Also, it seems like there should be more input from plugin developers > and users before a whole swath of plugins gets nuked from the CVS > repository. Unless the complete functionality of some of the > deceased plugins is implemented by the remaining survivors, why > should they be removed? Sure, check_ftpget.pl and check_dl_size.pl > (for example) may be insecure or inefficient, but so what if those > are the things you need to monitor as an admin? I don't know if you followed the thread from start, but all of the nuked plugins are obsoleted by official ones which have been extended since the contrib ones were contributed. All of them were also notoriously ugly in code and many of them suffered from lots of hardcoded paths and variables. Bringing them up to official standards would have taken more time than anyone can politely be asked to spend, and given their very narrow usage I think it's safe to say that noone would ever have done it. That said, if someone wants to check downloads from an FTP-site, I'll be happy to write a (much faster, safer and cleaner) version in C. Given the simplicity of the FTP protocol it shouldn't take much longer than 20-30 minutes. -- Andreas Ericsson andreas.ericsson at op5.se OP5 AB www.op5.se Lead Developer From seanius at seanius.net Tue Jun 28 08:18:02 2005 From: seanius at seanius.net (sean finney) Date: Tue Jun 28 08:18:02 2005 Subject: [Nagiosplug-devel] Obsoleted contrib and tarballs files In-Reply-To: <42C10145.90408@op5.se> <20050628042526.GA657@ws11114.aipo.gov.au> References: <20050626162720.GA14990@seanius.net> <42C037E2.12509.152FDE9@localhost> <42C10145.90408@op5.se> <20050626162720.GA14990@seanius.net> <42C037E2.12509.152FDE9@localhost> <20050627235500.GA31390@seanius.net> <20050628042526.GA657@ws11114.aipo.gov.au> Message-ID: <20050628151555.GA7661@seanius.net> hi, (quoting with permission a private mail from stanley hopcroft) On Tue, Jun 28, 2005 at 02:25:26PM +1000, Stanley Hopcroft wrote: > I have a different view of /contrib: that /contrib are candidates for > inclusion in the supported plugins (those in with the /plugin prefix) when > there is sufficient information to decide that they are popular enough or > conformant enough for one of the plugin developers to say they should be. > > At present, this is loosely decided based on the number of recommendations > about a contributed plugin (eg try plugins/check_ica or whatever it's called > these days). > > The matter of the lower quality of the code is understood by inclusion in > /contrib. The ISC BIND and DHCP projects both distribute /contrib code with > disclaimers about fitness for purpose or support; I thought that this was the > view this project took also. > > There is no doubt that there could be code that is less useful in /contrib but > it seems to me that there is > > 1 no cost in retaining it > > 2 a benefit in demonstrating the projects gratitude for contributed code so > that people will produce plugins for the project. both are good points. this has to be balanced with a certain amount of quality control, but i guess that should really be before the plugins are accepted into contrib. > Irrespective of whether there _is_ a superior published plugin > API/Framework/Modus operandi, I don't think it hurts to provide examples in > /contrib of simple, script kiddy code that still serves a useful purpose. > > Until the project clearly states that Nagios plugins require this this and > this and should adhere to these coding standards, I don't think we should > discard /contrib contributions. i'm coming around to the same opinion myself for the plugins that aren't superceded by 'official' plugins. > To sum up, I don't think this is a debate about the quality of contributed > code, but about the projects relationship with developers and about the metrics for > inclusion in the supported plugins.. On Tue, Jun 28, 2005 at 09:50:29AM +0200, Andreas Ericsson wrote: > I'll set up a different testing release then. Distributing it with the > sane plugins that aren't exclusively for testing doesn't make much sense > if you ask me, as only core testers will be able to make any use of it > at all. i think just another directory in CVS would be appropriate, wouldn't it? perhaps nagiosplug/debug-plugins? > I don't know if you followed the thread from start, but all of the nuked > plugins are obsoleted by official ones which have been extended since > the contrib ones were contributed. All of them were also notoriously with the exception of the rbl/ftp plugins... > ugly in code and many of them suffered from lots of hardcoded paths and > variables. Bringing them up to official standards would have taken more > time than anyone can politely be asked to spend, and given their very > narrow usage I think it's safe to say that noone would ever have done it. i think that for future reference, we should have a higher level of code quality required before plugins are brought into ./contrib (which should then be documented), but i'm beginning to side with ethan and stanley that existing plugins should be grandfathered (does that expression work in swedish too?) in until they can be replaced with something better. > That said, if someone wants to check downloads from an FTP-site, I'll be > happy to write a (much faster, safer and cleaner) version in C. Given > the simplicity of the FTP protocol it shouldn't take much longer than > 20-30 minutes. i'd be happy to see this. if it's complicated by the upcoming changes wrt the np_runcmd or other api stuff perhaps we can table it in a TODO until then. sean -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: Digital signature URL: From ae at op5.se Tue Jun 28 08:53:06 2005 From: ae at op5.se (Andreas Ericsson) Date: Tue Jun 28 08:53:06 2005 Subject: [Nagiosplug-devel] Obsoleted contrib and tarballs files In-Reply-To: <20050628151555.GA7661@seanius.net> References: <20050626162720.GA14990@seanius.net> <42C037E2.12509.152FDE9@localhost> <42C10145.90408@op5.se> <20050626162720.GA14990@seanius.net> <42C037E2.12509.152FDE9@localhost> <20050627235500.GA31390@seanius.net> <20050628042526.GA657@ws11114.aipo.gov.au> <20050628151555.GA7661@seanius.net> Message-ID: <42C17208.1080403@op5.se> sean finney wrote: > hi, > > (quoting with permission a private mail from stanley hopcroft) > > On Tue, Jun 28, 2005 at 02:25:26PM +1000, Stanley Hopcroft wrote: > >>I have a different view of /contrib: that /contrib are candidates for >>inclusion in the supported plugins (those in with the /plugin prefix) when >>there is sufficient information to decide that they are popular enough or >>conformant enough for one of the plugin developers to say they should be. >> >>At present, this is loosely decided based on the number of recommendations >>about a contributed plugin (eg try plugins/check_ica or whatever it's called >>these days). >> AFAIK, no plugins that have been in contrib for an extended period of time has ever been included in the official distro without a clean patch from an outside user that makes that last effort to push them into stable use. >>The matter of the lower quality of the code is understood by inclusion in >>/contrib. The ISC BIND and DHCP projects both distribute /contrib code with >>disclaimers about fitness for purpose or support; I thought that this was the >>view this project took also. >> >>There is no doubt that there could be code that is less useful in /contrib but >>it seems to me that there is >> >>1 no cost in retaining it >> This is only true if you count money. Maintaining code in contrib which has superior counterparts or are otherwise obsoleted makes auditing said plugins pure pain. I did just that, and scanning through the often-times very obscure and shoddy code to deduce what the plugin actually does (many don't have any comments or --help output) takes its fair amount of time. >>2 a benefit in demonstrating the projects gratitude for contributed code so >>that people will produce plugins for the project. > This would be greatly increased if those plugins were actively moved to the official distro once in a while. Using ideas from contrib to enhance the official counter-part of the plugin is also worthy of mentioning in the THANKS file. Accepting plugins per default so that people can feel fuzzy inside doesn't make much sense if the plugins only work on the plugin authors own machine. > > both are good points. this has to be balanced with a certain amount of > quality control, but i guess that should really be before the plugins > are accepted into contrib. > > >>Irrespective of whether there _is_ a superior published plugin >>API/Framework/Modus operandi, I don't think it hurts to provide examples in >>/contrib of simple, script kiddy code that still serves a useful purpose. >> >>Until the project clearly states that Nagios plugins require this this and >>this and should adhere to these coding standards, I don't think we should >>discard /contrib contributions. > > > i'm coming around to the same opinion myself for the plugins that aren't > superceded by 'official' plugins. > For those that aren't redundant with official ones, yes. > >>To sum up, I don't think this is a debate about the quality of contributed >>code, but about the projects relationship with developers and about the metrics for >>inclusion in the supported plugins.. > Umm... I would have thought the metrics for inclusion were in a very real way related to code quality. > > On Tue, Jun 28, 2005 at 09:50:29AM +0200, Andreas Ericsson wrote: > >>I'll set up a different testing release then. Distributing it with the >>sane plugins that aren't exclusively for testing doesn't make much sense >>if you ask me, as only core testers will be able to make any use of it >>at all. > > > i think just another directory in CVS would be appropriate, wouldn't it? > perhaps nagiosplug/debug-plugins? > Only beta-testers can use it, but whatever floats your dinghy. I'll still be maintaining my own fork of the plugins though. I have neither time nor energy to juggle the amount of patches I end up with after an audit-run, and I can't really justify my paycheck if I sit around waiting for others to do my work for me. > >>I don't know if you followed the thread from start, but all of the nuked >>plugins are obsoleted by official ones which have been extended since >>the contrib ones were contributed. All of them were also notoriously > > > with the exception of the rbl/ftp plugins... > > >>ugly in code and many of them suffered from lots of hardcoded paths and >>variables. Bringing them up to official standards would have taken more >>time than anyone can politely be asked to spend, and given their very >>narrow usage I think it's safe to say that noone would ever have done it. > > > i think that for future reference, we should have a higher level > of code quality required before plugins are brought into ./contrib > (which should then be documented), A small comment in the form of; # check_toaster.pl - checks heat emitted from the SNMP-enabled SuperToaster, using Net::SNMP. # Threshold values are in fahrenheit, unless suffixed by C. # usage: check_toaster.pl -H -w -c at the top of the script should do it. Some industrious script-person can then cook up the right --help function and make sure things are done properly. > but i'm beginning to side with ethan > and stanley that existing plugins should be grandfathered (does that > expression work in swedish too?) Not really. The exact translation (such as it is) would be "Farfara", which I'm fairly certain means something very rude in hebrew. > in until they can be replaced with > something better. > > >>That said, if someone wants to check downloads from an FTP-site, I'll be >>happy to write a (much faster, safer and cleaner) version in C. Given >>the simplicity of the FTP protocol it shouldn't take much longer than >>20-30 minutes. > > > i'd be happy to see this. if it's complicated by the upcoming changes > wrt the np_runcmd or other api stuff perhaps we can table it in a TODO > until then. > Setting up a socket and sending a few commands is not exactly difficult. I'll manage without the api, I think. np_runcmd() won't have any impact at all. -- Andreas Ericsson andreas.ericsson at op5.se OP5 AB www.op5.se Lead Developer From Nik.Sands at utas.edu.au Tue Jun 28 11:08:38 2005 From: Nik.Sands at utas.edu.au (Nik Sands) Date: Tue Jun 28 11:08:38 2005 Subject: [Nagiosplug-devel] check_swap divide by 0 error Message-ID: <107BE4AB-F3F7-4825-AFCC-8A2FEB9D282E@utas.edu.au> The "check_swap" nagios plugin has a minor flaw, in that the output is incorrect for machines with no swap configured (at least on Solaris). Some people may say, "well, you should have swap configured!", but when the machine has 16 GB of RAM, it really isn't necessary. In any case, it should at least show the correct percentage used, which would be either 100% (and warning or critical) or 0%. As it is it get's the result of a divide by zero, which is rather ugly. The line of code is question is: percent_used = 100 * ((double) used_swap) / ((double) total_swap); When there's no swap, this amounts to: percent_used = 100 * 0 / 0; If would be good to have a block before this, something like: if ( total_swap == 0 ) { /* percent_used = either 0 or 100, depending on your point of view */ } else Thanks for your consideration of this imporovement. Please note that I'm not a member of this list so won't see any responses posted to the list. If I need to see any responses (which I doubt), please CC them to me. Cheers, Nik. ======================================================== NIK SANDS - Systems Administrator, IT Services, University of Tasmania, Australia Phone: +61-3-63243732 (BH) VoIP (Free Call): (1800 262 218) 393 658821 AIM / iChat: brassnix From sivakumar.nellurandi at cingular.com Tue Jun 28 11:08:40 2005 From: sivakumar.nellurandi at cingular.com (Nellurandi, Sivakumar) Date: Tue Jun 28 11:08:40 2005 Subject: [Nagiosplug-devel] check_swap in SUN OS Message-ID: Thank you so much for the reply. Can you please get me the source code which is using swap -s command? Regards, Siva -----Original Message----- From: sean finney [mailto:seanius at seanius.net] Sent: Saturday, June 25, 2005 4:53 PM To: Nellurandi, Sivakumar Cc: kdebisschop at users.sourceforge.net; nagiosplug-devel at lists.sourceforge.net Subject: Re: [Nagiosplug-devel] check_swap in SUN OS hi siva, On Mon, Jun 20, 2005 at 10:13:57AM -0700, Nellurandi, Sivakumar wrote: > I am finding some difficulties for having the check_swap plugin worked > in SUN Solaris operating system. Can you please provide me the working > version source code of the check_swap plugin? sorry for the late reply, i've been afk for the last week or two, and i don't think anyone else here seems to have much to say about check_swap it seems. > printf (_("\n\ > On Solaris, if -a specified, uses swap -l, otherwise uses swap -s.\n\ > Will be discrepencies because swap -s counts allocated swap and > includes\n\ real memory\n")); > printf (_("\n\ > On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s.\n")); > > The above print statements clearly state that omitting the "-a" > argument to the plugin uses "swap -s" command on Solaris and "lsps -s" > command on AIX. > But in the code we did not find a similar execution of "swap -s" > command for Solaris. Could you point out where the execution of "swap > -s" command takes place. my guess is that this usage information is outdated, and that swap -s is not executed at all, because iirc the solaris check_swap heavily (or perhaps exclusively) favors usage of the swapctl library routines instead of executing the cmdline program. sean From noreply at sourceforge.net Tue Jun 28 11:16:32 2005 From: noreply at sourceforge.net (SourceForge.net) Date: Tue Jun 28 11:16:32 2005 Subject: [Nagiosplug-devel] [ nagiosplug-Bugs-1219557 ] Service fails to start with error Message-ID: Bugs item #1219557, was opened at 2005-06-13 01:57 Message generated for change (Comment added) made by slocs You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1219557&group_id=29880 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Closed Resolution: Invalid Priority: 5 Submitted By: Boris (dragon_sdc) Assigned to: Nobody/Anonymous (nobody) Summary: Service fails to start with error Initial Comment: Hello, I am having a problem staring NSClient on one of our Win 2003 servers. I am successfully running it on several others. When I try and start it I get "Error 1067 The process terminated unexpectedely". The event log shows the following (I have cut out all the binary data, as the last event log entry had way too much, although I can add it if necessary): --- Event Type: Error Event Source: Application Error Event Category: (100) Event ID: 1000 Date: 13/06/2005 Time: 09:36:58 User: N/A Computer: xxx Description: Faulting application pNSClient.exe, version 2.0.1.0, faulting module unknown, version 0.0.0.0, fault address 0x0084241d. For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp. --- Event Type: Information Event Source: NSClient Event Category: None Event ID: 1 Date: 13/06/2005 Time: 09:36:58 User: N/A Computer: xxx Description: NSClient is now responding to queries. --- Event Type: Error Event Source: NSClient Event Category: None Event ID: 2 Date: 13/06/2005 Time: 09:36:58 User: N/A Computer: xxx Description: NSClient CollectData: Call to retrieve counter value for failed, returning status code 4294967295. --- Event Type: Information Event Source: DrWatson Event Category: None Event ID: 4097 Date: 13/06/2005 Time: 09:36:59 User: N/A Computer: xxx Description: The application, C:\Program Files\NSClient\pNSClient.exe, generated an application error The error occurred on 06/13/2005 @ 09:36:59.174 The exception generated was c0000005 at address 0084241D () For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp. ---------------------------------------------------------------------- Comment By: j_slocs (slocs) Date: 2005-06-28 11:14 Message: Logged In: YES user_id=1304274 Found this solution at: http://www.pantz.org/blog/. NSClient will now run as a service on our Windows Server 2003 (SP1) box. W2k3 Data Execution Protection (DEP) Date/Time: 6-10-2005 9:45 PM EST I got nailed with windows 2003 server sp1's new Data Execution Protection (DEP) (stack protection) today. I was trying to install the nagios NS Client program on a server with DEP turned on. When you tried to start the nagios agent service you would get "System Error 1067 has occurred". Which means the process was aborted and windows says "The process terminated unexpectedly". To make an exception for certain programs to run without DEP you need to do the following in W2k3 SP1: Right click "My Computer" then "Properties". Click the "Advanced" tab then click the "Settings" button under the "Performance" section. Click on the "Data Execution Prevention" tab and then click the radio button "Turn on DEP for all programs and services except those I select". Then click the "Add" button and add your exe you don't want stack protection for. That problem was fun to hunt down. ---------------------------------------------------------------------- Comment By: M. Sean Finney (seanius) Date: 2005-06-27 19:11 Message: Logged In: YES user_id=226838 hi, this doesn't look like a problem with the nagios plugins, but instead looks like a problem with the program nsclient (which is not part of the nagios-plugins project). looking through our source and documentation, i found the following link, which might be helpful: http://nsclient.ready2run.nl/ ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1219557&group_id=29880 From ae at op5.se Tue Jun 28 12:29:05 2005 From: ae at op5.se (Andreas Ericsson) Date: Tue Jun 28 12:29:05 2005 Subject: [Nagiosplug-devel] check_swap divide by 0 error In-Reply-To: <107BE4AB-F3F7-4825-AFCC-8A2FEB9D282E@utas.edu.au> References: <107BE4AB-F3F7-4825-AFCC-8A2FEB9D282E@utas.edu.au> Message-ID: <42C1A48A.6070102@op5.se> Nik Sands wrote: > The "check_swap" nagios plugin has a minor flaw, in that the output is > incorrect for machines with no swap configured (at least on Solaris). > Some people may say, "well, you should have swap configured!", I'd rather say "If you don't have swap configured, why on earth are you running the check_swap plugin?", but perhaps that's just me. > but when > the machine has 16 GB of RAM, it really isn't necessary. Not really true actually. Maintaining a small swap lets the kernel avoid quite a bit of exception handling and makes branch prediction much more efficient. At least this holds true on Linux, although I can imagine the design is similar on Solaris. > In any case, > it should at least show the correct percentage used, which would be > either 100% (and warning or critical) or 0%. As it is it get's the > result of a divide by zero, which is rather ugly. > > The line of code is question is: > > percent_used = 100 * ((double) used_swap) / ((double) total_swap); > > When there's no swap, this amounts to: > > percent_used = 100 * 0 / 0; > > If would be good to have a block before this, something like: > > if ( total_swap == 0 ) > { > /* percent_used = either 0 or 100, depending on your point > of view */ > } > else > > Thanks for your consideration of this imporovement. > > Please note that I'm not a member of this list so won't see any > responses posted to the list. If I need to see any responses (which I > doubt), please CC them to me. > > Cheers, > Nik. > > > ======================================================== > NIK SANDS - Systems Administrator, IT Services, University of Tasmania, > Australia > Phone: +61-3-63243732 (BH) > VoIP (Free Call): (1800 262 218) 393 658821 > AIM / iChat: brassnix > > > > ------------------------------------------------------- > SF.Net email is sponsored by: Discover Easy Linux Migration Strategies > from IBM. Find simple to follow Roadmaps, straightforward articles, > informative Webcasts and more! Get everything you need to get up to > speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click > _______________________________________________________ > Nagios Plugin Development Mailing List > Nagiosplug-devel at lists.sourceforge.net > Unsubscribe at > https://lists.sourceforge.net/lists/listinfo/nagiosplug-devel > ::: Please include plugins version (-v) and OS when reporting any issue. > ::: Messages without supporting info will risk being sent to /dev/null > -- Andreas Ericsson andreas.ericsson at op5.se OP5 AB www.op5.se Lead Developer From seanius at seanius.net Tue Jun 28 17:23:21 2005 From: seanius at seanius.net (sean finney) Date: Tue Jun 28 17:23:21 2005 Subject: [Nagiosplug-devel] check_swap divide by 0 error In-Reply-To: <107BE4AB-F3F7-4825-AFCC-8A2FEB9D282E@utas.edu.au> References: <107BE4AB-F3F7-4825-AFCC-8A2FEB9D282E@utas.edu.au> Message-ID: <20050629002123.GA14137@seanius.net> On Fri, Jun 24, 2005 at 02:38:24PM +1000, Nik Sands wrote: > The "check_swap" nagios plugin has a minor flaw, in that the output > is incorrect for machines with no swap configured (at least on > Solaris). Some people may say, "well, you should have swap > configured!", but when the machine has 16 GB of RAM, it really isn't well, i wouldn't say anything about that, but i would wonder why you're running check_swap on a system with no swap :) but anyway, it's a good suggestion, and i'll put a fix in regardless. sean -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: Digital signature URL: From noreply at sourceforge.net Tue Jun 28 19:34:40 2005 From: noreply at sourceforge.net (SourceForge.net) Date: Tue Jun 28 19:34:40 2005 Subject: [Nagiosplug-devel] [ nagiosplug-Bugs-1185616 ] Hp Laserjet check Message-ID: Bugs item #1185616, was opened at 2005-04-19 13:21 Message generated for change (Comment added) made by fatherosam You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1185616&group_id=29880 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None >Status: Closed Resolution: None Priority: 5 Submitted By: David Andrew (fatherosam) Assigned to: M. Sean Finney (seanius) Summary: Hp Laserjet check Initial Comment: I have written a quick and nasty HP Laserjet checker. Un fortunatly I am not a programmer and it is a bit quick and dirty. Just wondering if anyone thinks it is useful. ---------------------------------------------------------------------- >Comment By: David Andrew (fatherosam) Date: 2005-06-29 12:32 Message: Logged In: YES user_id=926258 I'm more than happy if this feature is added to the current check_hpjd. I just couldn't find the option in the version I had at the time ---------------------------------------------------------------------- Comment By: David Andrew (fatherosam) Date: 2005-06-29 12:32 Message: Logged In: YES user_id=926258 this problem is now fixed in cvs. thank you for your report. ---------------------------------------------------------------------- Comment By: M. Sean Finney (seanius) Date: 2005-06-28 12:29 Message: Logged In: YES user_id=226838 are you sure the current version of check_hpjd (in cvs) doesn't provide this ability, looking at the source code, i see the MIBS for these defined... ---------------------------------------------------------------------- Comment By: Aaron Kent Moore (mooreak) Date: 2005-04-20 23:45 Message: Logged In: YES user_id=867794 I would be interested in seeing it added to the plugins. It would be handy to be able to check the paper and toner status when someone calls about their printer not working. ---------------------------------------------------------------------- Comment By: David Andrew (fatherosam) Date: 2005-04-20 08:20 Message: Logged In: YES user_id=926258 I found check_hpjd only reported on the Jet Direct Card, this reports on the printer. Toner levels and paper out and service error messages etc. While check_hpjd only reported on the HP Net card in the printer. ---------------------------------------------------------------------- Comment By: Subhendu Ghosh (sghosh) Date: 2005-04-20 04:46 Message: Logged In: YES user_id=46572 Whats wrong with check_hpjd (HP JetDirect)? ---------------------------------------------------------------------- Comment By: Subhendu Ghosh (sghosh) Date: 2005-04-19 13:43 Message: Logged In: YES user_id=46572 Whats wrong with check_hpjd (HP JetDirect)? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=397597&aid=1185616&group_id=29880 From seanius at seanius.net Tue Jun 28 21:14:38 2005 From: seanius at seanius.net (sean finney) Date: Tue Jun 28 21:14:38 2005 Subject: [Nagiosplug-devel] runcmd, common.h, and popen Message-ID: <20050629041253.GA16230@seanius.net> hey andreas, i've applied your patches after a bit of massaging for things that have changed in cvs since the submission, and have a new diff file of all this together. however, some of the plugins seem to no longer work after using the np_runcmd framework. this is what i've tested: successful check_dig check_dns check_load check_nagios check_ping check_procs check_swap unsuccessful check_by_ssh (segfaulted if i gave a remote cmd that didn't exist) check_fping (always issues a warning) check_snmp (doesn't seem to return data at all) check_users (doesn't return the correct number of users) untested check_game check_hpjd attached is a diff of your combined patches against our current cvs tree, if you or anyone else could help look into these problem or untested plugins, i'd be appreciative. sean -------------- next part -------------- Index: Makefile.am =================================================================== RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/Makefile.am,v retrieving revision 1.52 diff -u -u -r1.52 Makefile.am --- Makefile.am 28 Jun 2005 00:26:53 -0000 1.52 +++ Makefile.am 29 Jun 2005 04:11:45 -0000 @@ -25,7 +25,8 @@ check_nagios check_by_ssh check_dns check_nt check_ide_smart \ check_procs -EXTRA_DIST = t utils.c netutils.c popen.c utils.h netutils.h popen.h common.h \ +EXTRA_DIST = t common.h utils.c utils.h netutils.c netutils.h \ + runcmd.c runcmd.h \ getaddrinfo.c getaddrinfo.h gethostbyname.c gethostbyname.h PLUGINHDRS = common.h @@ -47,85 +48,85 @@ # the actual targets check_dhcp_LDADD = $(NETLIBS) -check_dig_LDADD = $(NETLIBS) popen.o -check_disk_LDADD = $(BASEOBJS) popen.o -check_dns_LDADD = $(NETLIBS) popen.o +check_dig_LDADD = $(NETLIBS) runcmd.o +check_disk_LDADD = $(BASEOBJS) runcmd.o +check_dns_LDADD = $(NETLIBS) runcmd.o check_dummy_LDADD = $(BASEOBJS) -check_fping_LDADD = $(NETLIBS) popen.o -check_game_LDADD = $(BASEOBJS) popen.o +check_fping_LDADD = $(NETLIBS) runcmd.o +check_game_LDADD = $(BASEOBJS) runcmd.o check_http_LDADD = $(NETLIBS) $(SSLLIBS) -check_hpjd_LDADD = $(NETLIBS) popen.o +check_hpjd_LDADD = $(NETLIBS) runcmd.o check_icmp_LDADD = $(SOCKETLIBS) check_ldap_LDADD = $(NETLIBS) $(LDAPLIBS) -check_load_LDADD = $(BASEOBJS) popen.o +check_load_LDADD = $(BASEOBJS) runcmd.o check_mrtg_LDADD = $(BASEOBJS) check_mrtgtraf_LDADD = $(BASEOBJS) check_mysql_LDADD = $(NETLIBS) $(MYSQLLIBS) -check_nagios_LDADD = $(BASEOBJS) popen.o +check_nagios_LDADD = $(BASEOBJS) runcmd.o check_nt_LDADD = $(NETLIBS) check_nwstat_LDADD = $(NETLIBS) check_overcr_LDADD = $(NETLIBS) check_pgsql_LDADD = $(NETLIBS) $(PGLIBS) -check_ping_LDADD = $(NETLIBS) popen.o -check_procs_LDADD = $(BASEOBJS) popen.o +check_ping_LDADD = $(NETLIBS) runcmd.o +check_procs_LDADD = $(BASEOBJS) runcmd.o check_radius_LDADD = $(NETLIBS) $(RADIUSLIBS) check_real_LDADD = $(NETLIBS) -check_snmp_LDADD = $(BASEOBJS) popen.o +check_snmp_LDADD = $(BASEOBJS) runcmd.o check_smtp_LDADD = $(NETLIBS) $(SSLLIBS) check_ssh_LDADD = $(NETLIBS) -check_swap_LDADD = $(MATHLIBS) $(BASEOBJS) popen.o +check_swap_LDADD = $(MATHLIBS) $(BASEOBJS) runcmd.o check_tcp_LDADD = $(NETLIBS) $(SSLLIBS) check_time_LDADD = $(NETLIBS) check_udp_LDADD = $(NETLIBS) check_ups_LDADD = $(NETLIBS) -check_users_LDADD = $(BASEOBJS) popen.o -check_by_ssh_LDADD = $(NETLIBS) popen.o +check_users_LDADD = $(BASEOBJS) runcmd.o +check_by_ssh_LDADD = $(NETLIBS) runcmd.o check_ide_smart_LDADD = $(BASEOBJS) -negate_LDADD = $(BASEOBJS) popen.o -urlize_LDADD = $(BASEOBJS) popen.o +negate_LDADD = $(BASEOBJS) runcmd.o +urlize_LDADD = $(BASEOBJS) runcmd.o check_dhcp_DEPENDENCIES = check_dhcp.c $(NETOBJS) $(DEPLIBS) -check_dig_DEPENDENCIES = check_dig.c $(NETOBJS) popen.o $(DEPLIBS) -check_disk_DEPENDENCIES = check_disk.c $(BASEOBJS) popen.o $(DEPLIBS) -check_dns_DEPENDENCIES = check_dns.c $(NETOBJS) popen.o $(DEPLIBS) +check_dig_DEPENDENCIES = check_dig.c $(NETOBJS) runcmd.o $(DEPLIBS) +check_disk_DEPENDENCIES = check_disk.c $(BASEOBJS) runcmd.o $(DEPLIBS) +check_dns_DEPENDENCIES = check_dns.c $(NETOBJS) runcmd.o $(DEPLIBS) check_dummy_DEPENDENCIES = check_dummy.c $(DEPLIBS) -check_fping_DEPENDENCIES = check_fping.c $(NETOBJS) popen.o $(DEPLIBS) +check_fping_DEPENDENCIES = check_fping.c $(NETOBJS) runcmd.o $(DEPLIBS) check_game_DEPENDENCIES = check_game.c $(DEPLIBS) check_http_DEPENDENCIES = check_http.c $(NETOBJS) $(DEPLIBS) -check_hpjd_DEPENDENCIES = check_hpjd.c $(NETOBJS) popen.o $(DEPLIBS) +check_hpjd_DEPENDENCIES = check_hpjd.c $(NETOBJS) runcmd.o $(DEPLIBS) check_icmp_DEPENDENCIES = check_icmp.c check_ide_smart_DEPENDENCIES = check_ide_smart.c $(BASEOBJS) $(DEPLIBS) check_ldap_DEPENDENCIES = check_ldap.c $(NETOBJS) $(DEPLIBS) -check_load_DEPENDENCIES = check_load.c $(BASEOBJS) popen.o $(DEPLIBS) +check_load_DEPENDENCIES = check_load.c $(BASEOBJS) runcmd.o $(DEPLIBS) check_mrtg_DEPENDENCIES = check_mrtg.c $(DEPLIBS) check_mrtgtraf_DEPENDENCIES = check_mrtgtraf.c $(DEPLIBS) check_mysql_DEPENDENCIES = check_mysql.c $(NETOBJS) $(DEPLIBS) -check_nagios_DEPENDENCIES = check_nagios.c $(BASEOBJS) popen.o $(DEPLIBS) +check_nagios_DEPENDENCIES = check_nagios.c $(BASEOBJS) runcmd.o $(DEPLIBS) check_nt_DEPENDENCIES = check_nt.c $(NETOBJS) $(DEPLIBS) check_nwstat_DEPENDENCIES = check_nwstat.c $(NETOBJS) $(DEPLIBS) check_overcr_DEPENDENCIES = check_overcr.c $(NETOBJS) $(DEPLIBS) check_pgsql_DEPENDENCIES = check_pgsql.c $(NETOBJS) $(DEPLIBS) -check_ping_DEPENDENCIES = check_ping.c $(NETOBJS) popen.o $(DEPLIBS) -check_procs_DEPENDENCIES = check_procs.c $(BASEOBJS) popen.o $(DEPLIBS) +check_ping_DEPENDENCIES = check_ping.c $(NETOBJS) runcmd.o $(DEPLIBS) +check_procs_DEPENDENCIES = check_procs.c $(BASEOBJS) runcmd.o $(DEPLIBS) check_radius_DEPENDENCIES = check_radius.c $(NETOBJS) $(DEPLIBS) check_real_DEPENDENCIES = check_real.c $(NETOBJS) $(DEPLIBS) -check_snmp_DEPENDENCIES = check_snmp.c $(BASEOBJS) popen.o $(DEPLIBS) +check_snmp_DEPENDENCIES = check_snmp.c $(BASEOBJS) runcmd.o $(DEPLIBS) check_smtp_DEPENDENCIES = check_smtp.c $(NETOBJS) $(DEPLIBS) check_ssh_DEPENDENCIES = check_ssh.c $(NETOBJS) $(DEPLIBS) -check_swap_DEPENDENCIES = check_swap.c $(BASEOBJS) popen.o $(DEPLIBS) +check_swap_DEPENDENCIES = check_swap.c $(BASEOBJS) runcmd.o $(DEPLIBS) check_tcp_DEPENDENCIES = check_tcp.c $(NETOBJS) $(DEPLIBS) check_time_DEPENDENCIES = check_time.c $(NETOBJS) $(DEPLIBS) check_udp_DEPENDENCIES = check_udp.c $(NETOBJS) $(DEPLIBS) check_ups_DEPENDENCIES = check_ups.c $(NETOBJS) $(DEPLIBS) -check_users_DEPENDENCIES = check_users.c $(BASEOBJS) popen.o $(DEPLIBS) -check_by_ssh_DEPENDENCIES = check_by_ssh.c $(NETOBJS) popen.o $(DEPLIBS) -negate_DEPENDENCIES = negate.c $(BASEOBJS) popen.o $(DEPLIBS) -urlize_DEPENDENCIES = urlize.c $(BASEOBJS) popen.o $(DEPLIBS) +check_users_DEPENDENCIES = check_users.c $(BASEOBJS) runcmd.o $(DEPLIBS) +check_by_ssh_DEPENDENCIES = check_by_ssh.c $(NETOBJS) runcmd.o $(DEPLIBS) +negate_DEPENDENCIES = negate.c $(BASEOBJS) runcmd.o $(DEPLIBS) +urlize_DEPENDENCIES = urlize.c $(BASEOBJS) runcmd.o $(DEPLIBS) ############################################################################## # secondary dependencies -popen.o: popen.c popen.h $(PLUGINHDRS) +runcmd.o: runcmd.c runcmd.h $(PLUGINHDRS) utils.o: utils.c utils.h $(PLUGINHDRS) Index: check_by_ssh.c =================================================================== RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_by_ssh.c,v retrieving revision 1.35 diff -u -u -r1.35 check_by_ssh.c --- check_by_ssh.c 25 Dec 2004 12:09:19 -0000 1.35 +++ check_by_ssh.c 29 Jun 2005 04:11:45 -0000 @@ -14,19 +14,19 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: check_by_ssh.c,v 1.35 2004/12/25 12:09:19 opensides Exp $ + $Id: check_by_ssh.c,v 1.3 2005/06/06 11:37:06 exon Exp $ *****************************************************************************/ const char *progname = "check_by_ssh"; -const char *revision = "$Revision: 1.35 $"; +const char *revision = "$Revision: 1.3 $"; const char *copyright = "2000-2004"; const char *email = "nagiosplug-devel at lists.sourceforge.net"; #include "common.h" #include "netutils.h" #include "utils.h" -#include "popen.h" +#include "runcmd.h" int process_arguments (int, char **); int validate_arguments (void); @@ -49,15 +49,15 @@ main (int argc, char **argv) { - char input_buffer[MAX_INPUT_BUFFER]; char *result_text; char *status_text; - char *output; + char *msg; char *eol = NULL; int cresult; int result = STATE_UNKNOWN; time_t local_time; FILE *fp = NULL; + struct output chld_out, chld_err; remotecmd = strdup (""); comm = strdup (SSH_COMMAND); @@ -82,48 +82,22 @@ if (verbose) printf ("%s\n", comm); - child_process = spopen (comm); - - if (child_process == NULL) { - printf (_("Could not open pipe: %s\n"), comm); - return STATE_UNKNOWN; - } - - - /* open STDERR for spopen */ - child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); - if (child_stderr == NULL) { - printf (_("Could not open stderr for %s\n"), SSH_COMMAND); - } - + result = np_runcmd(comm, &chld_out, &chld_err, 0); /* build up results from remote command in result_text */ - while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) - asprintf (&result_text, "%s%s", result_text, input_buffer); + if(skip_lines && skip_lines < chld_out.lines) + result_text = chld_out.line[skip_lines]; + else + result_text = chld_out.line[0]; /* WARNING if output found on stderr */ - while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) { - if (skip_lines > 0) { - if (input_buffer[strlen(input_buffer)-1] == '\n') { - skip_lines--; - } - } else { - printf ("%s", input_buffer); - result = STATE_WARNING; - } + if(chld_err.buflen) { + printf("%s\n", chld_err.line[0]); + return STATE_WARNING; } - (void) fclose (child_stderr); - if (result == STATE_WARNING) - return result; - - - /* close the pipe */ - result = spclose (child_process); - /* process output */ if (passive) { - if (!(fp = fopen (outputfile, "a"))) { printf (_("SSH WARNING: could not open %s\n"), outputfile); exit (STATE_UNKNOWN); @@ -137,19 +111,19 @@ printf ("%s", result_text); return result; } - asprintf (&output, "%s", result_text); + asprintf (&msg, "%s", result_text); result_text = strnl (status_text); - eol = strpbrk (output, "\r\n"); + eol = strpbrk (msg, "\r\n"); if (eol != NULL) eol[0] = 0; if (service[commands] && status_text - && sscanf (status_text, "STATUS CODE: %d", &cresult) == 1) { + && sscanf (status_text, "STATUS CODE: %d", &cresult) == 1) + { fprintf (fp, "[%d] PROCESS_SERVICE_CHECK_RESULT;%s;%s;%d;%s\n", - (int) local_time, host_shortname, service[commands++], cresult, - output); + (int) local_time, host_shortname, service[commands++], + cresult, msg); } } - } @@ -206,7 +180,7 @@ while (1) { c = getopt_long (argc, argv, "Vvh1246ft:H:O:p:i:u:l:C:S:n:s:", longopts, - &option); + &option); if (c == -1 || c == EOF) break; @@ -244,25 +218,27 @@ passive = TRUE; break; case 's': /* description of service to check */ - service = realloc (service, (++services) * sizeof(char *)); p1 = optarg; + service = realloc (service, (++services) * sizeof(char *)); while ((p2 = index (p1, ':'))) { *p2 = '\0'; - asprintf (&service[services-1], "%s", p1); + service[services - 1] = p1; service = realloc (service, (++services) * sizeof(char *)); p1 = p2 + 1; } - asprintf (&service[services-1], "%s", p1); + service[services - 1] = p1; break; case 'n': /* short name of host in nagios configuration */ host_shortname = optarg; break; + case 'u': c = 'l'; case 'l': /* login name */ case 'i': /* identity */ asprintf (&comm, "%s -%c %s", comm, c, optarg); break; + case '1': /* Pass these switches directly to ssh */ case '2': /* 1 to force version 1, 2 to force version 2 */ case '4': /* -4 for IPv4 */ Index: check_dig.c =================================================================== RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_dig.c,v retrieving revision 1.40 diff -u -u -r1.40 check_dig.c --- check_dig.c 26 Jan 2005 21:21:01 -0000 1.40 +++ check_dig.c 29 Jun 2005 04:11:45 -0000 @@ -14,29 +14,33 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: check_dig.c,v 1.40 2005/01/26 21:21:01 tonvoon Exp $ + $Id: check_dig.c,v 1.3 2005/06/06 11:37:06 exon Exp $ *****************************************************************************/ +/* Hackers note: + * There are typecasts to (char *) from _("foo bar") in this file. + * They prevent compiler warnings. Never (ever), permute strings obtained + * that are typecast from (const char *) (which happens when --disable-nls) + * because on some architectures those strings are in non-writable memory */ + const char *progname = "check_dig"; -const char *revision = "$Revision: 1.40 $"; +const char *revision = "$Revision: 1.3 $"; const char *copyright = "2002-2004"; const char *email = "nagiosplug-devel at lists.sourceforge.net"; #include "common.h" #include "netutils.h" #include "utils.h" -#include "popen.h" +#include "runcmd.h" int process_arguments (int, char **); int validate_arguments (void); void print_help (void); void print_usage (void); -enum { - UNDEFINED = 0, - DEFAULT_PORT = 53 -}; +#define UNDEFINED 0 +#define DEFAULT_PORT 53 char *query_address = NULL; char *record_type = "A"; @@ -51,16 +55,15 @@ int main (int argc, char **argv) { - char input_buffer[MAX_INPUT_BUFFER]; char *command_line; - char *output; + output chld_out, chld_err; + char *msg = NULL; + size_t i; char *t; long microsec; double elapsed_time; int result = STATE_UNKNOWN; - output = strdup (""); - setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); @@ -89,100 +92,75 @@ } /* run the command */ - child_process = spopen (command_line); - if (child_process == NULL) { - printf (_("Could not open pipe: %s\n"), command_line); - return STATE_UNKNOWN; + if((result = np_runcmd(command_line, &chld_out, &chld_err, 0)) != 0) { + result = STATE_WARNING; + msg = (char *)_("dig returned an error status"); } - child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); - if (child_stderr == NULL) - printf (_("Could not open stderr for %s\n"), command_line); - - while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) { - + for(i = 0; i < chld_out.lines; i++) { /* the server is responding, we just got the host name... */ - if (strstr (input_buffer, ";; ANSWER SECTION:")) { + if (strstr (chld_out.line[i], ";; ANSWER SECTION:")) { /* loop through the whole 'ANSWER SECTION' */ - do { + for(; i < chld_out.lines; i++) { /* get the host address */ - if (!fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) - break; - - if (strpbrk (input_buffer, "\r\n")) - input_buffer[strcspn (input_buffer, "\r\n")] = '\0'; + if (verbose) + printf ("%s\n", chld_out.line[i]); - if (verbose && !strstr (input_buffer, ";; ")) - printf ("%s\n", input_buffer); - - if (expected_address==NULL && strstr (input_buffer, query_address) != NULL) { - output = strdup(input_buffer); + if (strstr (chld_out.line[i], (expected_address == NULL ? query_address : expected_address)) != NULL) { + msg = chld_out.line[i]; result = STATE_OK; - } - else if (expected_address != NULL && strstr (input_buffer, expected_address) != NULL) { - output = strdup(input_buffer); - result = STATE_OK; - } - /* Translate output TAB -> SPACE */ - t = output; - while ((t = index(t, '\t')) != NULL) - *t = ' '; - - } while (!strstr (input_buffer, ";; ")); + /* Translate output TAB -> SPACE */ + t = msg; + while ((t = strchr(t, '\t')) != NULL) *t = ' '; + break; + } + } if (result == STATE_UNKNOWN) { - asprintf (&output, _("Server not found in ANSWER SECTION")); - result = STATE_WARNING; - } - } - - } - - if (result == STATE_UNKNOWN) { - asprintf (&output, _("No ANSWER SECTION found")); - } + msg = (char *)_("Server not found in ANSWER SECTION"); + result = STATE_WARNING; + } - while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) { - /* If we get anything on STDERR, at least set warning */ - result = max_state (result, STATE_WARNING); - printf ("%s", input_buffer); - if (strlen (output) == 0) - output = strdup (1 + index (input_buffer, ':')); + /* we found the answer section, so break out of the loop */ + break; + } } - (void) fclose (child_stderr); + if (result == STATE_UNKNOWN) + msg = (char *)_("No ANSWER SECTION found"); - /* close the pipe */ - if (spclose (child_process)) { - result = max_state (result, STATE_WARNING); - if (strlen (output) == 0) - asprintf (&output, _("dig returned an error status")); + /* If we get anything on STDERR, at least set warning */ + if(chld_err.buflen > 0) { + result = max_state(result, STATE_WARNING); + if(!msg) for(i = 0; i < chld_err.lines; i++) { + msg = strchr(chld_err.line[0], ':'); + if(msg) { + msg++; + break; + } + } } microsec = deltime (tv); elapsed_time = (double)microsec / 1.0e6; - if (output == NULL || strlen (output) == 0) - asprintf (&output, _(" Probably a non-existent host/domain")); - if (critical_interval > UNDEFINED && elapsed_time > critical_interval) result = STATE_CRITICAL; else if (warning_interval > UNDEFINED && elapsed_time > warning_interval) result = STATE_WARNING; - asprintf (&output, _("%.3f seconds response time (%s)"), elapsed_time, output); - - printf ("DNS %s - %s|%s\n", - state_text (result), output, + printf ("DNS %s - %.3f seconds response time (%s)|%s\n", + state_text (result), elapsed_time, + msg ? msg : _("Probably a non-existent host/domain"), fperfdata("time", elapsed_time, "s", - (warning_interval>UNDEFINED?TRUE:FALSE), - warning_interval, - (critical_interval>UNDEFINED?TRUE:FALSE), - critical_interval, - TRUE, 0, FALSE, 0)); + (warning_interval>UNDEFINED?TRUE:FALSE), + warning_interval, + (critical_interval>UNDEFINED?TRUE:FALSE), + critical_interval, + TRUE, 0, FALSE, 0)); return result; } @@ -359,6 +337,6 @@ { printf ("\ Usage: %s -H host -l lookup [-p ] [-T ]\n\ - [-w ] [-c ] [-t ]\n\ - [-a ] [-v]\n", progname); + [-w ] [-c ] [-t ]\n\ + [-a ] [-v]\n", progname); } Index: check_dns.c =================================================================== RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_dns.c,v retrieving revision 1.47 diff -u -u -r1.47 check_dns.c --- check_dns.c 30 Dec 2004 00:41:39 -0000 1.47 +++ check_dns.c 29 Jun 2005 04:11:46 -0000 @@ -17,19 +17,19 @@ LIMITATION: nslookup on Solaris 7 can return output over 2 lines, which will not be picked up by this plugin - $Id: check_dns.c,v 1.47 2004/12/30 00:41:39 opensides Exp $ + $Id: check_dns.c,v 1.3 2005/06/06 11:37:06 exon Exp $ ******************************************************************************/ const char *progname = "check_dns"; -const char *revision = "$Revision: 1.47 $"; +const char *revision = "$Revision: 1.3 $"; const char *copyright = "2000-2004"; const char *email = "nagiosplug-devel at lists.sourceforge.net"; #include "common.h" -#include "popen.h" #include "utils.h" #include "netutils.h" +#include "runcmd.h" int process_arguments (int, char **); int validate_arguments (void); @@ -51,8 +51,8 @@ { char *command_line = NULL; char input_buffer[MAX_INPUT_BUFFER]; - char *output = NULL; char *address = NULL; + char *msg = NULL; char *temp_buffer = NULL; int non_authoritative = FALSE; int result = STATE_UNKNOWN; @@ -61,6 +61,8 @@ struct timeval tv; int multi_address; int parse_address = FALSE; /* This flag scans for Address: but only after Name: */ + output chld_out, chld_err; + size_t i; setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); @@ -85,37 +87,31 @@ printf ("%s\n", command_line); /* run the command */ - child_process = spopen (command_line); - if (child_process == NULL) { - printf (_("Could not open pipe: %s\n"), command_line); - return STATE_UNKNOWN; + if((np_runcmd(command_line, &chld_out, &chld_err, 0)) != 0) { + msg = (char *)_("nslookup returned error status"); + result = STATE_WARNING; } - child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); - if (child_stderr == NULL) - printf (_("Could not open stderr for %s\n"), command_line); - /* scan stdout */ - while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) { - + for(i = 0; i < chld_out.lines; i++) { if (verbose) - printf ("%s", input_buffer); + printf ("%s", chld_out.line[i]); - if (strstr (input_buffer, ".in-addr.arpa")) { - if ((temp_buffer = strstr (input_buffer, "name = "))) + if (strstr (chld_out.line[i], ".in-addr.arpa")) { + if ((temp_buffer = strstr (chld_out.line[i], "name = "))) address = strdup (temp_buffer + 7); else { - output = strdup (_("Warning plugin error")); + msg = (char *)_("Warning plugin error"); result = STATE_WARNING; } } /* the server is responding, we just got the host name... */ - if (strstr (input_buffer, "Name:")) + if (strstr (chld_out.line[i], "Name:")) parse_address = TRUE; - else if (parse_address == TRUE && (strstr (input_buffer, "Address:") || - strstr (input_buffer, "Addresses:"))) { - temp_buffer = index (input_buffer, ':'); + else if (parse_address == TRUE && (strstr (chld_out.line[i], "Address:") || + strstr (chld_out.line[i], "Addresses:"))) { + temp_buffer = index (chld_out.line[i], ':'); temp_buffer++; /* Strip leading spaces */ @@ -135,59 +131,47 @@ asprintf(&address, "%s,%s", address, temp_buffer); } - else if (strstr (input_buffer, _("Non-authoritative answer:"))) { + else if (strstr (chld_out.line[i], _("Non-authoritative answer:"))) { non_authoritative = TRUE; } - result = error_scan (input_buffer); + result = error_scan (chld_out.line[i]); if (result != STATE_OK) { - output = strdup (1 + index (input_buffer, ':')); - strip (output); + msg = strchr (chld_out.line[i], ':'); + if(msg) msg++; break; } - } /* scan stderr */ - while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) { - + for(i = 0; i < chld_err.lines; i++) { if (verbose) - printf ("%s", input_buffer); + printf ("%s", chld_err.line[i]); - if (error_scan (input_buffer) != STATE_OK) { - result = max_state (result, error_scan (input_buffer)); - output = strdup (1 + index (input_buffer, ':')); - strip (output); + if (error_scan (chld_err.line[i]) != STATE_OK) { + result = max_state (result, error_scan (chld_err.line[i])); + msg = strchr(input_buffer, ':'); + if(msg) msg++; } } - /* close stderr */ - (void) fclose (child_stderr); - - /* close stdout */ - if (spclose (child_process)) { - result = max_state (result, STATE_WARNING); - if (output == NULL || !strcmp (output, "")) - output = strdup (_("nslookup returned error status")); - } - - /* If we got here, we should have an address string, - and we can segfault if we do not */ + /* If we got here, we should have an address string, + * and we can segfault if we do not */ if (address==NULL || strlen(address)==0) die (STATE_CRITICAL, - _("DNS CRITICAL - '%s' output parsing exited with no address\n"), + _("DNS CRITICAL - '%s' msg parsing exited with no address\n"), NSLOOKUP_COMMAND); /* compare to expected address */ if (result == STATE_OK && match_expected_address && strcmp(address, expected_address)) { result = STATE_CRITICAL; - asprintf(&output, _("expected %s but got %s"), expected_address, address); + asprintf(&msg, _("expected %s but got %s"), expected_address, address); } /* check if authoritative */ if (result == STATE_OK && expect_authority && non_authoritative) { result = STATE_CRITICAL; - asprintf(&output, _("server %s is not authoritative for %s"), dns_server, query_address); + asprintf(&msg, _("server %s is not authoritative for %s"), dns_server, query_address); } microsec = deltime (tv); @@ -206,13 +190,13 @@ } else if (result == STATE_WARNING) printf (_("DNS WARNING - %s\n"), - !strcmp (output, "") ? _(" Probably a non-existent host/domain") : output); + !strcmp (msg, "") ? _(" Probably a non-existent host/domain") : msg); else if (result == STATE_CRITICAL) printf (_("DNS CRITICAL - %s\n"), - !strcmp (output, "") ? _(" Probably a non-existent host/domain") : output); + !strcmp (msg, "") ? _(" Probably a non-existent host/domain") : msg); else printf (_("DNS UNKNOW - %s\n"), - !strcmp (output, "") ? _(" Probably a non-existent host/domain") : output); + !strcmp (msg, "") ? _(" Probably a non-existent host/domain") : msg); return result; } Index: check_fping.c =================================================================== RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_fping.c,v retrieving revision 1.24 diff -u -u -r1.24 check_fping.c --- check_fping.c 25 Dec 2004 23:17:44 -0000 1.24 +++ check_fping.c 29 Jun 2005 04:11:46 -0000 @@ -14,26 +14,24 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: check_fping.c,v 1.24 2004/12/25 23:17:44 opensides Exp $ + $Id: check_fping.c,v 1.2 2005/06/05 21:55:26 exon Exp $ ******************************************************************************/ const char *progname = "check_fping"; -const char *revision = "$Revision: 1.24 $"; +const char *revision = "$Revision: 1.2 $"; const char *copyright = "2000-2004"; const char *email = "nagiosplug-devel at lists.sourceforge.net"; #include "common.h" -#include "popen.h" #include "netutils.h" #include "utils.h" +#include "runcmd.h" -enum { - PACKET_COUNT = 1, - PACKET_SIZE = 56, - PL = 0, - RTA = 1 -}; +#define PACKET_COUNT 1 +#define PACKET_SIZE 56 +#define PL 0 +#define RTA 1 int textscan (char *buf); int process_arguments (int, char **); @@ -59,11 +57,11 @@ { /* normaly should be int result = STATE_UNKNOWN; */ - int status = STATE_UNKNOWN; + int result = STATE_UNKNOWN; char *server = NULL; char *command_line = NULL; - char *input_buffer = NULL; - input_buffer = malloc (MAX_INPUT_BUFFER); + output chld_out, chld_err; + size_t i; setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); @@ -79,43 +77,21 @@ packet_size, packet_count, server); if (verbose) - printf ("%s\n", command_line); + printf ("command_line: %s\n", command_line); /* run the command */ - child_process = spopen (command_line); - if (child_process == NULL) { - printf (_("Could not open pipe: %s\n"), command_line); - return STATE_UNKNOWN; - } - - child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); - if (child_stderr == NULL) { - printf (_("Could not open stderr for %s\n"), command_line); - } + if((np_runcmd(command_line, &chld_out, &chld_err, 0)) || chld_err.buflen) + result = STATE_WARNING; - while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) { - if (verbose) - printf ("%s", input_buffer); - status = max_state (status, textscan (input_buffer)); - } - - /* If we get anything on STDERR, at least set warning */ - while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) { - status = max_state (status, STATE_WARNING); - if (verbose) - printf ("%s", input_buffer); - status = max_state (status, textscan (input_buffer)); - } - (void) fclose (child_stderr); + for(i = 0; i < chld_out.lines; i++) + result = max_state (result, textscan (chld_out.line[i])); - /* close the pipe */ - if (spclose (child_process)) - /* need to use max_state not max */ - status = max_state (status, STATE_WARNING); + printf ("FPING %s - %s\n", state_text (result), server_name); - printf ("FPING %s - %s\n", state_text (status), server_name); + if (verbose) for(i = 0; i < chld_out.lines; i++) + printf ("%s", chld_out.line[i]); - return status; + return result; } @@ -127,7 +103,7 @@ char *losstr = NULL; double loss; double rta; - int status = STATE_UNKNOWN; + int result = STATE_UNKNOWN; if (strstr (buf, "not found")) { die (STATE_CRITICAL, _("FPING UNKNOW - %s not found\n"), server_name); @@ -143,7 +119,7 @@ } else if (strstr (buf, "is alive")) { - status = STATE_OK; + result = STATE_OK; } else if (strstr (buf, "xmt/rcv/%loss") && strstr (buf, "min/avg/max")) { @@ -156,18 +132,18 @@ loss = strtod (losstr, NULL); rta = strtod (rtastr, NULL); if (cpl_p == TRUE && loss > cpl) - status = STATE_CRITICAL; + result = STATE_CRITICAL; else if (crta_p == TRUE && rta > crta) - status = STATE_CRITICAL; + result = STATE_CRITICAL; else if (wpl_p == TRUE && loss > wpl) - status = STATE_WARNING; + result = STATE_WARNING; else if (wrta_p == TRUE && rta > wrta) - status = STATE_WARNING; + result = STATE_WARNING; else - status = STATE_OK; - die (status, + result = STATE_OK; + die (result, _("FPING %s - %s (loss=%.0f%%, rta=%f ms)|%s %s\n"), - state_text (status), server_name, loss, rta, + state_text (result), server_name, loss, rta, perfdata ("loss", (long int)loss, "%", wpl_p, wpl, cpl_p, cpl, TRUE, 0, TRUE, 100), fperfdata ("rta", rta/1.0e3, "s", wrta_p, wrta/1.0e3, crta_p, crta/1.0e3, TRUE, 0, FALSE, 0)); @@ -179,24 +155,24 @@ losstr = 1 + strstr (losstr, "/"); loss = strtod (losstr, NULL); if (atoi(losstr) == 100) - status = STATE_CRITICAL; + result = STATE_CRITICAL; else if (cpl_p == TRUE && loss > cpl) - status = STATE_CRITICAL; + result = STATE_CRITICAL; else if (wpl_p == TRUE && loss > wpl) - status = STATE_WARNING; + result = STATE_WARNING; else - status = STATE_OK; + result = STATE_OK; /* loss=%.0f%%;%d;%d;0;100 */ - die (status, _("FPING %s - %s (loss=%.0f%% )|%s\n"), - state_text (status), server_name, loss , + die (result, _("FPING %s - %s (loss=%.0f%% )|%s\n"), + state_text (result), server_name, loss , perfdata ("loss", (long int)loss, "%", wpl_p, wpl, cpl_p, cpl, TRUE, 0, TRUE, 100)); } else { - status = max_state (status, STATE_WARNING); + result = max_state (result, STATE_WARNING); } - return status; + return result; } Index: check_game.c =================================================================== RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_game.c,v retrieving revision 1.22 diff -u -u -r1.22 check_game.c --- check_game.c 25 Dec 2004 23:17:44 -0000 1.22 +++ check_game.c 29 Jun 2005 04:11:46 -0000 @@ -14,17 +14,17 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * -* $Id: check_game.c,v 1.22 2004/12/25 23:17:44 opensides Exp $ +* $Id: check_game.c,v 1.2 2005/06/05 21:55:26 exon Exp $ *****************************************************************************/ const char *progname = "check_game"; -const char *revision = "$Revision: 1.22 $"; +const char *revision = "$Revision: 1.2 $"; const char *copyright = "2002-2004"; const char *email = "nagiosplug-devel at lists.sourceforge.net"; #include "common.h" -#include "popen.h" #include "utils.h" +#include "runcmd.h" int process_arguments (int, char **); int validate_arguments (void); @@ -57,9 +57,9 @@ char *command_line; int result = STATE_UNKNOWN; FILE *fp; - char input_buffer[MAX_INPUT_BUFFER]; char *p, *ret[QSTAT_MAX_RETURN_ARGS]; - int i; + size_t i = 0; + output chld_out; setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); @@ -80,17 +80,9 @@ if (verbose > 0) printf ("%s\n", command_line); - /* run the command */ - fp = spopen (command_line); - if (fp == NULL) { - printf (_("Could not open pipe: %s\n"), command_line); - return STATE_UNKNOWN; - } - - fgets (input_buffer, MAX_INPUT_BUFFER - 1, fp); /* Only interested in the first line */ - - /* strip the newline character from the end of the input */ - input_buffer[strlen (input_buffer) - 1] = 0; + /* run the command. historically, this plugin ignores output on stderr, + * as well as return status of the qstat program */ + (void)np_runcmd(command_line, &chld_out, NULL, 0); /* sanity check */ /* was thinking about running qstat without any options, capturing the @@ -102,18 +94,13 @@ In the end, I figured I'd simply let an error occur & then trap it */ - if (!strncmp (input_buffer, "unknown option", 14)) { + if (!strncmp (chld_out.line[0], "unknown option", 14)) { printf (_("CRITICAL - Host type parameter incorrect!\n")); result = STATE_CRITICAL; return result; } - /* initialize the returned data buffer */ - for (i = 0; i < QSTAT_MAX_RETURN_ARGS; i++) - ret[i] = strdup(""); - - i = 0; - p = (char *) strtok (input_buffer, QSTAT_DATA_DELIMITER); + p = (char *) strtok (chld_out.line[0], QSTAT_DATA_DELIMITER); while (p != NULL) { ret[i] = p; p = (char *) strtok (NULL, QSTAT_DATA_DELIMITER); @@ -141,17 +128,14 @@ ret[qstat_game_field], ret[qstat_map_field], ret[qstat_ping_field], - perfdata ("players", atol(ret[qstat_game_players]), "", + perfdata ("players", atol(ret[qstat_game_players]), "", FALSE, 0, FALSE, 0, TRUE, 0, TRUE, atol(ret[qstat_game_players_max])), - fperfdata ("ping", strtod(ret[qstat_ping_field], NULL), "", + fperfdata ("ping", strtod(ret[qstat_ping_field], NULL), "", FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0)); } - /* close the pipe */ - spclose (fp); - return result; } Index: check_hpjd.c =================================================================== RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_hpjd.c,v retrieving revision 1.32 diff -u -u -r1.32 check_hpjd.c --- check_hpjd.c 27 Jun 2005 13:07:39 -0000 1.32 +++ check_hpjd.c 29 Jun 2005 04:11:46 -0000 @@ -23,15 +23,13 @@ const char *email = "nagiosplug-devel at lists.sourceforge.net"; #include "common.h" -#include "popen.h" #include "utils.h" #include "netutils.h" +#include "runcmd.h" #define DEFAULT_COMMUNITY "public" - -const char *option_summary = "-H host [-C community]\n"; - +/* this macro is only avavilable from main() */ #define HPJD_LINE_STATUS ".1.3.6.1.4.1.11.2.3.9.1.1.2.1" #define HPJD_PAPER_STATUS ".1.3.6.1.4.1.11.2.3.9.1.1.2.2" #define HPJD_INTERVENTION_REQUIRED ".1.3.6.1.4.1.11.2.3.9.1.1.2.3" @@ -44,42 +42,50 @@ #define HPJD_GD_DOOR_OPEN ".1.3.6.1.4.1.11.2.3.9.1.1.2.17" #define HPJD_GD_PAPER_OUTPUT ".1.3.6.1.4.1.11.2.3.9.1.1.2.19" #define HPJD_GD_STATUS_DISPLAY ".1.3.6.1.4.1.11.2.3.9.1.1.3" +#define SNMP_VARS 12 #define ONLINE 0 #define OFFLINE 1 -int process_arguments (int, char **); -int validate_arguments (void); -void print_help (void); +/* make it compile without warnings when internationalization is disabled */ +#ifndef ENABLE_NLS +# ifdef _ +# undef _ +# endif +# define _(x) x +#endif + +static int process_arguments (int, char **); +static int validate_arguments (void); +static void print_help (void); void print_usage (void); -char *community = NULL; -char *address = NULL; +static char *community = NULL; +static char *address = NULL; + int main (int argc, char **argv) { char command_line[1024]; - int result = STATE_UNKNOWN; - int line; - char input_buffer[MAX_INPUT_BUFFER]; - char query_string[512]; - char *errmsg; - char *temp_buffer; - int line_status = ONLINE; - int paper_status = 0; - int intervention_required = 0; - int peripheral_error = 0; - int paper_jam = 0; - int paper_out = 0; - int toner_low = 0; - int page_punt = 0; - int memory_out = 0; - int door_open = 0; - int paper_output = 0; - char display_message[MAX_INPUT_BUFFER]; - - errmsg = malloc(MAX_INPUT_BUFFER); + int result = STATE_OK; + size_t i, val = 0; + int errorflag = 0; /* bitflag error tracker */ + output chld_out, chld_err; + char *errmsg_strings[11]; + + /* populate the the error message array */ + errmsg_strings[0] = _("Printer Offline"); + errmsg_strings[1] = _("Unknown Paper Error"); + errmsg_strings[2] = _("Intervention Required"); + errmsg_strings[3] = _("Peripheral Error"); + errmsg_strings[4] = _("Paper Jam"); + errmsg_strings[5] = _("Out of Paper"); + errmsg_strings[6] = _("Toner Low"); + errmsg_strings[7] = _("Data too Slow for Engine"); + errmsg_strings[8] = _("Insufficient Memory"); + errmsg_strings[9] = _("A Door is Open"); + errmsg_strings[10] = _("Output Tray is Full"); setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); @@ -88,207 +94,99 @@ if (process_arguments (argc, argv) == ERROR) usage4 (_("Could not parse arguments")); - /* removed ' 2>1' at end of command 10/27/1999 - EG */ - /* create the query string */ - sprintf - (query_string, - "%s.0 %s.0 %s.0 %s.0 %s.0 %s.0 %s.0 %s.0 %s.0 %s.0 %s.0 %s.0", - HPJD_LINE_STATUS, - HPJD_PAPER_STATUS, - HPJD_INTERVENTION_REQUIRED, - HPJD_GD_PERIPHERAL_ERROR, - HPJD_GD_PAPER_JAM, - HPJD_GD_PAPER_OUT, - HPJD_GD_TONER_LOW, - HPJD_GD_PAGE_PUNT, - HPJD_GD_MEMORY_OUT, - HPJD_GD_DOOR_OPEN, HPJD_GD_PAPER_OUTPUT, HPJD_GD_STATUS_DISPLAY); - - /* get the command to run */ - sprintf (command_line, "%s -OQa -m : -v 1 -c %s %s %s", PATH_TO_SNMPGET, community, - address, query_string); + /* create the command-line. Get status display line first, so we can + * match line status against powersave as we parse it */ + sprintf (command_line, "%s -Oqv -m : -v 1 -c %s %s " + "%s.0 %s.0 %s.0 %s.0 %s.0 %s.0 %s.0 %s.0 %s.0 %s.0 %s.0 %s.0", + PATH_TO_SNMPGET, community, address, + HPJD_GD_STATUS_DISPLAY, + HPJD_LINE_STATUS, + HPJD_PAPER_STATUS, + HPJD_INTERVENTION_REQUIRED, + HPJD_GD_PERIPHERAL_ERROR, + HPJD_GD_PAPER_JAM, + HPJD_GD_PAPER_OUT, + HPJD_GD_TONER_LOW, + HPJD_GD_PAGE_PUNT, + HPJD_GD_MEMORY_OUT, + HPJD_GD_DOOR_OPEN, + HPJD_GD_PAPER_OUTPUT); /* run the command */ - child_process = spopen (command_line); - if (child_process == NULL) { - printf (_("Could not open pipe: %s\n"), command_line); - return STATE_UNKNOWN; - } - - child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); - if (child_stderr == NULL) { - printf (_("Could not open stderr for %s\n"), command_line); - } - - result = STATE_OK; - - line = 0; - while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) { + if((np_runcmd(command_line, &chld_out, &chld_err, 0)) || chld_err.buflen) + result = STATE_WARNING; - /* strip the newline character from the end of the input */ - if (input_buffer[strlen (input_buffer) - 1] == '\n') - input_buffer[strlen (input_buffer) - 1] = 0; - - line++; - - temp_buffer = strtok (input_buffer, "="); - temp_buffer = strtok (NULL, "="); - - if (temp_buffer == NULL && line < 13) { - - result = STATE_UNKNOWN; - strcpy (errmsg, input_buffer); - - } else { - - switch (line) { - - case 1: /* 1st line should contain the line status */ - line_status = atoi (temp_buffer); - break; - case 2: /* 2nd line should contain the paper status */ - paper_status = atoi (temp_buffer); - break; - case 3: /* 3rd line should be intervention required */ - intervention_required = atoi (temp_buffer); - break; - case 4: /* 4th line should be peripheral error */ - peripheral_error = atoi (temp_buffer); - break; - case 5: /* 5th line should contain the paper jam status */ - paper_jam = atoi (temp_buffer); - break; - case 6: /* 6th line should contain the paper out status */ - paper_out = atoi (temp_buffer); - break; - case 7: /* 7th line should contain the toner low status */ - toner_low = atoi (temp_buffer); - break; - case 8: /* did data come too slow for engine */ - page_punt = atoi (temp_buffer); - break; - case 9: /* did we run out of memory */ - memory_out = atoi (temp_buffer); - break; - case 10: /* is there a door open */ - door_open = atoi (temp_buffer); - break; - case 11: /* is output tray full */ - paper_output = atoi (temp_buffer); - break; - case 12: /* display panel message */ - strcpy (display_message, temp_buffer + 1); - break; - default: /* fold multiline message */ - strncat (display_message, input_buffer, - sizeof (display_message) - strlen (display_message) - 1); - } - - } - - /* break out of the read loop if we encounter an error */ - if (result != STATE_OK) - break; - } + /* if there was none or not enough output, display an error and exit */ + if (chld_out.buflen == 0 || chld_out.lines != SNMP_VARS - 1) { + if(chld_err.buflen) printf("%s : ", chld_err.line[0]); - /* WARNING if output found on stderr */ - if (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) { - result = max_state (result, STATE_WARNING); - /* remove CRLF */ - if (input_buffer[strlen (input_buffer) - 1] == '\n') - input_buffer[strlen (input_buffer) - 1] = 0; - sprintf (errmsg, "%s", input_buffer ); + if(chld_out.buflen == 0) + printf (_("No data returned from %s\n"), address ); + else + printf(_("Not enough data returned from %s\n"), address); - } - - /* close stderr */ - (void) fclose (child_stderr); - - /* close the pipe */ - if (spclose (child_process)) - result = max_state (result, STATE_WARNING); - - /* if there wasn't any output, display an error */ - if (line == 0) { - - /* might not be the problem, but most likely is. */ - result = STATE_UNKNOWN ; - asprintf (&errmsg, "%s : Timeout from host %s\n", errmsg, address ); - + return STATE_UNKNOWN; } - /* if we had no read errors, check the printer status results... */ - if (result == STATE_OK) { + for(i = 1; i < chld_out.lines; i++) { + /* move to next if there's no error tag */ + if(!(val = (size_t)strtol(chld_out.line[i], NULL, 0))) + continue; + + /* tag the error */ + errorflag |= 1 << i; + + /* this switch statement is only for additional exception handling */ + switch (i) { + case 1: /* line status */ + /* clear this flag if it's powersaving (we know it's set if + * we get here, so use xor and save 2 instructions) */ + if(!strstr(chld_out.line[0], "POWERSAVE ON")) + errorflag ^= 1 << i; + break; - if (paper_jam) { - result = STATE_WARNING; - strcpy (errmsg, _("Paper Jam")); - } - else if (paper_out) { - result = STATE_WARNING; - strcpy (errmsg, _("Out of Paper")); - } - else if (line_status == OFFLINE) { - if (strcmp (errmsg, "POWERSAVE ON") != 0) { - result = STATE_WARNING; - strcpy (errmsg, _("Printer Offline")); - } - } - else if (peripheral_error) { - result = STATE_WARNING; - strcpy (errmsg, _("Peripheral Error")); - } - else if (intervention_required) { - result = STATE_WARNING; - strcpy (errmsg, _("Intervention Required")); - } - else if (toner_low) { - result = STATE_WARNING; - strcpy (errmsg, _("Toner Low")); - } - else if (memory_out) { - result = STATE_WARNING; - strcpy (errmsg, _("Insufficient Memory")); - } - else if (door_open) { - result = STATE_WARNING; - strcpy (errmsg, _("A Door is Open")); - } - else if (paper_output) { - result = STATE_WARNING; - strcpy (errmsg, _("Output Tray is Full")); - } - else if (page_punt) { - result = STATE_WARNING; - strcpy (errmsg, _("Data too Slow for Engine")); - } - else if (paper_status) { - result = STATE_WARNING; - strcpy (errmsg, _("Unknown Paper Error")); + case 2: /* paper status */ + case 3: /* intervention required */ + case 4: /* peripheral error */ + case 5: /* paper jam */ + case 6: /* paper out */ + case 7: /* toner low */ + case 8: /* data came too slow for engine */ + case 9: /* out of memory */ + case 10: /* door open */ + case 11: /* output tray full */ + break; } } - if (result == STATE_OK) - printf (_("Printer ok - (%s)\n"), display_message); - - else if (result == STATE_UNKNOWN) { + /* if some error occurred, print a starting line and all the errors */ + if(errorflag) { + printf ("%s (%s)", chld_err.buflen != 0 ? chld_err.buf : "", + chld_out.line[0]); - printf ("%s\n", errmsg); + for(i = 0; i < SNMP_VARS; i++) { /* loop the error flags */ + if((errorflag >> i) & 1) /* only print if flag is set */ + printf(" :: %s", errmsg_strings[i++]); + } - /* if printer could not be reached, escalate to critical */ - if (strstr (errmsg, "Timeout")) - result = STATE_CRITICAL; + return STATE_CRITICAL; } - else if (result == STATE_WARNING) - printf ("%s (%s)\n", errmsg, display_message); + /* set WARNING if output on stderr */ + if (chld_err.buflen) { + printf("WARNING - Printer seems ok, but %s printed to stderr (%s)", + PATH_TO_SNMPGET, chld_err.line[0]); + return STATE_WARNING; + } - return result; + /* all is well if we end up here */ + printf (_("Printer ok - (%s)\n"), chld_out.line[0]); + return STATE_OK; } /* process command-line arguments */ -int +static int process_arguments (int argc, char **argv) { int c; @@ -297,9 +195,6 @@ static struct option longopts[] = { {"hostname", required_argument, 0, 'H'}, {"community", required_argument, 0, 'C'}, -/* {"critical", required_argument,0,'c'}, */ -/* {"warning", required_argument,0,'w'}, */ -/* {"port", required_argument,0,'P'}, */ {"version", no_argument, 0, 'V'}, {"help", no_argument, 0, 'h'}, {0, 0, 0, 0} @@ -308,7 +203,6 @@ if (argc < 2) return ERROR; - while (1) { c = getopt_long (argc, argv, "+hVH:C:", longopts, &option); @@ -318,7 +212,7 @@ switch (c) { case 'H': /* hostname */ if (is_host (optarg)) { - address = strscpy(address, optarg) ; + address = strdup(optarg) ; } else { usage2 (_("Invalid hostname/address"), optarg); @@ -347,26 +241,26 @@ usage2 (_("Invalid hostname/address"), argv[c]); } } - + if (community == NULL) { if (argv[c] != NULL ) community = argv[c]; else - community = strdup (DEFAULT_COMMUNITY); + community = DEFAULT_COMMUNITY; } return validate_arguments (); } -int +static int validate_arguments (void) { return OK; } -void +static void print_help (void) { print_revision (progname, revision); @@ -390,7 +284,6 @@ } - void print_usage (void) { Index: check_load.c =================================================================== RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_load.c,v retrieving revision 1.29 diff -u -u -r1.29 check_load.c --- check_load.c 28 Jun 2005 02:26:18 -0000 1.29 +++ check_load.c 29 Jun 2005 04:11:46 -0000 @@ -25,7 +25,7 @@ #include "common.h" #include "utils.h" -#include "popen.h" +#include "runcmd.h" #ifdef HAVE_SYS_LOADAVG_H #include @@ -47,12 +47,8 @@ /* strictly for pretty-print usage in loops */ static const int nums[3] = { 1, 5, 15 }; -/* provide some fairly sane defaults */ double wload[3] = { 0.0, 0.0, 0.0 }; double cload[3] = { 0.0, 0.0, 0.0 }; -#define la1 la[0] -#define la5 la[1] -#define la15 la[2] char *status_line; @@ -86,14 +82,16 @@ main (int argc, char **argv) { int result; - int i; + size_t i; /* size_t so we can match against chld_out.lines if need be */ double la[3] = { 0.0, 0.0, 0.0 }; /* NetBSD complains about unitialized arrays */ #ifndef HAVE_GETLOADAVG - char input_buffer[MAX_INPUT_BUFFER]; # ifdef HAVE_PROC_LOADAVG + char input_buffer[MAX_INPUT_BUFFER]; FILE *fp; char *str, *next; +# else + output chld_out, chld_err; # endif #endif @@ -127,23 +125,11 @@ fclose (fp); # else - child_process = spopen (PATH_TO_UPTIME); - if (child_process == NULL) { - printf (_("Error opening %s\n"), PATH_TO_UPTIME); - return STATE_UNKNOWN; - } - child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); - if (child_stderr == NULL) { - printf (_("Could not open stderr for %s\n"), PATH_TO_UPTIME); - } - fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process); - sscanf (input_buffer, "%*[^l]load average: %f, %f, %f", &la1, &la5, &la15); + if((result = np_runcmd(PATH_TO_UPTIME, &chld_out, &chld_err, 0)) || chld_err.buflen) + die(STATE_UNKNOWN, _("Error code %d returned in %s\n"), + result, PATH_TO_UPTIME); - result = spclose (child_process); - if (result) { - printf (_("Error code %d returned in %s\n"), result, PATH_TO_UPTIME); - return STATE_UNKNOWN; - } + sscanf (chld_out.buf, "%*[^l]load average: %f, %f, %f", &la[0], &la[1], &la[2]); # endif #endif @@ -163,17 +149,17 @@ /* we got this far, so assume OK until we've measured */ result = STATE_OK; - asprintf(&status_line, _("load average: %.2f, %.2f, %.2f"), la1, la5, la15); - for(i = 0; i < 3; i++) { if(la[i] > cload[i]) { result = STATE_CRITICAL; break; } - else if(la[i] > wload[i]) result = STATE_WARNING; + + if(la[i] > wload[i]) result = STATE_WARNING; } - printf("%s - %s|", state_text(result), status_line); + printf(_("%s - load average: %.2f, %.2f, %.2f|"), + state_text(result), la[0], la[1], la[2]); for(i = 0; i < 3; i++) printf("load%d=%.3f;%.3f;%.3f;0; ", nums[i], la[i], wload[i], cload[i]); @@ -249,14 +235,13 @@ int i = 0; /* match cload first, as it will give the most friendly error message - * if user hasn't given the -c switch properly */ + * if user hasn't given the -c switch properly. Don't make sure wload[i] + * < cload[i] as it prevents users from forcing a critical state */ for(i = 0; i < 3; i++) { - if(cload[i] < 0) + if(cload[i] == 0.0) die (STATE_UNKNOWN, _("Critical threshold for %d-minute load average is not specified\n"), nums[i]); - if(wload[i] < 0) + if(wload[i] == 0.0) die (STATE_UNKNOWN, _("Warning threshold for %d-minute load average is not specified\n"), nums[i]); - if(wload[i] > cload[i]) - die (STATE_UNKNOWN, _("Parameter inconsistency: %d-minute \"warning load\" is greater than \"critical load\"\n"), nums[i]); } return OK; Index: check_nagios.c =================================================================== RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_nagios.c,v retrieving revision 1.26 diff -u -u -r1.26 check_nagios.c --- check_nagios.c 25 May 2005 00:43:20 -0000 1.26 +++ check_nagios.c 29 Jun 2005 04:11:46 -0000 @@ -14,17 +14,17 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: check_nagios.c,v 1.26 2005/05/25 00:43:20 seanius Exp $ + $Id: check_nagios.c,v 1.3 2005/06/06 11:37:06 exon Exp $ ******************************************************************************/ const char *progname = "check_nagios"; -const char *revision = "$Revision: 1.26 $"; +const char *revision = "$Revision: 1.3 $"; const char *copyright = "1999-2004"; const char *email = "nagiosplug-devel at lists.sourceforge.net"; #include "common.h" -#include "popen.h" +#include "runcmd.h" #include "utils.h" int process_arguments (int, char **); @@ -55,6 +55,8 @@ int procrss = 0; float procpcpu = 0; char procstat[8]; + /* procetime is unused in most configurations, but may be in PS_VAR_LIST + * so it must be here in spite of it producing compiler warnings */ char procetime[MAX_INPUT_BUFFER]; char procprog[MAX_INPUT_BUFFER]; char *procargs; @@ -62,6 +64,8 @@ int expected_cols = PS_COLS - 1; const char *zombie = "Z"; char *temp_string; + output chld_out, chld_err; + size_t i; setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); @@ -99,40 +103,30 @@ printf(_("command: %s\n"), PS_COMMAND); /* run the command to check for the Nagios process.. */ - child_process = spopen (PS_COMMAND); - if (child_process == NULL) { - printf (_("Could not open pipe: %s\n"), PS_COMMAND); - return STATE_UNKNOWN; - } - - child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); - if (child_stderr == NULL) { - printf (_("Could not open stderr for %s\n"), PS_COMMAND); - } - - fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process); + if((result = np_runcmd(PS_COMMAND, &chld_out, &chld_err, 0)) != 0) + result = STATE_WARNING; /* count the number of matching Nagios processes... */ - while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) { - cols = sscanf (input_buffer, PS_FORMAT, PS_VARLIST); - /* Zombie processes do not give a procprog command */ - if ( cols == (expected_cols - 1) && strstr(procstat, zombie) ) { - cols = expected_cols; - /* Set some value for procargs for the strip command further below - Seen to be a problem on some Solaris 7 and 8 systems */ - input_buffer[pos] = '\n'; - input_buffer[pos+1] = 0x0; - } + for(i = 0; i < chld_out.lines; i++) { + cols = sscanf (chld_out.line[i], PS_FORMAT, PS_VARLIST); + /* Zombie processes do not give a procprog command */ + if ( cols == (expected_cols - 1) && strstr(procstat, zombie) ) { + cols = expected_cols; + /* Set some value for procargs for the strip command further below + * Seen to be a problem on some Solaris 7 and 8 systems */ + chld_out.line[i][pos] = '\n'; + chld_out.line[i][pos+1] = 0x0; + } if ( cols >= expected_cols ) { - asprintf (&procargs, "%s", input_buffer + pos); + asprintf (&procargs, "%s", chld_out.line[i] + pos); strip (procargs); - + /* Some ps return full pathname for command. This removes path */ - temp_string = strtok ((char *)procprog, "/"); - while (temp_string) { - strcpy(procprog, temp_string); - temp_string = strtok (NULL, "/"); - } + temp_string = strtok ((char *)procprog, "/"); + while (temp_string) { + strcpy(procprog, temp_string); + temp_string = strtok (NULL, "/"); + } /* May get empty procargs */ if (!strstr(procargs, argv[0]) && strstr(procargs, process_string) && strcmp(procargs,"")) { @@ -145,14 +139,7 @@ } /* If we get anything on stderr, at least set warning */ - while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) - result = max_state (result, STATE_WARNING); - - /* close stderr */ - (void) fclose (child_stderr); - - /* close the pipe */ - if (spclose (child_process)) + if(chld_err.buflen) result = max_state (result, STATE_WARNING); /* reset the alarm handler */ Index: check_ping.c =================================================================== RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_ping.c,v retrieving revision 1.44 diff -u -u -r1.44 check_ping.c --- check_ping.c 25 May 2005 14:25:55 -0000 1.44 +++ check_ping.c 29 Jun 2005 04:11:46 -0000 @@ -14,18 +14,18 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: check_ping.c,v 1.44 2005/05/25 14:25:55 sghosh Exp $ + $Id: check_ping.c,v 1.2 2005/06/05 21:55:26 exon Exp $ ******************************************************************************/ const char *progname = "check_ping"; -const char *revision = "$Revision: 1.44 $"; +const char *revision = "$Revision: 1.2 $"; const char *copyright = "2000-2004"; const char *email = "nagiosplug-devel at lists.sourceforge.net"; #include "common.h" #include "netutils.h" -#include "popen.h" +#include "runcmd.h" #include "utils.h" #define WARN_DUPLICATES "DUPLICATES FOUND! " @@ -40,7 +40,7 @@ int get_threshold (char *, float *, int *); int validate_arguments (void); int run_ping (const char *cmd, const char *addr); -int error_scan (char buf[MAX_INPUT_BUFFER], const char *addr); +int error_scan (const char *buf, const char *addr); void print_usage (void); void print_help (void); @@ -58,7 +58,7 @@ float rta = UNKNOWN_TRIP_TIME; int pl = UNKNOWN_PACKET_LOSS; -char *warn_text; +char *warn_text = NULL; @@ -95,10 +95,8 @@ if (is_inet6_addr(addresses[i]) && address_family != AF_INET) rawcmd = strdup(PING6_COMMAND); else - rawcmd = strdup(PING_COMMAND); -#else - rawcmd = strdup(PING_COMMAND); #endif + rawcmd = strdup(PING_COMMAND); /* does the host address of number of packets argument come first? */ #ifdef PING_PACKETS_FIRST @@ -119,8 +117,7 @@ if (pl == UNKNOWN_PACKET_LOSS || rta < 0.0) { printf ("%s\n", cmd); - die (STATE_UNKNOWN, - _("CRITICAL - Could not interpret output from ping command\n")); + die (STATE_UNKNOWN, _("CRITICAL - Could not interpret output from ping command\n")); } if (pl >= cpl || rta >= crta || rta < 0) @@ -136,11 +133,11 @@ if (display_html == TRUE) printf ("", CGIURL, addresses[i]); if (pl == 100) - printf (_("PING %s - %sPacket loss = %d%%"), state_text (this_result), warn_text, - pl); + printf (_("PING %s - %sPacket loss = %d%%"), + state_text(this_result), warn_text ? warn_text : " ", pl); else printf (_("PING %s - %sPacket loss = %d%%, RTA = %2.2f ms"), - state_text (this_result), warn_text, pl, rta); + state_text (this_result), warn_text ? warn_text : " ", pl, rta); if (display_html == TRUE) printf (""); printf ("\n"); @@ -399,42 +396,42 @@ int run_ping (const char *cmd, const char *addr) { - char buf[MAX_INPUT_BUFFER]; int result = STATE_UNKNOWN; - - if ((child_process = spopen (cmd)) == NULL) - die (STATE_UNKNOWN, _("Could not open pipe: %s\n"), cmd); - - child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); - if (child_stderr == NULL) - printf (_("Cannot open stderr for %s\n"), cmd); - - while (fgets (buf, MAX_INPUT_BUFFER - 1, child_process)) { - - result = max_state (result, error_scan (buf, addr)); - - /* get the percent loss statistics */ - if(sscanf(buf,"%*d packets transmitted, %*d packets received, +%*d errors, %d%% packet loss",&pl)==1 || - sscanf(buf,"%*d packets transmitted, %*d packets received, %d%% packet loss",&pl)==1 || - sscanf(buf,"%*d packets transmitted, %*d packets received, %d%% loss, time",&pl)==1 || - sscanf(buf,"%*d packets transmitted, %*d received, %d%% loss, time", &pl)==1 || - sscanf(buf,"%*d packets transmitted, %*d received, %d%% packet loss, time", &pl)==1 || - sscanf(buf,"%*d packets transmitted, %*d received, +%*d errors, %d%% packet loss", &pl) == 1 || - sscanf(buf,"%*d packets transmitted %*d received, +%*d errors, %d%% packet loss", &pl) == 1 - ) + output chld_out, chld_err; + char *p; + size_t mult = 1, i; + + if((result = np_runcmd(cmd, &chld_out, &chld_err, 0)) != 0) + result = STATE_WARNING; + + for(i = 0; i < chld_out.lines; i++) { + /* get the packet loss. Find the % sign and count backwards */ + if((p = memchr(chld_out.line[i], '%', chld_out.lens[i]))) { + p--; + pl = 0; + while(p != chld_out.line[i] && isdigit(*p)) { + pl += *p - '0' * mult; + mult *= 10; + p--; + } continue; - + } /* get the round trip average */ - else - if(sscanf(buf,"round-trip min/avg/max = %*f/%f/%*f",&rta)==1 || - sscanf(buf,"round-trip min/avg/max/mdev = %*f/%f/%*f/%*f",&rta)==1 || - sscanf(buf,"round-trip min/avg/max/sdev = %*f/%f/%*f/%*f",&rta)==1 || - sscanf(buf,"round-trip min/avg/max/stddev = %*f/%f/%*f/%*f",&rta)==1 || - sscanf(buf,"round-trip min/avg/max/std-dev = %*f/%f/%*f/%*f",&rta)==1 || - sscanf(buf,"round-trip (ms) min/avg/max = %*f/%f/%*f",&rta)==1 || - sscanf(buf,"round-trip (ms) min/avg/max/stddev = %*f/%f/%*f/%*f",&rta)==1 || - sscanf(buf,"rtt min/avg/max/mdev = %*f/%f/%*f/%*f ms",&rta)==1) - continue; + else { + if(sscanf(chld_out.line[i], "round-trip min/avg/max = %*f/%f/%*f", &rta) == 1 || + sscanf(chld_out.line[i], "round-trip min/avg/max/mdev = %*f/%f/%*f/%*f", &rta) == 1 || + sscanf(chld_out.line[i], "round-trip min/avg/max/sdev = %*f/%f/%*f/%*f", &rta) == 1 || + sscanf(chld_out.line[i], "round-trip min/avg/max/stddev = %*f/%f/%*f/%*f", &rta) == 1 || + sscanf(chld_out.line[i], "round-trip min/avg/max/std-dev = %*f/%f/%*f/%*f", &rta) == 1 || + sscanf(chld_out.line[i], "round-trip (ms) min/avg/max = %*f/%f/%*f", &rta) == 1 || + sscanf(chld_out.line[i], "round-trip (ms) min/avg/max/stddev = %*f/%f/%*f/%*f", &rta) == 1 || + sscanf(chld_out.line[i], "rtt min/avg/max/mdev = %*f/%f/%*f/%*f ms", &rta) == 1) + { + continue; + } + + result = max_state (result, error_scan (chld_out.line[i], addr)); + } } /* this is needed because there is no rta if all packets are lost */ @@ -442,19 +439,10 @@ rta = crta; /* check stderr, setting at least WARNING if there is output here */ - while (fgets (buf, MAX_INPUT_BUFFER - 1, child_stderr)) - if (! strstr(buf,"WARNING - no SO_TIMESTAMP support, falling back to SIOCGSTAMP")) - result = max_state (STATE_WARNING, error_scan (buf, addr)); - - (void) fclose (child_stderr); - - - /* close the pipe - WARNING if status is set */ - if (spclose (child_process)) - result = max_state (result, STATE_WARNING); - - if (warn_text == NULL) - warn_text = strdup(""); + if(chld_err.buflen > 0) { + if (! strstr(chld_err.line[0], "WARNING - no SO_TIMESTAMP support, falling back to SIOCGSTAMP")) + result = max_state (STATE_WARNING, error_scan (chld_err.line[0], addr)); + } return result; } @@ -462,7 +450,7 @@ int -error_scan (char buf[MAX_INPUT_BUFFER], const char *addr) +error_scan (const char *buf, const char *addr) { if (strstr (buf, "Network is unreachable")) die (STATE_CRITICAL, _("CRITICAL - Network unreachable (%s)"), addr); Index: check_procs.c =================================================================== RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_procs.c,v retrieving revision 1.45 diff -u -u -r1.45 check_procs.c --- check_procs.c 3 Jun 2005 13:53:43 -0000 1.45 +++ check_procs.c 29 Jun 2005 04:11:46 -0000 @@ -14,17 +14,17 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: check_procs.c,v 1.45 2005/06/03 13:53:43 seanius Exp $ + $Id: check_procs.c,v 1.3 2005/06/06 11:37:06 exon Exp $ ******************************************************************************/ const char *progname = "check_procs"; -const char *revision = "$Revision: 1.45 $"; +const char *revision = "$Revision: 1.3 $"; const char *copyright = "2000-2004"; const char *email = "nagiosplug-devel at lists.sourceforge.net"; #include "common.h" -#include "popen.h" +#include "runcmd.h" #include "utils.h" #include @@ -96,7 +96,7 @@ char procstat[8]; char procetime[MAX_INPUT_BUFFER] = { '\0' }; char *procargs; - char *temp_string; + output chld_out, chld_err; const char *zombie = "Z"; @@ -118,7 +118,7 @@ input_buffer = malloc (MAX_INPUT_BUFFER); procprog = malloc (MAX_INPUT_BUFFER); - asprintf (&metric_name, "PROCS"); + metric_name = "PROCS"; metric = METRIC_PROCS; if (process_arguments (argc, argv) == ERROR) @@ -136,27 +136,15 @@ if (verbose >= 2) printf (_("CMD: %s\n"), PS_COMMAND); - child_process = spopen (PS_COMMAND); - if (child_process == NULL) { - printf (_("Could not open pipe: %s\n"), PS_COMMAND); - return STATE_UNKNOWN; - } - - child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); - if (child_stderr == NULL) - printf (_("Could not open stderr for %s\n"), PS_COMMAND); - - /* flush first line */ - fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process); - while ( input_buffer[strlen(input_buffer)-1] != '\n' ) - fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process); - - while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) { - asprintf (&input_line, "%s", input_buffer); - while ( input_buffer[strlen(input_buffer)-1] != '\n' ) { - fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process); - asprintf (&input_line, "%s%s", input_line, input_buffer); - } + result = np_runcmd(PS_COMMAND, &chld_out, &chld_err, 0); + if(result) { + printf (_("System call returned nonzero status\n")); + result = max_state (result, STATE_WARNING); + } + + /* start parsing on second line */ + for(i = 1; i < chld_out.lines; i++) { + input_line = chld_out.line[i]; if (verbose >= 3) printf ("%s", input_line); @@ -177,8 +165,7 @@ /* Some ps return full pathname for command. This removes path */ #ifdef HAVE_BASENAME - temp_string = strdup(procprog); - procprog = basename(temp_string); + procprog = strdup(basename(procprog)); #endif /* HAVE_BASENAME */ /* we need to convert the elapsed time to seconds */ @@ -248,27 +235,17 @@ } /* If we get anything on STDERR, at least set warning */ - while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) { - if (verbose) - printf ("STDERR: %s", input_buffer); + if(chld_err.buflen > 0) { result = max_state (result, STATE_WARNING); printf (_("System call sent warnings to stderr\n")); } - - (void) fclose (child_stderr); - - /* close the pipe */ - if (spclose (child_process)) { - printf (_("System call returned nonzero status\n")); - result = max_state (result, STATE_WARNING); - } if (found == 0) { /* no process lines parsed so return STATE_UNKNOWN */ printf (_("Unable to read output\n")); return result; } - if ( result == STATE_UNKNOWN ) + if ( result == STATE_UNKNOWN ) result = STATE_OK; /* Needed if procs found, but none match filter */ @@ -459,7 +436,7 @@ } usage4 (_("PCPU must be a float!")); case 'm': - asprintf (&metric_name, "%s", optarg); + metric_name = optarg; if ( strcmp(optarg, "PROCS") == 0) { metric = METRIC_PROCS; break; @@ -494,7 +471,7 @@ if (cmax == -1 && argv[c]) cmax = atoi (argv[c++]); if (statopts == NULL && argv[c]) { - asprintf (&statopts, "%s", argv[c++]); + statopts = argv[c++]; asprintf (&fmt, _("%s%sSTATE = %s"), (fmt ? fmt : ""), (options ? ", " : ""), statopts); options |= STAT; } Index: check_snmp.c =================================================================== RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_snmp.c,v retrieving revision 1.57 diff -u -u -r1.57 check_snmp.c --- check_snmp.c 1 Jun 2005 19:41:01 -0000 1.57 +++ check_snmp.c 29 Jun 2005 04:11:47 -0000 @@ -14,18 +14,18 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: check_snmp.c,v 1.57 2005/06/01 19:41:01 sghosh Exp $ + $Id: check_snmp.c,v 1.2 2005/06/05 21:55:26 exon Exp $ ******************************************************************************/ const char *progname = "check_snmp"; -const char *revision = "$Revision: 1.57 $"; +const char *revision = "$Revision: 1.2 $"; const char *copyright = "1999-2004"; const char *email = "nagiosplug-devel at lists.sourceforge.net"; #include "common.h" #include "utils.h" -#include "popen.h" +#include "runcmd.h" #define DEFAULT_COMMUNITY "public" #define DEFAULT_PORT "161" @@ -136,11 +136,12 @@ char *command_line = NULL; char *response = NULL; char *outbuff; - char *output; + char *msg; char *ptr = NULL; char *p2 = NULL; char *show = NULL; char type[8]; + output chld_out, chld_err; setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); @@ -157,7 +158,7 @@ units = strdup (""); port = strdup (DEFAULT_PORT); outbuff = strdup (""); - output = strdup (""); + msg = strdup (""); delimiter = strdup (" = "); output_delim = strdup (DEFAULT_OUTPUT_DELIMITER); /* miblist = strdup (DEFAULT_MIBLIST); */ @@ -168,41 +169,25 @@ usage4 (_("Could not parse arguments")); /* create the command line to execute */ - if(usesnmpgetnext == TRUE) { - asprintf(&command_line, "%s -t %d -r %d -m %s -v %s %s %s:%s %s", - PATH_TO_SNMPGETNEXT, timeout_interval, retries, miblist, proto, - authpriv, server_address, port, oid); - }else{ - - asprintf (&command_line, "%s -t %d -r %d -m %s -v %s %s %s:%s %s", - PATH_TO_SNMPGET, timeout_interval, retries, miblist, proto, - authpriv, server_address, port, oid); - } - + asprintf(&command_line, "%s -t %d -r %d -m %s -v %s %s %s:%s %s", + usesnmpgetnext == TRUE ? PATH_TO_SNMPGETNEXT : PATH_TO_SNMPGET, + timeout_interval, retries, miblist, proto, + authpriv, server_address, port, oid); + if (verbose) printf ("%s\n", command_line); - /* run the command */ - child_process = spopen (command_line); - if (child_process == NULL) { - printf (_("Could not open pipe: %s\n"), command_line); - exit (STATE_UNKNOWN); - } - - child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); - if (child_stderr == NULL) { - printf (_("Could not open stderr for %s\n"), command_line); - } + if((np_runcmd(command_line, &chld_out, &chld_err, 0)) != 0 || chld_err.buflen) + result = STATE_WARNING; - while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) - asprintf (&output, "%s%s", output, input_buffer); + for(i = 0; (size_t)i < chld_out.lines; i++) + asprintf (&msg, "%s%s", msg, input_buffer); if (verbose) - printf ("%s\n", output); - - ptr = output; + printf ("%s\n", msg); + ptr = msg; strcat(perfstr, "| "); while (ptr) { char *foo; @@ -261,18 +246,11 @@ iresult = STATE_DEPENDENT; /* Process this block for integer comparisons */ - if (eval_method[i] & CRIT_GT || - eval_method[i] & CRIT_LT || - eval_method[i] & CRIT_GE || - eval_method[i] & CRIT_LE || - eval_method[i] & CRIT_EQ || - eval_method[i] & CRIT_NE || - eval_method[i] & WARN_GT || - eval_method[i] & WARN_LT || - eval_method[i] & WARN_GE || - eval_method[i] & WARN_LE || - eval_method[i] & WARN_EQ || - eval_method[i] & WARN_NE) { + if (eval_method[i] & (CRIT_GT | CRIT_LT | CRIT_GE | + CRIT_LE | CRIT_EQ | CRIT_NE | + WARN_GT | WARN_LT | WARN_GE | + WARN_LE | WARN_EQ | WARN_NE)) + { p2 = strpbrk (p2, "0123456789"); if (p2 == NULL) die (STATE_UNKNOWN,_("No valid data returned")); @@ -350,20 +328,6 @@ label, command_line); - /* WARNING if output found on stderr */ - if (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) - result = max_state (result, STATE_WARNING); - - /* close stderr */ - (void) fclose (child_stderr); - - /* close the pipe */ - if (spclose (child_process)) - result = max_state (result, STATE_WARNING); - -/* if (nunits == 1 || i == 1) */ -/* printf ("%s %s -%s %s\n", label, state_text (result), outbuff, units); */ -/* else */ printf ("%s %s -%s %s \n", label, state_text (result), outbuff, perfstr); return result; Index: check_swap.c =================================================================== RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_swap.c,v retrieving revision 1.50 diff -u -u -r1.50 check_swap.c --- check_swap.c 29 Jun 2005 01:04:10 -0000 1.50 +++ check_swap.c 29 Jun 2005 04:11:47 -0000 @@ -31,8 +31,8 @@ const char *email = "nagiosplug-devel at lists.sourceforge.net"; #include "common.h" -#include "popen.h" #include "utils.h" +#include "runcmd.h" int check_swap (int usp, float free_swap); int process_arguments (int argc, char **argv); @@ -64,6 +64,8 @@ char *temp_buffer; char *swap_command; char *swap_format; + output chld_out, chld_err; + size_t i = 0; # else # ifdef HAVE_DECL_SWAPCTL int i=0, nswaps=0, swapctl_res=0; @@ -145,15 +147,9 @@ if (verbose >= 3) printf (_("Format: %s\n"), swap_format); - child_process = spopen (swap_command); - if (child_process == NULL) { - printf (_("Could not open pipe: %s\n"), swap_command); - return STATE_UNKNOWN; - } - - child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); - if (child_stderr == NULL) - printf (_("Could not open stderr for %s\n"), swap_command); + /* run the command. set WARNING if non-zero return or output on stderr */ + if((np_runcmd(swap_command, &chld_out, &chld_err, 0)) || chld_err.buflen) + result = STATE_WARNING; sprintf (str, "%s", ""); /* read 1st line */ @@ -209,17 +205,6 @@ # ifdef _AIX } # endif - - /* If we get anything on STDERR, at least set warning */ - while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) - result = max_state (result, STATE_WARNING); - - /* close stderr */ - (void) fclose (child_stderr); - - /* close the pipe */ - if (spclose (child_process)) - result = max_state (result, STATE_WARNING); # else # ifdef CHECK_SWAP_SWAPCTL_SVR4 Index: check_users.c =================================================================== RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_users.c,v retrieving revision 1.19 diff -u -u -r1.19 check_users.c --- check_users.c 25 Dec 2004 23:17:44 -0000 1.19 +++ check_users.c 29 Jun 2005 04:11:47 -0000 @@ -14,17 +14,17 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: check_users.c,v 1.19 2004/12/25 23:17:44 opensides Exp $ + $Id: check_users.c,v 1.2 2005/06/05 21:55:26 exon Exp $ *****************************************************************************/ const char *progname = "check_users"; -const char *revision = "$Revision: 1.19 $"; +const char *revision = "$Revision: 1.2 $"; const char *copyright = "2000-2004"; const char *email = "nagiosplug-devel at lists.sourceforge.net"; #include "common.h" -#include "popen.h" +#include "runcmd.h" #include "utils.h" #define possibly_set(a,b) ((a) == 0 ? (b) : 0) @@ -41,52 +41,28 @@ { int users = -1; int result = STATE_UNKNOWN; - char input_buffer[MAX_INPUT_BUFFER]; - char *perf; + output chld_out, chld_err; + size_t i; setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); - perf = strdup(""); - if (process_arguments (argc, argv) == ERROR) usage4 (_("Could not parse arguments")); /* run the command */ - child_process = spopen (WHO_COMMAND); - if (child_process == NULL) { - printf (_("Could not open pipe: %s\n"), WHO_COMMAND); - return STATE_UNKNOWN; - } - - child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); - if (child_stderr == NULL) - printf (_("Could not open stderr for %s\n"), WHO_COMMAND); - - users = 0; - - while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) { - - /* increment 'users' on all lines except total user count */ - if (input_buffer[0] != '#') { - users++; - continue; - } - - /* get total logged in users */ - if (sscanf (input_buffer, _("# users=%d"), &users) == 1) - break; - - } + result = np_runcmd(WHO_COMMAND, &chld_out, &chld_err, 0); + if(result != 0) + result = STATE_UNKNOWN; + + /* one user is listed per line, except when it begins with '#' */ + users = chld_out.lines; + for(i = 0; i < chld_out.lines; i++) + if (chld_out.line[0][0] == '#') users--; /* check STDERR */ - if (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) - result = possibly_set (result, STATE_UNKNOWN); - (void) fclose (child_stderr); - - /* close the pipe */ - if (spclose (child_process)) + if(chld_err.buflen > 0) result = possibly_set (result, STATE_UNKNOWN); /* else check the user count against warning and critical thresholds */ @@ -98,16 +74,12 @@ result = STATE_OK; if (result == STATE_UNKNOWN) - printf (_("Unable to read output\n")); - else { - asprintf(&perf, "%s", perfdata ("users", users, "", - TRUE, wusers, - TRUE, cusers, - TRUE, 0, - FALSE, 0)); - printf (_("USERS %s - %d users currently logged in |%s\n"), state_text (result), - users, perf); - } + die (STATE_UNKNOWN, _("Unable to read output\n")); + + printf (_("USERS %s - %d users currently logged in |%s\n"), + state_text (result), users, + perfdata("users", users, "", + TRUE, wusers, TRUE, cusers, TRUE, 0, FALSE, 0)); return result; } @@ -129,8 +101,10 @@ {0, 0, 0, 0} }; - if (argc < 2) - usage ("\n"); + if (argc < 2) { + print_usage (); + exit(STATE_UNKNOWN); + } while (1) { c = getopt_long (argc, argv, "+hVvc:w:", longopts, &option); Index: common.h =================================================================== RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/common.h,v retrieving revision 1.15 diff -u -u -r1.15 common.h --- common.h 10 Dec 2004 00:13:43 -0000 1.15 +++ common.h 29 Jun 2005 04:11:47 -0000 @@ -32,7 +32,17 @@ * *****************************************************************************/ -#include "config.h" +#ifndef NAGIOSPLUG_COMMON_H +#define NAGIOSPLUG_COMMON_H + +/* For non-GNU compilers to ignore __attribute__ + * This must be here so that imported GNU headers can be used with non-gnu + * compilers and so we can safely (and properly) put prototypes here. */ +#ifndef __GNUC__ +# define __attribute__(x) /* do nothing */ +#endif + +# include "config.h" #ifdef HAVE_FEATURES_H #include @@ -131,19 +141,25 @@ #endif #ifndef HAVE_ASPRINTF -int asprintf(char **strp, const char *fmt, ...); +int asprintf(char **strp, const char *fmt, ...) + __attribute__((__format__(__printf__, 2, 3))); #endif +/* #ifndef HAVE_VASPRINTF -/* int vasprintf(char **strp, const char *fmt, va_list ap); */ +int vasprintf(char **strp, const char *fmt, va_list ap) + __attribute__((__format__(__printf__, 2, 0))); #endif +*/ #ifndef HAVE_SNPRINTF -int snprintf(char *str, size_t size, const char *format, ...); +int snprintf(char *str, size_t size, const char *format, ...) + __attribute__((__format__(__printf__, 3, 4))); #endif #ifndef HAVE_VSNPRINTF -int vsnprintf(char *str, size_t size, const char *format, va_list ap); +int vsnprintf(char *str, size_t size, const char *format, va_list ap) + __attribute__((__format__(__printf__, 3, 0))); #endif /* @@ -152,32 +168,31 @@ * */ -enum { - OK = 0, - ERROR = -1 -}; +/* These should be macros so they never have to be fetched + * from a different data-segment than the code evaluating it (which is + * bizarrely expensive on some weird architectures). It also makes it + * easier to develop and implement additional API's without mucking about + * with the "official" code (#ifdef STATE_CRITICAL etc). + */ +#define OK 0 +#define ERROR -1 /* AIX seems to have this defined somewhere else */ #ifndef FALSE -enum { - FALSE, - TRUE -}; -#endif - -enum { - STATE_OK, - STATE_WARNING, - STATE_CRITICAL, - STATE_UNKNOWN, - STATE_DEPENDENT -}; - -enum { - DEFAULT_SOCKET_TIMEOUT = 10, /* timeout after 10 seconds */ - MAX_INPUT_BUFFER = 1024, /* max size of most buffers we use */ - MAX_HOST_ADDRESS_LENGTH = 256 /* max size of a host address */ -}; +# define FALSE 0 +# define TRUE 1 +#endif + +#define STATE_OK 0 +#define STATE_WARNING 1 +#define STATE_CRITICAL 2 +#define STATE_UNKNOWN 3 +#define STATE_DEPENDENT 4 +#define STATE_OOB 5 /* status out of bounds. Must be last */ + +#define DEFAULT_SOCKET_TIMEOUT 10 /* timeout after 10 seconds */ +#define MAX_INPUT_BUFFER 1024 /* max size of most buffers we use */ +#define MAX_HOST_ADDRESS_LENGTH 256 /* max size of a host address */ /* * @@ -187,7 +202,4 @@ #include "gettext.h" #define _(String) gettext (String) -/* For non-GNU compilers to ignore __attribute__ */ -#ifndef __GNUC__ -# define __attribute__(x) /* do nothing */ -#endif +#endif /* NAGIOSPLUG_COMMON_H */ Index: negate.c =================================================================== RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/negate.c,v retrieving revision 1.24 diff -u -u -r1.24 negate.c --- negate.c 25 Dec 2004 23:17:44 -0000 1.24 +++ negate.c 29 Jun 2005 04:11:47 -0000 @@ -14,7 +14,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: negate.c,v 1.24 2004/12/25 23:17:44 opensides Exp $ + $Id: negate.c,v 1.2 2005/06/05 21:55:26 exon Exp $ @@-
@@ -54,7 +54,7 @@ ******************************************************************************/ const char *progname = "negate"; -const char *revision = "$Revision: 1.24 $"; +const char *revision = "$Revision: 1.2 $"; const char *copyright = "2002-2004"; const char *email = "nagiosplug-devel at lists.sourceforge.net"; @@ -62,7 +62,7 @@ #include "common.h" #include "utils.h" -#include "popen.h" +#include "runcmd.h" char *command_line; @@ -76,8 +76,9 @@ int main (int argc, char **argv) { - int found = 0, result = STATE_UNKNOWN; - char *buf; + int result = STATE_UNKNOWN; + output chld_out, chld_err; + size_t i; setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); @@ -92,43 +93,26 @@ (void) alarm ((unsigned) timeout_interval); - child_process = spopen (command_line); - if (child_process == NULL) - die (STATE_UNKNOWN, _("Could not open pipe: %s\n"), command_line); - - child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); - - if (child_stderr == NULL) { - printf (_("Could not open stderr for %s\n"), command_line); - } - - buf = malloc(MAX_INPUT_BUFFER); - while (fgets (buf, MAX_INPUT_BUFFER - 1, child_process)) { - found++; - printf ("%s", buf); - } - - if (!found) + result = np_runcmd(command_line, &chld_out, &chld_err, 0); + if (!chld_out.buflen) die (STATE_UNKNOWN, _("%s problem - No data received from host\nCMD: %s\n"),\ argv[0], command_line); - /* close the pipe */ - result = spclose (child_process); + for(i = 0; i < chld_out.lines; i++) + printf("%s", chld_out.line[i]); /* WARNING if output found on stderr */ - if (fgets (buf, MAX_INPUT_BUFFER - 1, child_stderr)) + if (chld_err.buflen != 0) result = max_state (result, STATE_WARNING); - /* close stderr */ - (void) fclose (child_stderr); - if (result == STATE_OK) exit (STATE_CRITICAL); - else if (result == STATE_CRITICAL) + + if (result == STATE_CRITICAL) exit (EXIT_SUCCESS); - else - exit (result); + + exit (result); } /****************************************************************************** Index: urlize.c =================================================================== RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/urlize.c,v retrieving revision 1.17 diff -u -u -r1.17 urlize.c --- urlize.c 25 Dec 2004 23:17:44 -0000 1.17 +++ urlize.c 29 Jun 2005 04:11:47 -0000 @@ -14,18 +14,18 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: urlize.c,v 1.17 2004/12/25 23:17:44 opensides Exp $ + $Id: urlize.c,v 1.2 2005/06/05 21:55:26 exon Exp $ ******************************************************************************/ const char *progname = "urlize"; -const char *revision = "$Revision: 1.17 $"; +const char *revision = "$Revision: 1.2 $"; const char *copyright = "2000-2004"; const char *email = "nagiosplug-devel at lists.sourceforge.net"; #include "common.h" #include "utils.h" -#include "popen.h" +#include "runcmd.h" void print_help (void); void print_usage (void); @@ -33,10 +33,11 @@ int main (int argc, char **argv) { - int found = 0, result = STATE_UNKNOWN; + int result = STATE_UNKNOWN; char *url = NULL; char *cmd; - char *buf; + output chld_out, chld_err; + size_t i; int c; int option = 0; @@ -67,55 +68,37 @@ exit (EXIT_SUCCESS); break; case 'u': - url = strdup (argv[optind]); + url = optarg; break; case '?': default: - usage2 (_("Unknown argument"), optarg); + usage3 (_("Unknown argument"), c); } } - if (url == NULL) - url = strdup (argv[optind++]); + if (url == NULL && optind < argc - 1) + url = argv[optind++]; cmd = strdup (argv[optind++]); for (c = optind; c < argc; c++) { asprintf (&cmd, "%s %s", cmd, argv[c]); } - child_process = spopen (cmd); - if (child_process == NULL) { - printf (_("Could not open pipe: %s\n"), cmd); - exit (STATE_UNKNOWN); - } - - child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); - if (child_stderr == NULL) { - printf (_("Could not open stderr for %s\n"), cmd); - } + result = np_runcmd(cmd, &chld_out, &chld_err, 0); + printf ("", url); - buf = malloc(MAX_INPUT_BUFFER); - printf ("", argv[1]); - while (fgets (buf, MAX_INPUT_BUFFER - 1, child_process)) { - found++; - printf ("%s", buf); - } - - if (!found) + if (!chld_out.lines) die (STATE_UNKNOWN, _("%s UNKNOWN - No data received from host\nCMD: %s\n"), argv[0], cmd); - /* close the pipe */ - result = spclose (child_process); + for(i = 0; i < chld_out.lines; i++) + printf("%s", chld_out.line[i]); /* WARNING if output found on stderr */ - if (fgets (buf, MAX_INPUT_BUFFER - 1, child_stderr)) + if (chld_err.buflen) result = max_state (result, STATE_WARNING); - /* close stderr */ - (void) fclose (child_stderr); - printf ("\n"); return result; } -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: Digital signature URL: From ae at op5.se Wed Jun 29 02:14:48 2005 From: ae at op5.se (Andreas Ericsson) Date: Wed Jun 29 02:14:48 2005 Subject: [Nagiosplug-devel] runcmd, common.h, and popen In-Reply-To: <20050629041253.GA16230@seanius.net> References: <20050629041253.GA16230@seanius.net> Message-ID: <42C26643.4050202@op5.se> sean finney wrote: > hey andreas, > > i've applied your patches after a bit of massaging for things that have > changed in cvs since the submission, and have a new diff file of all > this together. > Sorry, but I run off my own CVS currently. The patches grew burdensome. I haven't touched anything since I implemented the new API though, so it's most likely identical code insofar as that goes. It will however make patch submission quite a pain (indentation is a bit different and there are other fixes as well). I'll think of something though. > however, some of the plugins seem to no longer work after using the > np_runcmd framework. this is what i've tested: > > successful > > check_dig > check_dns > check_load > check_nagios > check_ping > check_procs > check_swap > > unsuccessful > > check_by_ssh (segfaulted if i gave a remote cmd that didn't exist) I'll look into it. Did you happen to have a backtrace of the core-dump? > check_fping (always issues a warning) This happens with urlize too. I'm not sure why, but I'll have a dig at it. > check_snmp (doesn't seem to return data at all) This I have fixed (more or less). > check_users (doesn't return the correct number of users) > What system was this on, and how does it differ (+-1 or wildly incoherent)? > untested > > check_game > check_hpjd > > attached is a diff of your combined patches against our current > cvs tree, if you or anyone else could help look into these problem > or untested plugins, i'd be appreciative. > Will do. -- Andreas Ericsson andreas.ericsson at op5.se OP5 AB www.op5.se Lead Developer From seanius at seanius.net Wed Jun 29 04:55:28 2005 From: seanius at seanius.net (sean finney) Date: Wed Jun 29 04:55:28 2005 Subject: [Nagiosplug-devel] runcmd, common.h, and popen In-Reply-To: <42C26643.4050202@op5.se> References: <20050629041253.GA16230@seanius.net> <42C26643.4050202@op5.se> Message-ID: <20050629115303.GA20556@seanius.net> hey andreas, On Wed, Jun 29, 2005 at 11:13:39AM +0200, Andreas Ericsson wrote: > >check_by_ssh (segfaulted if i gave a remote cmd that didn't exist) > > I'll look into it. Did you happen to have a backtrace of the core-dump? #0 0x000000000040197c in main (argc=5, argv=0x7fbffffa78) at check_by_ssh.c:91 91 result_text = chld_out.line[0]; > >check_users (doesn't return the correct number of users) > > What system was this on, and how does it differ (+-1 or wildly incoherent)? debian amd64. here's an example: copelandia[~]07:51:03$ w 07:51:04 up 20 min, 4 users, load average: 0.00, 0.00, 0.00 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT seanius :0 - 07:31 ?xdm? 3.42s 0.00s -:0 seanius pts/0 :0.0 07:32 2.00s 0.03s 0.03s ssh seanius at sat seanius pts/1 :0.0 07:47 40.00s 0.06s 0.05s vi check_by_ssh seanius pts/2 :0.0 07:51 0.00s 0.00s 0.00s w copelandia[~]07:51:04$ /usr/lib/nagios/plugins/check_users -w 3 -c 8 USERS WARNING - 4 users currently logged in |users=4;3;8;0 copelandia[~/nagios-plugins-1.5/plugins]07:51:52$ ./check_users -w 3 -c 8 USERS OK - 2 users currently logged in |users=2;3;8;0 i think the number is pretty much always 2 with the new plugin, fwiw. sean -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: Digital signature URL: From ae at op5.se Wed Jun 29 08:47:24 2005 From: ae at op5.se (Andreas Ericsson) Date: Wed Jun 29 08:47:24 2005 Subject: [Nagiosplug-devel] runcmd, common.h, and popen In-Reply-To: <20050629041253.GA16230@seanius.net> References: <20050629041253.GA16230@seanius.net> Message-ID: <42C2C224.8040206@op5.se> sean finney wrote: > hey andreas, > > i've applied your patches after a bit of massaging for things that have > changed in cvs since the submission, and have a new diff file of all > this together. > > however, some of the plugins seem to no longer work after using the > np_runcmd framework. this is what i've tested: > > successful > > check_dig > check_dns > check_load > check_nagios > check_ping > check_procs > check_swap > > unsuccessful > > check_by_ssh (segfaulted if i gave a remote cmd that didn't exist) Fixed (although I'm fairly certain the support for passive checks is broken). > check_fping (always issues a warning) Fixed. This plugin should be dropped in favor of check_icmp btw. I know of roughly 100 companies of varying sizes that have used check_icmp in production well over a year now without a hitch. There were previously some irregularities on *BSD but that's been sorted, and I've had reports of successful compiles and tests on Solaris, HP-UX, AIX and Irix as well. > check_snmp (doesn't seem to return data at all) Fixed. I had forgotten to remove the output line concatenation (which is stupid really, since it breaks the lines in the next loop anyways. Low-hanging fruit there, but I'm too fed up right now). > check_users (doesn't return the correct number of users) > Fixed. There was a typo in the counting loop. > untested > > check_game > check_hpjd > I haven't tested those either. Perhaps a friendly "testing help wanted" on nagios-users can settle it. I might be able to find someone to try check_hpjd, but check_game is lost to me. > attached is a diff of your combined patches against our current > cvs tree, if you or anyone else could help look into these problem > or untested plugins, i'd be appreciative. > > > > sean -- Andreas Ericsson andreas.ericsson at op5.se OP5 AB www.op5.se Lead Developer