Softpanorama

May the source be with you, but remember the KISS principle ;-)
Home Switchboard Unix Administration Red Hat TCP/IP Networks Neoliberalism Toxic Managers
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and  bastardization of classic Unix

Tivoli Perl scripts

News See also Recommended Links Perl TEC

TFM

TEC Perl Scripts Monitoring IBM humor Etc

The list of IBM-supplied Perl modules in Tivoli distribution

root@tmr_server/opt/TMF/bin/aix4-r1 # find . -name "*.pl"
./contrib/lib/perl/abbrev.pl
./contrib/lib/perl/assert.pl
./contrib/lib/perl/bigfloat.pl
./contrib/lib/perl/bigint.pl
./contrib/lib/perl/bigrat.pl
./contrib/lib/perl/cacheout.pl
./contrib/lib/perl/chat2.pl
./contrib/lib/perl/complete.pl
./contrib/lib/perl/ctime.pl
./contrib/lib/perl/dumpvar.pl
./contrib/lib/perl/exceptions.pl
./contrib/lib/perl/fastcwd.pl
./contrib/lib/perl/find.pl
./contrib/lib/perl/finddepth.pl
./contrib/lib/perl/flush.pl
./contrib/lib/perl/getcwd.pl
./contrib/lib/perl/getopt.pl
./contrib/lib/perl/getopts.pl
./contrib/lib/perl/importenv.pl
./contrib/lib/perl/look.pl
./contrib/lib/perl/newgetopt.pl
./contrib/lib/perl/open2.pl
./contrib/lib/perl/perldb.pl
./contrib/lib/perl/pwd.pl
./contrib/lib/perl/shellwords.pl
./contrib/lib/perl/stat.pl
./contrib/lib/perl/syslog.pl
./contrib/lib/perl/termcap.pl
./contrib/lib/perl/timelocal.pl
./contrib/lib/perl/validate.pl
./TAS/HTTPd/cgi-bin/cgi-lib.pl
./TAS/HTTPd/cgi-bin/tec_help.pl
./TME/TEC/jre/lib/font.properties.pl
./TME/TEC/ParseEvents.pl
./TME/TEC/SendEvents.pl
./TME/TEC/get_host_by_addr.pl
./TME/TEC/get_host_by_name.pl
./TME/TEC/whotec.pl
./TME/TEC/upg_baroc.pl
./TME/TEC/upg_templates.pl

NEWS CONTENTS

Old News

[Feb 15, 2008] tivstat12

#!/etc/Tivoli/bin/perl
# tivstat.pl
# Script to watch for critical tivoli processes dying.
#
# Notes:
# 1) Cache keys are forced to lowercase
#	status values of cache hash:
#	no key - this process has never been detected on this endpoint
#	1 - this process is running
#	0 - this process was running but has stopped
# 2) Includes work done by James Boone (see tme10 email forum "postemsg.pl")
# 3) Intended to be run as an lcfd boot_method with its own dependency set:
# on NT,
#  - ntprocinfo.exe (generates a process list on NT - Tivoli supplied)
#  - perl.exe (V4 Tivoli supplied)
#  - tivstat.tecs (data file that has to be created)
# on UNIX,
#  - perl (V4 Tivoli supplied)
#  - tivstat.tecs (data file that has to be created)
#
# V1.0,	Original,	Paul Claridge,	06Jun2001
# V1.1			Paul Claridge,	12Jun2001
#		Added more logic to correctly detect oserv restart
#		Tightened up string matches to avoid bad process matching
# V1.2			Paul Claridge,	13Jun2001
#		Further tightening of string matching to avoid wrong alerts in the
#		case where a process is a substring of another process

# You probably need to review all of these and the %tiv_sev hash!

$ENV{'UNIX95'}=1;					# improves portability for ps on UNIXs

