What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

How to bulk update device name with linux

Votes:

0

Is there a way to bulk rename devices from a Linux machine?
EDIT by Paessler: Former content moved to answer!

api bulk-rename linux

Created on Sep 1, 2014 10:10:32 PM

Last change on Sep 3, 2014 6:35:31 AM by  Konstantin Wolff [Paessler Support]



Best Answer

Accepted Answer

Votes:

1

I've created a way to do a bulk update of name with a linux script.

First, get a csv of all devices in PRTG. (You need the device ID)

This can be done by using the api below

https://<servername or IP>/api/table.xml?content=devices&output=csvtable&columns=objid,probe,group,device,host,downsens,partialdownsens,downacksens,upsens,warnsens,pausedsens,unusualsens,undefinedsens&count=10000

Note: the count is 10,000. This will return 10,000 devices. Edit to fit needs.

Second, create a csv for your Linux script to use and save it as PRTGLIST.csv

  • The format of the csv is <DeviceID>,<NewDeviceName>
  • Remove the < and > from CSV Below is an example
1234,Router1
1235,Router2
1236,Router3

Third, create a bash script with the following contents

 #!/bin/bash

OLDIFS=$IFS

IFS=,

UNAME="INSERT USERNAME"

pass="INSERT PASSWORD"

[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }

while read PRTGID NEWNAME

do
        curl -k "https://<server name or IP>/api/rename.htm?id=$PRTGID&value=$NEWNAME&username=$UNAME&password=$pass"

done < PRTGLIST.csv

IFS=$OLDIFS

Created on Sep 3, 2014 2:07:25 AM

Last change on Sep 3, 2014 6:34:16 AM by  Konstantin Wolff [Paessler Support]



3 Replies

Votes:

0

@jlenhart: Thank you very much for sharing your thoughts. If possible would you post your post again as answer to this as done here.
This would allow other users to choose a best answer as well as upvote your answer. Thanks again for sharing!

Created on Sep 2, 2014 11:28:56 AM by  Konstantin Wolff [Paessler Support]



Accepted Answer

Votes:

1

I've created a way to do a bulk update of name with a linux script.

First, get a csv of all devices in PRTG. (You need the device ID)

This can be done by using the api below

https://<servername or IP>/api/table.xml?content=devices&output=csvtable&columns=objid,probe,group,device,host,downsens,partialdownsens,downacksens,upsens,warnsens,pausedsens,unusualsens,undefinedsens&count=10000

Note: the count is 10,000. This will return 10,000 devices. Edit to fit needs.

Second, create a csv for your Linux script to use and save it as PRTGLIST.csv

  • The format of the csv is <DeviceID>,<NewDeviceName>
  • Remove the < and > from CSV Below is an example
1234,Router1
1235,Router2
1236,Router3

Third, create a bash script with the following contents

 #!/bin/bash

OLDIFS=$IFS

IFS=,

UNAME="INSERT USERNAME"

pass="INSERT PASSWORD"

[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }

while read PRTGID NEWNAME

do
        curl -k "https://<server name or IP>/api/rename.htm?id=$PRTGID&value=$NEWNAME&username=$UNAME&password=$pass"

done < PRTGLIST.csv

IFS=$OLDIFS

Created on Sep 3, 2014 2:07:25 AM

Last change on Sep 3, 2014 6:34:16 AM by  Konstantin Wolff [Paessler Support]



Votes:

0

If curl doesn't work in your case (and it didn't in mine), you can substitute wget...

wget -q -O- --no-check-certificate

Created on Jan 28, 2016 7:16:27 PM




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.