Shell script to get the IP address of running instance

40 views
Skip to first unread message

Amit Saini

unread,
Jan 9, 2017, 4:48:55 PM1/9/17
to scalr-discuss

Hi,

Is there any shell script to get the IP address of running instance from scalr database...??


Regards

Amit Saini

Jeff Gojkovich

unread,
Jan 10, 2017, 5:56:14 PM1/10/17
to scalr-discuss
Would the query be originating from the local instance, the Scalr servers, or some other location?

--
Jeff
Message has been deleted

Marc O'Brien

unread,
Jan 11, 2017, 3:29:48 PM1/11/17
to scalr-discuss
Hi Amit,

As Jeff noted, we need to get a bit of additional context about your use case so that we may provide the best recommendation.  Are you attempting to query this from the Scalr server and retrieve results from the Scalr database, or are you looking to obtain this information on your running instances as part of an Orchestration script?  Otherwise, are you looking to gather this information from your local workstation? What do you plan to do with these IPs once you have your query results?  This information will help to clarify your needs and isolate the best method to achieve your desired results.

Many thanks,
Wm. Marc O'Brien
Scalr Technical Support



On Monday, January 9, 2017 at 2:48:55 PM UTC-7, Amit Saini wrote:

Amit Saini

unread,
Jan 11, 2017, 3:37:07 PM1/11/17
to scalr-discuss

 Hi Marc,

I am planning to build a shell script to install the ansible on newly created instances because of that i need the Instance's IP address


Regards
Amit Saini

Marc O'Brien

unread,
Jan 11, 2017, 3:46:22 PM1/11/17
to scalr-discuss
Hi Amit,

Depending on the scope of the IPs you are interested in, you should be able to achieve this by using szradm queryenv within your orchestration script.  Let us know if you have any questions or troubles with implementation.


Many thanks,
Wm. Marc O'Brien
Scalr Technical Support

Amit Saini

unread,
Jan 13, 2017, 10:14:36 AM1/13/17
to scalr-discuss
Thanks Marc

Daniele Testa

unread,
Jan 13, 2017, 10:35:28 AM1/13/17
to scalr-...@googlegroups.com
Amit, this is already available to your scripts in the built-in Global Variables. Just make a simple script like:

#!/bin/bash
env

Then put it on the BeforeHostUp event on one of your Farm Roles and launch an instance. If you then look in the Orchestration Log, you will be able to see the complete list of built-in Global Variables that are available to your script.

In your specific case, as you need the instance IP address, the name of the Global Variables are:

SCALR_INTERNAL_IP
SCALR_EXTERNAL_UP

Access them in your script as normal Environment Variables, such as:

echo $SCALR_INTERNAL_IP
echo $SCALR_EXTERNAL_IP

--
You received this message because you are subscribed to the Google Groups "scalr-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalr-discuss+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Regards,
Daniele Testa | Sr. Solutions Architect @ Scalr | dan...@scalr.com | www.scalr.com | blog.scalr.com

Amit Saini

unread,
Jan 13, 2017, 10:53:22 AM1/13/17
to scalr-discuss
Thanks Deniele,

Its working....Its printed both Public and Private IP

To unsubscribe from this group and stop receiving emails from it, send an email to scalr-discus...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Auto Generated Inline Image 1
Reply all
Reply to author
Forward
0 new messages