Sponsored Content
Top Forums Shell Programming and Scripting Check connectivity with multiple hosts - BASH script available here Post 302937707 by Scrutinizer on Sunday 8th of March 2015 09:01:42 AM
Old 03-08-2015
Quote:
Originally Posted by Fr3dY
But that would only be true if error code 2 was added to the ignore list, right?
No. Just try it out..
Code:
$ ignoredErrors=(52 403 404 500)
$ for status in {0..10}; do printf "var status: $status "; if [[ "${ignoredErrors[@]}" =~ "$status" ]]; then echo yes; else echo no; fi; done
var status: 0 yes
var status: 1 no
var status: 2 yes
var status: 3 yes
var status: 4 yes
var status: 5 yes
var status: 6 no
var status: 7 no
var status: 8 no
var status: 9 no
var status: 10 no


Quote:
Tried it but couldn't make it work that way, still take the whole thing as a single option (I think that's why I used the array mode) Smilie
No it does not take it as a single option. It only does so if you put double quotes around it..

Code:
$ curlParameters=(--connect-timeout $timeout --insecure -S -s -f -o /dev/null)
$ printf "%s\n" ${curlParameters[@]}
--connect-timeout
--insecure
-S
-s
-f
-o
/dev/null
$ curlParameters="--connect-timeout $timeout --insecure -S -s -f -o /dev/null"
$ printf "%s\n" ${curlParameters}
--connect-timeout
--insecure
-S
-s
-f
-o
/dev/null

--edit--
But look what happens when you globally change IFS to $'\r\n' like you do in your script:
Code:
$ IFS=$'\r\n'
$ curlParameters="--connect-timeout $timeout --insecure -S -s -f -o /dev/null"
$ printf "%s\n" ${curlParameters}
--co

ect-timeout  --i
secu
e -S -s -f -o /dev/
ull

$ printf "%s\n" ${curlParameters[@]}
--co

ect-timeout
--i
secu
e
-S
-s
-f
-o
/dev/
ull
$ printf "%s\n" "${curlParameters[@]}"
--connect-timeout
--insecure
-S
-s
-f
-o
/dev/null


Last edited by Scrutinizer; 03-08-2015 at 10:33 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

script for df output from multiple hosts

I am trying get "df -k" output from multiple hosts along with their hostnames via ssh, my script is appending the "df -k" output from all the nodes to a single file but not getting the hostnames for those nodes, just wondering how to pass more than one command via ssh or may be someone could come... (6 Replies)
Discussion started by: barkath
6 Replies

2. Shell Programming and Scripting

Script to check connectivity

I want to write a script to check if a unix box say abc.tdc.cin.net can be connected or not on certain port say 22. right know i have to telnet them manually from DOS prompt and if it is successful then isay it is connected. Also to check Database connectivity I am using tnsping From DOS prompt.... (3 Replies)
Discussion started by: kukretiabhi13
3 Replies

3. Shell Programming and Scripting

Linux: Writing a tricky script to check connectivity

So, first and foremost, I'm having issues with my internet connection. Periodically, the connection drops across the network. The fix is simple enough: restart the modem. However, this gets old when the connection dies out every hour. I can hit my surfboard on 192.168.100.1, and navigate to a... (5 Replies)
Discussion started by: kungfujoe
5 Replies

4. Shell Programming and Scripting

Check connectivity script

This past weekend I had some issues with my ISP. So for future purpose I'm going to have some logging on my internet so I'm able to attach log files to my complaint email if this issue reoccurs. Decided to do a simple ping script that runs every 5 or 10 min with crontab if ping fail write date... (5 Replies)
Discussion started by: chipmunken
5 Replies

5. Solaris

Sybase Connectivity Check through Shell Script

Hi, I need to check the sysbase database connectivity through the Unix Shell Script. Can you help me on the how to write the script to test the sysbase database connection. Thanks in Advance Nandha (0 Replies)
Discussion started by: nandha2387
0 Replies

6. Shell Programming and Scripting

Check the connectivity of the DB through script, exit if no connection

