*ix script to check port of client server and return output
Hello EveryOne,
I am new to *ix. some could help to write a script.
Problem :- Have to ssh to so many client and check port or filesystem usage, so thinking to automate using script.
What i Need:- when i run script on my Launchpad server, it should
Should ask and SSH to user provided Server -> Authenticate User password-> Run port check commands (netstat) or Filesystem usage (df -k) -> return output to Launchpad server server screen(where i ran that script)
if fails to do- Return a valid reason( file not found) or (server not available)
You shouldn't use a password to log on to your servers from the launch pad system. Use exchanged keys instead.
You might want to design your script so that it reads from a list all the host names it has to work on. This way you can design a "template script" which provides the base logic of cycling through all the servers in the list, contacting them, writing the results in a log, etc..
You will need some logic to handle servers which are unreachable for some reason (not pingable, key not exchanged, network not reachable, ...). If the list of servers is really long you probably have always one or the other which is unreachable in the moment your run your script, so it should better be able to deal with such a condition until you don't want to do an awful lot of handiwork during its run. "Deal with it" meaning something as simple as writing the hostname in an output file "hosts.failed" for instance.
Run your tasks separately, so that you can handle all the logic on the launch pad server. It is easier to handle this locally:
then to handle it remote:
or, even more troublesome, first "roll out" all sorts of scripts to the remote servers and only then execute these from the central script. Chances are you introduce a lot of inconsistencies though this error-prone way, where older versions of your scripts interfere with newer versions, etc..
Ideally you can parallelize the work on remote servers by creating a special script which handles exactly one remote host and call that from a control script looping through the list of hosts. Put the calls to this script in the background and use "wait" and some counter to limit the number of background processes running in parallel. (You might want to avoid hitting the limit on processes on your launch pad box.)
In our work environment i have hell lot of servers. In a day i get 20 to 30 tickets or requests saying a port check have been failed on so and so(6445 or 6996) node. so everytime its new server(even i dont know there names)
script should prompt.
enter username
enter node name;
enter password
enter port number to check
check port (listening or established or nothing) and show me the result.
if the port is not up or server is unreachable show fixed error(try manually human :-)))
please help... i am fed up of doing same lengthy steps to check the tickets.
Hi,
I am trying to capture logs of the script in the file as well as on the screen. I have used exec and tee command for this. While using exec command I am getting the correct output in the file but, script output is not getting displayed on the screen as it get executed.
Below is my sample... (14 Replies)
Hi guys,
So i am in server1 and i have to login to server 2, 3,4 and run some script there(logging script) and output its result. What i am doing is running the script in server2 and outputting it to a file in server 2 and then Scp'ing the file to server1. Similarly i am doing this for other... (5 Replies)
Hi All,
There are 2 scripts A and B.
A --> It will invoke script B
B -->
It will generate below output.
100 - connected
105 - Not Connected
210 - Connected
I want to return this value to script A. Please advice. (4 Replies)
Hi,
I have an application running on HP-UX, from this application I need to findout if the port number. lets say 7890,7891, 7892 are listening on the remote server running on HP-UX.
Is there any way of doing it using "system()" function or any other?
I noticed that nmap, netcat are not... (0 Replies)
is there a better way to check if a port is active on linux and sunos systems?
this is currently what I'm using in my script:
netstat -an | egrep -i "$PORT"
i know this isn't the best way as there could be numbers in that output that has my port number in it but isn't necessarily a... (0 Replies)
Problem
- Linux Client/Server Socket Application: Preventing Client from quitting on server crash
Hi,
I am writing a Linux socket Server and Client using TCP protocol on Ubuntu 9.04 x64.
I am having problem trying to implement a scenario where the client should keep running even when the... (2 Replies)
Hi all,
I am referring to this website . What I'm trying to do is to have a server script which will receive data from GPS in one line and store it in some file. Now from what I can see in this server file, server is sending the data to client but I don't need that .. I need only server script... (3 Replies)
i want to run automated backup copy , using crontab and how to do that?
the backup file should be taken from the sun server and put it in the client machine daily.pls help.. (5 Replies)