IT

HPUX Itanium: replace mirrored boot disk 150 150 Roderick Derks

HPUX Itanium: replace mirrored boot disk

[ELITIL] ELITIL2: / # uname -a
HP-UX ELITIL2 B.11.23 U ia64 0686319827 unlimited-user license

[ELITIL] ELITIL2: / # model
ia64 hp server rx4640

To see which hardwarepath is connected to which scsi address (and to see if Unix has CLAIMED the device, that is loaded a driver for it):
[ELITIL] ELITIL2: / # ioscan -fnC disk

read more

VMware: registry edit after a P2V 150 150 Roderick Derks

VMware: registry edit after a P2V

Handy registry keys to check after doing a P2V

Configuration of network connections is mostly mest up. Clean up under hte following key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network

To find uninstall options for software not registrated in the Microsoft software tool:
HKEY_LOCAL_MACHINE\software\Microsoft\Windows\CurrentVersion\Uninstall

vi editor command summary 150 150 Roderick Derks

vi editor command summary

Starting vi

 

 

Command Description
vi file start at line 1 of file
vi +n file start at line n of file
vi + file start at last line of file
vi +/pattern file start at pattern in file
vi -r file recover file after a system crash

Saving files and quitting vi

 

Command Description
:e file edit file (save current file with :w first)
:w save (write out) the file being edited
:w file save as file
:w! file save as an existing file
:q quit vi
:wq save the file and quit vi
😡 save the file if it has changed and quit vi
:q! quit vi without saving changes

Moving the cursor

 

Keys pressed Effect
h left one character
l or <Space> right one character
k up one line
j or <Enter> down one line
b left one word
w right one word
( start of sentence
) end of sentence
{ start of paragraph
} end of paragraph
1G top of file
nG line n
G end of file
<Ctrl>W first character of insertion
<Ctrl>U up ½ screen
<Ctrl>D down ½ screen
<Ctrl>B up one screen
<Ctrl>F down one screen

Inserting text

 

Keys pressed Text inserted
a after the cursor
A after last character on the line
i before the cursor
I before first character on the line
o open line below current line
O open line above current line

Changing and replacing text

 

Keys pressed Text changed or replaced
cw word
3cw three words
cc current line
5cc five lines
r current character only
R current character and those to its right
s current character
S current line
~ switch between lowercase and uppercase

Deleting text

 

Keys pressed Text deleted
x character under cursor
12x 12 characters
X character to left of cursor
dw word
3dw three words
d0 to beginning of line
d$ to end of line
dd current line
5dd five lines
d{ to beginning of paragraph
d} to end of paragraph
:1,. d to beginning of file
:.,$ d to end of file
:1,$ d whole file

Using markers and buffers

 

Command Description
mf set marker named “f''
`f go to marker “f''
´f go to start of line containing marker “f''
"s12yy copy 12 lines into buffer “s''
"ty} copy text from cursor to end of paragraph into buffer “t''
"ly1G copy text from cursor to top of file into buffer “l''
"kd`f cut text from cursor up to marker “f'' into buffer “k''
"kp paste buffer “k'' into text

Searching for text

 

Search Finds
/and next occurrence of “and'', for example, “and'', “stand'', “grand''
?and previous occurrence of “and''
/^The next line that starts with “The'', for example, “The'', “Then'', “There''
/^The\> next line that starts with the word “The''
/end$ next line that ends with “end''
/[bB]ox next occurrence of “box'' or “Box''
n repeat the most recent search, in the same direction
N repeat the most recent search, in the opposite direction

Searching for and replacing text

 

Command Description
:s/pear/peach/g replace all occurrences of “pear'' with “peach'' on current line
:/orange/s//lemon/g change all occurrences of “orange'' into “lemon'' on next line containing “orange''
:.,$/\<file/directory/g replace all words starting with “file'' by “directory'' on every line from current line onward, for example, “filename'' becomes “directoryname''
:g/one/s//1/g replace every occurrence of “one'' with 1, for example, “oneself'' becomes “1self'', “someone'' becomes “some1''

Matching patterns of text

 

Expression Matches
. any single character
* zero or more of the previous expression
.* zero or more arbitrary characters
\< beginning of a word
\> end of a word
\ quote a special character
\* the character “*''
^ beginning of a line
$ end of a line
[set] one character from a set of characters
[XYZ] one of the characters “X'', “Y'', or “Z''
[[:upper:]][[:lower:]]* one uppercase character followed by any number of lowercase characters
[^set] one character not from a set of characters
[^XYZ[:digit:]] any character except “X'', “Y'', “Z'', or a numeric digit

Options to the :set command

 

Option Effect
all list settings of all options
ignorecase ignore case in searches
list display <Tab> and end-of-line characters
mesg display messages sent to your terminal
nowrapscan prevent searches from wrapping round the end or beginning of a file
number display line numbers
report=5 warn if five or more lines are changed by command
term=ansi set terminal type to “ansi''
terse shorten error messages
warn display “[No write since last change]'' on shell escape if file has not been saved


 

Openfiler, Freenas and RSYNC 150 150 Roderick Derks

Openfiler, Freenas and RSYNC

To Openfiler From Another Machine (a Freenas server)

  1. In Freenas run the RSYNC service
  2. Goto Services > RSYNC > Server > Modules and create a module from the right directory
  3. Use ssh to log into your Openfiler box
  4. To query which modules are available (notice the double colon):
    # rsync freenas.yourdomain.com::
    DATA            MY DATA
  5. To rsync from the module (notice the double colon again)
    # rsync -avu freenas.yourdomain.com::DATA/* /mnt/vg_data01/data01/data/
  6. This one worked for me too(create the user first in Freenas)
    # rsync -avu username@freenas.yourdomain.com:/mnt/DATA/* /mnt/vg_data01/data01/data