check the connectivity of the DBs through script, script should exit if no connection and display the output as below. connectivity for DB1 is OK connectivity for DB2 is OK connectivity for DB3 is FAILED for DB in 1 2 3 do (sqlplus -s... (5 Replies)
Discussion started by: only4satish
5 Replies

7. Shell Programming and Scripting

How to write bash script for creating user on multiple Linux hosts?

I wonder whether someone can help me with what I'm trying to achieve Basically, the objective is one script to create new user on more than 70 linux hosts if required. Everything works apart from the highlighted part. It gave me an output passwd: Unknown user name ''. when try to set... (35 Replies)
Discussion started by: fugeulu
35 Replies

8. Shell Programming and Scripting

Bash script to detect nonpingable hosts

I have a script to detect if a host is pingable or not. The problem is that I would like it to put the nonpingable hosts in one file and the pingable hosts in another. I have come up with this so far: for ip in `cat /tmp/testlist2`; do ping -c 3 $ip >/dev/null && echo "$ip is up" || echo "$ip... (5 Replies)
Discussion started by: newbie2010
5 Replies

9. Shell Programming and Scripting

Help with shell script to check the tcp network connectivity between server

Hello, I have a requirement to check the tcp network connectivity between server it's running on and the list of host's and ports combination. i have written the below code but it doesn't work, but when i execute the nc command outside the script it works fine. please help me where i am... (8 Replies)
Discussion started by: sknovice
8 Replies

10. IP Networking

Help with to check the tcp network connectivity between servers and hosts

ello, i am new to the networking side. I have a requirement to check the tcp network connectivity between server it's running on and the list of host's and ports combination. please help me where i am going wrong. my code: #!/bin/bash #read the file line by line cd "$1" cat... (17 Replies)
Discussion started by: sknovice
17 Replies
OCF_HEARTBEAT_PGSQL(7)						OCF resource agents					    OCF_HEARTBEAT_PGSQL(7)

NAME
ocf_heartbeat_pgsql - Manages a PostgreSQL database instance SYNOPSIS
pgsql [start | stop | status | monitor | meta-data | validate-all | methods] DESCRIPTION
Resource script for PostgreSQL. It manages a PostgreSQL as an HA resource. SUPPORTED PARAMETERS
pgctl Path to pg_ctl command. (optional, string, default /usr/bin/pg_ctl) start_opt Start options (-o start_opt in pg_ctl). "-i -p 5432" for example. (optional, string, no default) ctl_opt Additional pg_ctl options (-w, -W etc..). (optional, string, no default) psql Path to psql command. (optional, string, default /usr/bin/psql) pgdata Path to PostgreSQL data directory. (optional, string, default /var/lib/pgsql/data) pgdba User that owns PostgreSQL. (optional, string, default postgres) pghost Hostname/IP address where PostgreSQL is listening (optional, string, no default) pgport Port where PostgreSQL is listening (optional, integer, default 5432) config Path to the PostgreSQL configuration file for the instance (optional, integer, no default) start_opt Additional options passed to the PostgreSQL server daemon. (optional, string, no default) pgdb Database that will be used for monitoring. (optional, string, default template1) logfile Path to PostgreSQL server log output file. (optional, string, default /dev/null) stop_escalate Number of shutdown retries (using -m fast) before resorting to -m immediate (optional, integer, no default) SUPPORTED ACTIONS
This resource agent supports the following actions (operations): start Starts the resource. Suggested minimum timeout: 120. stop Stops the resource. Suggested minimum timeout: 120. status Performs a status check. Suggested minimum timeout: 60. monitor Performs a detailed status check. Suggested minimum timeout: 30. Suggested interval: 30. meta-data Retrieves resource agent metadata (internal use only). Suggested minimum timeout: 5. validate-all Performs a validation of the resource configuration. Suggested minimum timeout: 5. methods Suggested minimum timeout: 5. EXAMPLE
The following is an example configuration for a pgsql resource using the crm(8) shell: primitive example_pgsql ocf:heartbeat:pgsql op monitor depth="0" timeout="30" interval="30" SEE ALSO
http://www.linux-ha.org/wiki/pgsql_(resource_agent) AUTHOR
Linux-HA contributors (see the resource agent source for information about individual authors) resource-agents 1.0.3 07/05/2010 OCF_HEARTBEAT_PGSQL(7)
All times are GMT -4. The time now is 07:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy