Hello,
I'm new to Observium and coming from Zenoss I have to say I love the simplicity and completeness of all the information available.
I'm just stuck on one issue. I've added the hosts I want to monitor to the /etc/hosts file and have successfully added a few hosts manually. I've been reading through the wiki and looking through google and can't seem to find a way to bulk import hosts.
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
i504562 being one of the hosts in the list routerdt1. If I run the addhost.php script manually it works.
./addhost.php i504562 mycomm v2c
Trying community mycomm ...
Discovering i545973 (42)i545973 42 ios (cisco)
(etc etc)
The file routerdt1 is in the format:
I553476 I553500 I553364 I553173 I553274 I542788 I554040 I554398 I554488
Is there a way to take my list and add them into Observium? Am I missing something where there could be an auto add function?
Thanks for your help on this, looking forward to using this product more.
--Dave
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
Chris, your script is functionally identical to David's. Changing variables to upper case and leaving out the quotes will make no difference.
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
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
observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
On 07/04/2013 01:46 PM, Rob J. Epping wrote:
Hi,
On Jul 4, 2013 12:23 AM, "Paul Gear" <observium@gear.dyndns.org mailto: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.
In the scripts that David & Chris have used, each word in the file would cause a separate iteration of the loop, so there are no circumstances under which $NODE in Chris' script would be different to "$file" in David's.
Paul
On Thu, Jul 4, 2013 at 6:41 AM, Paul Gear observium@gear.dyndns.org wrote:
On 07/04/2013 01: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.
In the scripts that David & Chris have used, each word in the file would cause a separate iteration of the loop, so there are no circumstances under which $NODE in Chris' script would be different to "$file" in David's.
Not completely true. $NODE or $file does not make a difference, but "$file" is different from $file, especially when $file is set to abc123[space]
you can check it out by using bash -x <script>. -- GRTNX, RobJE
Apologies for not being more specificin my reply. T'was specificallythe absence of the " symbols I was referencing in the bash one-liner. Obviously the variable name has no effect (caps vs lower). Just the variable I typically type out for loops like this. Glad to hear it was just a source-text-file issue.
-Chris
On 7/4/13 6:51 AM, Rob J. Epping wrote:
On Thu, Jul 4, 2013 at 6:41 AM, Paul Gear observium@gear.dyndns.org wrote:
On 07/04/2013 01: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.
In the scripts that David & Chris have used, each word in the file would cause a separate iteration of the loop, so there are no circumstances under which $NODE in Chris' script would be different to "$file" in David's.
Not completely true. $NODE or $file does not make a difference, but "$file" is different from $file, especially when $file is set to abc123[space]
you can check it out by using bash -x <script>.
GRTNX, RobJE _______________________________________________ observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
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 mailto: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
Thanks everyone for your help... In the end rookie mistake.. Had imported hosts list from a MS-Excel file and had removed the ^M's but it would seem it still had 'DOS' attributes. Quick dos2unix on the file and the script(s) are working.
Once again, many thanks for your help --Dave
On Thu, Jul 04, 2013 at 02:50:19PM +1000, Matt Taylor wrote:
Hi,
I did this when I bulk added hosts (note: pwd = /opt/observium):
- 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
file named "newhosts", which contains each host on a new line.
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 mailto: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
observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
participants (5)
-
Chris Moody
-
David Lagace
-
Matt Taylor
-
Paul Gear
-
Rob J. Epping