November 17th, 2009
roger
Foi-me solicitado para monitorizar um determinado filesystem e que ao atingir uma determinado valor de ocupação deveria ser chamado um script externo. elaborei o seguinte script que deixo aqui para referência futura
#!/bin/ksh
#Data Actual
date=$( date )
#utilizacao de disco
fschk=$(bdf /arc | grep /arc | grep -v vg | awk ‘{ print $4} ‘ | sed ’s/%//’)
#confirma se bd ja esta a ser tratada
rman=$(ps -elf | grep rman | grep -v grep | wc -l)
#
if [ $fschk -ge 50 ] ; then
if [ $rman -gt 0 ] ; then
echo “$date $fschk % processo rman esta a correr” >> logmonfs
else
echo “$date $fschk % inicializando o script xpto.sh” >> logmonfs
sh -x xpto.sh
fi
else
echo “$date filesystem /arc ocupa $fschk % ” >> logmonfs
fi
September 25th, 2009
roger
Normalmente uso o putty para ligações ssh senti a falta de algo do género para linux mas em modo texto com alguma pesquisa descobri o seguinte programa sshmgr deixo aqui a referencia ao programa
SSH ManaGeR is now deprecated in favour of CONNection ManaGeR.
If you have many ssh accounts on different servers requiring different ports and user names, this is the tool for you!
This is more than _just_ a simple ssh wrapper, sshmgr is really seven applications in one!
There is sshmgr, scmdmgr, sftpmgr, scpget, scpput, ftpmgr and telnetmgr.
sshmgr depends on Perl (>= 5.6.0) and the CPAN module AppConfig. sshmgr also has an accompanying Bash (requires bash >= 2.05b) script for extending the tab auto completion for the commands sshmgr, scmdmgr, sftpmgr, ftpmgr and telnetmgr. There is now a Makefile included for all those that don’t want the hassles of the deb, rpm or tgz packages. Please don’t ask me to include password storing facilities, use ssh-agent and ssh keys to alleviate any password typing woes. Documentation on ssh-agent and ssh keys can be found here.
If you want to contribute bug-reports, feature requests, or code you can join the mailing list here or you can contact me directly.
Here’s my PGP Key.
PGP key num: 04A112AD
Fingerprint: 0864 D1CC E3E5 48BF 3B0F 4373 55EC C529 04A1 12AD
Tarefa abrir 80 zips e substituir um documento.
Uma vez que não gosto de tarefas rotineiras resolvi elaborar um script para isto e aqui fica.
#!/usr/bin/perl -w
use warnings;
#use strict;
use Archive::Zip qw( :ERROR_CODES );
#list directory
@files = <*.zip>;
foreach $file (@files) {
print $file . “\n”;
# Read the ZIP
my $zip = Archive::Zip->new();
unless( $zip->read($file) == AZ_OK ) {
die “read error\n”;
}
# Update file
$zip->removeMember( ‘Pathdentrodozip’);
$zip->addFile( ‘.Pathforadozip’, ‘Pathdentrodozip’ );
# Save the Zip file
$zip->overwrite();
}
Posso ainda melhorar mas não prevejo ter que usar novamente este script.
O que tive de ler: Modulo CPAN
E tive ajuda do Bruno Barão na interpretação do modulo que desde já agradeço