/****************************************************************************** * Nagios check_disk_io plugin * * License : GPL * Author : Patricio M Dorantes Jamarne * Version : 0.5 * * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Please visit also http://www.ibm.com/developerworks/wikis/display/WikiPtype/ryo * Parts of the code within this plugin come from there. * * Thanks to: Konstantin Reichert; I based this plugin on his own plugin * * Comments, complains or congrats, please write me via g+ * *******************************************************************************/ #include #include #include #include void print_usage() { } void print_help() { } int main(int argc, char* argv[]) { int arguments; int retval=3; float warn_th = 75; float crit_th = 90; double tmp; if ( warn_th > crit_th ) { printf("Error: warning threshold is greater than critical threshold"); } while ((arguments = getopt (argc, argv, ":w:c:h")) != -1) { switch (arguments) { case 'w': warn_th = atoi(optarg); break; case 'c': crit_th = atoi(optarg); break; case 'h': print_help(); break; case ':': fprintf (stderr, "Error: Option -%c requires an argument.\n", optopt); exit(2); break; case '?': fprintf (stderr, "Error: Unknown -%c argument.\n", optopt); exit(2); break; default: abort(); } } perfstat_memory_total_t ub; perfstat_memory_total ((perfstat_id_t*)NULL, &ub,sizeof(perfstat_memory_total_t),1); u_longlong_t used_memory = (ub.real_system+ub.real_process)*4/1024; u_longlong_t real_total = ub.real_total*4/1024; float memory_usage = ((float)used_memory/(float)real_total)*100; if (memory_usage >= crit_th ) { retval = 2; printf("AIXMEM CRITICAL - Memory usage is at %f |memusage=%f;%f;%f \n",memory_usage,memory_usage,warn_th,crit_th); } else if (memory_usage >= warn_th ) { retval = 1; printf("AIXMEM WARNING - Memory usage is at %f |memusage=%f;%f;%f \n",memory_usage,memory_usage,warn_th,crit_th); } else { retval = 0; printf("AIXMEM OK - Memory usage is at %f |memusage=%f;%f;%f \n",memory_usage,memory_usage,warn_th,crit_th); } return retval; }