$want_procs=1;					# 1 - check processes, 0 - don't
$want_hb=1;						# 1 - generate heartbeat, 0 - don't
$proc_class='Tivoli_process;source=ALL;';	# class and source for process events
$heartbeat_class='Tivoli_heartbeat;source=ALL;';	# class and source for hearbeat events
$proc_poll=$next_procs=20;			# interval in seconds for looking at the process list
$hb=$next_hb=60;					# interval in seconds for sending a heartbeat
$do_procs=$want_procs;				# set flag for first time through
$do_hb=$want_hb;					# set flag for first time through

%tiv_sev=('tmf_sched','FATAL',		# associate a TEC severity with each process.
	'ep_mgr','FATAL',
	'rptm','FATAL',
	'oserv','FATAL',
	'lcfd','MINOR',
	'gateway','FATAL',
	'rim_oracle_prog','FATAL',
	'trip','MINOR',
	'spider','MINOR',
	'rcserv','MINOR',
	'ntfserver','CRITICAL',
	'sentry_engine','CRITICAL',
	'sentry_gateway','CRITICAL',
	'tec_server','CRITICAL',
	'tec_gateway','CRITICAL',
	'oracle73','CRITICAL',
	'tnslsnr','CRITICAL',
	'tecadnts','CRITICAL',
	'tecad_snmps','CRITICAL',
	'dm_ep_engine','CRITICAL');

# make list of tivoli procs of interest
@tivprocs=keys %tiv_sev;

# associate command to generate proc list with interp
%proc_gen=('w32-ix86','ntprocinfo','aix4-r1','ps -eo pid,args','solaris2','ps -eo pid,args');
$proc_cmd=$proc_gen{$ENV{'INTERP'}};

# determine files location
$dir=$ENV{'LCF_DATDIR'} || $ENV{'PWD'} || '.';
$cache_file="$dir/tivstat.cache";
$log="$dir/tivstat.log";
$tec_list="$dir/tivstat.tecs";
$pid="$dir/tivstat.pid";

&init;	# check that we are not running already, open files etc

# determine endpoint name
chop($h=`hostname`);
$me= &get_ep_name || $h || $ENV{'COMPUTERNAME'} || $ENV{'HOST'};

# set up signal handlers (NT only seems to catch Cntrl-C)
for $s (HUP,INT,QUIT,KILL) { $SIG{$s}='signals'; }

# setup some static event information
$origin=join('.',unpack(C4,(gethostbyname($me))[4]));
$static="hostname=$me;origin=$origin;";

# loop continuously with variable sleeps
while (1) {
	$loop_start=time;	# capture loop start
	$pmsg='';		# reset packed message of event(s)

	&check_procs if $do_procs && $want_procs;

	&create_heartbeat if $do_hb && $want_hb;

	if ($pmsg) {		# send any events in one go, try tecs in order
		for $t (@tec_servers) {
			($techost,$pm_flag,$tec_recv)=split(/:/,$t);
			last if &send_events($tec_recv);
			next unless $pm_flag;
			# if this tec fails and is portmapped retry once in case of restart
			unless ($retried) {
				$new_triple=join(':',$techost,$pm_flag,pack('S n a4 x8',2,&get_port($techost),$tec_addrs{$techost}));
				$t=~s/^(.*)$/$new_triple/;
				$retried=1; redo;		# try that one again
				}
			else { $retried=0; }
			}
		}
	print CACHE join(',',%cache); seek(CACHE,0,0); # just keep latest values (1 line)
	if ($t=&calc_wait(time)) { sleep $t; }
	}

#### subroutines ####

