Skip to content

Instantly share code, notes, and snippets.

@asimpkin
Last active August 29, 2015 14:07
Show Gist options
  • Save asimpkin/9c0ae5fbbf2cca8331d5 to your computer and use it in GitHub Desktop.
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.
<?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