Operating System - HP-UX
1752781 Members
6067 Online
108789 Solutions
New Discussion юеВ

Re: favorite sysadmin scripts you always keep around (3)

 
SOLVED
Go to solution
Jim Gerken
Occasional Advisor

Re: favorite sysadmin scripts you always keep around (3)

Hey you guys are right on it...

I have the following script which seems to give me what I need.

echo "PID USER CPU% MEM_SIZE COMMAND"
while true
do
UNIX95= ps -eo "pid ruser pcpu vsz=Kbytes" -o comm | grep oracleT5751
sleep 1
done

It returns something like this...

8532 ormesa 0.02 32832 oracleT5751
536 ormesa 0.02 32832 oracleT5751
524 ormesa 0.02 32832 oracleT5751
22005 ormesa 0.02 32832 oracleT5751
8536 ormesa 0.02 40128 oracleT5751

I need to graph this in excel to show the memory / cpu consumed by each pid. I'm a little confused on how to setup the graph? any ideas...
H.Merijn Brand (procura
Honored Contributor

Re: favorite sysadmin scripts you always keep around (3)

perl/Tk

several examples can be found in the graph scripts included in the Statistics on https://www.beepz.com/personal/merijn/#Statistics or http://www.cmve.net/~merijn/#Statistics

Enjoy, have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Chris Vail
Honored Contributor

Re: favorite sysadmin scripts you always keep around (3)

The attached script answers the simplest, fundamental question that we syadmins have to deal with: are all systems up and running?

It uses secure shell to ll the /etc/hosts directory on each remote system. If the directory listing is successful, it assumes that the system is up and running. If not, it advises to "Update your resume'". It emails the results. We run this every day at 8 AM, so that we have no surprises at the 9 AM meeting.



Chris
Fragon
Trusted Contributor

Re: favorite sysadmin scripts you always keep around (3)

Hi,all
Here is my backup script,which is invoked by cron every night.
She will check the tape first, if type is not ready, she send a mail to a certain mailbox. When this mailbox receive this special mail, it will send a message to the adminiatrator by mobile phone.
After backup, it will truncate some log files of the DB, and make a total report and send it to the administrator.

This keep the backup always done correctly!!!

-ux
Jack C. Mahaffey
Super Advisor

Re: favorite sysadmin scripts you always keep around (3)

Looks like I didn't read the last post in the last post so I'm reposting in this thread.


There's been numerous times I've wanted to know which corresponding chmod command was needed to securing files and directories. Here's a script that I've created awhile back that others may want to have. Very useful for determining the chmod integer combinations. It lists the 4 digit code, security string, object type, owner:group, and filename. It has saved my rear-end multiple times and I call it from other scripts for when I may need to reset the security properties for a file or directory.

Here's an example of running the script...
# getchmod /etc/inetd.conf
0644 -rw-r--r-- file root:sys /etc/inetd.conf

And yes, it will use wildcards...

I've named the script getchmod....

jack...
Chris Vail
Honored Contributor

Re: favorite sysadmin scripts you always keep around (3)

Attached is one of my more involved scripts, diskasaurus. This is specifically for EMC Symmetrix users, but could be adapted as you see fit. It takes the output of BDF and provides additional interesting information. It determines if the disk is local or remote, whether and/or how it is mirrored. If the disk is striped, it determines whether it is a 4-way or 8-way stripe. Finally, it accumulates the data into .csv format for easy use with Excel or other spreadsheet. I email the results to myself for analysis. You will need the EMC command "inq" available to generate the base information.

It has a parent script, T-REX, that I'll attach if anyone is interested. This script uses secure copy to deploy diskasaurus to machines listed in a text file. It then executes it and captures its output into a larger .csv file, and does some interesting subtotals and totals of the data. The first script runs by itself nicely, but with T-REX it becomes a powerful tool to analyze multiple systems simoultaneously.
Steven E. Protter
Exalted Contributor

Re: favorite sysadmin scripts you always keep around (3)

Tired of two line commands to start and stop daemons?

Well suffer no longer.

restart

Let me know if the name causes problems, it is tested.

usage:

restart

It requires root $LOGNAME
It requires a single parameter

It saves me typing.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Massimo Bianchi
Honored Contributor

Re: favorite sysadmin scripts you always keep around (3)

Hi, a little query in oracle:


select p.spid from v$process p, v$session s, v$mystat m
where m.sid=s.sid and s.paddr=p.addr and rownum=1;



This is used to extract the pid of the session you are connected to.
Usefull because when you generate a user_trace (like in alter database backup controlfile to trace) the output goes to user_dump_dest/ora_.trc , format depending on otacle release.

I always hate to list the content and look for my file, guessing...

Massimo
Steven E. Protter
Exalted Contributor

Re: favorite sysadmin scripts you always keep around (3)

This beauty is for those Linux-heads who have stepped up to the world of real Unix. HP-UX.

In Linux you can stop, start and restart services with a single command.

service

service httpd restart

restarts the httpd daemon(web server)

Its nice.

As far as I know, no equivalent exists in HP-UX.

Until now.

It works just the same, taking three valid actions. It may be a bit verbose, but you can play with it to your hearts content.

attaching service.

This has been tested in all three valid modes.

If the script does not exist in /sbin/init.d/ it tells you.

WARNING: This script will not protect you from your own stupidity. If you use it to halt a critical service like NFS or the network, your system will lock up good and hard. Use at your own risk. Example: This script did not protect me from my own stupidity when I let it loose on Samba while a file transfer was going on. It is not smart enough to know if its a good idea to start/stop or restart the service, it relies on you for that part.

WARNING 2: There are probably some services that can't be stopped and started while the system is running. Once again, this script is only as smart as the person using. It does however ease the transition from Linux to HP-UX.

I'm thinking about doing chkcfg(chkconfig?) next. It actually sets up servcies to run which makes it a little harder to port.

Enjoy.

SEP

Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Steven E. Protter
Exalted Contributor

Re: favorite sysadmin scripts you always keep around (3)

I'm pretty sure this doesn't deserve any points.

Reason is I promised this pup months ago.

Its a really minor modification of a slick script given to me by Jordon Bean in response to an itrc post to port my Linux buildmail script.

What this script does is it builds the sendmail databases for alisees, access (spam stopper), and such things so you can use your HP-UX box to run an NSP.

I don't know how many people actually do that, but I'm in a jam right now.

My production Linux Server is running 7.3 Red Hat. It is having hardware problems. It only booted correctly six out of the last seven times. It hung on the memory check a few hours ago, after I loused up the named database.

A few weeks ago, its built in video card took a dump. The good news is it came back and the server wasn't down for more than 10 minutes.

What I need to do is take production offline, put in a reliable add in video card, put the two hard disks on different IDE channels and rebuild the box.

Normally I'd just switch to the backup Linux box. Its been upgraded to Red Hat 9 and none of my sendmail stuff works with sendmail 8.12.

So The old D320, my learning box may be pressed into a few days of service to save my tush.

DNS, httpd(apache 2 no less) works. sendmail has to work to give me the time I need to fix the Dell Linux box.

That was long winded. Here is the script. The script itself works. The sendmail functionaility it creates, databases and such is still being tested furious as I type.

Not surprisingly I was able to bring over all my virtusertable, genericstable, tab delimited databases without modification.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com