Id like to change a node details poller via the API with a Python script. Does anyone know if this can be done and if so how? I saw a post from about 5 or 6 years ago saying it couldnt, but wondered if its possible now?
Thanks
There is a github for solarwinds API using python her is the link https://github.com/solarwinds/orionsdk-python/tree/master. I recently created a python script to bulk update nodes captions using python and it work without any issues so I am sure you can do the same for the details. If you want to see the script I used for the captions just let me know and I will provide it.
Hi There I'm interested in your script if you can provide it, this is what I'm trying to do, I have a List of 1000 devices that will only be monitored using ICMP, I can easily add these using the discovery but what I need to do is update the devices to the correct hostname based on the IP address,
In this script I just use an excel spreadsheet that has column A IPAddress and column B as Name. The script will load the data from the spreadsheet make an API connection to Solarwinds will then query for node details then look through that data to update the captions field in Solarwinds. If no IPAddress match is found then it will be skipped. Make sure to replace Solarwind IP with your IP, Username and password. Also update the spreadsheet path. Let me know if you have any questions.
Here is the source code:
import pandas as pdimport requestsfrom orionsdk import SwisClient# SolarWinds server and spreadsheet informationnpm_server = 'Solarwind IP'username = 'Solarwinds Username'password = 'Solarwinds Password'verify = Falseif not verify: from requests.packages.urllib3.exceptions import InsecureRequestWarning requests.packages.urllib3.disable_warnings(InsecureRequestWarning)spreadsheet_path = "C:\\Users\\Username\\Documents\\My Projects\\Spreadsheets\\ImportExample.xlsx" # Update with the path to your spreadsheet# Load data from the spreadsheetspreadsheet_data = pd.read_excel(spreadsheet_path)# Create a SwisClient for SolarWinds APIswis = SwisClient(npm_server, username, password)# Define the query to retrieve node informationquery = "SELECT Nodes.NodeID, Nodes.Uri, Nodes.Caption FROM Orion.Nodes AS Nodes"try: # Execute the query to get node data results = swis.query(query) # Extract the Uris and Captions from the results uris = [row['Uri'] for row in results['results']] captions = [row['Caption'] for row in results['results']] # Iterate through nodes and update captions from the spreadsheet for uri, caption in zip(uris, captions): matching_row = spreadsheet_data[spreadsheet_data["IPAddress"] == caption] if not matching_row.empty: new_caption = matching_row["Name"].values[0] print(f"Updating caption on {caption} to {new_caption}") # Update the node's Caption field in SolarWinds swis.update(uri, Caption=new_caption) else: print(f"No matching data found for {caption}. Skipping.")except Exception as e: print(f"Error: {str(e)}")
Thank you so much for taking the time to reply and help me, I did find something on Thwack to help me, I ended up using this post https://thwack.solarwinds.com/product-forums/the-orion-platform/f/orion-sdk/96480/how-to-powershell-script-that-allows-you-to-bulk-edit-captions-from-a-spreadsheet
but I will be using what you have provided to brush up my Powershell Skills