Package: nsca
Version: 2.7.2
Severity: wishlist
When I use send_nsca from cronjobs like
#!/bin/sh
set -e
dumpdir=/data/mysqldump
dumper="mysqldump --defaults-file=/etc/mysql/debian.cnf -h localhost -u
debian-sys-maint"
$dumper tau TauDatabase tau_measure > $dumpdir/tau.dump
...
...
report="$(find $dumpdir/*.dump -printf "%f %s, ")"
printf "data\tbackup-mysqldump\t0\t$report\n" | /usr/sbin/send_nsca -H nagios |
grep -v "sent to host successfully."
it is really annoying that I need to use the grep to suppress output
that is printed when everything goes as requested.
Please consider the attached patch. It adds a --quiet option that does
not print "sent to host successfully" if at least one result was sent.
(There is only long option since I figured plain "-q" might collide
with something that upstream might add in the future.)
diff --git a/src/send_nsca.c b/src/send_nsca.c
index 868a9cb..543baef 100644
--- a/src/send_nsca.c
+++ b/src/send_nsca.c
@@ -43,6 +43,7 @@ struct crypt_instance *CI=NULL;
int show_help=FALSE;
int show_license=FALSE;
int show_version=FALSE;
+int verbose=TRUE;
int process_arguments(int,char **);
@@ -284,7 +285,8 @@ int main(int argc, char **argv){
/* close the connection */
close(sd);
- printf("%d data packet(s) sent to host successfully.\n",total_packets);
+ if (total_packets == 0 || verbose)
+ printf("%d data packet(s) sent to host successfully.\n",total_packets);
/* exit cleanly */
do_exit(STATE_OK);
@@ -385,6 +387,10 @@ int process_arguments(int argc, char **argv){
else if(!strcmp(argv[x-1],"-V") || !strcmp(argv[x-1],"--version"))
show_version=TRUE;
+ /* be quiet unless there are errors */
+ else if(!strcmp(argv[x-1],"--quiet"))
+ verbose=FALSE;
+
/* server name/address */
else if(!strcmp(argv[x-1],"-H")){
if(x<argc){
diff --git a/debian/send_nsca.1 b/debian/send_nsca.1
index 0392254..246d6a2 100644
--- a/debian/send_nsca.1
+++ b/debian/send_nsca.1
@@ -3,7 +3,7 @@
send_nsca \- send passive check results to an NSCA daemon
.SH SYNOPSIS
-.B send_nsca \-H <host_address> [\-p port] [\-to to_sec] [\-d delim] [ \-c config_file]
+.B send_nsca \-H <host_address> [\-p port] [\-to to_sec] [\-d delim] [ \-c config_file] [ \-\-quiet ]
.br
.Xc
@@ -37,6 +37,9 @@ Delimiter to use when parsing input (defaults to a tab)
.TP
config_file
Name of config file to use
+.TP
+\fB\-\-quiet\fR
+Do not print anything unless there are errors (or input contained no reports).
.SH SEE ALSO
.TP
-- System Information:
Debian Release: squeeze/sid
APT prefers testing
APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.32-5+lindi.5-amd64 (SMP w/4 CPU cores)
Locale: LANG=C, LC_CTYPE=fi_FI (charmap=ISO-8859-1)
Shell: /bin/sh linked to /bin/bash
Versions of packages nsca depends on:
ii debconf [debconf-2.0] 1.5.36 Debian configuration management sy
ii libc6 2.11.2-6+squeeze1 Embedded GNU C Library: Shared lib
ii libmcrypt4 2.5.8-3.1 De-/Encryption Library
nsca recommends no packages.
Versions of packages nsca suggests:
pn nagios <none> (no description available)
ii nagios-plugins 1.4.15-2 Plugins for the nagios network mon
ii nagios-plugins-basic 1.4.15-2 Plugins for the nagios network mon
-- debconf information excluded