Skip to content

Commit b3cf2a0

Browse files
Merge pull request #27 from jerewill-cisco/1.3.1
1.3.1
2 parents d1ca72c + d701462 commit b3cf2a0

File tree

6 files changed

+367
-53
lines changed

6 files changed

+367
-53
lines changed

README.md

Lines changed: 298 additions & 45 deletions
Large diffs are not rendered by default.

images/add_intersight.png

-416 Bytes
Loading

input_module_intersight.py

Lines changed: 60 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ def get_checkpoint(type):
6060
f"{account_name}_last_{type}_record")
6161
helper.log_debug(
6262
f"{s} | Checkpoint value for {type} records is {state}")
63+
if (state == None or state == "None"):
64+
raise Exception("State is none")
6365
return state
6466
except:
6567
# set the state if it's not set
@@ -215,7 +217,9 @@ def write_splunk(index, source, sourcetype, data):
215217
state = get_checkpoint('audit')
216218
# get the audit records
217219
RESPONSE = r_intersight(
218-
f"{endpoint}?$orderby=ModTime%20asc&$filter=ModTime%20gt%20{state}")
220+
f"{endpoint}?$inlinecount=allpages&$orderby=ModTime%20asc&$filter=ModTime%20gt%20{state}")
221+
helper.log_info(
222+
f"{s} | Found {RESPONSE.json()['Count']} audit records to retrieve")
219223
# process the audit records
220224
for data in RESPONSE.json()['Results']:
221225
# pop things we don't need
@@ -252,8 +256,9 @@ def write_splunk(index, source, sourcetype, data):
252256
state = get_checkpoint('alarm')
253257
# Let's get the alarm records
254258
RESPONSE = r_intersight(
255-
f"{endpoint}?$orderby=ModTime%20asc&$filter=ModTime%20gt%20{state}")
256-
259+
f"{endpoint}?$inlinecount=allpages&$orderby=ModTime%20asc&$filter=ModTime%20gt%20{state}")
260+
helper.log_info(
261+
f"{s} | Found {RESPONSE.json()['Count']} alarm records to retrieve")
257262
# Process the alarm records
258263
for data in RESPONSE.json()['Results']:
259264
data = pop(['AffectedMo', 'Ancestors', 'Owners', 'PermissionResources',
@@ -331,6 +336,8 @@ def write_splunk(index, source, sourcetype, data):
331336
###
332337
# Compute Inventory
333338
###
339+
340+
# Servers
334341
endpoint = "compute/PhysicalSummaries"
335342
if 'compute' in opt_inventory and doInventory:
336343
helper.log_debug(f"{s} | Retrieving Compute Inventory Records")
@@ -347,11 +354,14 @@ def write_splunk(index, source, sourcetype, data):
347354
f"{endpoint}?$expand=RegisteredDevice($select=ClaimedByUserName,ClaimedTime,ConnectionStatusLastChangeTime,ConnectionStatus,CreateTime,ReadOnly)&$top={results_per_page}&$skip={str(i)}")
348355
for data in RESPONSE.json()['Results']:
349356
data = pop(
350-
['Ancestors', 'PermissionResources', 'Owners', 'DomainGroupMoid', 'ClassId', 'FaultSummary', 'EquipmentChassis', 'InventoryDeviceInfo', 'KvmVendor', 'ObjectType', 'ScaledMode', 'Rn', 'SharedScope'], data)
357+
['Ancestors', 'Parent', 'Uuid', 'HardwareUuid', 'TopologyScanStatus', 'PermissionResources', 'Owners', 'DomainGroupMoid', 'ClassId', 'FaultSummary', 'Personality', 'InventoryDeviceInfo', 'KvmVendor', 'ObjectType', 'ScaledMode', 'Rn', 'SharedScope'], data)
351358
data['RegisteredDevice'] = pop(
352359
['ClassId', 'ObjectType'], data['RegisteredDevice'])
353360
data['AlarmSummary'] = pop(
354361
['ClassId', 'ObjectType'], data['AlarmSummary'])
362+
if data['EquipmentChassis'] != None:
363+
data['EquipmentChassis'] = pop(
364+
['ClassId', 'ObjectType', 'link'], data['EquipmentChassis'])
355365
write_splunk(index, account_name,
356366
'cisco:intersight:computePhysicalSummaries', data)
357367
# try to get HCL data also
@@ -373,6 +383,48 @@ def write_splunk(index, source, sourcetype, data):
373383
helper.log_debug(
374384
f"{s} | HCL for {data['Moid']} not found")
375385

