summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml2
-rw-r--r--THANKS.in1
-rw-r--r--lib/utils_base.c15
-rw-r--r--plugins/check_dig.c9
-rw-r--r--plugins/t/check_dns.t12
-rwxr-xr-xtools/generate-change-log2
6 files changed, 32 insertions, 9 deletions
diff --git a/.travis.yml b/.travis.yml
index cec7878..2275be3 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,6 +4,8 @@ before_install:
4 - sudo add-apt-repository -y ppa:waja/precise-backports 4 - sudo add-apt-repository -y ppa:waja/precise-backports
5 - sudo apt-get update -qq 5 - sudo apt-get update -qq
6 - sudo apt-get purge -qq gawk 6 - sudo apt-get purge -qq gawk
7 # ensure we have a test database in place for tests
8 - mysql -e "create database IF NOT EXISTS test;" -uroot
7 9
8install: 10install:
9 - sudo apt-get install -qq --no-install-recommends perl autotools-dev libdbi-dev libldap2-dev libpq-dev libmysqlclient-dev libfreeradius-client-dev libkrb5-dev libnet-snmp-perl procps 11 - sudo apt-get install -qq --no-install-recommends perl autotools-dev libdbi-dev libldap2-dev libpq-dev libmysqlclient-dev libfreeradius-client-dev libkrb5-dev libnet-snmp-perl procps
diff --git a/THANKS.in b/THANKS.in
index 4f65260..0d004aa 100644
--- a/THANKS.in
+++ b/THANKS.in
@@ -326,4 +326,5 @@ Mikael Falkvidd
326Patric Wust 326Patric Wust
327Julius Kriukas 327Julius Kriukas
328Patrick McAndrew 328Patrick McAndrew
329Alexander Wittig
329Jason Benguerel 330Jason Benguerel
diff --git a/lib/utils_base.c b/lib/utils_base.c
index addf26b..4fb6375 100644
--- a/lib/utils_base.c
+++ b/lib/utils_base.c
@@ -446,6 +446,7 @@ void np_enable_state(char *keyname, int expected_data_version) {
446 char *temp_filename = NULL; 446 char *temp_filename = NULL;
447 char *temp_keyname = NULL; 447 char *temp_keyname = NULL;
448 char *p=NULL; 448 char *p=NULL;
449 int ret;
449 450
450 if(this_monitoring_plugin==NULL) 451 if(this_monitoring_plugin==NULL)
451 die(STATE_UNKNOWN, _("This requires np_init to be called")); 452 die(STATE_UNKNOWN, _("This requires np_init to be called"));
@@ -476,9 +477,13 @@ void np_enable_state(char *keyname, int expected_data_version) {
476 this_state->state_data=NULL; 477 this_state->state_data=NULL;
477 478
478 /* Calculate filename */ 479 /* Calculate filename */
479 asprintf(&temp_filename, "%s/%lu/%s/%s", 480 ret = xasprintf(&temp_filename, "%s/%lu/%s/%s",
480 _np_state_calculate_location_prefix(), (unsigned long)geteuid(), 481 _np_state_calculate_location_prefix(), (unsigned long)geteuid(),
481 this_monitoring_plugin->plugin_name, this_state->name); 482 this_monitoring_plugin->plugin_name, this_state->name);
483 if (ret < 0)
484 die(STATE_UNKNOWN, _("Cannot allocate memory: %s"),
485 strerror(errno));
486
482 this_state->_filename=temp_filename; 487 this_state->_filename=temp_filename;
483 488
484 this_monitoring_plugin->state = this_state; 489 this_monitoring_plugin->state = this_state;
@@ -614,8 +619,8 @@ void np_state_write_string(time_t data_time, char *data_string) {
614 619
615 /* If file doesn't currently exist, create directories */ 620 /* If file doesn't currently exist, create directories */
616 if(access(this_monitoring_plugin->state->_filename,F_OK)!=0) { 621 if(access(this_monitoring_plugin->state->_filename,F_OK)!=0) {
617 asprintf(&directories, "%s", this_monitoring_plugin->state->_filename); 622 result = xasprintf(&directories, "%s", this_monitoring_plugin->state->_filename);
618 if(directories==NULL) 623 if(result < 0)
619 die(STATE_UNKNOWN, _("Cannot allocate memory: %s"), 624 die(STATE_UNKNOWN, _("Cannot allocate memory: %s"),
620 strerror(errno)); 625 strerror(errno));
621 626
@@ -633,8 +638,8 @@ void np_state_write_string(time_t data_time, char *data_string) {
633 np_free(directories); 638 np_free(directories);
634 } 639 }
635 640
636 asprintf(&temp_file,"%s.XXXXXX",this_monitoring_plugin->state->_filename); 641 result = xasprintf(&temp_file,"%s.XXXXXX",this_monitoring_plugin->state->_filename);
637 if(temp_file==NULL) 642 if(result < 0)
638 die(STATE_UNKNOWN, _("Cannot allocate memory: %s"), 643 die(STATE_UNKNOWN, _("Cannot allocate memory: %s"),
639 strerror(errno)); 644 strerror(errno));
640 645
diff --git a/plugins/check_dig.c b/plugins/check_dig.c
index d9481f2..d899b11 100644
--- a/plugins/check_dig.c
+++ b/plugins/check_dig.c
@@ -94,8 +94,8 @@ main (int argc, char **argv)
94 timeout_interval_dig = timeout_interval / number_tries + number_tries; 94 timeout_interval_dig = timeout_interval / number_tries + number_tries;
95 95
96 /* get the command to run */ 96 /* get the command to run */
97 xasprintf (&command_line, "%s @%s -p %d %s -t %s %s %s +tries=%d +time=%d", 97 xasprintf (&command_line, "%s %s %s -p %d @%s %s %s +tries=%d +time=%d",
98 PATH_TO_DIG, dns_server, server_port, query_address, record_type, dig_args, query_transport, number_tries, timeout_interval_dig); 98 PATH_TO_DIG, dig_args, query_transport, server_port, dns_server, query_address, record_type, number_tries, timeout_interval_dig);
99 99
100 alarm (timeout_interval); 100 alarm (timeout_interval);
101 gettimeofday (&tv, NULL); 101 gettimeofday (&tv, NULL);
@@ -296,7 +296,10 @@ process_arguments (int argc, char **argv)
296 dns_server = argv[c]; 296 dns_server = argv[c];
297 } 297 }
298 else { 298 else {
299 dns_server = strdup ("127.0.0.1"); 299 if (strcmp(query_transport,"-6") == 0)
300 dns_server = strdup("::1");
301 else
302 dns_server = strdup ("127.0.0.1");
300 } 303 }
301 } 304 }
302 305
diff --git a/plugins/t/check_dns.t b/plugins/t/check_dns.t
index b885880..035e768 100644
--- a/plugins/t/check_dns.t
+++ b/plugins/t/check_dns.t
@@ -10,7 +10,7 @@ use NPTest;
10 10
11plan skip_all => "check_dns not compiled" unless (-x "check_dns"); 11plan skip_all => "check_dns not compiled" unless (-x "check_dns");
12 12
13plan tests => 14; 13plan tests => 16;
14 14
15my $successOutput = '/DNS OK: [\.0-9]+ seconds? response time/'; 15my $successOutput = '/DNS OK: [\.0-9]+ seconds? response time/';
16 16
@@ -43,6 +43,12 @@ my $dns_server = getTestParameter(
43 "A non default (remote) DNS server", 43 "A non default (remote) DNS server",
44 ); 44 );
45 45
46my $host_nonresponsive = getTestParameter(
47 "NP_HOST_NONRESPONSIVE",
48 "The hostname of system not responsive to network requests",
49 "10.0.0.1",
50 );
51
46my $res; 52my $res;
47 53
48$res = NPTest->testCmd("./check_dns -H $hostname_valid -t 5"); 54$res = NPTest->testCmd("./check_dns -H $hostname_valid -t 5");
@@ -66,6 +72,10 @@ like ( $res->output, $successOutput, "Output OK" );
66$res = NPTest->testCmd("./check_dns -H $hostname_invalid -s $dns_server -t 1"); 72$res = NPTest->testCmd("./check_dns -H $hostname_invalid -s $dns_server -t 1");
67cmp_ok( $res->return_code, '==', 2, "Invalid $hostname_invalid on $dns_server"); 73cmp_ok( $res->return_code, '==', 2, "Invalid $hostname_invalid on $dns_server");
68 74
75$res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_valid_ip -s $host_nonresponsive -t 2");
76cmp_ok( $res->return_code, '==', 2, "Got no answer from unresponsive server");
77like ( $res->output, "/CRITICAL - /", "Output OK");
78
69$res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_valid_ip -t 5"); 79$res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_valid_ip -t 5");
70cmp_ok( $res->return_code, '==', 0, "Got expected address"); 80cmp_ok( $res->return_code, '==', 0, "Got expected address");
71 81
diff --git a/tools/generate-change-log b/tools/generate-change-log
index 3a6b38e..ad19ce9 100755
--- a/tools/generate-change-log
+++ b/tools/generate-change-log
@@ -19,6 +19,7 @@ use Text::Wrap;
19 19
20# The lines will have a length of no more than $columns - 1. 20# The lines will have a length of no more than $columns - 1.
21$Text::Wrap::columns = 81; 21$Text::Wrap::columns = 81;
22$Text::Wrap::huge = 'overflow';
22 23
23if (system('git rev-parse --git-dir >/dev/null 2>&1') != 0) { 24if (system('git rev-parse --git-dir >/dev/null 2>&1') != 0) {
24 print "Not a Git repository, so I won't update the ChangeLog.\n"; 25 print "Not a Git repository, so I won't update the ChangeLog.\n";
@@ -51,6 +52,7 @@ while ($git_log =~ /$regex/gm) {
51 $prev_date = $commit{date}; 52 $prev_date = $commit{date};
52 $prev_name = $commit{name}; 53 $prev_name = $commit{name};
53 $prev_email = $commit{email}; 54 $prev_email = $commit{email};
55 $commit{message} =~ s/\s*Signed\-off\-by.*$//sgmx;
54 56
55 my @files = split(/\n/, $commit{files}); 57 my @files = split(/\n/, $commit{files});
56 my @message = map { s/^ {4}//; $_ } split(/\n/, $commit{message}); 58 my @message = map { s/^ {4}//; $_ } split(/\n/, $commit{message});