Last active
August 29, 2015 14:07
-
-
Save asimpkin/9c0ae5fbbf2cca8331d5 to your computer and use it in GitHub Desktop.
A script to query the ServiceNow CMDB locating Linux production servers wo. an application relationship.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include("../common.inc.php"); | |
start_page("Linux Servers without Provides Production For :: Applications"); | |
// get stuff | |
$arr = getXML('cmdb_ci_linux_server','operational_status=1'); | |
// query for a production relationship where the parent is the application | |
foreach($arr as $k => $v) { | |
$query='child.sys_id='.$k; // PROD PROVIDED BY | |
$t = getXML('cmdb_rel_ci',$query); | |
if($t) unset($arr[$k]); // if you find a relationsip remove the key from the array | |
} // end test | |
// the remaining application are operational with no production server specified | |
echo'<table width=300 border=0><tr> | |
<th>Server Name | |
<th>Used For | |
<th>Link'; | |
foreach($arr as $v) echo '<tr> | |
<td>'.$v[name].' | |
<td>'.$v[used_for].' | |
<td><a href=https://[YOURINSTANCE].service-now.com/nav_to.do?uri=cmdb_ci_linux_server.do?sys_id='.$v[sys_id].'>'.$v[sys_id].'</a>'; | |
echo'<tr><th>'.count($arr).'<th></table>'; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment