2010-03-12

Two useful Zendmd commands on Event Management

1. dmd.ZenEventManager.getEventList()

This command can get a full list of active events objects

2.dmd.Events.manage_ackEvents()

This command can acknoledge a event, with the evid provided.

An example to utilize these two commands,

++++++++++++++++++++++++++++++++++++++

events = dmd.ZenEventManager.getEventList()

for e in events:

if e.eventClass == "/Perf/CPU":

dmd.Events.manage_ackEvents(e.evid)

++++++++++++++++++++++++++++++++++++++

This script will search all the active events, if the events is from Class "/Perf/CPU", script will acknowledge the event. If you want to delete them, dmd.Events.manage_deleteEvents() will do the job.

3. For a Event object, below properties can be very useful when you want to find cerntain type of events to work with.

e.eventClass: the event classs, such as "/Perf/CPU", "/Status/Ping"

Code Example: if e.eventClass == "/Perf/CPU":

e.eventState: the event state in number, 0 is active non acknoledged; 1 is acknoledged.

Code Example: if e.eventState == 1:

e.summary: the description about the events, such as “disk space usage 100%". It is a string type of variable, so you can apply all the string operation on it. str.split, str.replace.

e.device: the device name associate with this event.

Code Example: if e.device == "wwwsrv1":

e.evid: the event evid, whichi s a uniq identifier for a event. Many event operations require the evid as the parameter.

Code Example: dmd.Events.manage_ackEvents(e.evid)

2010-01-27

Migrate devices from Zenoss 2.3.0 to Zenoss 2.5.1

We have about 250 devices monitoring in a Zenoss Core 2.3.0. Now we decided to move the 2.5.1. The information we want to migrate from 2.3.0 is the devices, device group and device production state. The migration took two steps.

1.

zendevicedump -o

Run this command on 2.3.0. A xml generated contains device name and group information.

zendeviceload -i

Run this command on 2.5.1. All device were correctly loaded, and groups were created. Devices were correctly grouped according the xml.

The issue here is that the 'production state' was not exported to the xml file, so all devices in 2.5.1 are in 'production' state. To fix this issue, the DMD interface did the job.

2.Utilize the zendmd interface to export and import the device prodState and

2.1 Export from 2.3.0

f=open("/tmp/prodstat.txt","w")
for d in dmd.Devices.getSubDevices():
f.write(d.getDeviceName()+" "+d.getProdState()+"\n")
f.close()

2.2 Import to 2.5.1

>>> f=open("/tmp/prodstat.txt","r")
>>> for l in f:
... l = l.rstrip()
... name, state = l.split(" ")
... if state == "Decommissioned":
... number = -1
... elif state == "Maintenance":
... number = 300
... elif state == "Test":
... number = 400
... elif state == "Pre-Production":
... number = 500
... elif state == "Production":
... number = 1000
... d = find(name)
... d.setProdState(number)
...

>>>commit()

I have referenced to many articles in Zenoss Community, thanks.

2009-10-09

Print the /proc/slabinfo in M bytes.

awk '{printf "%5d MB %s\n", $3*$4/(1024*1024), $1}' < /proc/slabinfo | sort -n

2009-10-04

dumpe2fs and fsck -b for ext2/ext3 file system

If the default superblock of a ext2/ext3 file sytem is damaged. You may use dumpe2fs to view the location of backup superblock and then use fsck -b to repair the file sytem.

An example of dumpe2fs output: red is the backup superblock

+++++++++++++++++++++++++++++++++++++++++++++
c1:~ # dumpe2fs /dev/sda1
dumpe2fs 1.41.1 (01-Sep-2008)
Filesystem volume name:
Last mounted on:
Filesystem UUID: 2963e327-deeb-4265-a1e1-1a4e5c0f34dd
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery sparse_super
Filesystem flags: signed_directory_hash
Default mount options: (none)
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 18072
Block count: 72260
Reserved block count: 3613
Free blocks: 50006
Free inodes: 18028
First block: 1
Block size: 1024
Fragment size: 1024
Reserved GDT blocks: 256
Blocks per group: 8192
Fragments per group: 8192
Inodes per group: 2008
Inode blocks per group: 251
Filesystem created: Mon Aug 31 23:12:55 2009
Last mount time: Sun Oct 4 16:39:06 2009
Last write time: Sun Oct 4 16:39:06 2009
Mount count: 30
Maximum mount count: -1
Last checked: Mon Aug 31 23:12:55 2009
Check interval: 0 ()
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 128
Journal inode: 8
Default directory hash: half_md4
Directory Hash Seed: 08edb5d9-25d8-4092-8a2a-36de718d1aaa
Journal backup: inode blocks
Journal size: 4113k


