- CheckMates
- :
- Products
- :
- Quantum
- :
- Security Gateways
- :
- Re: ifconfig output differs from manual execution ...
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Are you a member of CheckMates?
×- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ifconfig output differs from manual execution to script execution
Hello
I run a script every day on our VSX platform clusters with extracts a number of metrics for reporting about usage for each of our customers.
I wanted to expand the script to get the interface-values to make sure our documentation are up to date, but when I include this command to the bash-script:
ifconfig | grep -A1 Ethernet | grep -v '\-\-' | paste -sd ' \n' | awk '{ print $1","$7","$9 }' | awk -v vsname=$VS_NAME -F '[,:]' '{ print vsname","$1","$3"/"$5 }' >> /var/tmp/$Ldate-cp_facts_vs_interfaces_output-$1.txt
I get a different output, than if I run the command manually. The output in the script match what the \ifconfig puts out.
Example output:
Running command manually on a vs:
vs-customer1,bond1.3237,10.50.237.240/255.255.255.0
vs-customer1,bond3.1349,47.29.2.60/255.255.255.248
vs-customer1,wrp384,200.83.4.25/255.255.255.0
Running command in script on a vs:
vs-customer1,bond1.3237,100.127.48.1/255.255.255.240
vs-customer1,bond3.1349,100.127.48.17/255.255.255.240
vs-customer1,wrp384,100.127.48.33/255.255.255.240
Do I need to set a parameter in the script for ifconfig to give me the correct output, like with using specific checkpoint commands in scripts: source /etc/profile.d/CP.sh; ?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
On VSX in interactive shells, 'ifconfig' is intercepted by the alias you saw above, which returns false results based on the cluster VIPs. Real 'ifconfig'—which your headless script is using—returns the real data.
To get the fake data via your script, you can source /etc/profile.d/CP.sh, then call /bin/cp-ifconfig.sh instead of ifconfig.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I suspect you’re ultimately referencing a different ifconfig in your script:
Use the command “which ifconfig” to see the precise location of the ifconfig binary you use on the CLI.
Use that in your script to ensure you are calling the same ifconfig binary.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Running which in the command gives this:
# which ifconfig
alias ifconfig='/bin/cp-ifconfig.sh'
/bin/cp-ifconfig.sh
So its a CP-script. So perhaps I need the source /etc/profile.d/CP.sh; in my script after all.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
use "/sbin/ifconfig" in the script.
Jozko Mrkvicka
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Nope, that gives the undesired result.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try adding source /etc/profile.d/vsenv.sh to your script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Nope, doesn't work either.
its source /etc/profile.d/CP.sh, then call /bin/cp-ifconfig.sh instead of ifconfig as Bob_Zimmerman describes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
On VSX in interactive shells, 'ifconfig' is intercepted by the alias you saw above, which returns false results based on the cluster VIPs. Real 'ifconfig'—which your headless script is using—returns the real data.
To get the fake data via your script, you can source /etc/profile.d/CP.sh, then call /bin/cp-ifconfig.sh instead of ifconfig.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This worked! Thanks!
