Reply
Highlighted

NetMRI Broker - Remote Command

[ Edited ]
mrsold
Techie
Posts: 8
3302     0

Hey All,

 

I have tried digging through examples and documentation but I'm not sure how to get the info I'm trying to do.  Essentially, I'd like to use the python broker to call the NetMRI API, get a list of devices in the device group and then use NetMRI to run some commands against that list.  The latter portion of this I can do and know how to do pretty easily and I've used the broker before to pull a list (can't say I remember how I got the id ^_~) but as far as pulling items from a device list, I'm a bit stumped...

 

Thanks!

 

Edit - I think I figured out the device portion and getting the list of items.  Still piecing together what variable names to use for what...

Re: NetMRI Broker - Remote Command

CHindy
Techie
Posts: 2
3303     0

I think what you want to do is first do a search on DeviceGroups bounded by GroupName.  For example, if you had a group called "Cisco" you could send a GET on:

 

https://<your-netmri>/api/3.2/device_groups/search?GroupName=Cisco

 

and that would give you back a JSON blob like:

 

 

{
  "total": 1,
  "start": 0,
  "limit": 1000,
  "current": 1,
  "device_groups": [
    {
      "ARPCacheRefreshInd": true,
      "AdvancedGroupInd": true,
      "CCSCollection": 1,
      "CLIPolling": 0,
      "ConfigLocked": false,
      "ConfigPolling": 1,
      "Criteria": "$Vendor = \"Cisco\"",
      "DataSourceID": 0,
      "DeviceGroupChangedCols": null,
      "DeviceGroupDefnID": 25,
      "DeviceGroupEndTime": null,
      "DeviceGroupID": 25,
      "DeviceGroupStartTime": "2017-10-08 01:25:04",
      "DeviceGroupTimestamp": "2018-01-20 13:57:18",
      "FingerPrint": 0,
      "GroupID": 25,
      "GroupName": "Cisco",
      "IncludeEndHostsInd": false,
      "MemberCount": 4,
      "NetBIOSScanningInd": false,
      "ParentDeviceGroupID": 24,
      "PerfEnvPollingInd": true,
      "PolicyScheduleMode": "change",
      "PortScanning": 1,
      "Rank": "1127024707237838848",
      "SAMLicensedInd": false,
      "SNMPAnalysis": 1,
      "SNMPPolling": 1,
      "SPMCollectionInd": true,
      "StandardsCompliance": 0,
      "VendorDefaultCollection": 0,
      "_class": "DeviceGroup"
    }
  ]
}

The key attribute you want from this collection is GroupID:

 

"GroupID": 25,

 

which you can then feed into a GroupMembers search, a la:

 

https://<your-netmri>/api/3.2/device_group_members/search?GroupID=25

and you'll get back:

 

{
    "total": 4,
    "start": 0,
    "limit": 1000,
    "current": 4,
    "device_group_members": [
        {
            "DataSourceID": 0,
            "DeviceGroupMemberChangedCols": null,
            "DeviceGroupMemberEndTime": null,
            "DeviceGroupMemberID": 121,
            "DeviceGroupMemberStartTime": "2017-10-08 01:25:05",
            "DeviceGroupMemberTimestamp": "2018-03-18 07:24:42",
            "DeviceID": 3,
            "GroupID": 25,
            "_class": "DeviceGroupMember"
        },
        {
            "DataSourceID": 0,
            "DeviceGroupMemberChangedCols": null,
            "DeviceGroupMemberEndTime": null,
            "DeviceGroupMemberID": 122,
            "DeviceGroupMemberStartTime": "2017-10-08 01:25:05",
            "DeviceGroupMemberTimestamp": "2018-03-21 20:14:06",
            "DeviceID": 4,
            "GroupID": 25,
            "_class": "DeviceGroupMember"
        },
        {
            "DataSourceID": 0,
            "DeviceGroupMemberChangedCols": null,
            "DeviceGroupMemberEndTime": null,
            "DeviceGroupMemberID": 294,
            "DeviceGroupMemberStartTime": "2017-10-31 20:12:07",
            "DeviceGroupMemberTimestamp": "2018-03-21 18:22:08",
            "DeviceID": 6,
            "GroupID": 25,
            "_class": "DeviceGroupMember"
        },
        {
            "DataSourceID": 0,
            "DeviceGroupMemberChangedCols": null,
            "DeviceGroupMemberEndTime": null,
            "DeviceGroupMemberID": 352,
            "DeviceGroupMemberStartTime": "2017-11-05 01:26:07",
            "DeviceGroupMemberTimestamp": "2018-03-21 13:34:08",
            "DeviceID": 74,
            "GroupID": 25,
            "_class": "DeviceGroupMember"
        }
    ]
}

and then finally for each member of the group you can set a GET on 

 

https://<your-netmri>/api/3.2/devices/search?DeviceID=74

 

and get back the device's details:

 

{
    "total": 1,
    "start": 0,
    "limit": 1000,
    "current": 1,
    "devices": [
        {
            "DataSourceID": 0,
            "DeviceAddlInfo": null,
            "DeviceAssurance": 99,
            "DeviceChangedCols": "DeviceUniqueKey",
            "DeviceDNSName": "router1.somedom.net",
            "DeviceEndTime": null,
            "DeviceFirstOccurrenceTime": "2017-11-05 01:21:04",
            "DeviceID": 74,
            "DeviceIPDotted": "10.255.255.2",
            "DeviceIPNumeric": 184549122,
            "DeviceMAC": "00:19:E8:69:2F:B8",
            "DeviceModel": "2811",
            "DeviceName": "router1",
            "DeviceNetBIOSName": null,
            "DeviceOUI": "Cisco",
            "DeviceStartTime": "2018-03-21 13:32:46",
            "DeviceSysContact": "Joe Bloggs",
            "DeviceSysDescr": "Cisco IOS Software, 2800 Software (C2800NM-ADVENTERPRISEK9-M), Version 15.1(4)M9, RELEASE SOFTWARE (fc3)  Technical Support: http://www.cisco.com/techsupport  Copyright (c) 1986-2014 by Cisco Systems, Inc.  Compiled Fri 12-Sep-14 10:45 by prod_rel_team",
            "DeviceSysLocation": "Server Rack, Bay 1",
            "DeviceSysName": "router1.somedom.net",
            "DeviceTimestamp": "2018-03-21 23:43:33",
            "DeviceType": "Router",
            "DeviceUniqueKey": "0f:1a:85:3b:7b:a0:2f:41:fb:57:bc:26:59:4c:0d:e5",
            "DeviceVendor": "Cisco",
            "DeviceVersion": "15.1(4)M9",
            "InfraDeviceInd": true,
            "MgmtServerDeviceID": 0,
            "NetworkDeviceInd": true,
            "ParentDeviceID": 0,
            "VirtualInd": false,
            "VirtualNetworkID": 1,
            "custom_psirt_severity_threshold": null,
            "custom_psirt_low_threshold": null,
            "custom_eox_status": "End of Support",
            "custom_end_of_sale": "2011-11-01",
            "custom_end_of_support": "2016-10-31 00:00:00",
            "_class": "Device"
        }
    ]
}

 

Of course, if you're only interested in certain details, you can focus your searches more tightly to optimize.

 

Hope this helps!

-c

Re: NetMRI Broker - Remote Command

jackyworne
Techie
Posts: 2
3303     0

Re: NetMRI Broker - Remote Command

jackyworne
Techie
Posts: 2
3303     0
<?php
// no direct access
defined ('_JEXEC') or die;
class plgContentExample extends JPlugin
{
	/**
	 * Load the language file on instantiation.
	 * Note this is only available in Joomla 3.1 and higher.
	 * If you want to support 3.0 series you must override the constructor
	 *
	 * @var boolean
	 * @since <your version>
	 */
	protected $autoloadLanguage = true;
 
	/**
	 * Prepare form and add my field.
	 *
	 * @param   JForm  $form  The form to be altered.
	 * @param   mixed  $data  The associated data for the form.
	 *
	 * @return  boolean
	 *
	 * @since   <your version>
	 */
	function onContentPrepareForm($form, $data)
	{
		$app    = JFactory::getApplication();
		$option = $app->input->get('option');
 
		switch($option)
		{
			case 'com_contact' :
				if ($app->isAdmin())
				{
					JForm::addFormPath(__DIR__ . '/forms');
					$form->loadFile('contact', false);
				}
 
				return true;
		}
 
		return true;
	}
}
?>

 

 

Re: NetMRI Broker - Remote Command

jackymltd
Techie
Posts: 1
3303     0
Wow, This is very impressive blog post. so many peoples like it and me. many many thanks for sharing this blog post with us. This is very informative and interesting like blog and article.
Showing results for 
Search instead for 
Do you mean 

Recommended for You