sub init {
	# open log file for errors etc
	open(LOG,">>$log") || warn "Could not open log file <$log>\n";
	select LOG; $|=1;

	unless ($want_procs || $want_hb)
		{ print LOG &now." # Neither \$want_procs nor \$want_hb flags have been set, exiting..\n" if LOG; exit; }

	# check we have command for this interp
	if ($proc_cmd) { &get_procs; }
	else { print LOG &now." # Do not know process command to run for interp <$ENV{'INTERP'}>\n" if LOG; exit; }

	# check for already running tivstat and exit if found
	if (open(PID,"$pid")) {
		$last_pid=<PID>;
		exit 0 if grep(/"$last_pid:perl"/,@p);
		close PID;
		}
	open(PID,">$pid"); print PID $$; close PID;	# write new pid file

	print LOG &now." # --- started, pid <$$>\n" if LOG;

	# read disk file if it exists - saved cache across restarts/reboots
	if (open(IN,"$cache_file")) { %cache=split(',',<IN>); close IN; } else { %cache=(); }

	# open new cache file for writing latest cache
	if (open(CACHE,">$cache_file")) { select CACHE; $|=1; }
	else { print LOG &now." # Could not open cache file <$cache_file>\n" if LOG; }

	# read tivstat.tecs file for tecserver(s)
	if (open(TL,"$tec_list")) {
		chop($tecs=<TL>); close TL;
		@tec_servers=split(',',$tecs);
		for $t (@tec_servers) {
			local($techost,$portmapper_flag)=split(/:/,$t);
			$tec_addrs{$techost}=(gethostbyname($techost))[4];
			$portmapper_flag ? ($port=&get_port($techost)) : ($port=5529);
			$t.=":".pack('S n a4 x8',2,$port,$tec_addrs{$techost});
			}
		}
	else { @tec_servers=(); print LOG &now." # No TEC servers defined in <$tec_list>, unable to send events!\n" if LOG; }
	}
sub get_procs {
	(@running,@not_running)=();				# reset for each run
	@p=grep(s/^\s*(\d*)\s*(\S*).*$/"$1:$2"/,`$proc_cmd`);	# make list of running processes
	for $p (@tivprocs) { (grep(/\b$p\b/i,@p)) ? push(@running,"\L$p") : push(@not_running,"\L$p"); }
	}
sub check_procs {
	&get_procs;
	# catch oserv restart
	if (grep(/^oserv$/,@running) && defined $cache{'oserv'} && $cache{'oserv'}==0) {
		&create_proc_event('oserv','restarted',HARMLESS);
		$cache{'oserv'}++;
		# now check children have restarted
		while ($r=shift @o_children) {
			if (grep(/^$r$/,@running)) { $cache{$r}++; }
			else { &create_proc_event($r,'not restarted with oserv',$tiv_sev{$r}); }
			}	
		}	

	for $r (@running) {
		next if $cache{$r};
		&create_proc_event($r,'restarted',HARMLESS) if grep(/^$r$/,keys %cache);
		$cache{$r}++;
		}

	# catch oserv failure to send only one event
	if (grep(/^oserv$/,@not_running) && $cache{'oserv'}) { $o_stop=1; } else { $o_stop=0; }

	for $n (@not_running) {
		$cache{$n} ? $cache{$n}-- : next;
		if ($n=~/^oserv$/ || !$o_stop) { &create_proc_event($n,'stopped',$tiv_sev{$n}); }
		if ($n!~/^oserv$/ && $o_stop) { push(@o_children,$n); }
		}
	}
sub calc_wait {
        $next_procs-=($_[0]-$loop_start);
        $next_hb-=($_[0]-$loop_start);
        if ($next_procs <= 0 || $next_hb <= 0 ) {
                if ($next_procs <= 0) { $do_procs=1; $next_procs+=$proc_poll; } else { $do_procs=0; }
                if ($next_hb <= 0) { $do_hb=1; $next_hb+=$hb; } else { $do_hb=0; }
                return 0;
                }
        elsif ($next_procs > $next_hb) { $wait=$next_hb; $do_hb=1; $do_procs=0; $next_procs-=$next_hb; $next_hb=$hb; }
        elsif ($next_procs < $next_hb) { $wait=$next_procs; $do_procs=1; $do_hb=0; $next_hb-=$next_procs; $next_procs=$proc_poll; }
        else { $wait=$next_procs; $do_procs=1; $do_hb=1; $next_procs=$proc_poll; $next_hb=$hb; }
        return $wait;
	}
sub create_heartbeat {
	local($date)="date=".&now;
	local($msg)=$heartbeat_class.$static."$date;severity=HARMLESS;".'END';
	$msg_l=length($msg);
	$term_l=$msg_l+2;	# text terminated by newline and Cntrl-A (0x01)
	local($packed)=pack("a8 N7 a$msg_l c2","<START>>",0,0,0,0,0,$term_l,$term_l,$msg,0x0a,0x01);
	$pmsg.=$packed;
	}
sub create_proc_event {
	local($proc,$mode,$sev)=@_;
	local($date)="date=".&now;
	local($msg)=$proc_class.$static."$date;msg=\"<$proc> has $mode.\";severity=\U$sev;".'END';
	print LOG &now." # <$msg>\n" if LOG;
	$msg_l=length($msg);
	$term_l=$msg_l+2;	# text terminated by newline and Cntrl-A (0x01)
	local($packed)=pack("a8 N7 a$msg_l c2","<START>>",0,0,0,0,0,$term_l,$term_l,$msg,0x0a,0x01);
	$pmsg.=$packed;
	}
sub now {
	local(@t)=localtime; $t[4]++; $t[5]+=1900;
	for (@t){ $_=~s/(.*)/sprintf("%02d",$_)/e; }
	return "$t[3]/$t[4]/$t[5]-$t[2]:$t[1]";
	}
sub send_events {
	if (socket(S,2,1,6) && connect(S,$_[0])) {
		select S; $|=1; $rc=send(S,$pmsg,0); close S;
		unless ($rc) { print LOG &now." # ERROR sending event(s) to <$techost>\n" if LOG; }
		}
	else { print LOG &now." # socket connect error to <$techost>\n" if LOG && (!$pm_flag || $retried); $rc=0; }
	return $rc;
	}
# send udp packet to portmapper to get tec recv port
sub get_port {		
	local($dg)=pack('N13 x2',12345,0,2,0x0186a0,2,3,0,0,0,0,100033057,1,6);
	local($tec_pm)=pack('S n a4 x8',2,111,$tec_addrs{$_[0]});
	socket(PM,2,2,17) || return -1;
	send(PM,$dg,0,$tec_pm) || return -1;
	recv(PM,$reply,256,0);
	close PM;
	return (unpack(N7,$reply))[6];
	}
sub get_ep_name {
	if (open(CFG,"$ENV{'LCF_DATDIR'}/last.cfg")) {
		local($ep_name)= grep(do{chop;s/^lcs.machine_name=(.*)$/$1/},<CFG>);
		close CFG;
		return $ep_name;
		}
	}
sub signals { print LOG &now." # Caught signal <$_[0]>, exiting..\n" if LOG; close CACHE; close LOG; exit; }

Tec-o-Bell V 2.1 Make Tivoli Enterprise Console events audible.

- General design: A daemon regulary polls the TEC server for new events. For each of the defined event groups the most recent event of each severity is read. This data is stored in files, one for each event group. A client program regulary reads one of these files. Which one depends on the event group the user is interested in. It checks each severity for a changed date since last access. A sound for the highest changed severity is being played. The Tec-o-Bell parts are very lightweight and do not slow down framework functionality. Event storms do not result in additional workload. Only short polling cycles could result in some reasonable CPU usage. The number of clients is nearly unlimited. Due to the polling mechanism of server daemon and client the alarm sounds are being played with some time delay. The primary goal was to serve many clients with little resource usage. So hearing an alarm one minute late seemed to be even better than not seeing a severe error because another desktop window hides the TEC console. - How to get it: This program is FREE (GPL) for anyone! To get a copy mailto:[email protected] copyright (c) 2000 by Robert Widmer [email protected]

http://members.mcnon.com/widi/webtec

