diff options
| author | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2004-12-21 10:33:21 +0000 |
|---|---|---|
| committer | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2004-12-21 10:33:21 +0000 |
| commit | 9dc352f3f664b2790e02fe2fcb15e3ab1b8e91c1 (patch) | |
| tree | a63b7d29a331b26cda68f5e4091924562351a493 /include | |
| parent | ca2968809a55e2d2b91c541a805062e15b6090c4 (diff) | |
Added zlog.c and zlog.h
git-svn-id: svn://svn.zabbix.com/trunk@1551 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'include')
| -rw-r--r-- | include/db.c | 1 | ||||
| -rw-r--r-- | include/db.h | 2 | ||||
| -rw-r--r-- | include/log.c | 1 | ||||
| -rw-r--r-- | include/zlog.c | 74 | ||||
| -rw-r--r-- | include/zlog.h | 27 |
5 files changed, 105 insertions, 0 deletions
diff --git a/include/db.c b/include/db.c index 20ecefb9..b03bafde 100644 --- a/include/db.c +++ b/include/db.c @@ -2333,3 +2333,4 @@ void DBget_item_from_db(DB_ITEM *item,DB_RESULT *result, int row) item->snmpv3_privpassphrase = DBget_field(result,i,28); item->formula = DBget_field(result,i,29); } + diff --git a/include/db.h b/include/db.h index 91d81497..65ee7b80 100644 --- a/include/db.h +++ b/include/db.h @@ -23,6 +23,7 @@ /* time_t */ #include <time.h> + #include "config.h" #include "common.h" @@ -239,6 +240,7 @@ void DBvacuum(void); int DBexecute( char *query ); + DB_RESULT *DBselect(char *query); char *DBget_field(DB_RESULT *result, int rownum, int fieldnum); int DBnum_rows(DB_RESULT *result); diff --git a/include/log.c b/include/log.c index 1c5016f6..927c1a63 100644 --- a/include/log.c +++ b/include/log.c @@ -146,3 +146,4 @@ void zabbix_log(int level, const char *fmt, ...) } return; } + diff --git a/include/zlog.c b/include/zlog.c new file mode 100644 index 00000000..d59153ff --- /dev/null +++ b/include/zlog.c @@ -0,0 +1,74 @@ +/* +** Zabbix +** Copyright (C) 2000,2001,2002,2003,2004 Alexei Vladishev +** +** 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 2 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, write to the Free Software +** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +**/ + + +#include <stdio.h> +#include <string.h> +#include <stdarg.h> +#include <syslog.h> + +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> + +#include <time.h> + +#include "common.h" +#include "functions.h" +#include "log.h" +#include "zlog.h" + +/* Update special host's item - "zabbix[log]" */ +void zabbix_syslog(const char *fmt, ...) +{ + int i; + va_list ap; + char sql[MAX_STRING_LEN]; + char value_str[MAX_STRING_LEN]; + + DB_ITEM item; + DB_RESULT *result; + + zabbix_log(LOG_LEVEL_DEBUG, "In zabbix_log()"); + + snprintf(sql,sizeof(sql)-1,"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,i.hostid,h.status,i.value_type,h.network_errors,i.snmp_port,i.delta,i.prevorgvalue,i.lastclock,i.units,i.multiplier,i.snmpv3_securityname,i.snmpv3_securitylevel,i.snmpv3_authpassphrase,i.snmpv3_privpassphrase,i.formula from items i,hosts h where h.hostid=i.hostid and i.key_='%s' and i.value_type=%d", SERVER_ZABBIXLOG_KEY,ITEM_VALUE_TYPE_STR); + result = DBselect(sql); + + if( DBnum_rows(result) == 0) + { + zabbix_log( LOG_LEVEL_DEBUG, "No zabbix[log] to update."); + } + else + { + for(i=0;i<DBnum_rows(result);i++) + { + DBget_item_from_db(&item,result, i); + + va_start(ap,fmt); + vsprintf(value_str,fmt,ap); + value_str[MAX_STRING_LEN]=0; + va_end(ap); + + process_new_value(&item,value_str); + update_triggers(item.itemid); + } + } + + DBfree_result(result); +} diff --git a/include/zlog.h b/include/zlog.h new file mode 100644 index 00000000..2dd59956 --- /dev/null +++ b/include/zlog.h @@ -0,0 +1,27 @@ +/* +** Zabbix +** Copyright (C) 2000,2001,2002,2003,2004 Alexei Vladishev +** +** 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 2 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, write to the Free Software +** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +**/ + +#ifndef ZABBIX_ZLOG_H +#define ZABBIX_ZLOG_H + +#include <stdarg.h> + +void zabbix_syslog(const char *fmt, ...); + +#endif |
