Month: February 2010

Nagios – Twitter alerts

This entry will cover how to send nagios alerts to twitter, in the examples to follow using curl.

Firstly edit commands.cfg

And add the two following line:

define command {
command_name notify-by-twitter
command_line /usr/bin/curl --basic --user "twitteruser:twitterpassword" --data-ascii "status=[Nagios] $NOTIFICATIONTYPE$ $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$" http://twitter.com/statuses/update.json
}

define command {
command_name host-notify-by-twitter
command_line /usr/bin/curl --basic --user "twitteruser:twitterpassword" --data-ascii "status=[Nagios] $HOSTSTATE$ alert for $HOSTNAME$" http://twitter.com/statuses/update.json
}

Now define a contact for this twitter service into: contacts.cfg

define contact{
contact_name twitter
service_notification_commands notify-by-twitter
host_notification_commands host-notify-by-twitter
service_notification_period 24x7
host_notification_period 24x7
service_notification_options a
host_notification_options a
}

Add this contact into your existing contact groups like this (in contacts.cfg):

define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members nagiosadmin,sms_alert,twitter
}

Then run a nagios prefly check to ensure you have no syntax errors, and restart nagios.

OpenVMS – Command line editing

DCL implements command line editing and recall, so that users can more easily correct typing errors and reuse previous command lines.

Recall buffer: access to recently issued commands

$ RECALL string Bring up last command beginning with string.
$ RECALL/ALL Displays all commands and their numbers.
$ RECALL number Use a number found in RECALL/ALL.

Command line editing (if it isn’t on, do: $ SET TERM/LINE):

$ {up-arrow} Previous command in recall buffer.
$ {down-arrow} Next command in recall buffer.
$ {Ctrl A} Toggle insert/overstrike editing.
$ {Ctrl D} Move one character left.
$ {Ctrl E} Move to the end of the line.
$ {Ctrl F} Move one character right.
$ {Ctrl H} Move to the beginning of the line.
$ {Ctrl J} Delete word left of cursor.
$ {Ctrl R} Rewrite the command line.
$ {Ctrl U} Delete line left of cursor.
$ {Ctrl X} Cancel the current command line.

Miscellaneous:

$ {Ctrl 3} ASCII code for {Esc}.
$ {Ctrl I} ASCII code for {Tab}.
$ {Ctrl Z} Tell DCL "end of file". Used in some programs
to indicate more general sorts of "end" commands.

Of these, only {Ctrl I} will insert a character into the command line,
rather than just move the cursor around. No new characters may be
inserted before a tab ({Ctrl I}) in a command line, but existing characters
may be changed in overstrike mode, or deleted. This behavior is documented in the “I/O User’s Guide” and has existed since VMS 4.0.

MSTSC – Admin session

Memo per il Giaco:

Syntax
MSTSC option
MSTSC /Edit"ConnectionFile"
MSTSC /migrate

Options
ConnectionFile The name of an RDP file for connection

/v: The remote computer to connect to

/console Connect to the console of a server (NT/XP)
/Admin Connect to a session for administering the server(Vista/2008)

/f Start in Full Screen mode

/w:width Width of the RDP screen
/h:height Height of the RDP screen

/span Match the Remote Desktop width and height with the local virtual
desktop, spanning across multiple monitors if necessary.(Vista/2008)

/public Run Remote Desktop in public mode. (Vista/2008)
In public mode, passwords and bitmaps are not cached.

/edit Open the RDP file for editing.
/migrate Convert a legacy Client connection file into an .RDP file

Exim – Spool destroyer

In case of massive spam attack.

#!/bin/bash
ls /var/spool/exim/input/ > /tmp/delspoorexim
declare -a ARRAY
exec 10< /tmp/delspoorexim
let count=0
while read dels <&10; do
rm -fr /var/spool/exim/input/$dels
echo $dels
ARRAY[$count]=$dels
((count++))
done
echo Number operation done: ${#ARRAY[@]}
#echo ${ARRAY[@]}
exec 10>&-
rm /tmp/delspoorexim

OpenVMS – SYS$BATCH Queue

Little memo about sys$batch queue:

If no queue manger set:

$ DEFINE/SYSTEM/EXECUTIVE_MODE QMAN$MASTER DKA100:[QUEMAN]
$ START/QUEUE/MANAGER DKA100:[SYSQUE]

Problem:

$ SHOW QUEUE SYS$BATCH
%JBC-E-NOSUCHQUE, no such queue

Resolution:

$ INIT/QUE/BATCH SYS$BATCH

Problem:

$ SHOW QUEUE SYS$BATCH
%JBC-E-JOBQUEDIS, system job queue manager is not running

Resolution:

$ START/QUE SYS$BATCH

Full Reset:

$ STOP/QUE SYS$BATCH
$ DELETE/QUE SYS$BATCH
$ INIT/QUE/BATCH SYS$BATCH

More info:
OpenVMS System Manager’s Manual
Chapter 13
Managing the Queue Manager and Queue Database

Solaris – Add swap to ZFS disk

I installed Solaris 10 05/09 on a machine and I used whatever the default swap space setting when I built the box. Now I need to increase the swap space and I can’t add a swap file, like was possible under UFS.

If your swap device is in use, then you might not be able to delete it. Check to see if the swap area is in use. For example:

$ swap -l
swapfile dev swaplo blocks free
/dev/zvol/dsk/rpool/swap 182,2 8 4194296 4194296

In the above output, blocks == free, so the swap device is not actually being used.

If the swap area is not is use, remove the swap area. For example:

$ swap -d /dev/zvol/dsk/rpool/swap

Confirm that the swap area is removed.

$ swap -l

No swap devices configured

Resize the swap volume. For example:

$ zfs set volsize=1G rpool/swap

Activate the swap area.

$ swap -a /dev/zvol/dsk/rpool/swap

$ swap -l
swapfile dev swaplo blocks free
/dev/zvol/dsk/rpool/swap 182,2 8 2097144 2097144

DEC 3000 Alpha – Firmware Upgrade

>>> boot esa0
INIT-S-CPU...
INIT-S-ASIC...
INIT-S-MEM...
INIT-S-NVR...
INIT-S-CXT...
INIT-S-SCC...
INIT-S-NI...
INIT-S-SCSI...
INIT-S-ISDN...
AUDIT_BOOT_STARTS ...
AUDIT_BOOT_REQ
AUDIT_BOOT_RETRY
AUDIT_BOOT_RETRY
AUDIT_BOOT_RETRY
AUDIT_BOOT_RETRY
AUDIT_BSERVER_FOUND
AUDIT_LOAD_BEGINS
AUDIT_LOAD_DONE
*** FIRMWARE UPDATE UTILITY V2.6a ***
*** SYSTEM TYPE: M300 ***
UPDATE
VERIFY
LIST
SHOW
?
UPD-> update
Read IO ROM Device ID
UPD-I VERIFY LOADED ROM IMAGE
...........................
UPD-I VERIFY LOADED ROM IMAGE DONE
MANUFACTURER = INTEL (0x89)
DEVICE CODE = 28F020 (0xbd) 256K x 8
Read System ROM Device ID
UPD-I VERIFY LOADED ROM IMAGE
...........................
UPD-I VERIFY LOADED ROM IMAGE DONE
MANUFACTURER = INTEL (0x89)
DEVICE CODE = 28F020 (0xbd) 256K x 8
UPDATE SYSTEM ROM DEVICE
UPD-I VERIFY LOADED ROM IMAGE
...........................
UPD-I VERIFY LOADED ROM IMAGE DONE
FIRMWARE REVISION: V7.0 LENGTH: 0x352e4 -> 217828 BYTES CHECKSUM: 0x1c
MANUFACTURER = INTEL (0x89)
DEVICE CODE = 28F020 (0xbd) 256K x 8
UPD-I *** ROM CONTENTS WILL BE DESTROYED ***
UPD-I ARE YOU READY TO PROGRAM DEVICE ? (Y/N ) y
UPD-I PRECHARGING DEVICE
................................................................
UPD-I ERASING ROM DEVICE
................................................................
UPD-I PROGRAMMING DEVICE
.....................................................
UPD-I PROGRAMMING COMPLETED
...........................
SYSTEM ROM UPDATE SUCCESSFUL
UPDATE IO ROM DEVICE
UPD-I VERIFY LOADED ROM IMAGE
...........................
UPD-I VERIFY LOADED ROM IMAGE DONE
FIRMWARE REVISION: V7.0 LENGTH: 0x34da8 -> 216488 BYTES CHECKSUM: 0x59
MANUFACTURER = INTEL (0x89)
DEVICE CODE = 28F020 (0xbd) 256K x 8
UPD-I PRECHARGING DEVICE
................................................................
UPD-I ERASING ROM DEVICE
................................................................
UPD-I PROGRAMMING DEVICE
....................................................
UPD-I PROGRAMMING COMPLETED
...........................
IO ROM UPDATE SUCCESSFUL
UPD->
UPD-> ?
UPDATE:
Update the ROMs. Jumpers MUST be installed on both roms.
For example
UPD->update

VERIFY [DEVICE]:
Verify the ROM[s]. If no qualifiers then all ROMS verified
The Checksum of file image is compared with rom image
For example
UPD->verify
UPD->verify system
UPD->verify io

SHOW [DEVICE]:
Show the current ROM Revision
For example
UPD->show
UPD->show system
UPD->show io

LIST :
List the supported ROM Devices
For example
UPD->list
*** ROM Devices Supported ***
SYSTEM: KN15-AA CPU Module 28F020 256Kx8 FLASH MEMORY
IO: IO-XXX I/O Module 28F020 256Kx8 FLASH MEMORY

*** FIRMWARE UPDATE UTILITY V2.6a ***
*** SYSTEM TYPE: M300 ***
UPDATE
VERIFY
LIST
SHOW
?
UPD->