Do you want to see TEC events in a web browser? and group this events in a business view tree? and have alarm sounds whenever a new event arrives? This is now available with "WebTEC". It's a tool I developed for our Tivoli environment. And it is now usable FREE (GPL) for anyone! Have a look at http://members.mcnon.com/widi/webtec

Key features:

1. multiple business view trees to a set of event groups

2. http based: on the client side only a standard web browser is needed nearly unlimited number of clients no firewall problems, access even through internet Framework functionality is only used to acknowledge/close events server part is based on Apache and PHP3, two great freeware products

3. event sensitive help documents with index engine

4. fast and easy configuration, event filters based on SQL syntax

5. configurable alarm sounds

6. asynchronous event display, unaffected by event storms

7. free software

Much more details and a limited "look and feel" prototype is available at:

http://members.mcnon.com/widi/webtec

Robert Widmer [email protected]

Tivoli - Perl extension for Tivoli TME10

NAME

        Tivoli - Perl extension for Tivoli TME10

SYNOPSIS

        Not (yet) Autoloader implemented.
        use Tivoli::DateTime;
        use Tivoli::Logging;
        use Tivoli::Fwk;
        use Tivoli::Endpoints;

VERSION

               v0.01

License

        Copyright (c) 2001 Robert Hase.
        All rights reserved.
        This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

DESCRIPTION

        This Module will handle about everything you may need for Tivoli TME10.
        If anything has been left out, please contact me at
        [email protected]
        so it can be added.

DETAILS

        This Module is still in work.
        The following Packages are included in v0.01
        (read Package-Documentations for Details)

DEPENDENCIES

        The Tivoli Environment should be sourced at first

Plattforms and Requirements

        read Package-Documentations for Details

HISTORY

INSTALLATION

UNIX

        To install this module type the following:

Win32

        Still in work

AUTHOR

        Robert Hase
        ID      : RHASE
        eMail   : [email protected]
        Web     : http://www.Muc-Net.de

SEE ALSO

               CPAN
       
       
       
        http://www.perl.com
               Tivoli
       
       
       
        http://www.tivoli.com

http://www.perl.com.search.cpan.org/src/RHASE/Tivoli_0.01/ Tivoli::Logging

Perl Extension for Tivoli ... please contact me at [email protected] so it can be added.

Tivoli::AccessManager::Admin, a set of Perl modules

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Tivoli is a trademark of IBM corp.backpan.perl.org/authors/id/C/ CH/CHLIGE/Tivoli-AccessManager-Admin-0.1.readme - 2k -

Recommended Links

Google matched content

Softpanorama Recommended

Top articles

Sites

TIVOLI INFORMATION EXCHANGE

http://members.mcnon.com/widi/webtec Do you want to see TEC events in a web browser? and group this events in a business view tree? and have alarm sounds whenever a new event arrives? This is now available with "WebTEC". It's a tool I developed for our Tivoli environment. And it is now usable FREE (GPL) for anyone! Have a look at

Key features:

  1. multiple business view trees to a set of event groups
  2. http based: on the client side only a standard web browser is needed nearly unlimited number of clients no firewall problems, access even through internet Framework functionality is only used to acknowledge/close events server part is based on Apache and PHP3, two great freeware products
  3. event sensitive help documents with index engine
  4. fast and easy configuration, event filters based on SQL syntax
  5. configurable alarm sounds
  6. asynchronous event display, unaffected by event storms
  7. free software

Much more details and a limited "look and feel" prototype is available at http://members.mcnon.com/widi/webtec Robert Widmer [email protected]



Etc

Society

Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy

Quotes

War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes

Bulletin:

Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law

History:

Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Hater’s Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D


Copyright © 1996-2021 by Softpanorama Society. www.softpanorama.org was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to to buy a cup of coffee for authors of this site

Disclaimer:

The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the Softpanorama society. We do not warrant the correctness of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Last modified: March 12, 2019