Sunday, December 13, 2009

[Sed] Delete one or more lines from a file - The solution

[Sed] Delete one or more lines from a file - The solution: "Remove the 3rd line:

sed '3d' fileName.txt



Removal of the line containing the string 'awk':

sed '/awk/d' filename.txt



Remove the last line:

sed '$d' filename.txt




Remove all empty lines:

sed '/^$/d' filename.txt
sed '/./!d' filename.txt"

expect in bash script ? - Dev Archives

expect in bash script ? - Dev Archives: "#!/bin/bash

RESULT=`echo 'set timeout -1
spawn ssh someaddress
expect {
Password: {send -- \'mypass\r\'; exp_continue}
user@ {send -- \'dosomething\r\'; exp_continue}
user@ {send -- \'exit\r\'}
} eof | expect -f -`

echo $RESULT
}"

Saturday, December 5, 2009

Absoblogginlutely! » Dell Open Manage Server Administrator (OMSA) alert setup – updated

Absoblogginlutely! » Dell Open Manage Server Administrator (OMSA) alert setup – updated: "Dellalert.bat should now contain the following lines.

@echo off
::Dell alert program
::v1.21
::Set variables below as appropriate
::needs blat downloaded (http://tinyurl.com/2qdxea) Put blat.exe in the system path
::No longer needs blat installed as configuration is set in the environment variables.

@echo on
setlocal
set log=c:\jobs\dell.txt
set pager=destinationpageraddress@company.com
set mail=destinationemailaddress@company.com
set company=Companyname
set server=%computername%
set mailserver=mailservername
set alertfrom=fromemailaddress@company.com

date /t >%log%
time /t >>%log%
echo %* >>%log%
if {%1}=={p} blat %log% -to %pager% -server %mailserver% -f %alertfrom% -subject “%company% %server% alert – %*”
if not {%1}=={} blat %log% -to %mail% -server %mailserver% -f %alertfrom% -subject “%company% %server% alert – %*”
endlocal

The commands to specify the call to dellalert.bat are below. Note that you need to specify cmd.exe and then the batch file. As the batch file has parameters with quotes, the quotes need to escaped with backslashes (as per the information below). I highly recommend you save these commands to a batch file called conf.bat and then run the batch file – a lot easier to manage, recall and implement on multiple servers. Each line starts with omconfig – you will probably find your web browser has wrapped the lines, but if you copy/paste the content into notepad your lines should be correct.

omconfig system alertaction event=batterywarn execappath=”cmd /c \”c:\jobs\dellalert p battery probe warning\”'
omconfig system alertaction event=batteryfail execappath=”cmd /c \”c:\jobs\dellalert p battery probe failure\”'
omconfig system alertaction event=fanwarn execappath=”cmd /c \”c:\jobs\dellalert fan probe warning\”'
omconfig system alertaction event=fanfail execappath=”cmd /c \”c:\jobs\dellalert p fan probe failure\”'
omconfig system alertaction event=hardwarelogwarn execappath=”cmd /c \”c:\jobs\dellalert hardware log warning\”'
omconfig system alertaction event=hardwarelogfull execappath=”cmd /c \”c:\jobs\dellalert p hardware log failure\”'
omconfig system alertaction event=intrusion execappath=”cmd /c \”c:\jobs\dellalert chassis intrusion detected\”'
omconfig system alertaction event=memprefail execappath=”cmd /c \”c:\jobs\dellalert p memory prefailure\”'"

Wednesday, November 25, 2009

Ubuntu Forums - View Single Post - SNMP and Dell OMSA on a PE 2950 with Ubuntu 6.06LTS server.

Ubuntu Forums - View Single Post - SNMP and Dell OMSA on a PE 2950 with Ubuntu 6.06LTS server.: "SNMP and Dell OMSA on a PE 2950 with Ubuntu 6.06LTS server.
The web interface will start up with /etc/init.d/dsm_om_connsvc start

If you want it to start automatically when you boot up, run this line without the quotes.

'/usr/sbin/update-rc.d dsm_om_connsvc start 20 2 3 4 5 . stop 19 0 1 6 . >/dev/nullssh'

To enable snmp to work with OMSA, you need to enable it. Run '/etc/init.d/dataeng enablesnmp'.
This will add a line at the bottom of your /etc/snmp/snmpd.conf so OMSA can connect to SNMP via smux.

This is the line it adds. 'smuxpeer .1.3.6.1.4.1.674.10892.1'

You still need to configure your snmpd.conf to allow connections to read the snmp. Here is a sample. NOTE: public is always the default community. For added security, change it to something else.


rwcommunity public 127.0.0.1
rocommunity public 127.0.0.1
rwcommunity public servername
rocommunity public servername
trapcommunity public
trapsink servername public
trapsink servername public
syscontact Root <root@localhost>
syslocation corp

Trapsink sends traps to that server, with the community string. I do localhsot AND the servers monitoring it. ro and rwcommunity is pretty self explanatory.

NOTE: Check your /etc/default/snmpd file and remove 127.0.0.1 from the line it's on. That is extra security so only localhost can read your snmp traps. Obviously you want others to read it, so make sure to remove it. When you are done, the line should look like this:

SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid' <-- don't copy and paste this in, just delete 127.0.0.1 out of that line. You need the back tics and the forum format may change them.

Now do: /etc/init.d/snmpd restart
then a /etc/init.d/dataeng restart

That should get you working for 32bit users.

64bit users, keep going.

If you cannot log in at https://servername:1311 and you keep getting log in, incorrect(and it should if you are running a 64 bit distro), you need to copy some files, as OMSA 5 uses PAM and not it's own authentication anymore.

Change /lib/security path to /lib32 in /etc/pam.d/omauth
This is what omauth will look like afterwards

auth required /lib32/pam_unix.so nullok
auth required /lib32/pam_nologin.so
account required /lib32/pam_unix.so nullok


and copy from a 32bit install (a server running a 32bit ubuntu/debian distro) theses files :

/lib/libsepol.so.1
/lib/libselinux.so.1
/lib/security/pam_unix.so
/lib/security/pam_nologin.so

copy into /lib32 on your amd64 servers.

I just run these lines on the 32bit server, to copy over to my amd64 server.

scp /lib/security/libse* root@server:/lib32/

scp /lib/security/pam_* root@server:/lib32/

then edit the /etc/pam.d/omauth as described above.

after a ldconfig (run ldconfig) you should be able to pam login to the web interface at https://server:1311

For snmp to work, I would restart a few services.

Do a /etc/init.d/snmpd restart
then a /etc/init.d/dataeng restart

If you don't have a 32 bit install, PM me, I could zip the files up and send them to you.

That should do it.

Good luck."

Tuesday, November 24, 2009

Dell PERC 6/i and RAID monitoring

Dell PERC 6/i and RAID monitoring: "Dell PERC 6/i and RAID monitoring

A few pointers for people trying to get Dell's PERC 6/i RAID monitoring working under Ubuntu, and any other linux for that matter. It also applies to PERC 5/i too, and... other stuff :-)

First, visit Dells Linux site. Have a poke about, see what's there.

Next, we need to download a tool to get information from your array. Download LSI's MegaRAID CLI tool for linux. It comes as a .RPM, so if you're an ubuntu user, you can convert it to a .deb using alien, or convert it to a .tar.gz.
# alien --to-tgz MegaCli-1.01.39-0.i386.rpm

You then have a CLI tool you can use to get all your data now! For example:
# ./opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -aALL | grep State State: Optimal

One thing I spent a while figuring out was how to get the rebuild progress, so here's how:
# ./opt/MegaRAID/MegaCli/MegaCli64 -PDRbld -ShowProg -PhysDrv \[32:1\] -aALL

There's also a really useful cheat sheet for common tasks

Don't forget to actually monitor this output with nagios, or your favorite monitoring tool!"

Thursday, November 19, 2009

lanmap – Network discovery tool that produces nice 2d images | Ubuntu Geek

lanmap – Network discovery tool that produces nice 2d images | Ubuntu Geek: "Lanmap Listens to all available traffic on the interface of your choice, figures out who’s talking to who, how much, using which protocols.

This information is then put into a nice human-readable 2d image (various formats are available) which can be used to understand a network’s topology.

Install lanmap in Ubuntu

sudo aptitude install lanmap

This will complete the installation

Using lanmap

lanmap syntax

lanmap [-o directory] [-e program] [-T {png,gif,svg}] [-f filtetr] [-D {#,all,raw}] [-r seconds]

[-i {?,*wildcard*,iface}] [-h] [-v] [-V]

lanmap example

lanmap -i eth0 -r 30 -T png -o /tmp/

This will create a lanmap.png file under tmp folder

You can see the same screen here

lanmap available options

-o directory – The directory in which to save the generated images. Default is the current directory.

-e program – The program to use to generate images. Default is twopi.

-T {png,gif,svg} – Output image format. Default is png.

-f filter – Traffic filter, in libpcap syntax.

-D {#,all,raw} – Debug mode; lots of output, use with caution. #: payload bytes to dump (default: 0)

-r seconds – Set the time interval between 2 consecutive graph generations. Default is 60 seconds.

-i {?,*wildcard*,iface} – Interface to use: ?: list all devices and exit *3Com*: use the first NIC with

“3Com” in it

-V – Version info.

-vv – Verbose mode, up to 3 levels (-vv, -vv09:21 29/11/2007v).

-h – Help message."

Network Discovery and Topology Mapping - Ubuntu Forums

Network Discovery and Topology Mapping - Ubuntu Forums: "I'm looking for an application to use to map an industrial ethernet network, and make a graphical network map.

I have tried nmap and it works for me at home but not at work, also it doesn't make graphical topology maps.

I'm looking for something that is easy to use and install under Kubuntu.

So far I have tried, and am not satisfied with or unable to get working

Cacti + weathermap
nessus
cheops
lanmap
AutoScan - gets stuck at update fingerprints
nagios
machinemon
scanrand
netdiscover

So if there is anything in the list that you think I really should be using please say so.

Also if there is anything not in the list that you thing will do the job for me, please tell me.

I have also tried using a few apps via wine, but not good there either.

Any advice at all would be helpful.
Thanks,"