nagios插件之监控单个tomcat线程数
来源:互联网 发布:windows为什么要激活 编辑:程序博客网 时间:2024/06/01 10:44
#include <stdio.h>#include <stdlib.h>#include <string.h>#define OK 0#define WARNING 1#define CRITICAL 2#define UNKNOWN 3#define LEN 1023#define CMD "ps -efL | grep tomcat | wc -l"int exitstatus=OK;char *exit_status[4]={"OK","WARNING","CRITICAL","UNKNOWN"};char status_information[LEN];char performance_data[LEN];int parse_cmd() { int ret; FILE *fp; char readbuf[1024]; int i; char *p,*str; fp=popen(CMD,"r"); if(fp==NULL) { fprintf(stderr,"popen() error.\n"); return -1; } // while(fgets(readbuf,1024,fp)!=NULL) {/* for(p=strtok(readbuf," ");p;p=strtok(NULL," ")) { // str=p; sprintf(status_information,"active call=%s",p); sprintf(performance_data,"call=%s;;;;",p); break; } break;*///readbuf[strlen(readbuf)-1]=0;ret=fscanf(fp,"%s",readbuf);if(ret!=1) {fprintf(stderr,"fscanf() error.\n");}if(atoi(readbuf)<300) {exitstatus=OK;}else if(atoi(readbuf)>=300 && atoi(readbuf)<=400) {exitstatus=WARNING;}else if(atoi(readbuf)>=400) {exitstatus=CRITICAL;} sprintf(status_information,"tomcat_threads=%s",readbuf); sprintf(performance_data,"tomcat_threads=%s;;;;",readbuf); // } ret=pclose(fp); if(fp==NULL) { fprintf(stderr,"pclose() error.\n"); return -1; }}int main() { int ret;ret=parse_cmd();if(ret!=0) {fprintf(stderr,"parse_cmd() error.\n"); // exitstatus=CRITICAL; // printf("%s: - %s | %s\n",exit_status[exitstatus],status_information,performance_data);exit(-1);} printf("%s: %s | %s\n",exit_status[exitstatus],status_information,performance_data); return exitstatus;}
0 0
- nagios插件之监控单个tomcat线程数
- nagios插件之监控单个tomcat日志
- nagios插件之监控多个tomcat线程数
- nagios插件之监控mqa线程数
- nagios插件之监控多个tomcat日志
- nagios插件之监控f5的VS会话数
- nagios插件之系统打开文件数监控
- nagios插件之登陆SBC监控电话数
- nagios插件之监控f5pool中cngw主机session数
- nagios插件之监控M1KB语音网关通话数
- nagios插件之监控MQA日志文件
- nagios插件之监控POI搜索情况
- nagios插件之监控web页面登陆
- nagios插件之监控获取driverID
- nagios插件之监控casa业务
- nagios插件之监控if8接口日志
- nagios插件之域名超时监控
- nagios插件之监控oracle日志
- 通过代码创建Java项目
- 迷你浏览器——WebView学习
- jquery去除回车换行
- HDOJ 题目3456 Universal Oracle(模拟,水)
- 论文中的图目录与表目录
- nagios插件之监控单个tomcat线程数
- Java网络编程-代理
- 程序存储问题
- 大数相加
- THREE.js -- 沿物体表面放置对象
- Clouder CDH Hadoop安装
- HashMap练习题
- 转瞬年华,新的开始
- 算法导论 计数排序