To a Freenas Server From Openfiler

  1. First create a module on Openfiler:
    # vi /etc/rsync.conf

    # PLEASE DO NOT MODIFY THIS CONFIGURATION FILE!
    #       This configuration file was autogenerated
    #       by Openfiler. Any manual changes will be overwritten
    #       Generated at: Sat Jun 6 0:32:09 CEST 2009

    port = 873
    motd file = /opt/openfiler/etc/rsync.motd
    address = 192.168.0.10

    # End of Openfiler configuration
    [data]
            comment = data
            path = /mnt/vg_data01/data01/data
            read only = no
            list = yes
            hosts allow = 192.168.0.0/24
            secrets file = /etc/rsyncd.secrets
            uid = nobody
            gid = nobody

    And then reload rsync:
    # service rsync reload

  2. Now you can schedule a RSYNC job in Freenas:
    Services > RSYNC > Client and create the job using the module name.
  3. Check the Freenas logs by going to:
    Diagnostics > Logs > RSYNC > Client

    So remember that this is for getting data TO freenas, not From Freenas to Openfiler. I thought it was the other way around and I lost 50GB of data before I was able to stop the process (by shutting down Freenas). Damn.

Automatically create DHCP addresses from the commandline 150 150 Roderick Derks

Automatically create DHCP addresses from the commandline

Create a csv file, each line contains :

 

10.20.220.0,10.20.221.238,00409D3C40FD,09-200-0277

 

10.20.220.0 = scope

10.20.221.238 = ip adress

00409D3C40FD = MAC adress

09-200.0277 = hostname

  

Then execute the following command that uses the file to make the reservations:

for /f “tokens=1-4 delims=,” %G IN (list.csv) do netsh dhcp server \\dhcp_servername scope %G add reservedip %H %I %J

 

Token-1-4 = select the 4 columns from above

List.csv = Bestand waar alle adressen in staan

Rest van de commando’s spreekt voor zich

 

Execute the following command as administrator:

for /f “tokens=1-4 delims=,” %G IN (list.csv) do netsh dhcp server \\dhcp_servername scope %G add reservedip %H %I %J

Nortel portdiscoverer script 150 150 Roderick Derks

Nortel portdiscoverer script

A couple of months ago I developped this script that pulls information out of Nortel routers and switches via snmp, and then creates a list with the following information about each connected device of which the interface (NIC) is up and running:

  • MAC address
  • IP address
  • DNS name
  • Stack
  • Switch
  • Portnumber

Result:

  • The output of this scripts makes it easy to locate the switch and portnumber a device is connected on. This can save you a lot of time and.
  • A csv file with the info from the list above sorted like this:
    00 1B 25 49 46 42;10.0.0.1;t001b252e4662.domain.com.;stack-h1;450;24;3;25
  • A webpage that is hosted on the same server so that your collegues can easily access the information (secure the webpage with i.e. Apache LDAP access because it contains sensitive info about your network)
  • A history so you can see when a network node has been moved, switched off (not available)
    Remember that every csv file is just a moment in time.
  • This script saves me a lot of time daily when I have to look up the location of a device!

The following hardware is supported:

  • Nortel Passport 8600
  • Nortel switches 5520, 5510, 470, 450
  • Other models have not been tested but might be supported too after some script adjustment

