diff options
Diffstat (limited to 'web/attachments/299693-patch-plugins__check_nt.c.txt')
| -rw-r--r-- | web/attachments/299693-patch-plugins__check_nt.c.txt | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/web/attachments/299693-patch-plugins__check_nt.c.txt b/web/attachments/299693-patch-plugins__check_nt.c.txt new file mode 100644 index 0000000..a004ad4 --- /dev/null +++ b/web/attachments/299693-patch-plugins__check_nt.c.txt | |||
| @@ -0,0 +1,77 @@ | |||
| 1 | --- plugins/check_nt.c.orig 2008-10-19 14:39:43.000000000 +0200 | ||
| 2 | +++ plugins/check_nt.c 2008-10-19 14:47:19.000000000 +0200 | ||
| 3 | @@ -97,6 +97,8 @@ | ||
| 4 | char *temp_string_perf=NULL; | ||
| 5 | char *description=NULL,*counter_unit = NULL; | ||
| 6 | char *minval = NULL, *maxval = NULL, *errcvt = NULL; | ||
| 7 | + char *fds=NULL; | ||
| 8 | + char *tds=NULL; | ||
| 9 | |||
| 10 | double total_disk_space=0; | ||
| 11 | double free_disk_space=0; | ||
| 12 | @@ -218,33 +220,41 @@ | ||
| 13 | else { | ||
| 14 | asprintf(&send_buffer,"%s&4&%s", req_password, value_list); | ||
| 15 | fetch_data (server_address, server_port, send_buffer); | ||
| 16 | - free_disk_space=atof(strtok(recv_buffer,"&")); | ||
| 17 | - total_disk_space=atof(strtok(NULL,"&")); | ||
| 18 | - percent_used_space = ((total_disk_space - free_disk_space) / total_disk_space) * 100; | ||
| 19 | - warning_used_space = ((float)warning_value / 100) * total_disk_space; | ||
| 20 | - critical_used_space = ((float)critical_value / 100) * total_disk_space; | ||
| 21 | - | ||
| 22 | - if (free_disk_space>=0) { | ||
| 23 | - asprintf(&temp_string,_("%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)"), | ||
| 24 | - value_list, total_disk_space / 1073741824, (total_disk_space - free_disk_space) / 1073741824, | ||
| 25 | - percent_used_space, free_disk_space / 1073741824, (free_disk_space / total_disk_space)*100); | ||
| 26 | - asprintf(&temp_string_perf,_("'%s:\\ Used Space'=%.2fGb;%.2f;%.2f;0.00;%.2f"), value_list, | ||
| 27 | - (total_disk_space - free_disk_space) / 1073741824, warning_used_space / 1073741824, | ||
| 28 | - critical_used_space / 1073741824, total_disk_space / 1073741824); | ||
| 29 | + fds=strtok(recv_buffer,"&"); | ||
| 30 | + tds=strtok(NULL,"&"); | ||
| 31 | |||
| 32 | - if(check_critical_value==TRUE && percent_used_space >= critical_value) | ||
| 33 | - return_code=STATE_CRITICAL; | ||
| 34 | - else if (check_warning_value==TRUE && percent_used_space >= warning_value) | ||
| 35 | - return_code=STATE_WARNING; | ||
| 36 | - else | ||
| 37 | - return_code=STATE_OK; | ||
| 38 | - | ||
| 39 | - output_message = strdup (temp_string); | ||
| 40 | - perfdata = temp_string_perf; | ||
| 41 | + if (fds != NULL) | ||
| 42 | + free_disk_space=atof(fds); | ||
| 43 | + if (tds != NULL) | ||
| 44 | + total_disk_space=atof(tds); | ||
| 45 | + | ||
| 46 | + if (total_disk_space>0) { | ||
| 47 | + percent_used_space = ((total_disk_space - free_disk_space) / total_disk_space) * 100; | ||
| 48 | + warning_used_space = ((float)warning_value / 100) * total_disk_space; | ||
| 49 | + critical_used_space = ((float)critical_value / 100) * total_disk_space; | ||
| 50 | + | ||
| 51 | + if (free_disk_space>=0) { | ||
| 52 | + asprintf(&temp_string,_("%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)"), | ||
| 53 | + value_list, total_disk_space / 1073741824, (total_disk_space - free_disk_space) / 1073741824, | ||
| 54 | + percent_used_space, free_disk_space / 1073741824, (free_disk_space / total_disk_space)*100); | ||
| 55 | + asprintf(&temp_string_perf,_("'%s:\\ Used Space'=%.2fGb;%.2f;%.2f;0.00;%.2f"), value_list, | ||
| 56 | + (total_disk_space - free_disk_space) / 1073741824, warning_used_space / 1073741824, | ||
| 57 | + critical_used_space / 1073741824, total_disk_space / 1073741824); | ||
| 58 | + | ||
| 59 | + if(check_critical_value==TRUE && percent_used_space >= critical_value) | ||
| 60 | + return_code=STATE_CRITICAL; | ||
| 61 | + else if (check_warning_value==TRUE && percent_used_space >= warning_value) | ||
| 62 | + return_code=STATE_WARNING; | ||
| 63 | + else | ||
| 64 | + return_code=STATE_OK; | ||
| 65 | + | ||
| 66 | + output_message = strdup (temp_string); | ||
| 67 | + perfdata = temp_string_perf; | ||
| 68 | + } | ||
| 69 | } else { | ||
| 70 | - output_message = strdup (_("Free disk space : Invalid drive ")); | ||
| 71 | - return_code=STATE_UNKNOWN; | ||
| 72 | - } | ||
| 73 | + output_message = strdup (_("Free disk space : Invalid drive ")); | ||
| 74 | + return_code=STATE_UNKNOWN; | ||
| 75 | + } | ||
| 76 | } | ||
| 77 | break; | ||