Group 0: (Blocks 1-8192)
Primary superblock at 1, Group descriptors at 2-2
Reserved GDT blocks at 3-258
Block bitmap at 259 (+258), Inode bitmap at 260 (+259)
Inode table at 261-511 (+260)
3057 free blocks, 1982 free inodes, 2 directories
Free blocks: 526-2560, 2998-3584, 4869-5303
Free inodes: 27-2008
Group 1: (Blocks 8193-16384)
Backup superblock at 8193, Group descriptors at 8194-8194
Reserved GDT blocks at 8195-8450
Block bitmap at 8451 (+258), Inode bitmap at 8452 (+259)
Inode table at 8453-8703 (+260)
0 free blocks, 2008 free inodes, 0 directories
Free blocks:
Free inodes: 2009-4016
Group 2: (Blocks 16385-24576)
Block bitmap at 16385 (+0), Inode bitmap at 16386 (+1)
Inode table at 16387-16637 (+2)
5864 free blocks, 2008 free inodes, 0 directories
Free blocks: 16638-16640, 18716-24576
Free inodes: 4017-6024
Group 3: (Blocks 24577-32768)
Backup superblock at 24577, Group descriptors at 24578-24578
Reserved GDT blocks at 24579-24834
Block bitmap at 24835 (+258), Inode bitmap at 24836 (+259)
Inode table at 24837-25087 (+260)
7681 free blocks, 2008 free inodes, 0 directories
Free blocks: 25088-32768
Free inodes: 6025-8032
Group 4: (Blocks 32769-40960)
Block bitmap at 32769 (+0), Inode bitmap at 32770 (+1)
Inode table at 32771-33021 (+2)
3826 free blocks, 2008 free inodes, 0 directories
Free blocks: 37135-40960
Free inodes: 8033-10040
Group 5: (Blocks 40961-49152)
Backup superblock at 40961, Group descriptors at 40962-40962
Reserved GDT blocks at 40963-41218
Block bitmap at 41219 (+258), Inode bitmap at 41220 (+259)
Inode table at 41221-41471 (+260)
7681 free blocks, 2008 free inodes, 0 directories
Free blocks: 41472-49152
Free inodes: 10041-12048
Group 6: (Blocks 49153-57344)
Block bitmap at 49153 (+0), Inode bitmap at 49154 (+1)
Inode table at 49155-49405 (+2)
7746 free blocks, 1990 free inodes, 1 directories
Free blocks: 49407-51712, 51715-52736, 52924-53760, 53764-57344
Free inodes: 12067-14056
Group 7: (Blocks 57345-65536)
Backup superblock at 57345, Group descriptors at 57346-57346
Reserved GDT blocks at 57347-57602
Block bitmap at 57603 (+258), Inode bitmap at 57604 (+259)
Inode table at 57605-57855 (+260)
7681 free blocks, 2008 free inodes, 0 directories
Free blocks: 57856-65536
Free inodes: 14057-16064
Group 8: (Blocks 65537-72259)
Block bitmap at 65537 (+0), Inode bitmap at 65538 (+1)
Inode table at 65539-65789 (+2)
6470 free blocks, 2008 free inodes, 0 directories
Free blocks: 65790-72259
Free inodes: 16065-18072
c1:~ #
++++++++++++++++++++++++++++++++++++++++++++++++

then run:

e2fsck -f -b 8193 /dev/sda1

2009-08-11

Find the files and socket opened by a process

#pfiles PID

Which will list all the files and sockets opened by this process.

If you have a port number and would like to know which process is using it, and you don't have a lsof installed, here is a short script to find it.

for i in `ps -ef -o pid | grep -v PID'`
do
pfiles $i | grep $PORTNUMBET && echo && echo "PID $i is using port number $PORTNUMBER." && echo && pfiles $i
done


#Basicly, this script run command pfiles command agains all running process and search for the process with the port opened.

2009-07-06

Disable a touchpad in Opensolaris

I installed an Opensolaris2009.06 in a Compaq laptop. One annoying thing is that both touchpad and external USB mouse work. When I type, it is unavoidable that the touchpad will be touched and move the pointer around. Here is a solution to disable the touchpad.

~$ modinfo | grep mouse
102 fffffffff79ed628 be8 116 1 mouse8042 (PS/2 Mouse)
103 fffffffff80f7000 2320 - 1 vuid3ps2 (mouse events to vuid events)
127 fffffffff813b000 2c68 - 1 usbms (USB mouse streams)

There is no PS/2 mouse installed for sure. So I remove the PS/2 mouse driver.

~$ pfexec modunload -i 102

If you want to reload this driver, here is the command,

~$ pfexec modload /kernel/drv/amd64/mouse8042

But it didn't bring back my touchpad.


( Actually, all these information is referred/copied from another guy's blog. Appreciate!
http://blogs.sun.com/lubos/entry/disabling_touchpad_in_opensolaris )

Chang Vista GUI from English to Chinese

Tried to convert the GUI of Windoes Vista Home Premium from English to Chinese. Directly downloading the MUI from Windows failed multi times. Then I googled and found this usaful tool to do this job perfectly.

http://www.froggie.sk/usage.html

Follow this usage page, you will convert the GUI lanaguage of Windoes Vista easily.