From 772e6d0f37d4533b39a51f7b5c42c618e6af7c13 Mon Sep 17 00:00:00 2001 From: hugetoad Date: Sat, 24 Nov 2001 14:20:36 +0000 Subject: - added columns alert_history and alarm_history to table config (Alexei) - added link from graphs to trends and vs (Alexei) - housekeeping process in zabbix_suckerd will also delete old records from tables alerts and alarms (Alexei) - added directory upgrades/dbpatches/1.0alpha11_to_1.0alpha12 (Alexei) - added index on column "clock" for table alarms (Alexei) git-svn-id: svn://svn.zabbix.com/trunk@252 97f52cf1-0a1b-0410-bd0e-c28be96e8082 --- ChangeLog | 8 +- create/mysql/schema.sql | 7 +- create/postgresql/schema.sql | 5 +- doc/manual.lyx | 302 ++++++++++++++++++++- frontends/php/config.html | 26 +- frontends/php/history.html | 2 +- frontends/php/include/config.inc | 27 +- frontends/php/trends.html | 8 +- include/common.h | 6 + src/zabbix_sucker/zabbix_sucker.c | 53 +++- src/zabbix_trapper/zabbix_trapperd.c | 2 +- .../1.0alpha11_to_1.0alpha12/mysql/patch.sql | 3 + .../1.0alpha11_to_1.0alpha12/postgresql/patch.sql | 3 + 13 files changed, 422 insertions(+), 30 deletions(-) create mode 100644 upgrades/dbpatches/1.0alpha11_to_1.0alpha12/mysql/patch.sql create mode 100644 upgrades/dbpatches/1.0alpha11_to_1.0alpha12/postgresql/patch.sql diff --git a/ChangeLog b/ChangeLog index 6441e3ed..bcf363e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,16 @@ Changes for 1.0alpha12: + - added columns alert_history and alarm_history to table config (Alexei) + - added link from graphs to trends and vs (Alexei) + - housekeeping process in zabbix_suckerd will also delete old records from tables + alerts and alarms (Alexei) + - added directory upgrades/dbpatches/1.0alpha11_to_1.0alpha12 (Alexei) + - added index on column "clock" for table alarms (Alexei) + - cleanup of all *.html files (Alexei) - removed doc/dbstructure (Alexei) - removed doc/manual.txt (Alexei) - minor changes in manual.lyx (Alexei) - - added version (draft 1.01) to manual.lyx - character '-' can be used to form server name (Alexei) - fixed dependencies in functions that delete information for zabbix tables (Alexei) diff --git a/create/mysql/schema.sql b/create/mysql/schema.sql index 8e445c5a..926e93c1 100644 --- a/create/mysql/schema.sql +++ b/create/mysql/schema.sql @@ -73,7 +73,9 @@ CREATE TABLE config ( smtp_server varchar(255) DEFAULT '' NOT NULL, smtp_helo varchar(255) DEFAULT '' NOT NULL, smtp_email varchar(255) DEFAULT '' NOT NULL, - password_required int(1) DEFAULT '0' NOT NULL + password_required int(1) DEFAULT '0' NOT NULL, + alert_history int(4) DEFAULT '0' NOT NULL, + alarm_history int(4) DEFAULT '0' NOT NULL ); # @@ -131,7 +133,8 @@ CREATE TABLE alarms ( clock int(4) DEFAULT '0' NOT NULL, istrue int(4) DEFAULT '0' NOT NULL, PRIMARY KEY (alarmid), - KEY (triggerid,clock) + KEY (triggerid,clock), + KEY (clock) ); # diff --git a/create/postgresql/schema.sql b/create/postgresql/schema.sql index bf7913ac..504dac74 100644 --- a/create/postgresql/schema.sql +++ b/create/postgresql/schema.sql @@ -53,7 +53,9 @@ CREATE TABLE config ( smtp_server varchar(255) DEFAULT '' NOT NULL, smtp_helo varchar(255) DEFAULT '' NOT NULL, smtp_email varchar(255) DEFAULT '' NOT NULL, - password_required int4 DEFAULT '0' NOT NULL + password_required int4 DEFAULT '0' NOT NULL, + alert_history int4 DEFAULT '0' NOT NULL, + alarm_history int4 DEFAULT '0' NOT NULL ); -- @@ -165,6 +167,7 @@ CREATE TABLE alarms ( ); CREATE INDEX alarms_triggerid_clock on alarms (triggerid, clock); +CREATE INDEX alarms_clock on alarms (clock); -- -- Table structure for table 'functions' diff --git a/doc/manual.lyx b/doc/manual.lyx index 39b5b1fd..c7f05c6d 100644 --- a/doc/manual.lyx +++ b/doc/manual.lyx @@ -24,7 +24,7 @@ \layout Title \added_space_top vfill -Zabbix Reference Manual for version 1.0 (draft v1.02) +Zabbix Reference Manual for version 1.0 (draft v1.03) \layout Author ALEXEI VLADISHEV @@ -1199,6 +1199,53 @@ IMPORTANT. tcp_count \series default is not supported anymore. +\layout Subsubsection + +Zabbix 1.0alpha12 +\layout Itemize + +Do not forget to apply DB patches +\layout Itemize + +Note that character '-' can be used in host names +\layout Itemize + +Note that if parameter is defined as +\series bold +parameter[*] +\series default +, you can pass any string as +\series bold +'*' +\series default +. +\layout Itemize + +Note that new parameter +\series bold +check_port[*] +\series default + added. + +\series bold +'*' +\series default + is any port number. +\layout Itemize + +Note that new operator +\series bold +'=' +\series default + added. +\layout Itemize + +Note that Zabbix manual will be distributed in the followinf formats: LyX, + PS, PDF and plain text. +\layout Itemize + +Zabbix 1.0alpha12 is latest alpha version. + Next Zabbix version will be called 1.0beta1. \layout Subsection ChangeLog @@ -1631,7 +1678,51 @@ h. One zabbix_suckerd process is used for housekeeping purposes only.\SpecialChar ~ The housekeepi ng process periodically (hourly, by default) deletes outdated information - from table history. + from +\latex default +the following tables: +\series bold +history +\series default +, +\series bold +alarms +\series default + and +\series bold +alerts +\series default +\latex no_latex +. +\layout Standard + +Constant SUCKER_HK from +\shape italic +include/common.h +\shape default + defines how often housekeping process executes. +\layout Standard + +Housekeeping process will delete all records from table +\series bold +alarms +\series default + older than value defined in Zabbix configuration. + +\layout Standard + +Housekeeping process will delete all records from table +\series bold +alerts +\series default + older than value defined in Zabbix configuration. + +\layout Standard + + +\latex no_latex +\SpecialChar ~ + \layout Standard @@ -5976,6 +6067,213 @@ Database structure The section describes structure of tables of Zabbix database. \layout Description +CONFIG The table contains global configuration parameters. +\layout Description + + +\begin_inset Tabular + + + + + + + +\begin_inset Text + +\layout Standard + +Column name +\end_inset + + +\begin_inset Text + +\layout Standard + +Type +\end_inset + + +\begin_inset Text + +\layout Standard + +Description +\end_inset + + + + +\begin_inset Text + +\layout Standard + +smtp_server +\end_inset + + +\begin_inset Text + +\layout Standard + +varchar +\end_inset + + +\begin_inset Text + +\layout Standard + +Name of SMTP server +\end_inset + + + + +\begin_inset Text + +\layout Standard + +smtp_helo +\end_inset + + +\begin_inset Text + +\layout Standard + +varchar +\end_inset + + +\begin_inset Text + +\layout Standard + +HELO string used for SMTP server +\end_inset + + + + +\begin_inset Text + +\layout Standard + +smtp_email +\end_inset + + +\begin_inset Text + +\layout Standard + +varchar +\end_inset + + +\begin_inset Text + +\layout Standard + +Email address used by Zabbix +\end_inset + + + + +\begin_inset Text + +\layout Standard + +password_required +\end_inset + + +\begin_inset Text + +\layout Standard + +int +\end_inset + + +\begin_inset Text + +\layout Standard + +Is password required for non-admin menu items +\end_inset + + + + +\begin_inset Text + +\layout Standard + +alarm_history +\end_inset + + +\begin_inset Text + +\layout Standard + +int +\end_inset + + +\begin_inset Text + +\layout Standard + +Zabbix will not store records in table +\series bold + alarms +\series default + older than this value +\end_inset + + + + +\begin_inset Text + +\layout Standard + +alert_history +\end_inset + + +\begin_inset Text + +\layout Standard + +int +\end_inset + + +\begin_inset Text + +\layout Standard + +Zabbix will not store records in table +\series bold +alerts +\series default + older than this value +\end_inset + + + + +\end_inset + + +\layout Description + GRAPHS_ITEMS The table contains list of monitored items belonging to graph. \layout Description diff --git a/frontends/php/config.html b/frontends/php/config.html index 3d2f0756..e18cde9a 100644 --- a/frontends/php/config.html +++ b/frontends/php/config.html @@ -17,7 +17,7 @@ { $password_required="0"; } - $result=update_config($smtp_server,$smtp_helo,$smtp_email,$password_required); + $result=update_config($smtp_server,$smtp_helo,$smtp_email,$password_required,$alarm_history,$alert_history); show_messages($result, "Configuration updated", "Configuation was NOT updated"); } ?> @@ -28,11 +28,7 @@ ?> "; echo "SMTP server"; show_table2_h_delimiter(); - echo ""; + echo ""; show_table2_v_delimiter(); echo "Value from SMTP HELO authentification"; show_table2_h_delimiter(); - echo ""; + echo ""; show_table2_v_delimiter(); echo "ZABBIX email address to send alarms from"; show_table2_h_delimiter(); - echo ""; + echo ""; show_table2_v_delimiter(); echo "Password required ?"; show_table2_h_delimiter(); echo ""; + show_table2_v_delimiter(); + echo "Do not keep alerts older than (in sec)"; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter(); + echo "Do not keep alarms older than (in sec)"; + show_table2_h_delimiter(); + echo ""; + show_table2_v_delimiter2(); echo ""; diff --git a/frontends/php/history.html b/frontends/php/history.html index 44f87333..cba219b5 100644 --- a/frontends/php/history.html +++ b/frontends/php/history.html @@ -46,7 +46,7 @@ $host : $description"; + echo "$host : $description"; show_table_v_delimiter(); echo("
"); if($action =="showhistory") diff --git a/frontends/php/include/config.inc b/frontends/php/include/config.inc index 2ee62b0f..5780bd3b 100644 --- a/frontends/php/include/config.inc +++ b/frontends/php/include/config.inc @@ -28,6 +28,29 @@ return $trigger; } + function select_config() + { + global $ERROR_MSG; + + $sql="select smtp_server,smtp_helo,smtp_email,password_required,alarm_history,alert_history from config"; + $result=DBselect($sql); + + if(DBnum_rows($result) == 1) + { + $config["smtp_server"]=DBget_field($result,0,0); + $config["smtp_helo"]=DBget_field($result,0,1); + $config["smtp_email"]=DBget_field($result,0,2); + $config["password_required"]=DBget_field($result,0,3); + $config["alarm_history"]=DBget_field($result,0,4); + $config["alert_history"]=DBget_field($result,0,5); + } + else + { + $ERROR_MSG="Unable to select configuration"; + } + return $config; + } + function select_host_by_hostid($hostid) { global $ERROR_MSG; @@ -1355,9 +1378,9 @@ # Update configuration - function update_config($smtp_server,$smtp_helo,$smtp_email,$password_required) + function update_config($smtp_server,$smtp_helo,$smtp_email,$password_required,$alarm_history,$alert_history) { - $sql="update config set smtp_server='$smtp_server',smtp_helo='$smtp_helo',smtp_email='$smtp_email',password_required=$password_required"; + $sql="update config set smtp_server='$smtp_server',smtp_helo='$smtp_helo',smtp_email='$smtp_email',password_required=$password_required,alarm_history=$alarm_history,alert_history=$alert_history"; return DBexecute($sql); } diff --git a/frontends/php/trends.html b/frontends/php/trends.html index f53addc1..3c127332 100644 --- a/frontends/php/trends.html +++ b/frontends/php/trends.html @@ -7,8 +7,12 @@ $host : $description"; show_table_v_delimiter(); diff --git a/include/common.h b/include/common.h index c3badf18..0b85252b 100644 --- a/include/common.h +++ b/include/common.h @@ -22,6 +22,12 @@ /* Housekeeping frequency */ #define SUCKER_HK 3600 +/* Keep alrt history (in sec) */ +#define ALERT_HISTORY 12*31*24*3600 + +/* Keep alarm history (in sec) */ +#define ALARM_HISTORY 12*31*24*3600 + #define SUCKER_TIMEOUT 5 #define AGENT_TIMEOUT 3 diff --git a/src/zabbix_sucker/zabbix_sucker.c b/src/zabbix_sucker/zabbix_sucker.c index 58595286..423df632 100644 --- a/src/zabbix_sucker/zabbix_sucker.c +++ b/src/zabbix_sucker/zabbix_sucker.c @@ -283,7 +283,7 @@ int get_value_zabbix(double *result,DB_ITEM *item) } if( *result<0 ) { - if( *result == NOTSUPPORTED) + if( cmp_double(*result,NOTSUPPORTED) == 0) { return SUCCEED; } @@ -454,7 +454,7 @@ int get_values(void) return SUCCEED; } -int housekeeping_items() +int housekeeping_items(int now) { char c[1024]; DB_ITEM item; @@ -462,9 +462,6 @@ int housekeeping_items() DB_RESULT *result; int i,rows; - int now; - - now = time(NULL); sprintf(c,"select i.itemid,i.lastdelete,i.history from items i where i.lastdelete<=%d", now); result = DBselect(c); @@ -483,11 +480,9 @@ int housekeeping_items() item.lastdelete=atoi(DBget_field(result,i,1)); item.history=atoi(DBget_field(result,i,2)); - now = time(NULL); sprintf (c,"delete from history where ItemId=%d and Clock<%d",item.itemid,now-item.history); DBexecute(c); - now = time(NULL); sprintf(c,"update items set LastDelete=%d where ItemId=%d",now,item.itemid); DBexecute(c); } @@ -495,11 +490,53 @@ int housekeeping_items() return SUCCEED; } +int housekeeping_alerts(int now) +{ + char c[1024]; + int alert_history; + DB_RESULT *result; + + sprintf(c,"select alert_history from config"); + result = DBselect(c); + + alert_history=atoi(DBget_field(result,0,0)); + + sprintf (c,"delete from alerts where clock<%d",now-alert_history); + DBexecute(c); + + DBfree_result(result); + return SUCCEED; +} + +int housekeeping_alarms(int now) +{ + char c[1024]; + int alarm_history; + DB_RESULT *result; + + sprintf(c,"select alarm_history from config"); + result = DBselect(c); + + alarm_history=atoi(DBget_field(result,0,0)); + + sprintf (c,"delete from alarms where clock<%d",now-alarm_history); + DBexecute(c); + + DBfree_result(result); + return SUCCEED; +} + int main_housekeeping_loop() { + int now; + + now = time(NULL); + for(;;) { - housekeeping_items(); + housekeeping_items(now); + housekeeping_alarms(now); + housekeeping_alerts(now); syslog( LOG_DEBUG, "Sleeping for %d seconds", SUCKER_HK); sleep(SUCKER_HK); } diff --git a/src/zabbix_trapper/zabbix_trapperd.c b/src/zabbix_trapper/zabbix_trapperd.c index d4036767..acbdcfcd 100644 --- a/src/zabbix_trapper/zabbix_trapperd.c +++ b/src/zabbix_trapper/zabbix_trapperd.c @@ -132,7 +132,7 @@ void process_child(int sockfd) { if(errno == EINTR) { - syslog( LOG_DEBUG, "Timeout while waiting for parameter"); + syslog( LOG_WARNING, "Timeout while waiting for parameter"); } else { diff --git a/upgrades/dbpatches/1.0alpha11_to_1.0alpha12/mysql/patch.sql b/upgrades/dbpatches/1.0alpha11_to_1.0alpha12/mysql/patch.sql new file mode 100644 index 00000000..28e835bd --- /dev/null +++ b/upgrades/dbpatches/1.0alpha11_to_1.0alpha12/mysql/patch.sql @@ -0,0 +1,3 @@ +alter table alarms add key (clock); +alter table config add alert_history int(4) DEFAULT '0' NOT NULL; +alter table config add alarm_history int(4) DEFAULT '0' NOT NULL; diff --git a/upgrades/dbpatches/1.0alpha11_to_1.0alpha12/postgresql/patch.sql b/upgrades/dbpatches/1.0alpha11_to_1.0alpha12/postgresql/patch.sql new file mode 100644 index 00000000..1056a5c5 --- /dev/null +++ b/upgrades/dbpatches/1.0alpha11_to_1.0alpha12/postgresql/patch.sql @@ -0,0 +1,3 @@ +CREATE INDEX alarms_clock on alarms (clock); +alter table config add alert_history int4 DEFAULT '0' NOT NULL; +alter table config add alert_history int4 DEFAULT '0' NOT NULL; -- cgit