Actually i am creating a new server using php file just to check can we create a new server or other CI from php scripts just to insert values in server related database table
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("mdb", $con);
//mysql_query("INSERT INTO connectableci (brand,model,serial_number,asset_ref) VALUES ('$brand','$model','$serial_number','$asset_ref')");
//mysql_query("INSERT INTO device (id) VALUES ('')");
mysql_query("INSERT INTO infrastructureci (description,location_id,location_details,management_ip,default_gateway) VALUES ('$description',$location_id,'$location_details','$management_ip','$default_gateway')");
mysql_query("INSERT INTO functionalci(name,status,org_id,importance,finalclass) VALUES ('$name','$status','$org_id','$importance','$finalclass')");
$result1 = mysql_query("SELECT id FROM functionalci ORDER BY id DESC LIMIT 1");
while($data = mysql_fetch_row($result1)){
$last_value=$data;
echo "$last_value" ;
}
mysql_query("INSERT INTO connectableci (id,brand,model,serial_number,asset_ref) VALUES ($last_value,'$brand','$model','$serial_number','$asset_ref')");
mysql_query("INSERT INTO device (id) VALUES ($last_value)");
mysql_query("INSERT INTO infrastructureci (id,description,location_id,location_details,management_ip,default_gateway) VALUES ($last_value,'$description',$location_id,'$location_details','$management_ip','$default_gateway')");
mysql_query("INSERT INTO priv_change (date, userinfo) VALUES ('$tim2 ','$pp')");
$result1 = mysql_query("SELECT id FROM priv_change ORDER BY id DESC LIMIT 1");
while($data_change = mysql_fetch_row($result1)){
$last_value_change=$data_change;
// echo "$last_value_change" ;
}
mysql_query("INSERT INTO priv_changeop(changeid,objclass,objkey,optype) VALUES('$last_value_change','$finalclass','$last_value','$optype')");
$result_changeop = mysql_query("SELECT id FROM priv_changeop ORDER BY id DESC LIMIT 1");
while($data_changeop = mysql_fetch_row($result_changeop)){
$last_value_changeop=$data_changeop;
// echo "$last_value_change" ;
}
mysql_query("INSERT INTO priv_changeop_create (id) VALUES ($last_value_changeop)");
// some code
?>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
you always try the most difficult way right? :)
Why you don`t use the import function of iTop? There is already a doc in the wiki how to do it. There is an import.php already in place to import all CIs from csv or commandline or directly from an URL with GET vars. Why do you try to insert the CIs directly to the DB? It`s just a hint. Sometimes there is no other way (I know that).
regards
/Stefan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks Stefan ,
You are right ,But I follows my Team lead instruction what he says we should be follows.I like your suggestion of re-enginerring itop and I told to my senior just give me a time for re-enginnering itop.lets hope for best..
Regards
Pankaj khurana
pankaj6513atgmaildotcom
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
Actually my TASK is Integrate Nagios with CI in itop.
when HOST in Nagios changes or updated then CI in itop is also changes automatically.thats what i like to do.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have already done or used import.php but not getting so much success to solve above case/issue.But i am very much thanksful to itop support team..
Special Thanks to Stefen Sir
Pankaj khurana
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
when I created a new server:its show error
Sorry, this object does not exist (or you are not allowed to view it).
Thanks in advance
Actually i am creating a new server using php file just to check can we create a new server or other CI from php scripts just to insert values in server related database table
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("mdb", $con);
$name="Server5";
$status="production";
$org_id=3;
$importance="high";
$finalclass="Server";
$pp="IT Admin";
$optype="CMDBChangeOpCreate";
$brand="pUNJAB";
$model="Mysqlserver2.0.1";
$serial_number=9997797200;
$asset_ref="RFA5879";
$description="just for demo" ;
$location_id=3;
$location_details=" PUNJAB technologies pvt ltd";
$management_ip="192.128.1.241";
$default_gateway="192.128.1.241";
$tim2 = date("Y-m-d H:i:s");
//mysql_query("INSERT INTO connectableci (brand,model,serial_number,asset_ref) VALUES ('$brand','$model','$serial_number','$asset_ref')");
//mysql_query("INSERT INTO device (id) VALUES ('')");
mysql_query("INSERT INTO infrastructureci (description,location_id,location_details,management_ip,default_gateway) VALUES ('$description',$location_id,'$location_details','$management_ip','$default_gateway')");
mysql_query("INSERT INTO functionalci(name,status,org_id,importance,finalclass) VALUES ('$name','$status','$org_id','$importance','$finalclass')");
$result1 = mysql_query("SELECT id FROM functionalci ORDER BY id DESC LIMIT 1");
while($data = mysql_fetch_row($result1)){
$last_value=$data;
echo "$last_value" ;
}
mysql_query("INSERT INTO connectableci (id,brand,model,serial_number,asset_ref) VALUES ($last_value,'$brand','$model','$serial_number','$asset_ref')");
mysql_query("INSERT INTO device (id) VALUES ($last_value)");
mysql_query("INSERT INTO infrastructureci (id,description,location_id,location_details,management_ip,default_gateway) VALUES ($last_value,'$description',$location_id,'$location_details','$management_ip','$default_gateway')");
mysql_query("INSERT INTO priv_change (date, userinfo) VALUES ('$tim2 ','$pp')");
$result1 = mysql_query("SELECT id FROM priv_change ORDER BY id DESC LIMIT 1");
while($data_change = mysql_fetch_row($result1)){
$last_value_change=$data_change;
// echo "$last_value_change" ;
}
mysql_query("INSERT INTO priv_changeop(changeid,objclass,objkey,optype) VALUES('$last_value_change','$finalclass','$last_value','$optype')");
$result_changeop = mysql_query("SELECT id FROM priv_changeop ORDER BY id DESC LIMIT 1");
while($data_changeop = mysql_fetch_row($result_changeop)){
$last_value_changeop=$data_changeop;
// echo "$last_value_change" ;
}
mysql_query("INSERT INTO priv_changeop_create (id) VALUES ($last_value_changeop)");
// some code
?>
Hi, you should not add data in this table. Create a synchronization table instead.
https://sourceforge.net/apps/mediawiki/itop/index.php?title=Data_Synchronization
Hi,
you always try the most difficult way right? :)
Why you don`t use the import function of iTop? There is already a doc in the wiki how to do it. There is an import.php already in place to import all CIs from csv or commandline or directly from an URL with GET vars. Why do you try to insert the CIs directly to the DB? It`s just a hint. Sometimes there is no other way (I know that).
regards
/Stefan
Thanks Stefan ,
You are right ,But I follows my Team lead instruction what he says we should be follows.I like your suggestion of re-enginerring itop and I told to my senior just give me a time for re-enginnering itop.lets hope for best..
Regards
Pankaj khurana
pankaj6513atgmaildotcom
Hello,
Actually my TASK is Integrate Nagios with CI in itop.
when HOST in Nagios changes or updated then CI in itop is also changes automatically.thats what i like to do.
I have already done or used import.php but not getting so much success to solve above case/issue.But i am very much thanksful to itop support team..
Special Thanks to Stefen Sir
Pankaj khurana