Adding AS400 to Discovery
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2013 01:09 PM
Out of box, ServiceNow does not give us the ability to scan and classify AS400 devices. However, if your AS400 administrator is willing to open SSH on the boxes, then you can create probes and sensors to do the work just like as if it was a Unix machine.
/*******************************************************************************
***** < I have attached the XML data to import to your instance for easy installation! > **********
*******************************************************************************/
First, you need a UNIX CI Classifier (Name it AS400). I suggest a brand new table to put these devices on (we are using "u_i5_server").
Make the classification criteria 'output' CONTAINS 'OS400' and in the On classification script, you can put in something like this to start with:
current.os = "OS/400";
current.os_name = "OS/400";
current.short_description = output;
Now you need to make a multiprobe. Call it "AS400 - Identity" with ECC queue topic as "MultiProbe" and the ECC queue name as "AS400 - Identity." Ensure the probe is a MultiProbe and save it. Later, we will add items to the related lists "Includes probes" and "Sensors".
Now lets make the first probe. Call it "AS400 - OS" and make the ECC queue topic SSHCommand, and the ECC queue name as "uname -a" (without the quotes). This will get the Operating system from the AS400 since if you are using SSH the AS400 gives you a simple UNIX shell to work with. In this probe, ensure Used by discovery is selected and in the Related List "Included by Multiprobe" add the previously created AS400 - Identity multiprobe.
Now, in the MultiSensor Scripts related list for the AS400 - OS probe, click on New and paste this code:
function(result, ciData, debug, sensor) { var output = result.output; if (output === null || gs.nil(output)) return; run(output, ciData, debug); function run(output, ciData, debug) { var ci_data = ciData.getData(); var uname = output; var unameParts = uname.split(/ /); var osName = unameParts[0]; var osHostname = unameParts[1] ? unameParts[1] : "unknown.host"; var osVersion = unameParts[2] ? unameParts[2] : ""; ci_data.os_name = osName; ci_data.os_version = osVersion; ci_data.output = output; // Don't bother with ssh hostname if we shouldn't trust the ssh name and DNS already has already populated it var trusted = JSUtil.toBoolean(gs.getProperty("glide.discovery.hostname.ssh_trusted", "false")); var haveNow = JSUtil.notNil(ci_data['name']); var haveNew = JSUtil.notNil(osHostname); if (!haveNew) return; if (!trusted && haveNow) return; var hn = new HostnameJS(); ci_data['name'] = hn.format(osHostname, JSUtil.notNil(ciData.ip_address)? ciData.ip_address:null); } }
Make sure that it Reacts to Probe "AS400 - OS" and click Save or Update.
Now, create a brand new MultiSensor called AS400 - Identity and make sure that it Reacts to Probe: AS400 - Identity. Use the following in the Script:
new DiscoveryIDSensor({
type: "AS400 Identity"
});
Save the MultiSensor and in the related list, ensure that Responds to Probes related list has the "AS400 - OS" probe that you created earlier.
Now, ensure that you have an SSH credential that will work set up in the Credentials table!
Create a new discovery on an AS400 box you know of and then see what happens!
Once you have confirmed that this works, you can add additional probes to the MultiProbe in the related list "Includes probes". Since AS400 has a UNIX shell you can use, you can make a Filesystem probe with simply "df -kP" and you can make an Active Processes probe with "ps -aef". In these extended probes, just ensure that they are Triggered by your AS400 classifier and that there are Sensors defined for each!
For active processes, simply use this in the script for the sensor:
new DiscoveryPsSensor({ type: "DiscoverySensor" });
For Filesystems, use this code in the script for the sensor:
new DiscoverySensor({ fileSystems: {}, process: function(result) { if (gs.nil(result.output)) return; this.parseOutput(result.output); this.updateFileSystems(); }, updateFileSystems: function() { var fsList = []; for (var fs in this.fileSystems) { var fileSystem = {}; fileSystem.name = this.fileSystems[fs].name; fileSystem.capacity = this.fileSystems[fs].capacity; fileSystem.available_space = this.fileSystems[fs].available_space; fileSystem.mount_point = fs; fsList.push(fileSystem); } this.addToRelatedList('cmdb_ci_file_system', fsList, 'provided_by', 'pid'); }, parseOutput: function(output) { var lines = output.split(/\n/); for (var i = 0; i < lines.length; i++) { var line = lines<i>.trim(); // handle the case where one of our data lines was split because the name was too long... if (line.indexOf(' ') < 0) { if ((i + 1 < lines.length) && (lines[i + 1].charAt(0) == ' ')) { i++; line = line + ' ' + lines<i>.trim(); } } if (!line.startsWith('/dev/')) continue; var parts = line.split(/\s+/); this.fileSystems[parts[5]] = {}; this.fileSystems[parts[5]].name = parts[0]; this.fileSystems[parts[5]].capacity = Math.round(parseInt(parts[1]) / 1024); this.fileSystems[parts[5]].available_space = Math.round(parseInt(parts[3]) / 1024); } }, type: 'DiscoverySensor' });
I hope this helps someone.
- Labels:
-
Discovery
-
Service Mapping
- 12,881 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-11-2013 08:39 AM
That's great to hear! I'm glad it helped.
I've updated the post to include a .zip file of the XML data so it should be easier to set up now.
Thanks,
Dustin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2016 02:52 PM
Thanks for the great work here! Very helpful stuff.
I see a "Disk Usage" command referenced by one of the xml files, but there seems to be something missing. I dont see the command to use mentioned in the files or in this post? Or maybe i am just not seeing it?
thanks,
Shaun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-16-2014 10:46 AM
Thanks for this great post, however i expereinced a bit of a problem setting up the multi-sensor script. I received an error as "JavaScript parse error at line (29) column (26) problem = missing ) after condition" I am assuming this is because of a copy/paste where " &&" should be "&&".
I have made the adjustment and will post updates on progress as i am able (this is a pet project, not central focus yet)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2017 09:02 AM
Is the custom route still the only way to discovery iSeries servers?
Has anyone created documentation on implimenting the functionality or do I need to glean it from the above posts?
Thanks everyone
TC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2017 02:09 PM
Thomas,
Yes, the above post is all we have for now. Personally I would like to see this rewritten as a Pattern but until Jakarta is released I am holding off...hoping they add it in natively.
Regards,
Shaun