diff options
| -rw-r--r-- | ChangeLog | 4 | ||||
| -rw-r--r-- | create/mysql/schema.sql | 22 | ||||
| -rw-r--r-- | doc/manual.lyx | 8 | ||||
| -rw-r--r-- | frontends/php/chart2.html | 18 | ||||
| -rw-r--r-- | frontends/php/include/config.inc | 51 | ||||
| -rw-r--r-- | frontends/php/services.html | 178 | ||||
| -rw-r--r-- | frontends/php/srv_status.html | 53 | ||||
| -rw-r--r-- | misc/conf/zabbix_agentd.conf | 5 | ||||
| -rw-r--r-- | src/zabbix_agent/zabbix_agentd.c | 19 |
9 files changed, 345 insertions, 13 deletions
@@ -1,7 +1,9 @@ Changes for 1.0beta1: + - added srv_status.html and services.html (Alexei) + - added table services and services_links (Alexei) + - support for parameter StartAgents in zabbix_agentd.conf (Alexei) - number of forked zabbix_trapperd decreased to 5 (Alexei) - - number of forked zabbix_agentd decreased to 5 (Alexei) - support for parameter UserParameter in zabbix_agentd.conf (Alexei) - support for advanced zabbix_agentd.conf (Alexei) diff --git a/create/mysql/schema.sql b/create/mysql/schema.sql index 59f20d16..02253238 100644 --- a/create/mysql/schema.sql +++ b/create/mysql/schema.sql @@ -1,4 +1,26 @@ # +# Table structure for table 'services' +# + +CREATE TABLE services ( + serviceid int(4) NOT NULL auto_increment, + name varchar(128) DEFAULT '' NOT NULL, + triggerid int(4), + PRIMARY KEY (serviceid) +); + +# +# Table structure for table 'services_links' +# + +CREATE TABLE services_links ( + serviceupid int(4) DEFAULT '0' NOT NULL, + servicedownid int(4) DEFAULT '0' NOT NULL, + KEY (serviceupid), + KEY (servicedownid) +); + +# # Table structure for table 'graphs_items' # diff --git a/doc/manual.lyx b/doc/manual.lyx index cb1c79d9..20d7534f 100644 --- a/doc/manual.lyx +++ b/doc/manual.lyx @@ -2093,6 +2093,12 @@ The file contains configuration parameters for zabbix_agentd. Server=<IP address of Zabbix server> \layout Itemize +StartAgents=<number of agents to start> +\newline +The parameter should be between 1 and 16. + Defauls value is 5. +\layout Itemize + DebugLevel=<debug level> \layout Itemize @@ -2100,7 +2106,7 @@ UserParameter=<key>,<shell command> \layout Standard Example: UserParameter=users,who|wc -l -\layout Standard +\newline \layout Standard diff --git a/frontends/php/chart2.html b/frontends/php/chart2.html index b72e976b..07f85468 100644 --- a/frontends/php/chart2.html +++ b/frontends/php/chart2.html @@ -27,16 +27,18 @@ $sizeX=$width; $sizeY=$height; - $shiftX=10; - $shiftYup=10; - $shiftYdown=25; - $nodata=1; Header( "Content-type: text/html"); // Header( "Content-type: image/png"); Header( "Expires: Mon, 17 Aug 1998 12:51:50 GMT"); + $result2=DBselect("select gi.itemid,i.description,gi.color,h.host from graphs_items gi,items i,hosts h where gi.itemid=i.itemid and gi.graphid=$graphid and i.hostid=h.hostid order by gi.gitemid"); + + $shiftX=10; + $shiftYup=10; + $shiftYdown=7+15*DBnum_rows($result2); + $im = imagecreate($sizeX+$shiftX+61,$sizeY+$shiftYup+$shiftYdown+10); $red=ImageColorAllocate($im,255,0,0); @@ -80,7 +82,6 @@ $from_time = time(NULL)-$period-3600*$from; $to_time = time(NULL)-3600*$from; - $result2=DBselect("select gi.itemid,i.description,gi.color from graphs_items gi,items i where gi.itemid=i.itemid and gi.graphid=$graphid order by gi.gitemid"); $len=array(); $x=array(); @@ -98,6 +99,7 @@ $itemid=DBget_field($result2,$item,0); $desc[$item]=DBget_field($result2,$item,1); $color[$item]=DBget_field($result2,$item,2); + $host[$item]=DBget_field($result2,$item,3); $result=DBselect("select clock,value from history where itemid=$itemid and clock>$from_time and clock<$to_time order by clock"); $len[$item]=0; @@ -142,8 +144,10 @@ { ImageLine($im,$shiftX,$shiftYup+$sizeY/2,$sizeX+$shiftX,$shiftYup+$sizeY/2,$colors[$color[$item]]); } - ImageFilledRectangle($im,$shiftX+200*$item,$sizeY+$shiftYup+19,$shiftX+200*$item+5,$sizeY+$shiftYup+15+9,$colors[$color[$item]]); - ImageString($im, 2,$shiftX+200*$item+9,$sizeY+$shiftYup+15, $desc[$item], $gray); +# ImageFilledRectangle($im,$shiftX+200*$item,$sizeY+$shiftYup+19,$shiftX+200*$item+5,$sizeY+$shiftYup+15+9,$colors[$color[$item]]); +# ImageString($im, 2,$shiftX+200*$item+9,$sizeY+$shiftYup+15, $desc[$item], $gray); + ImageFilledRectangle($im,$shiftX,$sizeY+$shiftYup+19+15*$item,$shiftX+5,$sizeY+$shiftYup+15+9+15*$item,$colors[$color[$item]]); + ImageString($im, 2,$shiftX+9,$sizeY+$shiftYup+15*$item+15, $host[$item].": ".$desc[$item], $gray); } if($nodata == 0) diff --git a/frontends/php/include/config.inc b/frontends/php/include/config.inc index 4586397b..c2c777a1 100644 --- a/frontends/php/include/config.inc +++ b/frontends/php/include/config.inc @@ -468,6 +468,21 @@ ?> </font> </td> + <td colspan=1 bgcolor=FFFFFF align=center valign="top" width="15%"> + <font face="Arial,Helvetica" size=2> + <a href="srv_status.html"> +<? + if($page["file"]=="srv_status.html") + { + echo "<b>[SERVICES]</b></a>"; + } + else + { + echo "SERVICES</a>"; + } +?> + </font> + </td> </tr> <tr> <td colspan=2 bgcolor=FFFFFF align=center valign="top" width="15%"> @@ -485,7 +500,7 @@ ?> </font> </td> - <td colspan=2 bgcolor=FFFFFF align=center valign="top" width="15%"> + <td colspan=3 bgcolor=FFFFFF align=center valign="top" width="15%"> <font face="Arial,Helvetica" size=2> <a href="report1.html"> <? @@ -626,6 +641,21 @@ ?> </font> </td> + <td colspan=1 bgcolor=FFFFFF align=center valign="top" width="15%"> + <font face="Arial,Helvetica" size=2> + <a href="services.html"> +<? + if($page["file"]=="services.html") + { + echo "<b>[SERVICES]</b></a>"; + } + else + { + echo "SERVICES</a>"; + } +?> + </font> + </td> </tr> </table> </td> @@ -860,6 +890,25 @@ return DBexecute($sql); } + function add_service($name,$triggerid,$linktrigger) + { + if( isset($linktrigger)&&($linktrigger=="on") ) + { + $sql="insert into services (serviceid,name,triggerid) values (NULL,'$name',$triggerid)"; + } + else + { + $sql="insert into services (serviceid,name) values (NULL,'$name')"; + } + return DBexecute($sql); + } + + function add_service_link($servicedownid,$serviceupid) + { + $sql="insert into services_links (servicedownid,serviceupid) values ($servicedownid,$serviceupid)"; + return DBexecute($sql); + } + # Update Action function update_action( $actionid, $userid, $good, $delay, $subject, $message ) diff --git a/frontends/php/services.html b/frontends/php/services.html new file mode 100644 index 00000000..afde6132 --- /dev/null +++ b/frontends/php/services.html @@ -0,0 +1,178 @@ +<? + $page["title"] = "High-level representation of monitored data"; + $page["file"] = "services.html"; + + include "include/config.inc"; + show_header($page["title"],0,0); +?> + +<? + if(isset($register)) + { + if($register=="add") + { + $result=add_service($name,$triggerid,$linktrigger); + show_messages($result,"Service added","Cannot add service"); + } + if($register=="add link") + { + $result=add_service_link($servicedownid,$serviceupid); + show_messages($result,"Service link added","Cannot add service link"); + } + } +?> + +<? + show_table_header("IT's SERVICES"); + + echo "<br>"; + + show_table_header("SERVICES"); +?> +<? + $now=time(); + $result=DBselect("select serviceid,name from services order by name"); + echo "<table border=0 width=100% bgcolor='#CCCCCC' cellspacing=1 cellpadding=3>"; + echo "\n"; + echo "<tr><td><b>Service</b></td></tr>"; + echo "\n"; + $col=0; + for($i=0;$i<DBnum_rows($result);$i++) + { + $serviceid_=DBget_field($result,$i,0); + $name_=DBget_field($result,$i,1); + + if(isset($serviceid)&&($serviceid==$serviceid_)) + { + echo "<tr bgcolor=#99AABB>"; + } + else + { + if($col==1) + { + echo "<tr bgcolor=#EEEEEE>"; + $col=0; + } else + { + echo "<tr bgcolor=#DDDDDD>"; + $col=1; + } + } + echo "<td><a href=\"services.html?serviceid=$serviceid_\">$name_</a></td>"; + echo "</tr>"; + } + echo "</table>"; +?> + +<? + if(isset($serviceid)) + { + $result=DBselect("select serviceid,triggerid,name from services where serviceid=$serviceid"); + $triggerid=DBget_field($result,0,1); + $name=DBget_field($result,0,2); + } + else + { + $name=""; + unset($triggerid); + } + + echo "<br>"; + show_table2_header_begin(); + echo "New service"; + + show_table2_v_delimiter(); + echo "<form method=\"post\" action=\"services.html\">"; + if(isset($serviceid)) + { + echo "<input name=\"serviceid\" type=\"hidden\" value=$serviceid>"; + } + echo "Name"; + show_table2_h_delimiter(); + echo "<input name=\"name\" value=\"$name\" size=32>"; + + show_table2_v_delimiter(); + echo "Link to trigger ?"; + show_table2_h_delimiter(); + if(isset($linktrigger)&&($triggerid!="")) + { + echo "<INPUT TYPE=\"CHECKBOX\" NAME=\"linktrigger\" VALUE=\"true\">"; + } + else + { + echo "<INPUT TYPE=\"CHECKBOX\" NAME=\"linktrigger\">"; + } + + show_table2_v_delimiter(); + echo "Trigger"; + show_table2_h_delimiter(); + $result=DBselect("select triggerid,description from triggers order by description"); + echo "<select name=\"triggerid\" size=1>"; + for($i=0;$i<DBnum_rows($result);$i++) + { + $triggerid_=DBget_field($result,$i,0); + $description_=DBget_field($result,$i,1); + if(isset($triggerid) && ($triggerid==$triggerid_)) + { + echo "<OPTION VALUE='$triggerid_' SELECTED>$description_"; + } + else + { + echo "<OPTION VALUE='$triggerid_'>$description_"; + } + } + echo "</SELECT>"; + show_table2_v_delimiter2(); + echo "<input type=\"submit\" name=\"register\" value=\"add\">"; + if(isset($serviceid)) + { + echo "<input type=\"submit\" name=\"register\" value=\"update\">"; + } + + show_table2_header_end(); +?> + +<? + if(isset($serviceid)) + { + $result=DBselect("select serviceid,triggerid,name from services where serviceid=$serviceid"); + $triggerid=DBget_field($result,0,1); + $name=DBget_field($result,0,2); + } + else + { + $name=""; + unset($triggerid); + } + + echo "<br>"; + show_table2_header_begin(); + echo "New link"; + + show_table2_v_delimiter(); + echo "<form method=\"post\" action=\"services.html\">"; + if(isset($serviceid)) + { + echo "<input name=\"serviceid\" type=\"hidden\" value=$serviceid>"; + echo "<input name=\"servicedownid\" type=\"hidden\" value=$serviceid>"; + } + echo "Name"; + show_table2_h_delimiter(); + $result=DBselect("select serviceid,triggerid,name from services order by name"); + echo "<select name=\"serviceupid\" size=1>"; + for($i=0;$i<DBnum_rows($result);$i++) + { + $serviceupid_=DBget_field($result,$i,0); + $name_=DBget_field($result,$i,2); + echo "<OPTION VALUE='$serviceupid_'>$name_"; + } + echo "</SELECT>"; + show_table2_v_delimiter2(); + echo "<input type=\"submit\" name=\"register\" value=\"add link\">"; + + show_table2_header_end(); +?> + +<? + show_footer(); +?> diff --git a/frontends/php/srv_status.html b/frontends/php/srv_status.html new file mode 100644 index 00000000..ed02663f --- /dev/null +++ b/frontends/php/srv_status.html @@ -0,0 +1,53 @@ +<? + $page["title"] = "High-level representation of monitored data"; + $page["file"] = "srv_status.html"; + + include "include/config.inc"; + show_header($page["title"],0,0); +?> + +<? + show_table_header("IT's SERVICES"); + + echo "<br>"; + + show_table_header("SERVICES"); +?> +<? + $now=time(); + $result=DBselect("select serviceid,name from services order by name"); + echo "<table border=0 width=100% bgcolor='#CCCCCC' cellspacing=1 cellpadding=3>"; + echo "\n"; + echo "<tr><td><b>Service</b></td></tr>"; + echo "\n"; + $col=0; + for($i=0;$i<DBnum_rows($result);$i++) + { + $serviceid_=DBget_field($result,$i,0); + $name_=DBget_field($result,$i,1); + + if(isset($serviceid)&&($serviceid==$serviceid_)) + { + echo "<tr bgcolor=#99AABB>"; + } + else + { + if($col==1) + { + echo "<tr bgcolor=#EEEEEE>"; + $col=0; + } else + { + echo "<tr bgcolor=#DDDDDD>"; + $col=1; + } + } + echo "<td><a href=\"srv_status.html?serviceid=$serviceid_\">$name_</a></td>"; + echo "</tr>"; + } + echo "</table>"; +?> + +<? + show_footer(); +?> diff --git a/misc/conf/zabbix_agentd.conf b/misc/conf/zabbix_agentd.conf index e344ac90..2ce8dd64 100644 --- a/misc/conf/zabbix_agentd.conf +++ b/misc/conf/zabbix_agentd.conf @@ -7,6 +7,11 @@ Server=127.0.0.1 +# Number of pre-forked instances of zabbix_agentd. +# Default value is 5 +# This parameter must be between 1 and 16 +StartAgents=5 + # Specifies debug level # 1 - critical information # 2 - warnings (default) diff --git a/src/zabbix_agent/zabbix_agentd.c b/src/zabbix_agent/zabbix_agentd.c index 6d9780bb..c008b34f 100644 --- a/src/zabbix_agent/zabbix_agentd.c +++ b/src/zabbix_agent/zabbix_agentd.c @@ -37,6 +37,7 @@ static pid_t *pids; char *config_host_allowed=NULL; +int config_agentd_forks=AGENTD_FORKS; void signal_handler( int sig ) { @@ -99,6 +100,7 @@ void process_config_file(void) char *value; char *value2; int lineno; + int i; file=fopen("/etc/zabbix/zabbix_agentd.conf","r"); if(NULL == file) @@ -135,6 +137,17 @@ void process_config_file(void) config_host_allowed=(char *)malloc(strlen(value)); strcpy(config_host_allowed,value); } + else if(strcmp(parameter,"StartAgents")==0) + { + i=atoi(value); + if( (i<1) || (i>16) ) + { + syslog( LOG_CRIT, "Wrong value of StartAgents in line %d. Should be between 1 and 16.", lineno); + fclose(file); + exit(1); + } + config_agentd_forks=i; + } else if(strcmp(parameter,"DebugLevel")==0) { if(strcmp(value,"1") == 0) @@ -168,7 +181,7 @@ void process_config_file(void) value2[0]=0; value2++; syslog( LOG_WARNING, "Added user-defined parameter [%s] Command [%s]", value, value2); -// add_user_parameter("system[test]","who|wc -l"); + add_user_parameter(value, value2); } else { @@ -352,9 +365,9 @@ int main() listenfd = tcp_listen(host,port,&addrlen); - pids = calloc(AGENTD_FORKS, sizeof(pid_t)); + pids = calloc(config_agentd_forks, sizeof(pid_t)); - for(i = 0; i< AGENTD_FORKS; i++) + for(i = 0; i<config_agentd_forks; i++) { pids[i] = child_make(i, listenfd, addrlen); /* syslog( LOG_WARNING, "zabbix_agentd #%d started", pids[i]);*/ |
