1006/ 0040755 0001750 0001750 00000000000 07302471626 011335 5 ustar rreames rreames 1006/voglmaierl2.txt 0100644 0001750 0001750 00000002331 07247506134 014316 0 ustar rreames rreames Listing 2
01 #!/usr/bin/perl
02 use LWP::UserAgent;
03 use HTTP::Status ;
04
05 # All Configuration Data goes here:
06 my $RemotePage = "http://www.What.Ever.You/want.html" ;
07 c
08 my $ProxyServer = "http://proxy.enterprise.com" ;
09 my $NoProxyDomains = "enterprise.com" ;
10 my $BrowserName = "Spider/1.00 [en] (X11; I; SunOS 5.7 )";
11 my $TimeOut = 1040 ;
12
13 # Initialize the User Agent:
14 my $ua = LWP::UserAgent->new();
15 $ua->proxy(['http','ftp'], $ProxyServer );
16 $ua->no_proxy($NoProxyDomains);
17 $ua->agent($BrowserName);
18 $ua->timeout($TimeOut);
19
20 # Formulate the request:
21 my $request = HTTP::Request->new('GET', $RemotePage) ;
22
23 # Now we get the page:
24 my $result = $ua->request($request);
25
26 # Evaluate the result:
27 $Result = $result->code();
28 if ( $ Result == OK ) {
29 printf ("Page copied \n") ;
30 } elseif ( $Result == RC_NOT_MODIFIED ) {
31 printf ("Page has not changed \n") ;
32 } else {
33 printf ("Error: %d\n%s\n",$result->code(),
34 $result->message(),
35 );
36 }
37 # Now we have the page:
38 my $HTML_Page = $response->content() ;
39
1006/voglmaierl1.txt 0100644 0001750 0001750 00000000536 07247506074 014325 0 ustar rreames rreames Listing 1
01 #!/usr/bin/perl
02 use LWP::UserAgent;
03
04 my $RemotePage = "http://www.What.Ever.You/want.html" ;
05 my $LocalPage = "/www/my/final/location/Page.html" ;
06
07 my $ua = LWP::UserAgent->new();
08 my $request = HTTP::Request->new('GET', $RemotePage) ;
09
10 my $result = $ua->request($request,$LocalPage) ;
1006/passil1.txt 0100644 0001750 0001750 00000012730 07266630026 013452 0 ustar rreames rreames #Variables
Home=/home/httpd/html/sys_info
Main_Info=main.txt
Main_Info_Html=index.html
Df_Info=df
Df_Info_Html=df.html
Fstab_Info=fstab
Fstab_Info_Html=fstab.html
Disk_Txt=disk.txt
Disk_Html=disk.html
Lan_Txt=lan.txt
Lan_Html=lan.html
Print_Txt=print.txt
Print_Html=print.html
SW_Txt=swlist.txt
SW_List=SW_Inventory.html
OS_Ver=`uname -r`
OS_Name=`uname -s`
LastReboot=`uptime|awk '{print $3,$4}'|cut -d, -f1`
Date=`date`
BG_Color=WHITE
# Functions
Clean_House ()
{
if [ -d $Home ];then
rm -f $Home/*
else
mkdir $Home
fi
}
Get_Mem_Swap ()
{
case $OS_Name in
HP-UX ) Memory=`/usr/sam/lbin/getmem`
Swap=`swapinfo -m -q`;;
Linux ) Memory=`/usr/bin/free -m|awk '{print $1,$2}'|grep Mem|awk
'{print $2}'`
Swap=`/usr/bin/free -m|awk '{print $1,$2}'|grep Swap|awk
'{print$2}'`;;
esac
}
Get_Hostname ()
{
case $OS_Name in
HP-UX ) HostName=`hostname`;;
Linux ) HostName=`hostname -s`;;
esac
}
Make_Header ()
{
echo "
" > $2
echo "" >> $2
echo "$1[$Date] | " >> $2
echo "
" >> $2
echo "
" >> $2
}
Make_Footer ()
{
echo "
" >> $1
echo "Date run: $Date
" >> $1
}
Get_Main_Info ()
{
Make_Header "System Information - $HostName" $Home/$$
Get_Mem_Swap
printf '%s\n%s\n%s\n%s\n%s\n' "Host" "OS" "Last Reboot" "Memory" "Swap" >>
$Home/$Main_Info
#echo "Host\nOS\nLastReboot\nMemory\nSwap" >> $Home/$Main_Info
printf '%s\n%s\n%s\n%s\n%s\n' "$HostName" "$OS_Ver" "$LastReboot"
"$Memory" "$Swap" >> $Home/$Main_Info
#echo "$HostName\n$OS_Ver\n$LastReboot\n$Memory\n$Swap" >>
$Home/$Main_Info
create_table $Home/$Main_Info 5 $Home/$Main_Info_Html
for n in 1 2 3
do
echo "" >> $Home/$Main_Info_Html
done
# Create links to the other sections
echo "
Software Inventory" >>
$Home/$Main_Info_Html
echo " | Disk Information" >>
$Home/$Main_Info_Html
echo " | Printer Information" >>
$Home/$Main_Info_Html
echo " | Lan Information" >>
$Home/$Main_Info_Html
Make_Footer $Home/$Main_Info_Html
cat $Home/$Main_Info_Html >> $Home/$$
mv $Home/$$ $Home/$Main_Info_Html
}
Get_Disk_Info ()
{
Make_Header "Disk Information" $Home/$Disk_Txt
Make_Header "Disk Space Usage" $Home/$Df_Info
Make_Header "File : /etc/fstab" $Home/$Fstab_Info
cat /etc/fstab >> $Home/$Fstab_Info
case $OS_Name in
HP-UX ) /etc/ioscan -kFnC disk|awk -F: '{print $NF}'|awk '{print
$1}'|grep dsk|sort > $Home/alldisks
strings /etc/lvmtab|grep dsk|sort > $Home/useddisks
echo " All Disks" >> $Home/$Disk_Txt
cat $Home/alldisks >> $Home/$Disk_Txt
echo " " >> $Home/$Disk_Txt
echo "Used Disks" >> $Home/$Disk_Txt
cat $Home/useddisks >> $Home/$Disk_Txt
bdf > $Home/$Df_Info;;
Linux ) sysinfo --disk --notitle --noheader >> $Home/$Disk_Txt
df -k >> $Home/$Df_Info;;
esac
echo " | Current df Output" >> $Home/$Disk_Txt
echo " | Current fstab" >>
$Home/$Disk_Txt
make_html $Home/$Disk_Txt $Home/$Disk_Html
make_html $Home/$Df_Info $Home/$Df_Info_Html
make_html $Home/$Fstab_Info $Home/$Fstab_Info_Html
Make_Footer $Home/$Disk_Html
make_html $Home/$Df_Info $Home/$Df_Info_Html
Make_Footer $Home/$Df_Info_Html
make_html $Home/$Fstab_Info $Home/$Fstab_Info_Html
Make_Footer $Home/$Fstab_Info_Html
}
Get_Lan_Info ()
{
Make_Header "LAN Information" $Home/$Lan_Txt
case $OS_Name in
HP-UX ) Interfaces=`/usr/sbin/lanscan -i |cut -c1-4`
for i in $Interfaces
do
ifconfig $i >> $Home/$Lan_Txt
done
echo Routing Information >> $Home/$Lan_Txt
/usr/bin/netstat -rn >> $Home/$Lan_Txt;;
Linux ) ifconfig -a >> $Home/$Lan_Txt;;
esac
make_html $Home/$Lan_Txt $Home/$Lan_Html
Make_Footer $Home/$Lan_Html
}
Get_Printer_Info ()
{
Make_Header "Printer Information" $Home/$Print_Txt
lpstat -v >> $Home/$Print_Txt
make_html $Home/$Print_Txt $Home/$Print_Html
Make_Footer $Home/$Print_Html
}
Get_SW_info ()
{
Make_Header "Software Information" $Home/$$
case $OS_Name in
HP-UX ) /usr/sbin/swlist|grep -v "#" > $Home/$SW_Txt
create_table $Home/$SW_Txt 6 $Home/$SW_List;;
Linux ) rpm -q -a > $Home/$SW_Txt
create_table $Home/$SW_Txt 6 $Home/$SW_List;;
esac
Make_Footer $Home/$SW_List
cat $Home/$SW_List >> $Home/$$
mv $Home/$$ $Home/$SW_List
}
create_table ()
{
File=$1
Cols=$2
OFile=$3
echo "" > $OFile
echo "" >> $OFile
#echo " $Header " >> $OFile
echo " " >> $OFile
echo "" >> $OFile
cnt=1
cat $File|while read lyne
do
echo "$lyne | " >> $OFile
if [ "$cnt" -lt "$Cols" ];then
let cnt=$cnt+1
else
echo " " >> $OFile
cnt=1
fi
done
echo "" >> $OFile
echo " " >> $OFile
echo "" >> $OFile
echo "" >> $OFile
}
make_html ()
{
File_In=$1
File_Out=$2
echo "" >
1006/kranzl1.txt 0100644 0001750 0001750 00000002052 07245247204 013453 0 ustar rreames rreames #!/bin/sh
#
# 2001-01-30 Tom Kranz (thomas.kranz@flutter.com)
#
# We return the following error codes:
# 0 - network connectivity is OK as it as - apart from annoyingly printing
# 'Woohoo' nothing has happened
# 1 - something's fubar on the network, and we've had to swap interfaces
# 2 - you didn't enter a IP address to ping to test connectivity - we'll
# print a nice error message and then leave
if [ $# -ne 1 ]
then
echo
echo "Usage: if_checker.sh "
echo
echo "Where is an always-reachable address you can"
echo "use to verify connectivity"
echo
exit 2
fi
if /usr/sbin/ping $1
then
echo "Woohoo!"
exit 0
else
upif="`/usr/sbin/ifconfig -a | grep -v LOOPBACK | grep UP | cut -b 1-4`"
downif="`/usr/sbin/ifconfig -a | grep -v LOOPBACK | grep -v UP | grep RU
NNING | cut -b 1-4`"
/usr/sbin/ifconfig $upif down
/usr/sbin/ifconfig $downif up
fi
/usr/sbin/ping $1
exit 1
1006/kranzl2.txt 0100644 0001750 0001750 00000002627 07245247204 013464 0 ustar rreames rreames #!/sbin/sh
#
# 2001-01-30 Tom Kranz (thomas.kranz@flutter.com)
#
# This script will config the 2nd interface on bootup, but not bring it up
# Our redundant-interface script will do that for us
# We can't use /etc/hostname. and /etc/hosts entries, as the boot
# sequence will automatically ifconfig up all interfaces configured that way
#
# If things are lovey dovey, we have an exit code of 0.
# If there's no config file, that's bad, so we print an error message and bomb
# with an exit code of 2
PATH=/usr/bin:/usr/sbin:/sbin ; export PATH
# We'll pull the redundant interface name from a config file
if [ -r /etc/redundant.int ]; then
INT=`cat /etc/redundant.int`
else
echo
echo "Warning:"
echo "/etc/redundant.int must exist, containing the redundant interface n
ame!"
echo
echo " eg. qfe0"
echo
exit 2
fi
# Let's get ready to rumble!
/sbin/ifconfig $INT plumb
# Let's find out what our hostname is, shall we?
hostname=`cat /etc/hostname.hme0`
# We'll also need an address, I'm guessing
addr=`cat /etc/hosts | grep $hostname | cut -f1`
# Now we'll config the interface, but keep it down
/sbin/ifconfig $INT inet $addr netmask + broadcast + down >/dev/null 2>&1
# It's only polite to let people know what's just been going on
echo
echo "$INT has been configured as the redundant interface"
echo
exit 0
1006/shearerl2.txt 0100644 0001750 0001750 00000002447 07251724150 013765 0 ustar rreames rreames Listing 2
#!/usr/bin/perl -w
# /usr/local/bin/rtr-traff
# Collect InterNet Router Traffic Information (written in PERL)
use strict;
use Getopt::Long;
use Net::SNMP;
use vars qw/$opt_cfg/;
use vars qw/$name @interfaces $tmp_dir/;
use vars qw/$comm $address/;
my $now = time;
&GetOptions("cfg=s");
die "Need a configuration file!\n" unless (defined $opt_cfg);
die "Can't open config file: /etc/$opt_cfg\n" unless -e "/etc/$opt_cfg";
require ("/etc/$opt_cfg");
my ($mday,$mon,$year) = (localtime(time))[3,4,5];
my $today = sprintf ("%4d%2.2d%2.2d", $year += 1900, $mon += 1, $mday);
my ($session) = Net::SNMP->session(Hostname => $address,
Community => $comm);
my $inmib = '1.3.6.1.2.1.2.2.1.10';
my $outmib = '1.3.6.1.2.1.2.2.1.16';
foreach my $int (@interfaces) {
$int =~ s/^(\d+):\d*/$1/;
my @mibs = ("$inmib.$int", "$outmib.$int");
my $response = $session->get_request(@mibs);
die $session->error."\n" if ($session->error);
my $innow = $response->{$mibs[0]};
my $outnow = $response->{$mibs[1]};
chomp($innow);
chomp($outnow);
if (($outnow gt "") && ($innow gt "")) {
open (FILE, ">>$tmp_dir/traf.$name.$today.$int");
print FILE "$now $outnow $innow\n";
close FILE;
}
}
1006/shearerl1.txt 0100644 0001750 0001750 00000000525 07251724132 013757 0 ustar rreames rreames Listing 1
# This is simply executed as a perl script to
# set the variables
$name = "traffic";
@interfaces = ("1", "2");
$y_axis_def = 10;
$tmp_dir = "/tmp";
$www_dir = "/var/www/html/traffic";
$offset = 86400;
$comm = "public";
$address = '192.168.1.254';
$tile = '2x1';
$skip = 5;
$gr_width = "300";
$gr_height = "300";
1006/shearerl3.txt 0100644 0001750 0001750 00000007350 07251724164 013771 0 ustar rreames rreames Listing 3
#!/usr/bin/perl
# /usr/local/bin/rtr-graph
# Graph data for InterNet Router Traffic
use strict;
use GD::Graph::lines;
use Image::Magick;
use Getopt::Long;
use vars qw/$opt_cfg $opt_date $opt_help @files/;
use vars qw/$tmp_dir $www_dir $name $gr_width $gr_height/;
use vars qw/$offset $y_axis_def @interfaces $skip $tile/;
&GetOptions("cfg=s", "date=s", "help");
if ( $opt_help ) {
print < [--date yyyymmdd]
Config File is optional - default is /etc/traffic.cfg.
Date is optional - if not specified, it will use yesterday.
('today' is a valid date)
EOF
exit;
}
if ( defined($opt_cfg) ) {
require ("/etc/$opt_cfg");
}
else {
require ("/etc/traffic.cfg");
}
if ( (defined $opt_date) && ($opt_date eq "today") ) {
$offset = 0;
undef $opt_date;
}
my ($mday,$mon,$year) = (localtime(time-$offset))[3,4,5];
my $yest = sprintf ("%4d%2.2d%2.2d", $year += 1900, $mon += 1, $mday);
( $opt_date ) && ( $yest=$opt_date );
###################################
foreach (@interfaces) {
my (@data, $timeold, $inold, $outold, $innew, $outnew);
my @val = split /:/;
my $int = shift @val;
my $y_axis = ($val[0]?(shift @val):$y_axis_def);
my $inlogfile = "$tmp_dir/traf.$name.$yest.$int";
my $ylabel = "Bits per Second ($y_axis/mbs max)";
my $max = '4294967294';
my $scale = .125;
push @files, "$tmp_dir/graph.$name.$int.png";
undef @data;
undef $timeold;
undef $inold;
undef $outold;
open (INFILE, "$inlogfile") or die "Cannot open data file: $inlogfile\n";
while () {
my @current = split / /;
chomp(@current);
if ($current[0] eq "") { shift(@current) }
if ( !defined $timeold ) {
$timeold = $current[0];
$inold = $current[1];
$outold = $current[2];
next;
}
my $timenew = $current[0] - $timeold;
if ($inold > $current[1]) {
$innew = int((($max - $inold) + $current[1]) / $timenew);
}
else {
$innew = int(($current[1] - $inold) / $timenew);
}
if ($outold > $current[2]) {
$outnew = int((($max - $outold) + $current[2]) / $timenew);
}
else {
$outnew = int(($current[2] - $outold) / $timenew);
}
my ($min, $hour) = (localtime $current[0])[1,2];
my $time = sprintf("%2.2d:%2.2d", $hour, $min);
push @{$data[0]}, $time;
push @{$data[1]}, ($innew / $scale);
push @{$data[2]}, ($outnew / $scale);
$timeold = $current[0];
$inold = $current[1];
$outold = $current[2];
}
close (INFILE);
################################
my $my_graph = new GD::Graph::lines($gr_width,$gr_height);
$my_graph->set(
x_label => 'Time of Day',
x_labels_vertical => 1,
y_label => $ylabel,
title => "$name - $yest ($int)",
x_label_skip => $skip,
x_all_ticks => 1,
y_min_value => 0,
y_max_value => ($y_axis * 1000000),
);
$my_graph->set_legend( 'Traffic OUT', 'Traffic IN' );
my $gd = $my_graph->plot(\@data)->png;
open (IMG, ">$tmp_dir/graph.$name.$int.png") or die;
binmode IMG;
print IMG $gd;
close IMG;
}
###################################
my $image = Image::Magick->new;
$image->Read(@files);
my $cimage = $image->Montage(geometry=>$gr_width ."x". $gr_height, tile=>$tile);
$cimage->Write("$www_dir/$name.$yest.jpg");
#$cimage->Display();
# Cleanup tmp files, set perms, etc.
( $< == 0 ) && (system("chown root:root $www_dir/$name.$yest.jpg"));
unlink @files;
exit;
1006/shearerl4.txt 0100644 0001750 0001750 00000004323 07251724652 013771 0 ustar rreames rreames Listing 4
#!/usr/bin/perl -w
# traf-lister.cgi - Perl/HTML/CGI front end to graphs
# created by rtr-graph
use strict;
use CGI;
my $www_dir = '/www/html/traffic';
my $cgi_dir = '/cgi-bin2';
my $bin_dir = '/usr/local/bin';
my $url = 'http://10.62.1.105/traffic';
my $page = CGI::new();
my ($mday, $mon, $year) = (localtime(time))[3,4,5];
my $today = sprintf("%4d%2.2d%2.2d", $year += 1900, $mon += 1, $mday);
my @data = $page->param;
print $page->header(-type=>'text/html',
-expires=>'now');
print $page->start_html('Pick a Graph');
foreach (@data) {
next if (!/^button/);
foreach my $val ($page->param("$_")) {
system("$bin_dir/rtr-graph --cfg $val.cfg --date today");
}
}
opendir (DIR, "$www_dir");
my %list;
foreach my $file (sort(readdir DIR)) {
if ( $file =~ /\.jpg$/ ) {
(my $pre = $file) =~ s/^(\w*)\..*/$1/;
unshift(@{$list{$pre}}, $file);
}
}
closedir DIR;
print "\n";
print $page->h1("Traffic Graphs for Network Devices");
print $page->h4("Select one or more Traffic Graphs to view");
print "To generate a new graph, select the button and press Submit\n";
print $page->startform(-method=>'POST',
-action=>"$cgi_dir/traf-lister.cgi",
-name=>'Form');
my @keys = keys(%list);
print " ";
print $page->submit(-name=>'SUBMIT',
-value=>'Submit');
print $page->reset;
print " ";
foreach (@data) {
next if (!/^list/);
foreach my $graph ($page->param("$_")) {
next if ($graph eq "No Graph");
print " ";
}
}
print "\n";
print $page->end_html();
1006/pragerl1.txt 0100644 0001750 0001750 00000001144 07253724614 013613 0 ustar rreames rreames
Listing 1
#!/bin/csh -f
set limit = 90
set comp_list = 'baracuda medusa stingray tuna dolphin sword seal salmon octopus'
touch /tmp/comp
rm /tmp/comp
foreach comp ( $comp_list )
set df = `rsh $comp df -F ufs -k | grep -v 'capa' | awk '{print $5}' | sed -e s/\%// `
set mnt = `rsh $comp df -F ufs -k | grep -v 'capa' | awk '{print $6}'`
set i = 0
foreach use ( $df )
@ i = $i + 1
if ( "$use" > "$limit" ) then
echo " $use% on $comp : $mnt[$i]" >> /tmp/comp
endif
end
end
if (-f /tmp/comp) then
/usr/ucb/Mail mark.prager@seabridgenetworks.com < /tmp/comp
endif
1006/pragerl2.txt 0100644 0001750 0001750 00000002513 07253724706 013617 0 ustar rreames rreames Listing 2
1#!/bin/ksh
2function mail_to_user
3{
4 echo $last has $count processes on host $host@
5 iaddress=${last}"+"
6 mailaddress=`grep $iaddress /usr/local/scripts/mailusermap | tr '+' ' ' | awk '{print $2}'`
7 /usr/local/scripts/proc_letter $mailaddress $count $host > /tmp/pl$$
8 /usr/local/bin/pstree -wu $last >> /tmp/pl$$
9 /usr/local/scripts/proc_letter2 $host >> /tmp/pl$$
10
11 cat /tmp/pl$$ | /bin/mailx -s "Urgent system letter" $mailaddress
12 rm /tmp/pl$$
13}
14# MAIN - First get all valid processes owners
15 processes=`ps -ef | awk '{print $1}' | sort | grep -v root | grep -v daemon | grep -v UID`
16 limit=1 ; count=1 ; last="qwert" ; host=`hostname`
17 for i in $processes
18 do
19 userquota=`grep $last /usr/local/scripts/mailusermap | tr '+' ' ' | awk '{print $3}'`
20 if [[ $userquota == "" ]] then
21 userquota=999
22 fi
23 uquota=`echo $userquota | awk '{print $1}'`
24 if [[ $i != $last ]] then
25 if (( $count > $uquota )) then
26 mail_to_user
27 fi
28 count=1
29 else
30 (( count=$count + 1 ))
31 fi
32 last=$i
33 done
34 userquota=`grep $i /usr/local/scripts/mailusermap | tr '+' ' ' | awk '{print $3}'`
35 if [[ $userquota == "" ]] then
36 userquota=999
37 fi
38 uquota=`echo $userquota | awk '{print $1}'`
39 if (( $count > $uquota )) then
40 mail_to_user
41 fi
1006/kingl3.o 0100644 0001750 0001750 00000002347 07262464516 012714 0 ustar rreames rreames #!/usr/bin/perl
package scan_misc;
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(long_to_ip ip_to_long commify char_to_ip ip_to_char ip_to_hex hex_to_ip);
use Socket;
#===========================================
#------ Convert a long int to an IP address
sub long_to_ip
{
my ($lip) = @_;
inet_ntoa(pack 'N', $lip);
}
#-------- Convert an IP address to a long int
sub ip_to_long
{
my ($ip) = @_;
unpack 'L', inet_aton($ip);
}
#==================================================
#-------- Convert a 4-byte char to an IP address
sub char_to_ip
{
my ($cip) = @_;
inet_ntoa($cip);
}
#-------- Convert an IP address to a 4-byte char
sub ip_to_char
{
my ($ip) = @_;
inet_aton $ip;
}
sub ip_to_hex
{
my ($ip) = @_;
my $hex = unpack("H8", inet_aton($ip));
$hex = "0x" . $hex;
}
sub hex_to_ip
{
my ($hex) = @_;
inet_ntoa(pack('N', hex($hex)));
}
#---------------- commify ------------------
# I would like to give credit to the authors
# of the Perl Cookbook for this code.
# It has been modified to meet my needs.
sub commify {
(@_ == 0) ? '' :
(@_ == 1) ? $_[0] :
(@_ == 2) ? join(", ", @_) :
join(", ", @_[0 .. ($#_-1)], "$_[-1]");
}
1006/kingf1.html 0100644 0001750 0001750 00000006163 07262464516 013412 0 ustar rreames rreames
Web Network Information Center (NIC)
1006/velazquezl1.txt 0100644 0001750 0001750 00000003703 07267054146 014365 0 ustar rreames rreames Listing 1 Example of hosts.conf
########################################################
#
# Configuration file for hosts definition in PICA
#
# $Id: hosts.conf,v 1.3 2001/02/08 14:58:50 cvs Exp $
#
# Miguel Armas
# Esteban Manchado
########################################################
defaults {
## ---- The following entries are MANDATORY ----
picaroot = '/var/lib/pica'; # root dir of PICA cfg tree
ssh = '/usr/bin/ssh'; # ssh binary
## ---- Optional configuration entries ----
diff = '/usr/bin/diff'; # diff binary for -f command
method = 'tar'; # distribution method (tar or ssh)
tar = '/bin/tar'; # tar binary
## ---- Optional directory definitions ----
#picaalrm = ''; # where to install the alarms (def: $picaroot/alarms)
#picatmp = ''; # PICA temp dir (def: $picaroot/tmp)
picasrc = '/opt/SysAdm'; # Where to find the source files
vars {
## ---- User defined variable ----
docdir = '/var/www/html/doc';
picasrc = '/opt/SysAdm';
}
}
###########################
# Host Group Definitions #
###########################
## RedHat Linux Servers
hostgroup redhat {
vars {
method = 'rsync';
}
members {
fobos,
deimos,
mercurio
}
}
## Solaris Servers
hostgroup solaris {
vars {
ssh = '/usr/local/bin/ssh';
}
members {
sar
}
}
## DNS servers
hostgroup dnsservers {
vars {
dnsdir = '/var/named';
}
members { fobos, deimos, mercurio }
}
## Documentation servers
hostgroup doc {
vars {
docdir = '/var/named';
}
members { mercurio }
}
#####################
# Host Definitions #
#####################
host mercurio {
fqdn = mercurio.ulpgc.es;
vars {
docdir = '/home/httpd/html/doc';
}
}
host sar;
host fobos;
host deimos;
1006/velazquezl2.txt 0100644 0001750 0001750 00000003326 07267054646 014374 0 ustar rreames rreames Listing 2 Example of objects.conf
########################################################
#
# Configuration file for objects definition in PICA
#
# $Id: objects.conf,v 1.3 2001/02/08 14:58:50 cvs Exp $
#
# Miguel Armas
# Esteban Manchado
#
########################################################
## Default values
defaults {
uid = 0;
gid = 0;
perms = 644;
verbatim = 0;
vars {
globalvar1 = 'value1';
}
}
file motd {
path = '/etc/motd';
source = 'Services/Info/motd';
}
##################################
# Configuration for Service: NTP #
##################################
group NTP {
file ntp.conf {
path = '/etc/ntp.conf';
source = 'Services/NTP/ntp_conf.cfg';
}
file step-tickers {
path = '/etc/ntp/step-tickers';
source = 'Services/NTP/step-tickers.cfg';
}
##
## Documentation for this Service
##
#if (ingroup('doc'))
file README.ntp {
path = '<#$docdir#>/Services/NTP/README';
source = <#'$picasrc#>/Services/NTP/README';
}
#fi
}
##################################
# Configuration for Service: DNS #
##################################
#if (ingroup('dnsservers'))
group DNS {
file named.conf {
path = '/etc/named.conf';
source = 'Services/DNS/named_conf.cfg';
}
##
## Documentation for this Service
##
# if (ingroup('doc'))
file README.dns {
path = '<#$docdir#>/Services/DNS/README';
source = 'Services/DNS/README';
}
# fi
#fi
}
## DNS check
alarm DNSChkUrgent {
priority = 'Urgent';
source = 'alarms/DNSChk';
perms = '755';
}
1006/callal2.txt 0100644 0001750 0001750 00000001514 07256662170 013412 0 ustar rreames rreames
function CreateApplicationLock
{
# Usage: CreateApplicationLock
#
# Description: Creates a directory to keep multiple copies of the
# program from running simultaneously.
#
# Example: CreateApplicationLock ${0}:${ORACLE_SID}
#
# Local Variables
typeset x
typeset LockDir=/tmp/lock$1
# Must pass an argument
if [[ "$1" == "" ]]
then
DebugMsg 1 CreateApplicationLock: Must pass a unique application key such as program name
return 1
fi
# Debug program announcement
DebugMsg 10 CreateApplicationLock on directory $LockDir
# Create the lock dir. Use /tmp to minimize damage on removal/leftover.
mkdir "/tmp/lock$1" 2>&1 | read x
if [[ "$x" != '' ]]
then
DebugMsg 1 $x
DebugMsg 1 "Cannot acquire lock $LockDir -- presume $0 is running"
return 1
fi
}
1006/callal3.txt 0100644 0001750 0001750 00000001654 07256662226 013422 0 ustar rreames rreames
function RemoveApplicationLock
{
# Usage: RemoveApplicationLock
#
# Description: Removes a directory that was created by CreateApplicationLock
# Will not remove contents of the directory.
#
# Example: RemoveApplicationLock ${0}:${ORACLE_SID}
#
# Known bug: Needs to allow only the starting PID to remove the lock.
# This could be accomplished by placing the PID in the lock dir.
# Local Variables
typeset x
typeset LockDir=/tmp/lock$1
# Must pass an argument
if [[ "$1" == "" ]]
then
DebugMsg 1 Must pass a unique application key such as program name
return 1
fi
# Debug program announcement
DebugMsg 10 RemoveApplicationLock $LockDir
# Remove the lock dir. Use /tmp to minimize damage on removal/leftover.
rmdir $LockDir 2>&1 | read x
if [[ "$x" != '' ]]
then
DebugMsg 1 "Cannot remove lock $LockDir"
DebugMsg 1 $x
return 1
fi
}
1006/callal1.txt 0100644 0001750 0001750 00000002036 07256662126 013412 0 ustar rreames rreames
function DebugMsg
{
# Usage: DebugMsg
#
# DebugLevel 1=error 5=info 10=debug
# Do not print anything for DebugLevel=0
#
# Example:
# DebugMsg 5 Your wish is my command
# Local variables
typeset Prefix=""
typeset Parameter1=""
# User variables
# DebugLevel 1=Error 5=info 10=debug
if [[ "$DebugLevel" == "" ]]
then
DebugLevel=1
fi
# Parameter checking
if [[ "$1" == "" ]]
then
return
fi
# Begin Execution
if (( $DebugLevel <= 0 ))
then
return
fi
# For 5 and above put the program name
if (( $DebugLevel >= 5 ))
then
Prefix=`basename $0`
fi
# For 10 and above put the process id
if (( $DebugLevel >= 10 ))
then
Prefix=${Prefix}'['"$$"".${1}"']'
fi
# Starting at 5 (where there IS a prefix) add a tab between
if (( $DebugLevel >= 5 ))
then
Prefix="${Prefix}:\t"
fi
if (( $1 <= $DebugLevel ))
then
shift
# The - is to prevent interpretation of - as part of $Prefix
print - ${Prefix} $*
fi
}
1006/callal5.txt 0100644 0001750 0001750 00000003332 07256662312 013413 0 ustar rreames rreames
function GetFileSize
{
#
# Usage: GetFileSize [hostname]
# Output: size in bytes as stdout, or null for
# Return: 0 for success
# 1 for syntax error#
# 2 for file size 0
#
# Features:
# Returns the file size of local and remote size
#
# Known bugs
# * Will not accurately report the size of a file with that is soft linked
#
typeset FilePath=$1
typeset HostName=$2
typeset lperms llinks lowner lgroup lsize lmm ldd lti lname
typeset rperms rlinks rowner rgroup rsize rmm rdd rti rname
case $# in
0) DebugMsg 1 Must pass filepath
return 1;;
1) # Check for local file readable
typeset -i lsize
ls -l ${FilePath} 2> /dev/null \
|read lperms llinks lowner lgroup lsize lmm ldd lti lname
if ((lsize == 0))
then
# Zero could be a valid zero size or dne
if [[ -r $FilePath ]]
then
echo 0
return 0
else
DebugMsg 1 File $FilePath does not exist
return 2
fi
else
# Good file size return
echo $lsize
return 0
fi;;
2) # Determine the remote location name
typeset -i rsize
rsh -n $HostName \
"ls -l ${FilePath}" 2> /dev/null \
| read rperms rlinks rowner rgroup rsize rmm rdd rti rname
if ((rsize == 0))
then
if [[ "$rperms" == "" ]]
then
DebugMsg 1 $FilePath on $HostName does not exist
return 2
else
# Really exists and has size 0
echo 0
return 0
fi
else
echo $rsize
return 0
fi;;
esac
}
1006/callal6.txt 0100644 0001750 0001750 00000003072 07256662344 013422 0 ustar rreames rreames
function GetFileSum
{
#
# Usage: GetFileSum [hostname]
# Output: size in bytes as stdout, or null for
# Return: 0 for success
# 1 for syntax error#
# 2 for file size 0
#
# Features:
# Returns the file sum of local and remote size
# Environment variable Safety=OFF will skip this function
#
#
#
# Used to turn off sum for faster speed
if [[ "$Safety" == "OFF" ]]
then
echo 0 0
return 0
fi
typeset FilePath=$1
typeset HostName=$2
typeset CheckSum1 CheckSum2 trash
typeset rperms rlinks rowner rgroup rsize rmm rdd rti rname
case $# in
0) DebugMsg 1 Must pass filepath
return 1;;
1) # Check for local file readable
typeset -i lsize
if [[ ! -f "$FilePath" ]]
then
echo 0
return 2
fi
/usr/bin/sum ${FilePath} 2> /dev/null | read CheckSum1 CheckSum2 trash
if [[ "$CheckSum1" == "" ]]
then
echo 0
return 2
fi
if [[ "$CheckSum2" == "" ]]
then
echo 0
return 2
fi
echo $CheckSum1 $CheckSum2
return 0;;
2) # Determine the remote location name
typeset -i rsize
rsh -n $HostName \
"/usr/bin/sum ${FilePath}" 2> /dev/null | read CheckSum1 CheckSum2 trash
if [[ "$CheckSum1" == "" ]]
then
echo 0
return 2
fi
if [[ "$CheckSum2" == "" ]]
then
echo 0
return 2
fi
echo $CheckSum1 $CheckSum2
return 0;;
esac
}
1006/callal7.txt 0100644 0001750 0001750 00000016746 07256662412 013433 0 ustar rreames rreames
function ReliableTransfer
{
#
# Usage: ReliableTransfer
#
# Features:
# Will not overwrite another file
# Checks source sum against destination sum
# Is host-smart to use rcp or cp
# Copies file to temp name then renames when complete
#
# Note:
# Built to be safe, not FAST!
# Must send to a destination file, not directory
#
# Note: Uses r-commands requiring rlogin permissions
#
# Known bugs/issues
# * Uses sum to check transfer accuracy - potentially slow but very safe
# File size has problem to check linked file size without full scan
# Use env variable Safety=OFF to disable sum check
# * Safety=OFF must be used for hot backups because files may change
# during copy
# * RemoteSpace overflow can occur, and code needs to be updated to ignore
# space calc if negative
#
typeset x
typeset Source SourceHost SourcePath SourceSize
typeset Destination DestHost DestPath DestSize
typeset LocalHost
typeset RemoteEnable
DebugMsg 5 ReliableTransfer $1 $2
# Check for correct number of arguments
if (($# != 2))
then
DebugMsg 1 Must pass source and destination only to ReliableTransfer
return 1
fi
if [[ $1 == $2 ]]
then
DebugMsg 1 Source and destination are the same
return 1
fi
Source=$1
Destination=$2
#################### Parse the parameters
LocalHost=`hostname`
echo $Source | grep : > /dev/null 2>&1
if (($?==0))
then
SourceHost=${Source%%:*}
SourcePath=${Source#*:}
else
SourceHost=$LocalHost
SourcePath=$Source
fi
echo $Destination | grep : > /dev/null 2>&1
if (($?==0))
then
DestHost=${Destination%%:*}
DestPath=${Destination#*:}
else
DestHost=$LocalHost
DestPath=$Destination
fi
typeset SourceDir=`dirname $SourcePath`
typeset SourceFile=`basename $SourcePath`
typeset DestDir=`dirname $DestPath`
typeset DestFile=`basename $DestPath`
DebugMsg 10 LocalHost=$LocalHost
DebugMsg 10 Source=$Source
DebugMsg 10 SourceHost=$SourceHost
DebugMsg 10 SourcePath=$SourcePath
DebugMsg 10 SourceDir=$SourceDir
DebugMsg 10 SourceFile=$SourceFile
DebugMsg 10 Destination=$Destination
DebugMsg 10 DestHost=$DestHost
DebugMsg 10 DestPath=$DestPath
DebugMsg 10 DestDir=$DestDir
DebugMsg 10 DestFile=$DestFile
#################### Determine the command to use
RemoteEnable=0
if [[ ("$SourceHost" == "$LocalHost") && ("$DestHost" == "$LocalHost") ]]
then
RemoteEnable=0 # Can use local commands
else
RemoteEnable=1 # Must use remote copy
fi
# Check reachability and rsh-ability of hosts
for testhost in $SourceHost $DestHost
do
if [[ "$testhost" == "$LocalHost" ]]
then
continue # skip if local host
else
DebugMsg 10 Checking remote host $testhost
fi
# Check ping
/usr/sbin/ping $testhost > /dev/null 2>&1
if (($?!=0))
then
DebugMsg 1 Host $testhost does not return a successful ping.
/usr/sbin/ping $testhost 2>&1 | read x
DebugMsg 1 Second ping results: $x
return 1
else
DebugMsg 10 Ping ${testhost} was successful
fi
# Check rsh
rsh -n $testhost date > /dev/null 2>&1
if (($?!=0))
then
DebugMsg 1 Host $testhost does not work with rsh
rsh -n $testhost date 2>&1 | read x
DebugMsg 1 Second \'rsh -n $testhost date\' results: $x
return 1
else
DebugMsg 10 rsh -n ${testhost} was successful
fi
#
done
#################### Check SourcePath to see if exists and readable
if [[ "$SourceHost" != "$LocalHost" ]]
then
SourceSize=`GetFileSize $SourcePath $SourceHost`
if (($?!=0))
then
DebugMsg 1 Source file does not exist
return 1
fi
else
SourceSize=`GetFileSize $SourcePath`
if (($?!=0))
then
DebugMsg 1 Source file does not exist
return 1
fi
fi
DebugMsg 10 SourceSize is $SourceSize
#################### Check DestPath to see if exists and won't overwrite file
# Also check for tempname
if [[ "$DestHost" != "$LocalHost" ]]
then
DestSize=`GetFileSize $DestPath $DestHost`
# If file exists, stop
if (($?==0))
then
DebugMsg 1 Destination file exists - do not continue
return 1
fi
else
DestSize=`GetFileSize $DestPath`
if (($?==0))
then
DebugMsg 1 Destination file exists - do not continue
return 1
fi
fi
# Check for temp file name
if [[ "$DestHost" != "$LocalHost" ]]
then
DestSize=`GetFileSize ${DestPath}.tmp $DestHost`
# If file exists, stop
if (($?==0))
then
DebugMsg 1 Destination tmpfile exists - do not continue
return 1
fi
else
DestSize=`GetFileSize ${DestPath}.tmp`
if (($?==0))
then
DebugMsg 1 Destination tmpfile exists - do not continue
return 1
fi
fi
##################### Check to see if there is space on the target host
DebugMsg 10 check for space on target
# Check for sufficient space to copy
if [[ ${DestHost} != ${LocalHost} ]]
then
typeset SpaceLeft=`RemoteSpace $DestHost $DestDir`
# Need to check for return code in case of overflow
DebugMsg 10 remote space left is $SpaceLeft
else
typeset a b c trash Value
typeset x=`cd ${DestDir}; df -k .|tail -1`
echo $x|read a b c Value trash
# Compute in bytes
typeset -i SpaceLeft=$Value*1024
DebugMsg 10 local space left is $SpaceLeft
fi
DebugMsg 10 SpaceLeft $SpaceLeft SourceSize $SourceSize
# Is it safe to transfer?
if (( SpaceLeft <= SourceSize ))
then
DebugMsg 1 Not enough space left on target
return 1
fi
#################### Do the copy
# copy to temp name
if ((RemoteEnable == 1))
then
DebugMsg 10 rcp ${Source} ${Destination}.tmp
rcp ${Source} ${Destination}.tmp
DebugMsg 10 rcp ${Source} ${Destination}.tmp finished
if (($?!=0))
then
DebugMsg 1 rcp failed
return 1
fi
else
# Must be DestPath not Destination for localhost case
DebugMsg 10 cp ${SourcePath} ${DestPath}.tmp
cp ${SourcePath} ${DestPath}.tmp
if (($?!=0))
then
DebugMsg 1 cp failed
return 1
fi
fi
############### check for links - does not work with ls
# Check the destination file size and compare to source
typeset DestSum SourceSum
DebugMsg 10 Check for dest file sum
if [[ "${DestHost}" != "${LocalHost}" ]]
then
DestSum=`GetFileSum ${DestPath}.tmp ${DestHost}`
else
DestSum=`GetFileSum ${DestPath}.tmp`
fi
DebugMsg 10 Check for source file sum
if [[ "${SourceHost}" != "${LocalHost}" ]]
then
SourceSum=`GetFileSum ${SourcePath} ${SourceHost}`
else
SourceSum=`GetFileSum ${SourcePath}`
fi
DebugMsg 10 DestSum is $DestSum SourceSum is $SourceSum
DebugMsg 10 Check for dest file sum and compare
if [[ "$DestSum" != "$SourceSum" ]]
then
DebugMsg 1 Destination file sum $DestSum does not match local sum $SourceSum
return 1
fi
DebugMsg 10 Destination file sum $DestSum Local size $SourceSum
# Rename to actual target name
if [[ "${DestHost}" != "${LocalHost}" ]]
then
DebugMsg 10 Rename remote file.tmp to file
# echo rsh "$DestHost" mv ${DestPath}.tmp ${DestPath}
rsh -n "$DestHost" mv ${DestPath}.tmp ${DestPath}
if (($?!=0))
then
DebugMsg 1 Temp file rename failed
return 1
fi
else
DebugMsg 10 Rename file.tmp to file
mv ${DestPath}.tmp ${DestPath}
if (($?!=0))
then
DebugMsg 1 Temp file rename failed
return 1
fi
fi
}
1006/callal8.txt 0100644 0001750 0001750 00000001010 07256662442 013411 0 ustar rreames rreames
function RemoteSpace
{
# Usage: RemoteSpace hostname directory_path
#
# Description
# Get remote file size in bytes return as echo
#
# Known bugs
# * Cannot handle byte size bigger than 2147483647
# Results in negative number (overflow) and return 1
#
typeset x a b c Value trash
x=`rsh -n $1 "cd $2; df -k .|cat|tail -1"`
echo $x|read a b c Value trash
# Compute in bytes
typeset -i Value=$Value*1024
echo $Value
# Check for ksh integer overflow
if ((Value<0))
then
return 1
fi
}
1006/callal9.txt 0100644 0001750 0001750 00000003212 07256662476 013427 0 ustar rreames rreames
function LogEvent
{
#
# Usage: LogEvent host:file arguments to append to file
#
# Description: Adds a line to a .log or .map file on host
# local host assumed if not passed
#
# Example:
# LogEvent mercury:/tmp/my.log This is my comment
# This will add "This is my comment" to the end of my.log on mercury
if (( $# < 1 ))
then
DebugMsg 1 Usage: LogEvent filename message
return 1
fi
typeset LocalHost=`hostname`
typeset LogFileSpec=$1
shift
Message="$*"
echo $LogFileSpec | grep : > /dev/null 2>&1
if (($?==0))
then
LogFileHost=${LogFileSpec%%:*}
LogFilePath=${LogFileSpec#*:}
else
LogFileHost=$LocalHost
LogFilePath=$LogFileSpec
fi
DebugMsg 10 LogFileSpec $LogFileSpec
DebugMsg 10 LogFileHost $LogFileHost
DebugMsg 10 LogFilePath $LogFilePath
DebugMsg 10 Message $Message
# Check to see that the file is a safe name
# This could be dangerous to write to ANY writable file
echo $LogFilePath|egrep "\.log|\.map" >/dev/null
if (($?!=0))
then
DebugMsg 1 LogEvent: Filename must contain .log or .map
return 1
fi
# Write a line to the log file
if [[ "$LogFileHost" == "$LocalHost" ]]
then
touch $LogFilePath
echo $Message >> $LogFilePath
if (($?!=0))
then
DebugMsg 1 LogEvent: Write failed to log $LogFileSpec
return 1
fi
else
# Remote file entry
typeset ErrorState
rsh -n $LogFileHost "echo $Message >> $LogFilePath" 2>&1 | read ErrorState
if [[ "$ErrorState" != "" ]]
then
DebugMsg 1 LogEvent: Write failed to log $LogFileSpec
DebugMsg 1 LogEvent: $ErrorState
return 1
fi
fi
}
1006/marxertar.gz 0100644 0001750 0001750 00003431717 07260456632 013724 0 ustar rreames rreames 9 unixdoc.tar =iWH|֯uӯkڇn]xCdAܒl`oDJ,#G7Y(WFFF!ug6Q;Tz=2TE?y)ʫx"?ClY3YgzS0epy=S.\h<+wpp!
aVO'PPN@E
P`4PA ll[9-~ޚW!K#`=EpjیDTk;vo8.$$F6IZpnm0au&5XI<@]3wgs&n%5 |