From 36f804cfecab25c55e71e3d2f20ffbc35ee5a5fb Mon Sep 17 00:00:00 2001 From: hugetoad Date: Thu, 29 Mar 2001 17:47:53 +0000 Subject: config.inc moved to include/. Added .htaccess file to prevent read access to config.inc. PHP pages updated with new path to the file. git-svn-id: svn://svn.zabbix.com/trunk@14 97f52cf1-0a1b-0410-bd0e-c28be96e8082 --- frontends/php/include/.htaccess | 7 + frontends/php/include/config.inc | 1165 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 1172 insertions(+) create mode 100644 frontends/php/include/.htaccess create mode 100644 frontends/php/include/config.inc (limited to 'frontends/php/include') diff --git a/frontends/php/include/.htaccess b/frontends/php/include/.htaccess new file mode 100644 index 00000000..89b8ddb2 --- /dev/null +++ b/frontends/php/include/.htaccess @@ -0,0 +1,7 @@ +Order Deny,Allow +Deny from All + + +Order Deny,Allow +Deny from All + diff --git a/frontends/php/include/config.inc b/frontends/php/include/config.inc new file mode 100644 index 00000000..75c48082 --- /dev/null +++ b/frontends/php/include/config.inc @@ -0,0 +1,1165 @@ + + + + + + +"; + } +?> + <? echo $title; ?> + + + + + + + +
+ + + + + + + + + + + + + + + +
+ + LATEST VALUES + + + + STATUS OF TRIGGERS + + + + QUEUE + + + + ALARMS + + + + ALERTS + +
+ + CONFIG + + + + USERS + + + + HOSTS + + + + ITEMS + + + + TRIGGERS + +
+
+ +
+$from and clock<$till order by clock",$mysql); + + echo "
";
+		while($row=mysql_fetch_row($result))
+		{
+			$clock=$row[0];
+			$value=$row[1];
+			echo date("Y-m-d H:i:s",$clock);
+			echo "\t$clock\t$value\n";
+		}
+	}
+ 
+
+	# Translate {10}>10 to something like localhost:procload.last(0)>10
+
+	function	explode_exp ($expression, $html)
+	{
+		global	$mysql;
+
+#		echo "EXPRESSION:",$expression,"
"; + + $functionid=''; + $exp=''; + for($i=0;$i".$row1[0].":".$row1[1].".".$row1[2]."(".$row1[3].")}"; + } + continue; + } + if($state == "FUNCTIONID") + { + $functionid=$functionid.$expression[$i]; + continue; + } + $exp=$exp.$expression[$i]; + } +# echo "EXP:",$exp,"
"; + return $exp; + } + + # Translate localhost:procload.last(0)>10 to {12}>10 + + function implode_exp ($expression, $triggerid) + { + global $mysql; + + $exp=''; + for($i=0;$i"; +# echo "KEY:$key
"; +# echo "FUNCTION:$function
"; +# echo "PARAMETER:$parameter
"; + $state=''; + + $sql="select i.itemid from items i,hosts h where i.key_='$key' and h.host='$host' and h.hostid=i.hostid"; +# echo $sql,"
"; + $res=mysql_query($sql,$mysql); + $row=mysql_fetch_row($res); + + $itemid=$row[0]; +# echo "ITEMID:$itemid
"; + +# $sql="select functionid from functions where function='$function' and parameter=$parameter"; +# echo $sql,"
"; +# $res=mysql_query($sql,$mysql); +# $row=mysql_fetch_row($res); + +# if($row) +# { +# $functionid=$row[0]; +# } +# else +# { + $sql="insert into functions (functionid,itemid,triggerid,function,parameter) values (NULL,$itemid,$triggerid,'$function',$parameter)"; +# echo $sql,"
"; + $res=mysql_query($sql,$mysql); + $functionid=mysql_insert_id($mysql); +# } +# echo "FUNCTIONID:$functionid
"; + + $exp=$exp.'{'.$functionid.'}'; + + continue; + } + if($expression[$i] == '(') + { + if($state == "FUNCTION") + { + $state='PARAMETER'; + continue; + } + } + if($expression[$i] == ')') + { + if($state == "PARAMETER") + { + $state=''; + continue; + } + } + if($expression[$i] == ':') + { + $state="KEY"; + continue; + } + if($expression[$i] == '.') + { + if($state == "KEY") + { + $state="FUNCTION"; + continue; + } + } + if($state == "HOST") + { + $host=$host.$expression[$i]; + continue; + } + if($state == "KEY") + { + $key=$key.$expression[$i]; + continue; + } + if($state == "FUNCTION") + { + $function=$function.$expression[$i]; + continue; + } + if($state == "PARAMETER") + { + $parameter=$parameter.$expression[$i]; + continue; + } + $exp=$exp.$expression[$i]; + } + return $exp; + } + + # Update Trigger status + + function update_trigger_status($triggerid,$status) + { + global $mysql; + + $sql="update triggers set istrue=$status where triggerid=$triggerid"; + $result=mysql_query($sql,$mysql); + } + + # Update Item status + + function update_item_status($itemid,$status) + { + global $mysql; + + $sql="update items set status=$status where itemid=$itemid"; + $result=mysql_query($sql,$mysql); + } + + # Update Host status + + function update_host_status($hostid,$status) + { + global $mysql; + + $sql="update hosts set status=$status where hostid=$hostid"; + $result=mysql_query($sql,$mysql); + } + + # Update Item definition + + function update_item($itemid,$description,$key,$hostid,$delay,$history,$status) + { + global $mysql; + + $sql="update items set description='$description',key_='$key',hostid=$hostid,delay=$delay,history=$history,lastdelete=0,nextcheck=0,status=$status where itemid=$itemid"; + $result=mysql_query($sql,$mysql); + } + + # Add Action + + function add_action( $triggerid, $userid, $good, $delay, $subject, $message ) + { + global $mysql; + + $sql="insert into actions (actionid,triggerid,userid,good,delay,nextcheck,subject,message) values (NULL,$triggerid,$userid,$good,$delay,0,'$subject','$message')"; + $result=mysql_query($sql,$mysql); + } + + # Update Action + + function update_action( $actionid, $userid, $good, $delay, $subject, $message ) + { + global $mysql; + + $sql="update actions set userid=$userid,good=$good,delay=$delay,nextcheck=0,subject='$subject',message='$message' where actionid=$actionid"; + $result=mysql_query($sql,$mysql); + } + + # Delete Action by userid + + function delete_actions_by_userid( $userid ) + { + global $mysql; + + $sql="delete from actions where userid=$userid"; + $result=mysql_query($sql,$mysql); + } + + # Delete Action + + function delete_action( $actionid ) + { + global $mysql; + + $sql="delete from actions where actionid=$actionid"; + $result=mysql_query($sql,$mysql); + } + + # Delete from History + + function delete_history_by_itemid( $itemid ) + { + global $mysql; + + + $sql="delete from history where itemid=$itemid"; + $result=mysql_query($sql,$mysql); + } + + # Add Item definition + + function add_item($description,$key,$hostid,$delay,$history,$status) + { + global $mysql; + + $sql="insert into items (itemid,description,key_,hostid,delay,history,lastdelete,nextcheck,status) values (NULL,'$description','$key',$hostid,$delay,$history,0,0,$status)"; + $result=mysql_query($sql,$mysql); + return mysql_insert_id($mysql); + } + + # Delete Function definition + + function delete_function_by_triggerid($triggerid) + { + global $mysql; + + $sql="delete from functions where triggerid=$triggerid"; + $result=mysql_query($sql,$mysql); + } + + # Delete Function and Trigger definitions by itemid + + function delete_triggers_functions_by_itemid($itemid) + { + global $mysql; + + $sql="select triggerid from functions where itemid=$itemid"; + $result=mysql_query($sql,$mysql); + while($row=mysql_fetch_row($result)) + { + delete_function_by_triggerid($row[0]); + } + + $sql="delete from functions where itemid=$itemid"; + $result=mysql_query($sql,$mysql); + } + + # Delete Item definition + + function delete_item($itemid) + { + global $mysql; + + $sql="delete from items where itemid=$itemid"; + $result=mysql_query($sql,$mysql); + + delete_triggers_functions_by_itemid($itemid); + delete_history_by_itemid($itemid); + } + + # Add alarm + + function add_alarm($triggerid,$istrue) + { + global $mysql; + + $now=mktime(); + $sql="insert into alarms(triggerid,clock,istrue) values($triggerid,$now,$istrue)"; + $result=mysql_query($sql,$mysql); + } + + # Add Trigger definition + + function add_trigger($expression,$description,$priority,$istrue,$comments) + { + global $mysql; + + $sql="insert into triggers (triggerid,description,priority,istrue,comments) values (NULL,'$description',$priority,$istrue,'$comments')"; +# echo $sql,"
"; + $result=mysql_query($sql,$mysql); + + $triggerid=mysql_insert_id($mysql); + + $expression=implode_exp($expression,$triggerid); + $sql="update triggers set expression='$expression' where triggerid=$triggerid"; +# echo $sql,"
"; + $result=mysql_query($sql,$mysql); + } + + # Delete Trigger definition + + function delete_trigger($triggerid) + { + global $mysql; + + $sql="delete from triggers where triggerid=$triggerid"; + $result=mysql_query($sql,$mysql); + + delete_function_by_triggerid($triggerid); + } + + # Update Trigger definition + + function update_trigger($triggerid,$expression,$description,$priority,$istrue,$comments) + { + global $mysql; + + delete_trigger($triggerid); + + $triggerid=add_trigger($expression,$description,$priority,$istrue,$comments); + } + + # Add User definition + + function add_user($name,$surname,$alias) + { + global $mysql; + + $sql="insert into users (userid,name,surname,alias) values (NULL,'$name','$surname','$alias')"; + $result=mysql_query($sql,$mysql); + + return $result; + } + + # Add Items and Triggers from template + + function add_from_templates($hostid,$platformid,$host) + { + global $mysql; + + $result=mysql_query("select itemtemplateid,description,key_,delay from items_template where platformid=$platformid",$mysql); + while($row=mysql_fetch_row($result)) + { + $itemtemplateid=$row[0]; + $description=$row[1]; + $key=$row[2]; + $delay=$row[3]; + + $itemid=add_item($description,$key,$hostid,$delay,24*3600,0); + + $result2=mysql_query("select triggertemplateid,description,expression from triggers_template where itemtemplateid=$itemtemplateid",$mysql); + while($row2=mysql_fetch_row($result2)) + { + $itemtemplateid=$row2[0]; + $description=$row2[1]; + $expression=$row2[2]; + + for($i=0;$i"; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo " "; + cr(); + } + + function show_table2_h_delimiter() + { + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo " "; + cr(); + } + + function show_table_v_delimiter() + { + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + } + + function show_table2_v_delimiter() + { + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + } + + function show_table2_v_delimiter2() + { + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + } + + + + function show_table2_header_begin() + { + echo "
"; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo "
"; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo "
"; + cr(); + echo " "; + cr(); + } + + function show_table_header_begin() + { + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo "
"; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo "
"; + cr(); + echo " "; + cr(); + } + + function show_table2_header_end() + { + echo " "; + cr(); + echo "
"; + cr(); + echo "
"; + cr(); + echo ""; + cr(); + } + + function show_table_header_end() + { + echo "
"; + cr(); + echo "
"; + cr(); + echo "
"; + cr(); + } + + function show_table_header($title) + { + show_table_header_begin(); + cr(); + echo $title; + cr(); + show_table_header_end(); + cr(); + } + + # Show History Graph + + function show_history($itemid,$from,$period) + { + if (!isset($from)) + { + $from=0; + $till="NOW"; + } + else + { + $till=time(NULL)-$from*3600; + $till=date("d M - H:i:s",$till); + } + + echo "
"; + + if (!isset($period)) + { + $period=3600; + show_table_header("TILL $till (LAST HOUR)"); + } + else + { + $tmp=$period/3600; + show_table_header("TILL $till ($tmp HOURs)"); + } + echo("
"); + echo ""; + echo("
"); + + + // Start of <<< WEEK >>> + $tmp=$from+12*14; + echo("["); + echo("Week back] "); + + // Start of <<< 12h >>> + $tmp=$from+12; + echo("["); + echo("12h back] "); + // End of <<< 12h >>> + + // HOUR BACK + $tmp=$from+1; + echo("["); + echo("1h back] "); + + // Start of --- + $tmp=$period+3600; + echo("["); + echo("+1h] "); + + if ($period>3600) + { + $tmp=$period-3600; + echo("["); + echo("-1h] "); + } + else + { + echo("[-1h]"); + } + // End of ------ + + if ($from>0) // HOUR FORWARD + { + $tmp=$from-1; + echo("["); + echo("1h forward] "); + } + else + { + echo("[1h forward]"); + } + + + if ($From>0) // 12h FORWARD + { + $tmp=$from-12; + echo("["); + echo("12h forward] "); + } + else + { + echo("[12h forward]"); + } + + if ($From>0) // WEEK Forward + { + $tmp=$from-12*14; + echo("["); + echo("Week forward] "); + } + else + { + echo("[Week forward]"); + } + + echo("\n"); + } + + # Show history + function show_freehist($itemid,$period) + { + + echo "
"; + show_table2_header_begin(); + echo "Choose period"; + + show_table2_v_delimiter(); + echo "
"; + echo ""; + echo "Period in seconds"; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter(); + echo "From (in hours)"; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter2(); + echo "Press "; + echo " to see graph"; + + show_table2_header_end(); + + show_footer(); + } + + # Show in plain text + function show_plaintxt($itemid,$period) + { + show_table2_header_begin(); + echo "Data in plain text format"; + + show_table2_v_delimiter(); + echo ""; + echo ""; + echo ""; + echo "From: (yyyy/mm/dd - HH:MM)"; + show_table2_h_delimiter(); + echo "/"; + echo "/"; + echo " - "; + echo ":"; + echo ""; + + show_table2_v_delimiter(); + echo "Till: (yyyy/mm/dd - HH:MM)"; + show_table2_h_delimiter(); + echo "/"; + echo "/"; + echo " - "; + echo ":"; + echo ""; + + show_table2_v_delimiter2(); + echo "Press to see data in "; + echo ""; + + show_table2_header_end(); + + show_footer(); + } + + # Insert form for Item information + function insert_item_form($itemid) + { + global $mysql; + + if(isset($itemid)) + { + mysql_select_db("monitor"); + $result=mysql_query("select i.description, i.key_, h.host, h.port, i.delay, i.history, i.status from items i,hosts h where i.itemid=$itemid and h.hostid=i.hostid",$mysql); + $row=mysql_fetch_row($result); + + $description=$row[0]; + $key=$row[1]; + $host=$row[2]; + $port=$row[3]; + $delay=$row[4]; + $history=$row[5]; + $status=$row[6]; + } + if( !isset($port) ) + { + $port=10000; + } + if( !isset($delay) ) + { + $delay=30; + } + if( !isset($history) ) + { + $history=30*24*3600; + } + if( !isset($status) ) + { + $status=0; + } + + echo "
"; + + show_table2_header_begin(); + echo "Item configuration"; + + show_table2_v_delimiter(); + echo ""; + echo ""; + echo "Description"; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter(); + echo "Host"; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter(); + echo "Key"; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter(); + echo "Delay"; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter(); + echo "History"; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter(); + echo "Status"; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter2(); + echo ""; + if(isset($itemid)) + { + echo ""; + echo ""; + } + + show_table2_header_end(); +?> + + + + +
+ + + + +"; + + show_table2_header_begin(); + echo "Trigger configuration"; + + show_table2_v_delimiter(); + echo "
"; + echo ""; + echo "Description"; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter(); + echo "Expression"; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter(); + echo "Priority"; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter(); + echo "Comments"; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter(); + echo "Disabled"; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter2(); + echo ""; + if(isset($triggerid)) + { + echo ""; + echo ""; + } + show_table2_header_end(); + } + + + function show_footer() + { + echo ""; + echo ""; + echo "
"; + echo ""; + echo ""; + echo "
"; + echo ""; + echo "ZABBIX Copyright 2000,2001 by Alexei Vladishev"; + echo ""; + echo "
"; + echo "
"; + } +?> -- cgit