summaryrefslogtreecommitdiffstats
path: root/plugins/check_nt.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_nt.c')
-rw-r--r--plugins/check_nt.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/plugins/check_nt.c b/plugins/check_nt.c
index 4d9157a6..ee5e2a63 100644
--- a/plugins/check_nt.c
+++ b/plugins/check_nt.c
@@ -93,6 +93,7 @@ int main(int argc, char **argv){
93 char *temp_string_perf=NULL; 93 char *temp_string_perf=NULL;
94 char *description=NULL,*counter_unit = NULL; 94 char *description=NULL,*counter_unit = NULL;
95 char *minval = NULL, *maxval = NULL, *errcvt = NULL; 95 char *minval = NULL, *maxval = NULL, *errcvt = NULL;
96 char *fds=NULL, *tds=NULL;
96 97
97 double total_disk_space=0; 98 double total_disk_space=0;
98 double free_disk_space=0; 99 double free_disk_space=0;
@@ -214,13 +215,18 @@ int main(int argc, char **argv){
214 else { 215 else {
215 asprintf(&send_buffer,"%s&4&%s", req_password, value_list); 216 asprintf(&send_buffer,"%s&4&%s", req_password, value_list);
216 fetch_data (server_address, server_port, send_buffer); 217 fetch_data (server_address, server_port, send_buffer);
217 free_disk_space=atof(strtok(recv_buffer,"&")); 218 fds=strtok(recv_buffer,"&");
218 total_disk_space=atof(strtok(NULL,"&")); 219 tds=strtok(NULL,"&");
219 percent_used_space = ((total_disk_space - free_disk_space) / total_disk_space) * 100; 220 if(fds!=NULL)
220 warning_used_space = ((float)warning_value / 100) * total_disk_space; 221 free_disk_space=atof(fds);
221 critical_used_space = ((float)critical_value / 100) * total_disk_space; 222 if(tds!=NULL)
223 total_disk_space=atof(tds);
224
225 if (total_disk_space>0 && free_disk_space>=0) {
226 percent_used_space = ((total_disk_space - free_disk_space) / total_disk_space) * 100;
227 warning_used_space = ((float)warning_value / 100) * total_disk_space;
228 critical_used_space = ((float)critical_value / 100) * total_disk_space;
222 229
223 if (free_disk_space>=0) {
224 asprintf(&temp_string,_("%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)"), 230 asprintf(&temp_string,_("%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)"),
225 value_list, total_disk_space / 1073741824, (total_disk_space - free_disk_space) / 1073741824, 231 value_list, total_disk_space / 1073741824, (total_disk_space - free_disk_space) / 1073741824,
226 percent_used_space, free_disk_space / 1073741824, (free_disk_space / total_disk_space)*100); 232 percent_used_space, free_disk_space / 1073741824, (free_disk_space / total_disk_space)*100);
@@ -238,7 +244,7 @@ int main(int argc, char **argv){
238 output_message = strdup (temp_string); 244 output_message = strdup (temp_string);
239 perfdata = temp_string_perf; 245 perfdata = temp_string_perf;
240 } else { 246 } else {
241 output_message = strdup (_("Free disk space : Invalid drive ")); 247 output_message = strdup (_("Free disk space : Invalid drive"));
242 return_code=STATE_UNKNOWN; 248 return_code=STATE_UNKNOWN;
243 } 249 }
244 } 250 }