summaryrefslogtreecommitdiffstats
path: root/frontends/php
diff options
context:
space:
mode:
authorjames_wells <james_wells@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-11-18 03:17:13 +0000
committerjames_wells <james_wells@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-11-18 03:17:13 +0000
commitf7c2b61c66cc33bb15842c4db07b145ace7ba7e9 (patch)
tree82d878bee71b96b3ecd66eacfb1bf97788754c7d /frontends/php
parent715779b96fa92ec73fdb4e5d58791af6bb2e5683 (diff)
Added preliminary host and user bulk loader. Still a lot more needs to be added.
zabbix/frontends/php/include/bulkloader.inc.php zabbix/frontends/php/include/config.inc.php zabbix/frontends/php/bulkloader.php Applied SNMPv3 fix zabbix/src/zabbix_server/poller/poller.c zabbix/src/zabbix_server/poller/checks_snmp.c Applied graph dropdown patch zabbix/frontends/php/charts.php zabbix/frontends/php/history.php zabbix/frontends/php/screens.php zabbix/frontends/php/include/graphs.inc.php git-svn-id: svn://svn.zabbix.com/trunk@2334 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php')
-rw-r--r--frontends/php/bulkloader.php59
-rw-r--r--frontends/php/charts.php8
-rw-r--r--frontends/php/history.php24
-rw-r--r--frontends/php/include/bulkloader.inc.php89
-rw-r--r--frontends/php/include/config.inc.php13
-rw-r--r--frontends/php/include/graphs.inc.php12
-rw-r--r--frontends/php/screens.php8
7 files changed, 167 insertions, 46 deletions
diff --git a/frontends/php/bulkloader.php b/frontends/php/bulkloader.php
index 1a58b51e..bddb58f7 100644
--- a/frontends/php/bulkloader.php
+++ b/frontends/php/bulkloader.php
@@ -19,6 +19,7 @@
**/
include "include/config.inc.php";
include "include/forms.inc.php";
+ include "include/bulkloader.inc.php";
$page["file"] = "bulkloader.php";
$page["title"] = "S_BULKLOADER_MAIN";
$fileuploaded=0;
@@ -111,20 +112,19 @@
// Determine which group(s) this host belongs to, create any group(s) necessary;
$hostGroups=array();
$groupnum=0;
-// $tmpGroupList=explode(',',rtrim(rtrim($tmpHostGroups," "),"\n"));
foreach(explode(',',rtrim(rtrim($tmpHostGroups," "),"\n")) as $tmpGroup)
{
$groupnum++;
- $sqlResult=DBSelect("select distinct(groupid) from groups where name='$tmpGroup'");
+ $sqlResult=DBselect("select distinct(groupid) from groups where name='$tmpGroup'");
if(DBnum_rows($sqlResult)==0)
{
// Create new group
- $hostGroups=array_merge($hostGroups,array(add_group($tmpGroup)));
+ $hostGroups=array_merge($hostGroups,array(create_Host_Group($tmpGroup)));
}
else
{
// Found Existing Group;
- $row=DBFetch($sqlResult);
+ $row=DBfetch($sqlResult);
$hostGroups=array_merge($hostGroups,array($row["groupid"]));
}
}
@@ -135,7 +135,26 @@
DBselect("update hosts set serverid=$hostServer where host='$tmpHost'");
break;
case "USER":
- echo "Importing Users is not yet implemented";
+ list($tmpName,$tmpSurname,$tmpAlias,$tmpPasswd,$tmpURL,$tmpAutologout,$tmpLang,$tmpRefresh,$tmpUserGroups) = explode(",",$tmpField,9);
+ $autologout=@iif($tmpAutologout==NULL,900,$tmpAutologout);
+ $lang=@iif($tmpLang==NULL,'en_gb',$tmpLang);
+ $refresh=@iif($tmpRefresh==NULL,30,$tmpRefresh);
+ $passwd=@iif($tmpPasswd==NULL,md5($tmpAlias),md5($tmpPasswd));
+ $result=@iif($tmpAlias==NULL,0,add_user($tmpName,$tmpSurname,$tmpAlias,$passwd,$tmpURL,$autologout,$lang,$refresh));
+ show_messages($result, S_USER_ADDED .': '. $tmpAlias, S_CANNOT_ADD_USER .': '. $tmpAlias);
+ $row=DBfetch(DBselect("select distinct(userid) from users where alias='$tmpAlias'"));
+ $tmpUserID=$row["userid"];
+ if($tmpUserID)
+ {
+ foreach(explode(',',rtrim(rtrim($tmpUserGroups," "),"\n")) as $tmpGroup)
+ {
+ $tmpGroupID=create_User_Group($tmpGroup);
+ add_User_To_Group($tmpGroupID,$tmpUserID);
+ }
+ }
+ break;
+ case "PERM":
+ echo "Importing User Permissions is not yet implemented";
break;
case "ITEM":
echo "Importing Items is not yet implemented";
@@ -157,11 +176,6 @@
}
table_begin();
table_row(array(
- "Currently, The bulk loader, only loads Host Entries."
- ), 0);
- table_end();
- table_begin();
- table_row(array(
'Host Entry Format.',
'HOST,&lt;Hostname&gt;,&lt;Host IP&gt;,&lt;Host Port&gt;,&lt;Host Status&gt;,&lt;Template Host&gt;,&lt;Zabbix Server&gt;,&lt;Host Group(s)&gt<BR>'.
'&nbsp;&nbsp;&nbsp;<STRONG>HOST</STRONG>: This is the command to tell the bulk loader that this entry is a host<BR>'.
@@ -175,6 +189,31 @@
''
), 2);
+ table_row(array(
+ 'User Entry Format.',
+ 'USER,&lt;User First Name&gt;,&lt;User Surname&gt;,&lt;Login Name&gt;,&lt;Password&gt;,&lt;URL&gt;,&lt;Auto Logout Time&gt;,&lt;Language&gt;,&lt;Screen Refresh Time&gt;,&lt;Host Group(s)&gt<BR>'.
+ '&nbsp;&nbsp;&nbsp;<STRONG>USER</STRONG>: This is the command to tell the bulk loader that this entry is a User<BR>'.
+ '&nbsp;&nbsp;&nbsp;<STRONG>User First Name</STRONG>: This is the users first name<BR>'.
+ '&nbsp;&nbsp;&nbsp;<STRONG>User Surname</STRONG>: This is the users last name<BR>'.
+ '&nbsp;&nbsp;&nbsp;<STRONG>Login Name</STRONG>: This is the name the user will login with. NOTE: User will not be created if this is blank.<BR>'.
+ '&nbsp;&nbsp;&nbsp;<STRONG>Password</STRONG>: This is the password that user will login with. If blank, this will default to the login name.<BR>'.
+ '&nbsp;&nbsp;&nbsp;<STRONG>URL</STRONG>: This is the URL the user is redirected to upon login.<BR>'.
+ '&nbsp;&nbsp;&nbsp;<STRONG>Auto Logout Time</STRONG>: This is the number of seconds before an idle user will be logged off. If blank, this will default to 900 seconds.<BR>'.
+ '&nbsp;&nbsp;&nbsp;<STRONG>Language</STRONG>: This is the the language that that Zabbix will display to the user. If blank, this will default to en_gb. Valid Choices are;<BR>'.
+ '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&gt; en_gb -- English<BR>'.
+ '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&gt; fr_fr -- French<BR>'.
+ '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&gt; de_de -- German<BR>'.
+ '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&gt; it_it -- Itallian<BR>'.
+ '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&gt; ja_ja -- Japanese<BR>'.
+ '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&gt; lv_lv -- Latvian<BR>'.
+ '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&gt; ru_ru -- Russian<BR>'.
+ '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&gt; sp_sp -- Spanish<BR>'.
+ ''.
+ '&nbsp;&nbsp;&nbsp;<STRONG>Screen Refresh Time</STRONG>: This is the number of seconds before monitoring pages will refresh. If blank, this will default to 30 seconds.<BR>'.
+ '&nbsp;&nbsp;&nbsp;<STRONG>User Group(s)</STRONG>: This is a comma separated list of user groups that the user belongs to. If this contains one or more groups that are not in the Zabbix Server, the groups will be created and user added to those groups.<BR>'.
+
+ ''
+ ), 2);
table_end();
table_begin();
table_row(array(
diff --git a/frontends/php/charts.php b/frontends/php/charts.php
index b63ebc5f..86ac99f5 100644
--- a/frontends/php/charts.php
+++ b/frontends/php/charts.php
@@ -36,7 +36,7 @@
{
show_header($page["title"],0,$nomenu);
}
- navigation_bar_calc();
+ $effectiveperiod=navigation_bar_calc();
?>
@@ -51,9 +51,9 @@
{
$_REQUEST["from"]=0;
}
- if(!isset($_REQUEST["period"]))
+ if(!isset($effectiveperiod))
{
- $_REQUEST["period"]=3600;
+ $effectiveperiod=3600;
}
if(!isset($_REQUEST["keep"]))
@@ -172,7 +172,7 @@
if(isset($_REQUEST["graphid"]))
{
echo "<script language=\"JavaScript\">";
- echo "document.write(\"<IMG SRC='chart2.php?graphid=".$_REQUEST["graphid"].url_param("stime")."&period=".$_REQUEST["period"]."&from=".$_REQUEST["from"]."&width=\"+(document.width-108)+\"'>\")";
+ echo "document.write(\"<IMG SRC='chart2.php?graphid=".$_REQUEST["graphid"].url_param("stime")."&period=".$effectiveperiod."&from=".$_REQUEST["from"]."&width=\"+(document.width-108)+\"'>\")";
echo "</script>";
}
else
diff --git a/frontends/php/history.php b/frontends/php/history.php
index f01c8c8c..d59be7a4 100644
--- a/frontends/php/history.php
+++ b/frontends/php/history.php
@@ -79,7 +79,7 @@
?>
<?php
- navigation_bar_calc();
+ $effectiveperiod=navigation_bar_calc();
?>
<?php
@@ -120,15 +120,15 @@
<?php
if($_REQUEST["action"]=="showfreehist")
{
- show_freehist($_REQUEST["itemid"],$_REQUEST["period"]);
+ show_freehist($_REQUEST["itemid"],$effectiveperiod);
exit;
}
if($_REQUEST["action"]=="showplaintxt")
{
-// if(!isset($_REQUEST["period"]))
+// if(!isset($effectiveperiod))
{
- show_plaintxt($_REQUEST["itemid"],$_REQUEST["period"]);
+ show_plaintxt($_REQUEST["itemid"],$effectiveperiod);
}
exit;
@@ -140,15 +140,15 @@
{
$_REQUEST["from"]=0;
}
- if(!isset($_REQUEST["period"]))
+ if(!isset($effectiveperiod))
{
- $_REQUEST["period"]=3600;
+ $effectiveperiod=3600;
}
- $time=time(NULL)-$_REQUEST["period"]-$_REQUEST["from"]*3600;
+ $time=time(NULL)-$effectiveperiod-$_REQUEST["from"]*3600;
$till=time(NULL)-$_REQUEST["from"]*3600;
- $hours=$_REQUEST["period"]/3600;
+ $hours=$effectiveperiod/3600;
- show_table_header("Showing history of ".$_REQUEST["period"]." seconds($hours h)<BR>[from: ".date("Y.M.d H:i:s",$time)."] [till: ".date("Y.M.d H:i:s",$till)."]");
+ show_table_header("Showing history of ".$effectiveperiod." seconds($hours h)<BR>[from: ".date("Y.M.d H:i:s",$time)."] [till: ".date("Y.M.d H:i:s",$till)."]");
echo "<TABLE BORDER=0 COLS=2 ALIGN=CENTER WIDTH=100% BGCOLOR=\"#AAAAAA\" cellspacing=1 cellpadding=3>";
echo "<TR BGCOLOR=\"#CCCCCC\">";
@@ -238,9 +238,9 @@
if($_REQUEST["action"]=="showhistory")
{
- if(!isset($_REQUEST["period"]))
+ if(!isset($effectiveperiod))
{
- $_REQUEST["period"]=3600;
+ $effectiveperiod=3600;
}
if(!isset($_REQUEST["from"]))
{
@@ -250,7 +250,7 @@
{
$_REQUEST["from"]=($now-mktime($_REQUEST["hour"], 0, 0, $_REQUEST["month"], $_REQUEST["day"],$_REQUEST["year"]))/3600;
}
- @show_history($_REQUEST["itemid"],$_REQUEST["from"],$_REQUEST["period"]);
+ @show_history($_REQUEST["itemid"],$_REQUEST["from"],$effectiveperiod);
show_footer();
exit;
}
diff --git a/frontends/php/include/bulkloader.inc.php b/frontends/php/include/bulkloader.inc.php
new file mode 100644
index 00000000..a8a1a9aa
--- /dev/null
+++ b/frontends/php/include/bulkloader.inc.php
@@ -0,0 +1,89 @@
+<?php
+/*
+** ZABBIX
+** Copyright (C) 2000-2005 SIA Zabbix
+**
+** 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_once "include/config.inc.php";
+
+/*
+** This include file contains all of the non-standard functions required
+** by the bulk loader system.
+**/
+
+ // This function takes a host group name and populates the database.
+ // Returns: 0 if unable to create, otherwise it returns the groupID
+ function create_Host_Group($group)
+ {
+ $sql="select * from groups where name='$group'";
+ $result=DBselect("select distinct(groupid) from groups where name='$name'");
+ if(DBnum_rows($result)>0)
+ {
+ $row=DBfetch($result);
+ return $row["groupid"];
+ }
+
+ $result=DBexecute("insert into groups (name) values ('$group')");
+ if($result)
+ {
+ return DBinsert_id($result,"groups","name");
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
+ // This function takes a user group name and populates the database.
+ // Returns: 0 if unable to create, otherwise it returns the groupID
+ function create_User_Group($group)
+ {
+ $sql="select * from groups where name='$group'";
+ $result=DBselect("select distinct(usrgrpid) from usrgrp where name='$group'");
+ if(DBnum_rows($result)>0)
+ {
+ $row=DBfetch($result);
+ return $row["usrgrpid"];
+ }
+
+ $result=DBexecute("insert into usrgrp (name) values ('$group')");
+ if($result)
+ {
+ return DBinsert_id($result,"usrgrp","name");
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
+ // This function adds user to a user group based on ID numbers.
+ // Returns: 0 on failure, otherwise it returns 1
+ function add_User_To_Group($groupid=0,$userid=0)
+ {
+ if($groupid==0||$userid==0)
+ {
+ return 0;
+ }
+ $result=DBexecute("insert into users_groups (usrgrpid,userid) values ($groupid,$userid)");
+ if($result)
+ {
+ return 1;
+ }
+ return 0;
+ }
+
+?>
diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php
index bea0bcad..4673149f 100644
--- a/frontends/php/include/config.inc.php
+++ b/frontends/php/include/config.inc.php
@@ -1674,19 +1674,6 @@ echo "</head>";
}
}
- function add_group($group)
- {
- $result=DBexecute("insert into groups (name) values ('$group')");
- if($result)
- {
- return DBinsert_id($result,"groups","name");
- }
- else
- {
- return 0;
- }
- }
-
function add_host_group($name,$hosts)
{
// if(!check_right("Host","A",0))
diff --git a/frontends/php/include/graphs.inc.php b/frontends/php/include/graphs.inc.php
index f2d44c2a..14ea38cb 100644
--- a/frontends/php/include/graphs.inc.php
+++ b/frontends/php/include/graphs.inc.php
@@ -207,14 +207,16 @@
if(!isset($_REQUEST["period"])) $_REQUEST["period"]=3600;
if(!isset($_REQUEST["from"])) $_REQUEST["from"]=0;
- if(isset($_REQUEST["inc"])) $_REQUEST["period"]= $_REQUEST["period"]+$_REQUEST["inc"];
- if(isset($_REQUEST["dec"])) $_REQUEST["period"]= $_REQUEST["period"]-$_REQUEST["dec"];
+ if(isset($_REQUEST["inc"])) $workingperiod= $_REQUEST["period"]+$_REQUEST["inc"];
+ if(isset($_REQUEST["dec"])) $workingperiod= $workingperiod-$_REQUEST["dec"];
+ //if(isset($_REQUEST["inc"])) $_REQUEST["period"]= $_REQUEST["period"]+$_REQUEST["inc"];
+ //if(isset($_REQUEST["dec"])) $_REQUEST["period"]= $_REQUEST["period"]-$_REQUEST["dec"];
if(isset($_REQUEST["left"])) $_REQUEST["from"]= $_REQUEST["from"]+$_REQUEST["left"];
if(isset($_REQUEST["right"])) $_REQUEST["from"]= $_REQUEST["from"]-$_REQUEST["right"];
- unset($_REQUEST["inc"]);
- unset($_REQUEST["dec"]);
+ //unset($_REQUEST["inc"]);
+ //unset($_REQUEST["dec"]);
unset($_REQUEST["left"]);
unset($_REQUEST["right"]);
@@ -225,7 +227,9 @@
{
$_REQUEST["period"]=3600;
$_REQUEST["from"]=0;
+ $workingperiod=3600;
}
+ return $workingperiod;
}
function navigation_bar($url)
diff --git a/frontends/php/screens.php b/frontends/php/screens.php
index b3748a07..832a9a75 100644
--- a/frontends/php/screens.php
+++ b/frontends/php/screens.php
@@ -39,7 +39,7 @@
?>
<?php
- navigation_bar_calc();
+ $effectiveperiod=navigation_bar_calc();
?>
<?php
@@ -155,11 +155,13 @@
{
if($resource == 0)
{
- echo "<a href=charts.php?graphid=$resourceid><img src='chart2.php?graphid=$resourceid&width=$width&height=$height&".url_param("period").url_param("from")."border=0' border=0></a>";
+ echo "<a href=charts.php?graphid=$resourceid".url_param("period").url_param("inc").url_param("dec")."><img src='chart2.php?graphid=$resourceid&width=$width&height=$height&period=$effectiveperiod".url_param("from")."border=0' border=0></a>";
+ //echo "<a href=charts.php?graphid=$resourceid><img src='chart2.php?graphid=$resourceid&width=$width&height=$height&".url_param("period").url_param("from")."border=0' border=0></a>";
}
else if($resource == 1)
{
- echo "<a href=history.php?action=showhistory&itemid=$resourceid><img src='chart.php?itemid=$resourceid&width=$width&height=$height&".url_param("period").url_param("from")."border=0' border=0></a>";
+ echo "<a href=history.php?action=showhistory&itemid=$resourceid".url_param("period").url_param("inc").url_param("dec")."><img src='chart.php?itemid=$resourceid&width=$width&height=$height&period=$effectiveperiod".url_param("from")."border=0' border=0></a>";
+ //echo "<a href=history.php?action=showhistory&itemid=$resourceid><img src='chart.php?itemid=$resourceid&width=$width&height=$height&".url_param("period").url_param("from")."border=0' border=0></a>";
}
else if($resource == 2)
{