summaryrefslogtreecommitdiffstats
path: root/lib/utils_base.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/utils_base.c')
-rw-r--r--lib/utils_base.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/utils_base.c b/lib/utils_base.c
index 0f521263..eabcd7ee 100644
--- a/lib/utils_base.c
+++ b/lib/utils_base.c
@@ -6,21 +6,21 @@
6* Copyright (c) 2006 Monitoring Plugins Development Team 6* Copyright (c) 2006 Monitoring Plugins Development Team
7* 7*
8* Library of useful functions for plugins 8* Library of useful functions for plugins
9* 9*
10* 10*
11* This program is free software: you can redistribute it and/or modify 11* This program is free software: you can redistribute it and/or modify
12* it under the terms of the GNU General Public License as published by 12* it under the terms of the GNU General Public License as published by
13* the Free Software Foundation, either version 3 of the License, or 13* the Free Software Foundation, either version 3 of the License, or
14* (at your option) any later version. 14* (at your option) any later version.
15* 15*
16* This program is distributed in the hope that it will be useful, 16* This program is distributed in the hope that it will be useful,
17* but WITHOUT ANY WARRANTY; without even the implied warranty of 17* but WITHOUT ANY WARRANTY; without even the implied warranty of
18* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19* GNU General Public License for more details. 19* GNU General Public License for more details.
20* 20*
21* You should have received a copy of the GNU General Public License 21* You should have received a copy of the GNU General Public License
22* along with this program. If not, see <http://www.gnu.org/licenses/>. 22* along with this program. If not, see <http://www.gnu.org/licenses/>.
23* 23*
24* 24*
25*****************************************************************************/ 25*****************************************************************************/
26 26
@@ -640,10 +640,10 @@ int _np_state_read_file(FILE *f) {
640} 640}
641 641
642/* 642/*
643 * If time=NULL, use current time. Create state file, with state format 643 * If time=NULL, use current time. Create state file, with state format
644 * version, default text. Writes version, time, and data. Avoid locking 644 * version, default text. Writes version, time, and data. Avoid locking
645 * problems - use mv to write and then swap. Possible loss of state data if 645 * problems - use mv to write and then swap. Possible loss of state data if
646 * two things writing to same key at same time. 646 * two things writing to same key at same time.
647 * Will die with UNKNOWN if errors 647 * Will die with UNKNOWN if errors
648 */ 648 */
649void np_state_write_string(time_t data_time, char *data_string) { 649void np_state_write_string(time_t data_time, char *data_string) {
@@ -658,7 +658,7 @@ void np_state_write_string(time_t data_time, char *data_string) {
658 time(&current_time); 658 time(&current_time);
659 else 659 else
660 current_time=data_time; 660 current_time=data_time;
661 661
662 /* If file doesn't currently exist, create directories */ 662 /* If file doesn't currently exist, create directories */
663 if(access(this_monitoring_plugin->state->_filename,F_OK)!=0) { 663 if(access(this_monitoring_plugin->state->_filename,F_OK)!=0) {
664 result = asprintf(&directories, "%s", this_monitoring_plugin->state->_filename); 664 result = asprintf(&directories, "%s", this_monitoring_plugin->state->_filename);
@@ -697,15 +697,15 @@ void np_state_write_string(time_t data_time, char *data_string) {
697 np_free(temp_file); 697 np_free(temp_file);
698 die(STATE_UNKNOWN, _("Unable to open temporary state file")); 698 die(STATE_UNKNOWN, _("Unable to open temporary state file"));
699 } 699 }
700 700
701 fprintf(fp,"# NP State file\n"); 701 fprintf(fp,"# NP State file\n");
702 fprintf(fp,"%d\n",NP_STATE_FORMAT_VERSION); 702 fprintf(fp,"%d\n",NP_STATE_FORMAT_VERSION);
703 fprintf(fp,"%d\n",this_monitoring_plugin->state->data_version); 703 fprintf(fp,"%d\n",this_monitoring_plugin->state->data_version);
704 fprintf(fp,"%lu\n",current_time); 704 fprintf(fp,"%lu\n",current_time);
705 fprintf(fp,"%s\n",data_string); 705 fprintf(fp,"%s\n",data_string);
706 706
707 fchmod(fd, S_IRUSR | S_IWUSR | S_IRGRP); 707 fchmod(fd, S_IRUSR | S_IWUSR | S_IRGRP);
708 708
709 fflush(fp); 709 fflush(fp);
710 710
711 result=fclose(fp); 711 result=fclose(fp);