diff options
author | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2001-09-23 15:31:11 +0000 |
---|---|---|
committer | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2001-09-23 15:31:11 +0000 |
commit | 419fb9970aecbdfe99e4131d437046858326018b (patch) | |
tree | 0e3d6fd14a55a6930f11501f0f26cfc40fea1c66 /src | |
parent | 84ef2d972ab484757d91fe78f1fe6c1fdda34f9a (diff) | |
download | zabbix-419fb9970aecbdfe99e4131d437046858326018b.tar.gz zabbix-419fb9970aecbdfe99e4131d437046858326018b.tar.xz zabbix-419fb9970aecbdfe99e4131d437046858326018b.zip |
- no full list of triggers and items will be shown
- deleted column triggers.lastcheck
- fixed PostgreSQL upgrade patch to 1.0alpha10
- if item.history==0, not values will be added to table history for this item
- added directory upgrades/dbpatches/1.0alpha10_to_1.0alpha11/
git-svn-id: svn://svn.zabbix.com/trunk@211 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src')
-rw-r--r-- | src/zabbix_agent/sysinfo.c | 4 | ||||
-rw-r--r-- | src/zabbix_agent/zabbix_agent.c | 2 | ||||
-rw-r--r-- | src/zabbix_sucker/zabbix_sucker.c | 59 | ||||
-rw-r--r-- | src/zabbix_trapper/zabbix_trapper.c | 61 | ||||
-rw-r--r-- | src/zabbix_trapper/zabbix_trapperd.c | 61 |
5 files changed, 35 insertions, 152 deletions
diff --git a/src/zabbix_agent/sysinfo.c b/src/zabbix_agent/sysinfo.c index b719e462..04b332af 100644 --- a/src/zabbix_agent/sysinfo.c +++ b/src/zabbix_agent/sysinfo.c @@ -235,6 +235,7 @@ float FILESIZE(const char * filename) float PROCCNT(const char * procname) { +#ifdef HAVE_PROC_1_STATUS DIR *dir; struct dirent *entries; struct stat buf; @@ -281,6 +282,9 @@ float PROCCNT(const char * procname) } closedir(dir); return (float)proccount; +#else + return FAIL; +#endif } float INODE(const char * mountPoint) diff --git a/src/zabbix_agent/zabbix_agent.c b/src/zabbix_agent/zabbix_agent.c index c4e77e3a..d0d276d5 100644 --- a/src/zabbix_agent/zabbix_agent.c +++ b/src/zabbix_agent/zabbix_agent.c @@ -1,4 +1,4 @@ -#define TEST_PARAMETERS +/* #define TEST_PARAMETERS */ #include "config.h" diff --git a/src/zabbix_sucker/zabbix_sucker.c b/src/zabbix_sucker/zabbix_sucker.c index a1cb2d02..5e2f43af 100644 --- a/src/zabbix_sucker/zabbix_sucker.c +++ b/src/zabbix_sucker/zabbix_sucker.c @@ -371,25 +371,26 @@ int get_values(void) { double value; char c[1024]; - DB_ITEM item; DB_RESULT *result; int i,rows; int now; + DB_ITEM item; + char *s; now = time(NULL); - sprintf(c,"select i.itemid,i.key_,h.host,h.port,i.delay,i.description,i.nextcheck,i.type,i.snmp_community,i.snmp_oid,h.useip,h.ip from items i,hosts h where i.nextcheck<=%d and i.status=0 and h.status=0 and h.hostid=i.hostid and i.itemid%%%d=%d order by i.nextcheck", now, SUCKER_FORKS-1,sucker_num-1); + sprintf(c,"select i.itemid,i.key_,h.host,h.port,i.delay,i.description,i.nextcheck,i.type,i.snmp_community,i.snmp_oid,h.useip,h.ip,i.history,i.lastvalue,i.prevvalue from items i,hosts h where i.nextcheck<=%d and i.status=0 and h.status=0 and h.hostid=i.hostid and i.itemid%%%d=%d order by i.nextcheck", now, SUCKER_FORKS-1,sucker_num-1); result = DBselect(c); - if(result==NULL) + rows = DBnum_rows(result); + if( (result==NULL) || (rows == 0)) { syslog( LOG_DEBUG, "No items to update."); DBfree_result(result); return SUCCEED; } - rows = DBnum_rows(result); for(i=0;i<rows;i++) { @@ -405,31 +406,39 @@ int get_values(void) item.snmp_oid=DBget_field(result,i,9); item.useip=atoi(DBget_field(result,i,10)); item.ip=DBget_field(result,i,11); + item.history=atoi(DBget_field(result,i,12)); + s=DBget_field(result,i,13); + if(s==NULL) + { + item.lastvalue_null=1; + } + else + { + item.lastvalue_null=0; + item.lastvalue=atof(s); + } + s=DBget_field(result,i,14); + if(s==NULL) + { + item.prevvalue_null=1; + } + else + { + item.prevvalue_null=0; + item.prevvalue=atof(s); + } + if( get_value(&value,&item) == SUCCEED ) { - if( value == NOTSUPPORTED) + if( cmp_double(value,NOTSUPPORTED) == 0) { sprintf(c,"update items set status=3 where itemid=%d",item.itemid); DBexecute(c); } else { - now = time(NULL); - sprintf(c,"insert into history (itemid,clock,value) values (%d,%d,%g)",item.itemid,now,value); - DBexecute(c); - - sprintf(c,"update items set NextCheck=%d,PrevValue=LastValue,LastValue=%f,LastClock=%d where ItemId=%d",now+item.delay,value,now,item.itemid); - DBexecute(c); - - /* - if( update_functions( item.itemid ) == FAIL) - { - syslog( LOG_WARNING, "Updating simple functions failed" ); - } - - update_triggers( item.itemid ); - */ + process_new_value(&item,value); } } else @@ -439,15 +448,7 @@ int get_values(void) } } - if(rows>0) - { - if( update_functions( sucker_num, 1 ) == FAIL) - { - syslog( LOG_WARNING, "Updating simple functions failed" ); - } - - update_triggers( sucker_num, 1 ); - } + update_triggers( 0, sucker_num, now ); DBfree_result(result); return SUCCEED; diff --git a/src/zabbix_trapper/zabbix_trapper.c b/src/zabbix_trapper/zabbix_trapper.c index 52ca102c..5cf001fd 100644 --- a/src/zabbix_trapper/zabbix_trapper.c +++ b/src/zabbix_trapper/zabbix_trapper.c @@ -43,67 +43,6 @@ void signal_handler( int sig ) exit( FAIL ); } -int process_data(char *server,char *key, double value) -{ - char sql[1024]; - int itemid; - double lastvalue; - int now; - - DB_RESULT *result; - - sprintf(sql,"select i.itemid,i.lastvalue from items i,hosts h where h.status=0 and h.hostid=i.hostid and h.host='%s' and i.key_='%s' and i.status=2;",server,key); - result = DBselect(sql); - - if(result==NULL) - { - DBfree_result(result); - return FAIL; - } - if(DBnum_rows(result)==0) - { - DBfree_result(result); - return FAIL; - } - - if( DBget_field(result,0,0) == NULL ) - { - DBfree_result(result); - return FAIL; - } - - itemid=atoi(DBget_field(result,0,0)); - - now = time(NULL); - sprintf(sql,"insert into history (itemid,clock,value) values (%d,%d,%g);",itemid,now,value); - DBexecute(sql); - - if(NULL == DBget_field(result,0,1)) - { - now = time(NULL); - sprintf(sql,"update items set lastvalue=%g,lastclock=%d where itemid=%d;",value,now,itemid); - } - else - { - lastvalue=atof(DBget_field(result,0,1)); - now = time(NULL); - sprintf(sql,"update items set prevvalue=%g,lastvalue=%g,lastclock=%d where itemid=%d;",lastvalue,value,now,itemid); - } - - DBexecute(sql); - - if( update_functions( itemid, 0 ) == FAIL) - { - return FAIL; - } - - update_triggers( itemid, 0 ); - - DBfree_result(result); - - return SUCCEED; -} - int main() { char *s,*p; diff --git a/src/zabbix_trapper/zabbix_trapperd.c b/src/zabbix_trapper/zabbix_trapperd.c index 66f5bfbc..2c8140a6 100644 --- a/src/zabbix_trapper/zabbix_trapperd.c +++ b/src/zabbix_trapper/zabbix_trapperd.c @@ -48,67 +48,6 @@ void signal_handler( int sig ) exit( FAIL ); } -int process_data(char *server,char *key, double value) -{ - char sql[1024]; - int itemid; - double lastvalue; - int now; - - DB_RESULT *result; - - sprintf(sql,"select i.itemid,i.lastvalue from items i,hosts h where h.status=0 and h.hostid=i.hostid and h.host='%s' and i.key_='%s' and i.status=2;",server,key); - result = DBselect(sql); - - if(result==NULL) - { - DBfree_result(result); - return FAIL; - } - if(DBnum_rows(result)==0) - { - DBfree_result(result); - return FAIL; - } - - if( DBget_field(result,0,0) == NULL ) - { - DBfree_result(result); - return FAIL; - } - - itemid=atoi(DBget_field(result,0,0)); - - now = time(NULL); - sprintf(sql,"insert into history (itemid,clock,value) values (%d,%d,%g);",itemid,now,value); - DBexecute(sql); - - if(NULL == DBget_field(result,0,1)) - { - now = time(NULL); - sprintf(sql,"update items set lastvalue=%g,lastclock=%d where itemid=%d;",value,now,itemid); - } - else - { - lastvalue=atof(DBget_field(result,0,1)); - now = time(NULL); - sprintf(sql,"update items set prevvalue=%g,lastvalue=%g,lastclock=%d where itemid=%d;",lastvalue,value,now,itemid); - } - - DBexecute(sql); - - if( update_functions( itemid, 0 ) == FAIL) - { - return FAIL; - } - - update_triggers( itemid, 0 ); - - DBfree_result(result); - - return SUCCEED; -} - int process(char *s) { char *p; |