386+
# Chassis
387+
endpoint = "equipment/Chasses"
388+
if 'compute' in opt_inventory and doInventory:
389+
helper.log_debug(f"{s} | Retrieving Chassis Inventory Records")
390+
doChassis = check_intersight(endpoint)
391+
392+
if 'compute' in opt_inventory and doInventory and doChassis:
393+
RESPONSE = r_intersight(f"{endpoint}?$count=True")
394+
count = RESPONSE.json()['Count']
395+
helper.log_info(
396+
f"{s} | Found {str(count)} chassis inventory records to retrieve")
397+
results_per_page = 10 # adjust the number of results we pull per API call
398+
for i in range(0, count, results_per_page):
399+
RESPONSE = r_intersight(
400+
f"{endpoint}?$top={results_per_page}&$skip={str(i)}&$expand=Siocs($select=ConnectionPath,ConnectionStatus,Dn,Model,OperState,Serial,SystemIoControllerId),Ioms($select=ConnectionPath,ConnectionStatus,Dn,Model,ModuleId,OperReason,OperState,Serial,Side,Version,Vid),FanControl($select=Mode),Fanmodules($select=Model,OperState,OperReason),PsuControl($select=Redundancy),Psus($select=Model,OperReason,OperState,PsuId,PsuInputSrc,PsuWattage,Voltage),ExpanderModules($select=Dn,Model,ModuleId,OperReason,OperState,Serial),PowerControlState($select=ExtendedPowerCapacity,AllocatedPower,GridMaxPower,MaxRequiredPower,MinRequiredPower,N1MaxPower,N2MaxPower,NonRedundantMaxPower,PowerRebalancing,PowerSaveMode)")
401+
for data in RESPONSE.json()['Results']:
402+
data = pop(['Ancestors', 'ClassId', 'DeviceMoId', 'DomainGroupMoid', 'FaultSummary', 'InventoryDeviceInfo', 'Sasexpanders', 'StorageEnclosures',
403+
'LocatorLed', 'ObjectType', 'Owners', 'PermissionResources', 'RegisteredDevice', 'SharedScope', 'VirtualDriveContainer'], data)
404+
for x in range(0, len(data['Blades'])):
405+
data['Blades'][x] = pop(
406+
['ClassId', 'ObjectType', 'link'], data['Blades'][x])
407+
for x in range(0, len(data['Fanmodules'])):
408+
data['Fanmodules'][x] = pop(
409+
['ClassId', 'ObjectType', 'Moid'], data['Fanmodules'][x])
410+
for x in range(0, len(data['Ioms'])):
411+
data['Ioms'][x] = pop(
412+
['ClassId', 'ObjectType', 'Moid'], data['Ioms'][x])
413+
for x in range(0, len(data['Siocs'])):
414+
data['Siocs'][x] = pop(
415+
['ClassId', 'ObjectType', 'Moid'], data['Siocs'][x])
416+
for x in range(0, len(data['ExpanderModules'])):
417+
data['ExpanderModules'][x] = pop(
418+
['ClassId', 'ObjectType', 'Moid'], data['ExpanderModules'][x])
419+
for x in range(0, len(data['Psus'])):
420+
data['Psus'][x] = pop(
421+
['ClassId', 'ObjectType', 'Moid'], data['Psus'][x])
422+
for x in ['AlarmSummary', 'PsuControl', 'FanControl', 'PowerControlState']:
423+
data[x] = pop(['ClassId', 'ObjectType', 'Moid'], data[x])
424+
length = len(json.dumps(data))
425+
write_splunk(
426+
index, account_name, 'cisco:intersight:equipmentChassis', data)
427+
376428
if not 'compute' in opt_inventory:
377429
helper.log_debug(
378430
f"{s} | Compute was not selected in the Inventory configuration")
@@ -484,7 +536,7 @@ def write_splunk(index, source, sourcetype, data):
484536
f"{endpoint}?$expand=Encryption($select=State),License,RegisteredDevice($select=ClaimedByUserName,ClaimedTime,ConnectionStatusLastChangeTime,ConnectionStatus,CreateTime,ReadOnly)&$top={results_per_page}&$skip={str(i)}")
485537
for data in RESPONSE.json()['Results']:
486538
data = pop(['Alarm', 'Ancestors', 'ChildClusters', 'DomainGroupMoid', 'ClassId', 'Owners', 'ObjectType', 'PermissionResources',
487-
'StorageContainers', 'SharedScope', 'Nodes', 'Health', 'ParentCluster', 'Volumes'], data)
539+
'StorageContainers', 'SharedScope', 'Nodes', 'Health', 'ParentCluster', 'Volumes', 'StorageClientIpPools', 'StorageClientVrf'], data)
488540
data['License'] = pop(
489541
['Ancestors', 'Cluster', 'Owners', 'DomainGroupMoid', 'PermissionResources', 'RegisteredDevice'], data['License'])
490542
data['RegisteredDevice'] = pop(
@@ -668,7 +720,8 @@ def write_splunk(index, source, sourcetype, data):
668720
# NetApp Storage VMs
669721
endpoint = "storage/NetAppStorageVms"
670722
if 'netapp' in opt_inventory and doInventory:
671-
helper.log_debug(f"{s} | Retrieving NetApp Storage VM Inventory Records")
723+
helper.log_debug(
724+
f"{s} | Retrieving NetApp Storage VM Inventory Records")
672725
doNetAppStorageVms = check_intersight(endpoint)
673726

674727
if 'netapp' in opt_inventory and doInventory and doNetAppStorageVms:
@@ -742,7 +795,7 @@ def write_splunk(index, source, sourcetype, data):
742795
RESPONSE = r_intersight(
743796
f"{endpoint}?$expand=RegisteredDevice($select=ClaimedByUserName,ClaimedTime,ConnectionStatusLastChangeTime,ConnectionStatus,CreateTime,ReadOnly)&$top={results_per_page}&$skip={str(i)}")
744797
for data in RESPONSE.json()['Results']:
745-
data = pop(['Ancestors', 'DomainGroupMoid', 'ClassId', 'DeviceMoId', 'Owners',
798+
data = pop(['Ancestors', 'DomainGroupMoid', 'ClassId', 'DeviceMoId', 'Owners', 'ProtectionGroup',
746799
'ObjectType', 'PermissionResources', 'SharedScope', 'Uuid'], data)
747800
for x in ['RegisteredDevice', 'StorageUtilization']:
748801
data[x] = pop(['ClassId', 'ObjectType'], data[x])

splunk_em.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def get_arg(self, arg_name):
2424
if arg_name == 'validate_ssl':
2525
return True
2626
if arg_name == 'enable_aaa_audit_records':
27-
return False
27+
return True
2828
if arg_name == 'enable_alarms':
2929
return True
3030
if arg_name == 'inventory_interval':

splunkbase/details.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ The Add-on leverages the [Cisco Intersight RESTful API](https://intersight.com/a
1010
| Alarms | [cond/Alarms][2] | cisco:intersight:condAlarms |
1111
| Advisories | [tam/AdvisoryInstances][3] | cisco:intersight:tamAdvisoryInstances |
1212
| Compute | [compute/PhysicalSummaries][4] | cisco:intersight:computePhysicalSummaries |
13+
| Compute | [equipment/Chasses][26] | cisco:intersight:equipmentChassis |
1314
| Compute | [cond/HclStatuses][9] | cisco:intersight:condHclStatuses |
1415
| Contract | [asset/DeviceContractStatusInformations][10] | cisco:intersight:assetDeviceContractInformations |
1516
| Hitachi | [storage/HitachiArrays][19] | cisco:intersight:storageHitachiClusters |
@@ -57,6 +58,7 @@ The Add-on leverages the [Cisco Intersight RESTful API](https://intersight.com/a
5758
[23]: https://intersight.com/apidocs/apirefs/api/v1/license/LicenseInfos/model/
5859
[24]: https://intersight.com/apidocs/apirefs/api/v1/hyperflex/Licenses/model/
5960
[25]: https://intersight.com/apidocs/apirefs/api/v1/storage/NetAppStorageVms/model/
61+
[26]: https://intersight.com/apidocs/apirefs/api/v1/equipment/Chasses/model/
6062

6163
Further documentation, sample searches, and known issues are all available at [the Github repository](https://github.com/jerewill-cisco/intersight-splunk-addon).
6264

splunkbase/releasenotes.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Cisco Intersight Add-on for Splunk Release Notes
22

3+
## 1.3.1 - 3 August 2022
4+
5+
- Found a serious bug in checkpointing that might cause Audit Logs and Alerts to never be retrieved for an input
6+
- Additional pruning for cisco:intersight:computePhysicalSummaries and a few other items
7+
- Added cisco:intersight:equipmentChassis to Compute inventory
8+
39
## 1.3.0 - 28 July 2022
410

511
>New Inventory types are not automatically added to existing configurations. Please review your input configurations after upgrading to enable the new options.

0 commit comments

Comments
 (0)