Prequisits

  • linux OS, perl, the snmptool snmpbulkwalk
  • all switches need to have the same SNMP read community string
  • I know that you need the Nortel SNMP MIB file rfc1573rcc.mib (it's in the downloadable package and installed automaticaly when running the install script). You might need other Nortel MIB files, I'm not sure. Let me know!
  • if you want to use the webpage you need to have Apache running on your server

Installation

  • uncompress the tar file i.e. in /tmp
  • run the install script
  • files will be added in /usr/local/portdiscoverer /etc/http/conf.d and /usr/share/snmp/mibs, never overwritten
  • edit the file that contains the list of switches you want to query in /usr/local/portdiscoverer/etc
  • reload the local apache install to activate http://localhost/portdiscoverer
  • a configuration example for ldap access to a W2003R2 Active Directory is located in /etc/http/conf.d/portdiscoverer.conf

Execution

  • Two command line parameters:
    portdiscoverer.pl full
    fullscan alle switches, output in csv file and on html page, email to subscribers to let people know the script was executed
    portdiscoverer.pl <switch dnsname|ipaddress>
    scan one switch, output on console (fast and furious)
  • schedule the cron like this:
    8 9 * * * /usr/local/portdiscoverer/bin/portdiscoverer.pl full > /dev/null 2>&1
    It takes me around 15 minutes to query around 20 stacks with 60 switches and around 2500 connected devices. Mind you that the older switchtypes (nortel 450 and 470) take much longer to query, especially when the stack contains more then 3 switches.

Download!

Enjoy! Let me know if you like it or not when you use it, I would appreciate that.

Cheers!

 

 

#!/usr/bin/perl # #    Copyright (C) 2008 Roderick Derks #    W: http://www.r71.nl #     #    This program is free software; you can redistribute it and/or modify #    it under the terms of the GNU General Public License as published by #    the Free Software Foundation; either version 2 of the License, or #    (at your option) any later version. #     #    This program is distributed in the hope that it will be useful, #    but WITHOUT ANY WARRANTY; without even the implied warranty of #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.    See the #    GNU General Public License for more details. #     #    You should have received a copy of the GNU General Public License #    along with this program; if not, write to the Free Software #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA    02111-1307    USA # #    Adjusted by Roderick Derks (email: roderick at r71.nl) #    Output of snmp query for remaing battery runtime is in minutes or in hours. This #    is a problem when you want to create some nice graphs because of the different #    output. Now hours are converted to minutes. # #    Networkscan for collecting and combining the following data #    on Nortel Passport 8600, 5520, 5510, 470, 450 routers and switches #     - MAC addresses #     - IP addresses #     - DNS names #     - Stack #     - Switch #     - Portnumber # #    v1.0.4 25-08-2008 #    v1.0.5 26-08-2008 #    v1.0.6 26-08-2008 #    v2.0.0 28-08-2008 -> strategie gewijzigd, per switch mac adressen opvragen ipv aan de hand van arptabel op router #    v2.1.1 29-08-2008 -> webpagina genereren #    v2.1.2 29-08-2008 -> webpagina en csv file publiceren op andere lokatie #    v2.2.0 03-09-2008 -> history opbouwen door files met datumnotatie te kopieren naar history dir #    v2.3.1 16-09-2008 -> PORTID's al van te voren opvragen en in een hash gooien (sub FindPortId2) -> 30% tijdwinst #    v2.4.1 16-09-2008 -> Switch- en poortnummers van te voren op te vragen en in een hash gooien -> 50% tijdwinst #    v2.4.2 24-09-2008 -> Fout hersteld met uitprinten tijdens debug #    v2.4.3 24-09-2008 -> bug: webpagina verscheen niet als debugmode lager dan 3 was #    v2.5.0 24-09-2008 -> Uitbreiding: per stack info opvragen en op commandline weergeven. 1e commandline parameter is stack adres #    v2.5.1 24-09-2008 -> Kleine aanpassing: commandline parameter full #    v2.5.2 07-05-2009 -> Download version #    v2.5.3 26-08-2009 -> Added support to use a different snmp string for each stack # ###############################################################  # configurable parameters:  $router=ezh2; $communitystring_router = "public";  # snmp read access community string for router $communitystring_default = "public"; # read access community string for switches $email_address="your_address\@domain.com"; # leave in the \ before the @ $debug="0";  # do not adjust anything from here if you have doubts about what you are doing  $baystacklist="/usr/local/portdiscoverer/etc/baystacklist";  ############################################################## &current_time_and_date;  $procesfile="/usr/local/portdiscoverer/bin/portdiscoverer.lock"; $resultfile="/usr/local/portdiscoverer/var/portdiscoverer.csv"; $tempfile="/usr/local/portdiscoverer/var/portdiscoverer.tmp"; $resultfileonweb="/var/www/html/portdiscoverer/portdiscoverer.csv"; $webpagedir="/var/www/html/portdiscoverer"; $webpage="/var/www/html/portdiscoverer/portdiscoverer.html"; $fakemibfile="/usr/share/snmp/mibs/SNMPv2-SMI.mib"; # to prevent snmp commands using the MIBS ALL setting which preolads MIB files $historydir="/usr/local/portdiscoverer/var/history"; $historyfile="${historydir}/${year}${mon}${mday}${hour}${min}_portdiscoverer.csv";   ############################################################################# # MAIN ROUTINE ############################################################################# # # &make_html; # &OrderByIp; # &make_html; #exit 0;   #&GetBayStacks;  &load_baystacks;   if ( "${ARGV[0]}" eq "" ) {    print "$0 <full>\nfullscan alle switches, output on html page\n\n";    print "$0 <switch dnsname|ipaddress> [snmp RO string]\nscan one switch, output on console\n\n";    exit 1; } if ( "${ARGV[0]}" eq "full" ) {      $mode = "fullreport";      system "echo $$ > $procesfile";     &GetArpTableFromRouter;      open(FILE_WRITE, "> $resultfile");      &current_time_and_date;     $starttime="${mday}-${mon}-${year} ${hour}:${min}:${sec}";      foreach $line (@BayStacks) {          # split info uit $line (stack adres en snmp RO string)         $Stack =  ((split /:/, ${line})[0]);         $communitystring =  ((split /:/, ${line})[1]);         &ZuigDeStackLeeg      }      &current_time_and_date;     $endtime="${mday}-${mon}-${year} ${hour}:${min}:${sec}";      close (FILE_WRITE);      &OrderByIp;       if (! -d "$historydir") {        print "dir $historydir does not exist, creating it...\n" if ( $debug >= 1) ;        system "mkdir $historydir";        }     if (! -d "$webpagedir") {        print "dir $webpagedir does not exist, creating it...\n" if ( $debug >= 1) ;        system "mkdir $webpagedir";        }       system "cp -f $resultfile $webpage";     system "cp -f $resultfile $historyfile";     system "echo \"Portdiscoverer tabel is beschikbaar: http://\${HOSTNAME}/portdiscoverer/portdiscoverer.html\" | /bin/mail -s \"Portdiscoverer tabel\" $email_address";      &make_html;      system "cp -f $resultfile $resultfileonweb";     system "rm -f $procesfile";  }  else {       $Stack = "$ARGV[0]" ;     $stack = "$ARGV[0]" ;     $mode = "singlestack";      if ( "${ARGV[1]}" eq "" ) {        $communitystring = "$communitystring_default"; # read access needed     }     else {        $communitystring = "${ARGV[1]}"; # read access needed     }      print "Scan one switch ${ARGV[0]}, output on console\n";     print "Informatie ophalen uit de routers...\n";     &GetArpTableFromRouter;     print "Informatie ophalen uit stack ${ARGV[0]}...\n";     &ZuigDeStackLeeg ; }  exit 0;   ############################################################################# #############################################################################  sub GetArpTableFromRouter {      print "Getting Arp table from ${router}\n" if ($debug >= 3);      # opvragen MAC adressen per switch en in een tabel jassen      open(ARPTABLE, "snmpbulkwalk -v2c -c ${communitystring_router} $router IP-MIB::ipNetToMediaPhysAddress|");     @ARPTABLE = <ARPTABLE>;     close(ARPTABLE);      print "command: snmpbulkwalk -v2c -c ${communitystring_router} $router IP-MIB::ipNetToMediaPhysAddress\n" if ($debug >= 3);      %ArpTable=();                                         # create the table      foreach $IpMac (@ARPTABLE) {         chomp $IpMac;        $Ip = $IpMac;        $Mac = $IpMac;         # RFC1213-MIB::ipNetToMediaPhysAddress.2056.10.20.180.254 = Hex-STRING: 00 00 5E 00 01 B4        $Ip = ((split / = /, ${Ip})[0]);        $Ip = ((split /ipNetToMediaPhysAddress./, ${Ip})[1]);        $Ip =~ s/[0-9][0-9][0-9][0-9].//g;        #print "Ip: ${Ip}\n" if ($debug >= 3);                $Mac = ((split /Hex-STRING: /, ${Mac})[1]);        chomp $Mac;        chop $Mac;        $Mac2 = $Mac;        $Mac2 =~ s/ /:/g;        #print "Mac: ${Mac} ${Mac2}\n" if ($debug >= 3);         # Toevoegen aan tabel        #print "Naar tabel ArpTable: $Mac, $Ip\n" if ($debug >= 3);        ${ArpTable}{"$Mac"} =  "${Ip}";      }     print "size of hash:  " . keys( %ArpTable ) . ".\n" if ($debug >= 3);     for $key ( keys %ArpTable ) {  $value = $ArpTable{$key};  print "$key => $value\n" if ($debug >= 2); }  }  #############################################################################  sub GetSwitchTypeInfo {    open(OUTPUT, "snmpbulkwalk -m ${fakemibfile} -v2c -c ${communitystring} ${Stack} SNMPv2-MIB::sysDescr.0|");   @OUTPUT = <OUTPUT>;   close(OUTPUT);    print "command: snmpbulkwalk -m ${fakemibfile} -v2c -c ${communitystring} ${Stack} SNMPv2-MIB::sysDescr.0\n" if ($debug >= 3);   $Stacktype="@OUTPUT";   chomp $Stacktype;   print "searching for Stacktype and number\n" if ($debug >= 3);   print "command: snmpbulkwalk -v2c -c ${communitystring} ${Stack} SNMPv2-MIB::sysDescr.0\n" if ($debug >= 3);   print "Stacktype $Stacktype\n" if ($debug >= 3);   $Stacktype = ((split /STRING: /, ${Stacktype})[1]);   print "Stacktype $Stacktype\n" if ($debug >= 3);    if ( $Stacktype =~ /BayStack/ ) {       $Stacktype = ((split /BayStack /, ${Stacktype})[1]);       print "BayStack Stacktype $Stacktype\n" if ($debug >= 3);   }   else {       $Stacktype = ((split /Switch /, ${Stacktype})[1]);       print "Stacktype $Stacktype\n" if ($debug >= 3);   }       $Stacktype = ((split / /, ${Stacktype})[0]);       print "Stacktype $Stacktype\n" if ($debug >= 3);    my @Stacktype_char = split /-/, $Stacktype;    $StackTypeNumber = "${Stacktype_char[0]}";   $NrPortsOnSwitch = ((split /T/, ${Stacktype_char[1]})[0]);    chomp $NrPortsOnSwitch; chomp $StackTypeNumber;    print "Stacktypenumber: ${StackTypeNumber}\n" if ($debug >= 2);   print "nr of ports: ${NrPortsOnSwitch}\n" if ($debug >= 2);  }   #############################################################################  sub current_time_and_date {     # get time and date and set layout of how time variables are printed to the screen    ($sec, $min, $hour, $mday, $mon, $year, $wday) = localtime(time) ;   $mon = sprintf("%0.2d", ++$mon);   $mday = sprintf("%0.2d", $mday);   $hour = sprintf("%0.2d", $hour);   $min = sprintf("%0.2d", $min);   $sec = sprintf("%0.2d", $sec);   $year = $year + 1900;   } # close subroutine  #############################################################################  sub FindPortId {       $we_got_em=0;      foreach $PortId ( @PORTIDS ) {         chomp $PortId;         print "looking for SNMPv2-SMI::mib-2.17.4.3.1.2.${HostId} in $PortId\n" if ($debug >= 3);         if ( "$PortId" =~ "SNMPv2-SMI::mib-2.17.4.3.1.2.${HostId} " ) {     # spatie erachter om einde oid aan te geven            print "PortId 1: $PortId\n"  if ($debug >= 3);             $PortId = ((split /INTEGER: /, ${PortId})[1]);            print "PortId 2: $PortId\n" if ($debug >= 3);             $we_got_em=1;            $PortId2 = "$PortId";         }         last if ( $we_got_em == 1 );      }      $PortId = "$PortId2";  }  ##############################################################################  sub FindSwitchAndPortNumber {       $we_got_em=0;      foreach $SwitchAndPortNr ( @SWITCH_PORT_NUMBERS ) {        chomp $SwitchAndPortNr;         if ( ${StackTypeNumber} == "450" ) {           print "looking for RFC1213-MIB::ifDescr.${PortId} in $SwitchAndPortNr\n" if ($debug >= 3);          if ( "$SwitchAndPortNr" =~ "RFC1213-MIB::ifDescr.${PortId} " ) {     # spatie erachter om einde oid aan te geven             print "switch_and_port:\t$SwitchAndPortNr\n" if ($debug >= 3);              $Switch = ((split /module /, $SwitchAndPortNr)[1]);            print "switch 1:\t${Switch}\n" if ($debug >= 3);             $Switch = ((split /\, port/, ${Switch})[0]);            print "Switch 2:\t${Switch}\n" if ($debug >= 3);              $port = ((split /port /, $SwitchAndPortNr)[1]);            $port = ((split /\"/, ${port})[0]);            print "port 1:\t${port}\n" if ($debug >= 3);              $we_got_em=1;            $Switch2 = "$Switch";            $port2 = "$port";          }        }        else {          print "looking for IF-MIB::ifName.${PortId} in $SwitchAndPortNr\n" if ($debug >= 3);          if ( "$SwitchAndPortNr" =~ "IF-MIB::ifName.${PortId} " ) {     # spatie erachter om einde oid aan te geven             print "switch_and_port:\t$SwitchAndPortNr\n" if ($debug >= 3);              $Switch = ((split /Slot: /, $SwitchAndPortNr)[1]);            print "Switch 1:\t${Switch}\n" if ($debug >= 3);             $Switch = ((split / Port:/, ${Switch})[0]);            print "Switch 2:\t${Switch}\n" if ($debug >= 3);              $port = ((split /Port: /, $SwitchAndPortNr)[1]);            $port = ((split /\)/, ${port})[0]);            print "port 1:\t${port}\n" if ($debug >= 3);              $we_got_em=1;            $Switch2 = "$Switch";            $port2 = "$port";          }        }        last if ( $we_got_em == 1 );         $Switch = "$Switch2";        $port   = "$port2";      } # $SwitchAndPortNr ( @SWITCH_PORT_NUMBERS ) }  ##############################################################################  sub GetAllInfoRightNow {      #     # opvragen MAC adressen van een stack/switch en in een tabel jassen     #      open(OUTPUT, "snmpbulkwalk -v2c -m ${fakemibfile} -c ${communitystring} ${Stack} SNMPv2-SMI::mib-2.17.4.3.1.1|");     @MAC_ADDRESSES = <OUTPUT>;     close(OUTPUT);     print "Collect MAC addresses on the stack ${Stack}\n" if ($debug >= 3);     print "command: snmpbulkwalk -v2c -m ${fakemibfile} -c ${communitystring} ${Stack} SNMPv2-SMI::mib-2.17.4.3.1.1\n" if ($debug >= 3);      # Find port ID's and put 'm in a hash..     # snmpbulkwalk -v2c -c public 10.20.3.250 SNMPv2-SMI::mib-2.17.4.3.1.2.0.17.133.194.65.24     # SNMPv2-SMI::mib-2.17.4.3.1.2.0.17.133.194.65.24 = INTEGER: 133      print "Colect port ID's and put 'm in a hash..\n" if ($debug >= 3);     print "command: snmpbulkwalk -v2c -m ${fakemibfile} -c ${communitystring} ${Stack} SNMPv2-SMI::mib-2.17.4.3.1.2\n" if ($debug >= 3);     open(PORTIDS, "snmpbulkwalk -v2c -m ${fakemibfile} -c ${communitystring} ${Stack} SNMPv2-SMI::mib-2.17.4.3.1.2|");     @PORTIDS = <PORTIDS>;     close(PORTIDS);      #     # Find port- and switchnumbers and put 'm in a hash     #      if ( ${StackTypeNumber} == "450" ) {         print "Collect switchnr and portnr and put 'm in a hash:\n" if ($debug >= 3);        print "command: snmpbulkwalk -v2c -m ${fakemibfile} -c ${communitystring} ${Stack} RFC1213-MIB::ifDescr\n" if ($debug >= 3);        open(SWITCH_PORT_NUMBERS, "snmpbulkwalk -v2c -m ${fakemibfile} -c ${communitystring} ${Stack} RFC1213-MIB::ifDescr|");        @SWITCH_PORT_NUMBERS = <SWITCH_PORT_NUMBERS>;        close(SWITCH_PORT_NUMBERS);     }     else {        print "Collect switchnr and portnr and put 'm in a hash:\n" if ($debug >= 3);        print "command: snmpbulkwalk -v2c -m ${fakemibfile} -c ${communitystring} ${Stack} IF-MIB::ifName\n" if ($debug >= 3);        open(SWITCH_PORT_NUMBERS, "snmpbulkwalk -v2c -m ${fakemibfile} -c ${communitystring} ${Stack} IF-MIB::ifName|");        @SWITCH_PORT_NUMBERS = <SWITCH_PORT_NUMBERS>;        close(SWITCH_PORT_NUMBERS);     }  }  ##############################################################################  sub ZuigDeStackLeeg {      # Het Plan:     # 1. stack systeeminfo uitlezen     # 2. met 1 snmp query mac tabel op stack uitlezen     # 3. met 1 snmp query portid tabel op de stack uitlezen     # 4. met 1 snmp query port en switch tabel op de stack uitlezen     # 5. info combineren: mac -> portid -> port en switch nummer -> ip adres arp tabel router     # 6. dns naam resolven indien ip adres is gevonden     # 7. schrijven naar array en naar file        &GetSwitchTypeInfo;     &GetAllInfoRightNow;       foreach $MacOpDeStack (@MAC_ADDRESSES) {         chomp $MacOpDeStack;        chop $MacOpDeStack;        $HostId = $MacOpDeStack;        # RFC1213-MIB::mib-2.17.4.3.1.1.0.224.216.10.82.174 = Hex-STRING: 00 E0 D8 0A 52 AE        print "MacOpDeStack: $MacOpDeStack\n" if ($debug >= 3);        $MacOpDeStack = ((split /Hex-STRING: /, ${MacOpDeStack})[1]);        print "MacOpDeStack: ${MacOpDeStack}\n" if ($debug >= 3);        $MacId = ${MacOpDeStack};        $MacId =~ s/\ //g;        $MacOpDeStackOfficieel = ${MacOpDeStack};        $MacOpDeStackOfficieel =~ s/\ /\:/g;        print "MacId: ${MacId}\n" if ($debug >= 3);         $HostId = ((split /17.4.3.1.1./, ${HostId})[1]);        print "HostId: ${HostId}\n" if ($debug >= 3);        $HostId = ((split / = /, ${HostId})[0]);        print "HostId: ${HostId}\n" if ($debug >= 3);         &FindPortId;        &FindSwitchAndPortNumber;         if ( $port != ${NrPortsOnSwitch} ) {            $IpArpTable =""; # flush it           $MacArpTable =""; # flush it            # HIER OPZOEKEN BIJBEHORENDE IP ADRES IN %ArpTable           print "Zoek naar ${MacOpDeStack} en bijbehorend ip adres\n" if ($debug >= 3 );            for $MacArpTable ( keys %ArpTable ) {                      $IpArpTable = $ArpTable{$MacArpTable};                      print "Zoek naar ${MacOpDeStack}: $MacArpTable => $IpArpTable\n" if ($debug >= 3 );                      $MacArpTable2 = "$MacArpTable";                      if ( "$MacArpTable" eq "$MacOpDeStack" ) { $MacArpTable2 = "$MacArpTable"; $SearchSuccess=1; }                       if ( "$MacArpTable" ne "$MacOpDeStack" ) { $IpArpTable = ""; $SearchSuccess=0; }                      last if ( "$MacArpTable" eq "$MacOpDeStack" ) ;            }            if ( $SearchSuccess == 0 ) {              print "MAC: $MacOpDeStack in ArpTabel niet teruggevonden. Geen bijbehorend IP adres gevonden $IpArpTable\n" if ($debug >= 3 );           }           elsif ( $SearchSuccess == 1 ) {              print "MAC: $MacOpDeStack in ArpTabel teruggevonden: ${MacArpTable2}, bijbehorend IP adres gebruiken: $IpArpTable\n" if ($debug >= 3 );           }            # DNS resolve alleen indien MAC en IP adres in ARP tabel zijn gevonden           if ($IpArpTable) {              @octet = split /\./, $IpArpTable;             if ( "${octet[3]}"  < 255 ) {                print "resolven ${IpArpTable}\n" if ($debug >= 3);                open(DNS, "dig -x $IpArpTable +short +time=1 2> /dev/null|");                @DNS = <DNS>;                close(DNS);                if ( $? == 0 ) {                   $Dns="@DNS";                   chomp $Dns;                   $Dns =~ s/\n//g; #alias wordt aangeleverd op twee regels, <CR> verwijderen                   if ( $Dns =~ "reply from unexpected source" ) {                      $Dns="dns server returned error";                   }                }                print "Dns: ${Dns}\n" if ($debug >= 3);             }           }            # SCHRIJVEN NAAR EEN TABEL             $HostTable="HostId_${MacId}";           print "Naar tabel ${HostTable}: ${MacOpDeStack}, ${HostId}, ${Stack}, ${StackTypeNumber}, ${NrPortsOnSwitch}, $port, $Switch\n" if ($debug >= 3);           %${HostTable}=();                                         # create the table           %${HostTable} = ( 'MacOpDeStack' => "${MacOpDeStack}",                           'HostId' => ${HostId},                  # add key and value to the table                           'Stack' => ${Stack},                           'StackTypeNumber' => ${StackTypeNumber},                            'NrPortsOnSwitch' => ${NrPortsOnSwitch},                           'Port' => ${port},                           'Switch' => ${Switch},                            'Ip' => ${IpArpTable},                            'Dns' => ${Dns}, );             print "size of hash:  " . keys( %${HostTable} ) . ".\n" if ($debug >= 3);           #for my $key ( keys %${HostTable} ) {  my $value = $$HostTable{$key};  print "$key => $value\n" if ($debug >= 2); }           for $key ( keys %${HostTable} ) {  $value = $$HostTable{$key};  print "$key => $value\n" if ($debug >= 2); }    #          print FILE_WRITE "${MacOpDeStack}, ${IpArpTable}, ${Dns}, ${Stack}, ${StackTypeNumber}-${NrPortsOnSwitch}, $Switch/$port\n";            $rapport = "${MacOpDeStack}\;${IpArpTable}\;${Dns}\;${Stack}\;${StackTypeNumber}\;${NrPortsOnSwitch}\;${Switch};${port}\n";   #             # this is to create a report that can be printed to the screen or to a file #             formline q{@<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<< @>>>-@< @>/@<< #             }, ${MacOpDeStackOfficieel}, $IpArpTable, $Dns, ${Stack}, ${StackTypeNumber}, ${NrPortsOnSwitch}, ${Switch}, ${port}; #             #this is to print the collected statistics to a variable #             $rapport = $^A; #             $^A = ""; # leegmaken anders wordt het rapport cumulatief               # singlestack or full report              if ( "$mode" eq "fullreport" ) {                 print FILE_WRITE "$rapport";              }              else {                 print "$rapport";              }               $MacOpDeStackOfficieel="";              $IpArpTable="";              $Dns="";              $Switch="";              $port="";         }        else {             print "Found MAC on port $port and number of ports on switch is ${NrPortsOnSwitch} and this is maybe a trunk port so we are skipping it.\n" if ($debug >= 3);        }         } # foreach $Stack  }  ##############################################################################  sub WriteToHash {         #$${table}{$MacOpDeStack} = "$HostId";				# add key $MacOpDeStack with value $ServerId to table %table         #$${HostTable}{'HostId'}=${HostId};                        # add to table a key and a value        #$${HostTable}{'MacOpDeStack'}=${MacOpDeStack};         #$${HostTable}{'Stack'}=${Stack};         #$${HostTable}{'StackTypeNumber'}=${StackTypeNumber};         #$${HostTable}{'NrPortsOnSwitch'}=${NrPortsOnSwitch};    }  ##############################################################################   sub OrderByIp {    #system "cp ${resultfile} ${tempfile}";    $column = 1; # 0 is startingpoint, 1 is 2nd column    open(FILEWRITE, "> ${tempfile}");   open(FILEREAD, "< ${resultfile}");    my %lines;   while (<FILEREAD>) {       chomp;       #my $ip = (split)[$column]; # scheidingsteken is spatie       my $ip = (split /;/)[$column];       if ($ip =~ m/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/) {           $ip = ($1 * 256 * 256 * 256) + ($2 * 256 *256) + ($3 * 256) + $4;       } else {           $ip = 0;       }       $lines{$ip} = []           unless $lines{$ip};       push @{ $lines{$ip} }, $_;   }   foreach my $ary (sort keys %lines) {       foreach my $l (@{ $lines{$ary} }) {           print $l, "\n";           print FILEWRITE $l, "\n";       }   }   close (FILEREAD);   close (FILEWRITE);    system "mv -f ${tempfile} ${resultfile}";   #system "rm -f ${tempfile}"; }  ##############################################################################  sub load_baystacks {     # Open file for input    open(BAYSTACKLIST, "<$baystacklist");    # Walk through data file    while (<BAYSTACKLIST>) {        # Skip blank lines       next if (/^\n$/);       # Skip comments       next if (/^#/);        #print "DEBUG: adding $_ to our list of devices \n" if ($DEBUG);        # Remove the CR/LF       chomp;        push (@BayStacks, $_);     } #end while     close(BAYSTACKLIST);     return 1;  } #end sub load_baystacks   ##############################################################################  sub make_html {    # Open the webpage we are going to create open(WEBPAGE, ">$webpage"); flock(WEBPAGE,2) or die "cannot lock file: $!" ;  #write directly to the file, don't wait till the filehandle is closed select((select(WEBPAGE), $| = 1)[0]);  open(FILEREAD, "< ${resultfile}") || die print ">>>ERROR: Can't open FILEREAD: ${resultfile}\n"; @filecontent = <FILEREAD>; close FILEREAD; $NrOfLines = @filecontent;     print WEBPAGE qq| <HEAD>\n|;    print WEBPAGE qq| <TITLE>Portdiscoverer</TITLE>\n|;   # sommige speciale karakters worden voorafgegaan door een escape (oftwel een \) print WEBPAGE qq {    <meta name="author" content="Roderick Derks www.r71.nl">    <STYLE TYPE="text/css">    body {background-color: #FFFFFF}    a.alarm:link {line-height: 2; color: #990000; font-family: arial; font-weight: bold; text-decoration: none; font-size: 70% }   a.alarm:visited {line-height: 2; color: #990000; font-family: arial; font-weight: bold; text-decoration: none; font-size: 70% }   a.alarm:hover {line-height: 2; color: #990000; font-family: arial; font-weight: bold; text-decoration: none; font-size: 75% }   a.alarm:active {line-height: 2; color: #990000; font-family: arial; font-weight: bold; text-decoration: none; font-size: 75% }    a.melding:link {line-height: 2; color: navy; font-family: arial; text-decoration: none; font-size: 70% }   a.melding:visited {line-height: 2; color: navy; font-family: arial; text-decoration: none; font-size: 70% }   a.melding:hover {line-height: 2; color: navy; font-family: arial; text-decoration: none; font-weight: bold; font-size: 70% }   a.melding:active {line-height: 2; color: navy; font-family: arial; text-decoration: none; font-size: 70% }    a.headline:link {color: #000066; font-family: "CG Times"; font-weight: bold; text-decoration: none; font-size: 180% }   a.headline:visited {color: #000066; font-family: "CG Times"; font-weight: bold; text-decoration: none; font-size: 180% }   a.headline:hover {color: #000066; font-family: "CG Times"; font-weight: bold; text-decoration: underline; font-size: 180% }   a.headline:active {color: #000066; font-family: "CG Times"; font-weight: bold; text-decoration: none; font-size: 180% }    a.voetnoot:link {color: #000066; font-family: arial; font-weight: bold; text-decoration: none; font-size: 70% }   a.voetnoot:visited {color: #000066; font-family: arial; font-weight: bold; text-decoration: none; font-size: 70% }   a.voetnoot:hover {color: #000066; font-family: arial; font-weight: bold; text-decoration: underline; font-size: 70% }   a.voetnoot:active {color: #000066; font-family: arial; font-weight: bold; text-decoration: underline; font-size: 70% }    p.description {color: #000000; font-size: 90%; font-family: "Arial"; font-weight: bold; }   p.uitleg {color: #000000; font-size: 70%; font-family: "Arial";}   p.alinea {padding-left: 2cm}    </STYLE>   </HEAD>   <BODY leftmargin="10" topmargin="10" marginwidth="10" marginheight="20" bgcolor="#FFFFFF" onload="blinking_header()" onunload="stoptimer()">   <TABLE align="center" valign="top" id="Headline" cellSpacing="0" cellPadding="0" width="100%" border="0">    <tr bgcolor="#B6C4E0">     <th width="12"><img src="./images/bl_corner_top_left.jpg" width="12" height="12" alt=" "></th>     <td width="100%" height="12"></td>     <th width="12" height="10"><img src="./images/bl_corner_top_right.jpg" width="12" height="12" alt=" "></th>   </tr>   <tr bgcolor="#B6C4E0">     <td width="12" height="100%">&nbsp;</td>     <td width="100%" height="100%" align="center">  };    # eerste drie regels altijd vast: $link_same_page = "http://${HOSTNAME}/portdiscoverer/portddiscoverer.html"; print WEBPAGE qq|     <a target="_top" class="headline" href="$link">Portdiscoverer</a><br>\n|; print WEBPAGE qq|     <p target="_top" class="description"></a>overzicht netwerkapparatuur st. elisabeth ziekenhuis<br>\n|;  &current_time_and_date;            print WEBPAGE qq|       <p class="uitleg" >Gevonden MAC adressen: $NrOfLines</p>\n|;           print WEBPAGE qq|       <a target="_top" class="voetnoot" href="http://ezhappl21/portdiscoverer/portdiscoverer.csv">download csv file</a>\n|;           print WEBPAGE qq|       <p class="uitleg" >pagina gegenereert op ${mday}-${mon}-${year} ${hour}:${min}:${sec}</p><br>\n|;  print WEBPAGE qq {    <td width="12" height="100%">&nbsp;</td>   </tr>   <tr bgcolor="#B6C4E0">     <th width="12" height="10"><img src="./images/bl_corner_bottom_left.jpg" width="12" height="12" alt=" "></th>     <td  height="12"></td>     <th width="12" height="10"><img src="./images/bl_corner_bottom_right.jpg" width="12" height="12" alt=" "></th>   </tr>  </TABLE>   <TABLE align="center" valign="top" id="Alerts" cellSpacing="0" cellPadding="0" width="100%" border="0" bgcolor="#e7ecf6">    <tr bgcolor="#E7ECF6">     <th width="12"><img src="./images/lb_corner_top_left.jpg" width="12" height="12" alt=" "></th>     <td  height="12"></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>     <th width="12" height="10"><img src="./images/lb_corner_top_right.jpg" width="12" height="12" alt=" "></th>   </tr>   <tr bgcolor="#E7ECF6">     <td width="12" height="100%">&nbsp;</td>     <td  height="100%" align="left"><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><p class="alinea" >      <br>  };          print WEBPAGE qq|     <tr class="melding"><td></td><td><p class="description">MAC</td><td><p class="description">IP</td><td><p class="description">DNS</td><td><p class="description">Stack</td><td><p class="description">Type</td><td><p class="description">Aantal poorten</td><td><p class="description">Switch</td><td><p class="description">Port</td><td></td></tr>|;  foreach my $line (@filecontent) {         #$line =~ s/\;/<\/td><td>/g;         $line =~ s/\;/<\/td><td><p class="uitleg">/g;         print "$line\n" if ($debug >= 3) ;         $line = "<td><p class=\"uitleg\">$line<\/td>";         #print WEBPAGE qq|     <a target="_top" class="melding" href="$link">$line</a><br>\n|;         print WEBPAGE qq|     <tr><td></td>$line<td></td></tr>|; }    # sommige speciale karakters worden voorafgegaan door een escape (oftwel een \) print WEBPAGE qq {  <br> </td> <td width="12" height="100%">&nbsp;</td> </tr> <tr bgcolor="#E7ECF6"> <th width="12" height="10"><img src="./images/lb_corner_bottom_left.jpg" width="12" height="12" alt=" "></th> <td height="12"></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td> <th width="12" height="10"><img src="./images/lb_corner_bottom_right.jpg" width="12" height="12" alt=" "></th> </tr>  </TABLE>  <br>  <TABLE align="center" valign="top" id="Bottom" cellSpacing="0" cellPadding="0" width="100%" border="0">  <tr bgcolor="#FFFFFF"> <th width="12"></th> <td height="12"></td> <th width="12" height="10"></th> </tr> <tr bgcolor="#FFFFFF"> <td width="12" height="100%">&nbsp;</td> <td  height="100%" align="center">  };             print WEBPAGE qq|       <a target="_self" class="voetnoot" href="http://${HOSTNAME}/portdiscoverer/portdiscoverer.html">portdiscoverer started at $starttime and finished at $endtime </a><br>\n|;     # Laatste deel vd tabel print WEBPAGE qq {  <td width="12" height="100%">&nbsp;</td>   </tr>   <tr bgcolor="#FFFFFF">     <th width="12" height="10"></th>     <td width="100%" height="12"></td>     <th width="12" height="10"></th>   </tr>  </TABLE>  </BODY> };  close(WEBPAGE);  } # einde sub   

Fedora10 preps for joomla 150 150 Roderick Derks

Fedora10 preps for joomla

# yum -y httpd mysql-server mysql
# yum -y install php php-mysql
# yum install sendmail-cf

————————————————————
# vi /etc/httpd/conf/httpd.conf

<Directory />
    Options Indexes FollowSymLinks
    AllowOverride None
</Directory>

DirectoryIndex index.php index.html index.html.var
————————————————————

voor com_expose:

yum -y install php-gd php-xml

————————————————————

———–
 security!
———–

chown -R root:root .
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
chmod 707 images
chmod 707 images/stories
chmod 707 images/frontpage
chown apache:apache cache
find modules/mod_* -type d -exec chown root:apache {} \;

Check RW status of dirs in administration website Joomla > help > system info > directory permissions

 

Phocagallery remove footer:

components\com_phocagallery\views\category
view.html.php
on line number 81 delete or /* */
$tmpl['lm'] = ''.'P'.'o'.'w'.'e'.'r'.'e'.'d'.' '.'b'.'y'.' '.''.'P'.'h'.'o'.'c'.'a'.''.' '.''.'G'.'a'.'l'.'l'.'e'.'r'.'y'.''.'';

Adjust Hivemind CSS stylesheet 150 150 Roderick Derks

Adjust Hivemind CSS stylesheet

 Adjust the height of the moduleslider (the tabs on the frontpage) by editing the following lines:

# vi templates/rt_hivemind_j15/css/template.css

#moduleslider-size {
        height: 220px;
        overflow: hidden;
}

 

VMware: esxi configuration backup 150 150 Roderick Derks

VMware: esxi configuration backup

The commands vicfg-cfgbackup.pl (esxcfg-cfgbackup.pl) allow you to backup and restore the configuration of your ESX 3i host. Install the RCLI on your pc, download it by clicking the link on the webpage on an ESXi host.

To backup the host you would run the command.

vicfg-cfgbackup.pl –server <server_name> -s <backup_file_name>

To restore your backup configuration to your host you would run the following command. This will cause the host to reboot once the process is complete.

vicfg-cfgbackup.pl –server <server_name> -l <backup_file_name>

NOTES

– While this command can be used to restore your configuration, it is not a substitute for backup of your virtual machines. At this time, a new install of ESX 3i Installable will wipe out any existing datastores that exist on the host when you perform a new install.

– You can use the -q switch to supress the confirmation request that you will receive when you restore a configuratio backup or restore a host back to factory defaults.

– You must have all VMs on the host stopped and have put the host in maintenance mode. Also the build of the install on the ESX host must match the build that is recorded in the backup file. If that is not the case, you can use the -f switch to force the restore. This document is based on the 0.26 version of the RCLI and at this point both the maintenance mode and build number requirements are not enforced.

vicfg-cfgbackup.pl –server <server_name> -f -l <backup_file_name>

To reset the host backup to factory defaults, use the below command. It will put the host in maintenance mode and it will not wipe out any existing datastores. Thus you will be able to add an existing virtual machines back into inventory by either manually adding the virtual machines or by restoring a configuration backup.

vicfg-cfgbackup.pl –server <server_name> -r

 

More online info about the RCLI commands you can find here

VMWare: create VMFS storage from the commandline 150 150 Roderick Derks

VMWare: create VMFS storage from the commandline

I just had to create a couple VMFS volumes from the command-line on a local disk. It’s pretty straight forward but I needed to document it anyway, here it is:

  1. fdisk -l (check what the last partition is)
  2. fdisk /dev/disks/vmhba1\:0\:0\:0
  3. d (I had to delete formerly created linux partitions)
  4. n (new)
  5. default (start block)
  6. default (end block)
  7. t (partition type)
  8. fb (vmfs type)
    1. X
    2. b
    3. 1
    4. 128 (disk alignment, check your SAN manual for the correct value, 128 is correct in most cases…)
    5. W
  9. reboot if needed (I did not have to reboot on my ESXi USB VMware server)
  10. ~ # vmkfstools -C vmfs3 /dev/disks/vmhba1\:0\:0\:1
    Creating vmfs3 file system on “vmhba1:0:0:1” with blockSize 1048576 and volume label “none”.
    Successfully created new volume: 49ce3608-2b378b66-c502-00123fba3df2
  11. Go to VI Client, Refresh storage view and rename the newly created volume

    Your Name (required)

    Your Email (required)

    Subject

    Your Message

      Your Name (required)

      Your Email (required)

      Subject

      Your Message