Hi,

I did this when I bulk added hosts (note: pwd = /opt/observium):

1) File named "addhost.sh", chmod +x it of course.

#!/bin/bash
echo "Adding: $1"
./addhost.php $1 communityhere v2c
./discovery.php -h $1
./poller.php -h $1

2) file named "newhosts", which contains each host on a new line.

3) Loop through "newhosts", adding each host etc..

for HOST in `cat newhosts`; do ./addhost.sh $HOST; sleep 5; done | tee /tmp/observium-addhost.log

Check "/tmp/observium-addhost.log" later on if there's any dramas.

Cheers,
Matt.

On 4/07/13 1:46 PM, Rob J. Epping wrote:

Hi,

On Jul 4, 2013 12:23 AM, "Paul Gear" <observium@gear.dyndns.org> wrote:
>
> Chris, your script is functionally identical to David's. Changing variables to upper case and leaving out the quotes will make no difference.

Quotes do make a difference when there is a space in the file. Because of the quotes it will become part of the hostname.

> David, can you ping the given host by name?  That message means that the name lookup (whether using the local hosts file or DNS) failed.
>
>
> On 07/04/2013 07:42 AM, Chris Moody wrote:
>>
>> Your bash loop syntax is likely the culprit.
>>
>> If you have your devices/nodes listed in a text file, I'd iterate like so:
>>
>> for NODE in `cat textfile.txt`; do ./addhost.php $NODE community v2c; done
>>
>> -Chris
>>
>> On 7/3/13 3:45 PM, David Lagace wrote:
>>>
>>> I tried to script it in the following way (please don't hurt me I'm not much
>>> of a coder)
>>>
>>> for file in `cat routerdt1`; do ./addhost.php "$file" mycomm v2c; done
>>>
>>>
>>> But keep getting:  Could not resolve i504562
>