1833875 Members
3113 Online
110063 Solutions
New Discussion

tcpip script

 
SOLVED
Go to solution
Shivkumar
Super Advisor

tcpip script

Dear Sirs,

I want know a script so that the output of the below mentioned commands gets recorded in a file:

egrep 'maxfiles|maxfiles_lim' /stand/system

ndd -get /dev/tcp tcp_conn_request_max

ndd -get /dev/tcp tcp_ip_abort_interval

Appreciate if anyone can suggest the script ?

Thanks,
Shiv
7 REPLIES 7
Ranjith_5
Honored Contributor

Re: tcpip script

Hi Shiv,


Do the following..

#script /tmp/info.txt
Script started, file is /tmp/info.txt

#egrep 'maxfiles|maxfiles_lim' /stand/system

#ndd -get /dev/tcp tcp_conn_request_max

#ndd -get /dev/tcp tcp_ip_abort_interval
#exit
Script done, file is /tmp/info.txt


Hope this helps.

Regards,
Syam
Patrick Wallek
Honored Contributor
Solution

Re: tcpip script

Put the stuff between the rows of *'s in a file:

*********
#!/usr/bin/sh
grep maxfiles /stand/system >> /var/tmp/yourfile
echo "" >> /var/tmp/yourfile
ndd -get /dev/tcp tcp_conn_request_max >> /var/tmp/yourfile
echo "" >> /var/tmp/yourfile
ndd -get /dev/tcp tcp_ip_abort_interval >> /var/tmp/yourfile

**********

Save the file as something like myscript.sh and make it executable (chmod 700 myscript.sh).

Now run it:

# ./myscript.sh

When it finishes look at the file /var/tmp/yourfile

Mel Burslan
Honored Contributor

Re: tcpip script

actually what you are asking is pretty simple.

MYLOGFILE=somefilename
date >> $MYLOGFILE
egrep 'maxfiles|maxfiles_lim' /stand/system >> $MYLOGFILE
ndd -get /dev/tcp tcp_conn_request_max >> $MYLOGFILE
ndd -get /dev/tcp tcp_ip_abort_interval >> $MYLOGFILE
echo "--------------------------------------" >> $MYLOGFILE #separator line

just put all of the above into a file called mytcpipscript,

chmod 755 mytcpipscript

and if you want to run it lets say every hour, add the following into your crontab:

00 * * * * * /path/to/mytcpipscript

hope this helps
________________________________
UNIX because I majored in cryptology...
Sandman!
Honored Contributor

Re: tcpip script

You could also use command grouping and direct stdout to a file i.e.

# (
> egrep 'maxfiles|maxfiles_lim' /stand/system;
> ndd -get /dev/tcp tcp_conn_request_max;
> ndd -get /dev/tcp tcp_ip_abort_interval
) > outfile
Ranjith_5
Honored Contributor

Re: tcpip script

Hi Shiv,

#!/usr/bin/sh
echo "Max_Files">>/tmp/info.txt
echo "*************">>/tmp/info.txt
egrep 'maxfiles|maxfiles_lim' /stand/system>>/tmp/info.txt
echo "\n\n">>/tmp/info.txt
echo "tcp_conn_request_max">>/tmp/info.txt
echo "*************************">>/tmp/info.txt
ndd -get /dev/tcp tcp_conn_request_max>>/tmp/info.txt
echo Abort_Interval">>/tmp/info.txt
echo ""************************">>/tmp/info.txt
ndd -get /dev/tcp tcp_ip_abort_interval>>/tmp/info.txt
echo "******************* NEXT *********************\n">>/tmp/info.txt


The above is tested and OK. You may put this in cron and use it.

Regards,
Syam
Sandman!
Honored Contributor

Re: tcpip script

Matter of fact use the one below as it reports on the parameters and their values:

# (
> egrep 'maxfiles|maxfiles_lim' /stand/system;
> echo "tcp_conn_request_max: \c";
> ndd -get /dev/tcp tcp_conn_request_max;
> echo "tcp_ip_abort_interval: \c";
> ndd -get /dev/tcp tcp_ip_abort_interval;
> ) > outfile
Ranjith_5
Honored Contributor

Re: tcpip script

Hi Shiva,

Sorry No pts for my last post...There was some typing mistake.

the following will work for you with the time stamp.

#!/usr/bin/sh
date>>/tmp/info.txt
echo "">>/tmp/info.txt
echo "Max_Files">>/tmp/info.txt
echo "*************">>/tmp/info.txt
egrep 'maxfiles|maxfiles_lim' /stand/system>>/tmp/info.txt
echo "">>/tmp/info.txt
echo "tcp_conn_request_max">>/tmp/info.txt
echo "*************************">>/tmp/info.txt
ndd -get /dev/tcp tcp_conn_request_max>>/tmp/info.txt
echo "">>/tmp/info.txt
echo "Abort_Interval">>/tmp/info.txt
echo "************************">>/tmp/info.txt
ndd -get /dev/tcp tcp_ip_abort_interval>>/tmp/info.txt
echo "">>/tmp/info.txt
echo "******************* NEXT *********************\n">>/tmp/info.txt



Regards,
Syam