defaults write com.apple.dashboard mcx-disabled -boolean YES killall Dock
Friday, May 24, 2013
Get rid of Dashboard in Mac OS 10.9
I rarely use the dashboard. All these widgets can be fun, but I did not find one that would make me go to the dashboard regularly. I like gesture though and mission control. And I find that the dashboard is a waste of space when in mission control. So I looked around and saw this post http://www.macworld.com.au/help/how-to-use-terminal-to-speed-up-mountain-lion-70147/#.UZ8GP5VR0TM . One of the tips is how to disable completely the dashboard. So here it is, in 2 commands, how to disable dashboard ( do not use sudo here, just your normal user ) :
Friday, March 22, 2013
Safari opens gmail in mobile view on mac OSX
Ever wonder why your safari browser would open gmail in mobile mode on mac OSX ? It looks like it is due to a cookie. To reset this setting, open up "preferences" in Safari and go to the privacy tab. Then click on the "details" button as illustrated below :
Because you might have a LOT of cookie as I do, you might want to type google in the next window to narrow down the search. Then you should only the google's cookies. The one to remove is googleusercontent. Click on it, then click remove :
You can then click Done, and Safari should now opens gmail in Desktop mode.
Thursday, March 21, 2013
Graphing Summit switches temperature and fan speed
ExtremeNetworks switches can report internal temperature and fan speed. Because I could not find any corresponding snmp values, I decided to use a bash script to get the values. And I used Cacti to graph the result. This document is a documentation on how to do it.
Writing the script
As I mentioned, I could not find any snmp values related to internal temperature or fan speed, so I decided to write a shell script. Because ssh module for ExtremeNetworks switches need to be downloaded, I decided to use the "vanilla" conf and use telnet instead. So the script requires expect to simulate login name and password to enter the switch.
So here is the script :
This is one of the format supported by Cacti to get values from a script. I like it because we have names associated with data and not just the data.
Save the script in cacti script directory. On my installation it is in /var/www/html/scripts/
Then login to cacti and let the fun begins !!!! It is quite tedious to create all the templates needed to graph what you want but it is worth the work. Once done, you can add as many devices as you want with just few clicks.
So let's start with the first template : Data Input Method.
In the console tab of Cacti, go to Collection Methods section and click on Data Input Method. This will list any existing DIM. On the top right corner, click on the "Add" to add a new one and fill the form like below :
It is good pratice when you create template to append its name with the type of template you are creating. In this case it is a Data Input Method, so we'll append DIM to its name.
Input type is script/command. In the next field make sure to add <hostname> after your script name. Without it Cacti won't provide this parameter to your script.
Click create.
On the next form, input fields are the data Cacti provides to your script and outfields the data your script provides to Cacti. So it should look like this :
Save it.
Once you have your Data Input Method, you have to create your Data Template. In the templates section, click on data templates. On the top right corner click "Add".
In the data template, you specify what kind of data you are going to use. There are basically 2 types :
- counter : for data that will constantly increase like a packet count on a network interface
- gauge : a reading like temperature or memory used for instance.
In our case, it's gonna be only gauge.
Fill in the form so it looks like this :
Make sure you write |host_description| in the name of the data source. This will be replace by Cacti with a proper name depending on the host.
Also make sure to match the Output field name ( speedfan1- speedfan1 ) with the datasource item [ speedfan1 ] your are configuring.
We move on to the graph template. Click on graph templates then click "Add". Begin with its name and title ( don't forget the |host_description| ) then click save. You will now be prompted with a new form onto which you add all the graph items you want. This part requires a little more information :
- temperature : I made 2 graph items for the temperature. The first one will fill an area from 0 to the current temperature. So basically, instead of having a single line for the temperature, the surface between 0 and current temperature will also be painted. This is not at all mandatory but it looks better. The second item is simply the line showing the temperature.
- fan speed : Because I wanted to display both fan speed and temperature on the same graph, I had to play a little bit with the scale. Fan speed is typically 1000 and temp should be around 30. So if we try to display both on the same graph with the same scale, temperature will be almost invisible. I decided to divide the fan speed by 100. So 1000 will show up as 10. This is achieve by creating a new CDEF function that I called divide by 100. To do that you go to GraphManagement and click right below on --- CDEF, then click "Add".
The CDEF function "Divide by 100" should be as follow :
So back to the graph template. Your definition should look like this :
Your temperature graph items should be :
And your fan speed graph item like this :
Note here the use of CDEF function "Divide by 100".
The last part of the template definition is the host template. This is basically to associate a type of host with a type of graph. So in our case, we are going to associate the host type "Summit" with the graph type "Extreme - Temp and fan speed - GT" :
Once done, all your templates have been created and this one time job is done. Now it's time to create devices. A device is the actual equipment you want the graph for. Click on Device and "Add" and fill in the form like this :
then the graph should show up in the graph section. Click on it to select then click on "Create graph for this host" :
You might have to wait for up to 5 mns for the graph to be created. Don't panic ! If after 5mns it is still not there then there might be an issue.
If everything is fine you will have something like this :
Hope this document will help.
Writing the script
As I mentioned, I could not find any snmp values related to internal temperature or fan speed, so I decided to write a shell script. Because ssh module for ExtremeNetworks switches need to be downloaded, I decided to use the "vanilla" conf and use telnet instead. So the script requires expect to simulate login name and password to enter the switch.
So here is the script :
#!/bin/bash
USER="XXXXXX"
PASSWORD="XXXXXX"
SWITCHNAME=$1
OUTFILE=$$.expect
if [ -e $1 ]
then
echo "Please provide a switch name..."
exit 99
fi
expect -c "spawn telnet $SWITCHNAME
expect \"login:\"
send \"$USER\r\"
expect \"password:\"
send \"$PASSWORD\r\"
expect \"#\"
send \"sh temp\r\"
expect \"#\"
send \"sh fans\r\"
expect \"#\"
send \"exit\r\"
expect \"(y/N)\"
send \"N\r\"
" >> /tmp/$OUTFILE
TEMPERATURE=`grep "^Switch" /tmp/$OUTFILE | awk '{print $4}'`
FAN1=`grep "Fan-1" /tmp/$OUTFILE | awk '{print $4}'`
FAN2=`grep "Fan-2" /tmp/$OUTFILE | awk '{print $4}'`
FAN3=`grep "Fan-3" /tmp/$OUTFILE | awk '{print $4}'`
FAN4=`grep "Fan-4" /tmp/$OUTFILE | awk '{print $4}'`
#echo "Current switch temperature is : $TEMPERATURE"
#echo "Current fan speed are : $FAN1, $FAN2, $FAN3, $FAN4"
rm /tmp/$OUTFILE
RRDSTRING="temperature:$TEMPERATURE speedfan1:$FAN1 speedfan2:$FAN2 speedfan3:$FAN3 speedfan4:$FAN4"
echo "$RRDSTRING"
I named this script summit-temp. Please replace USER and PASSWORD with your credentials. This script will accept one parameter : hostname. When you run it, it will only output the following line :# ./summit-temp myhost temperature:33.00 speedfan1:1000 speedfan2:1000 speedfan3:1000 speedfan4:1000 #
This is one of the format supported by Cacti to get values from a script. I like it because we have names associated with data and not just the data.
Save the script in cacti script directory. On my installation it is in /var/www/html/scripts/
Then login to cacti and let the fun begins !!!! It is quite tedious to create all the templates needed to graph what you want but it is worth the work. Once done, you can add as many devices as you want with just few clicks.
So let's start with the first template : Data Input Method.
In the console tab of Cacti, go to Collection Methods section and click on Data Input Method. This will list any existing DIM. On the top right corner, click on the "Add" to add a new one and fill the form like below :
It is good pratice when you create template to append its name with the type of template you are creating. In this case it is a Data Input Method, so we'll append DIM to its name.
Input type is script/command. In the next field make sure to add <hostname> after your script name. Without it Cacti won't provide this parameter to your script.
Click create.
On the next form, input fields are the data Cacti provides to your script and outfields the data your script provides to Cacti. So it should look like this :
Save it.
Once you have your Data Input Method, you have to create your Data Template. In the templates section, click on data templates. On the top right corner click "Add".
In the data template, you specify what kind of data you are going to use. There are basically 2 types :
- counter : for data that will constantly increase like a packet count on a network interface
- gauge : a reading like temperature or memory used for instance.
In our case, it's gonna be only gauge.
Fill in the form so it looks like this :
Make sure you write |host_description| in the name of the data source. This will be replace by Cacti with a proper name depending on the host.
Also make sure to match the Output field name ( speedfan1- speedfan1 ) with the datasource item [ speedfan1 ] your are configuring.
We move on to the graph template. Click on graph templates then click "Add". Begin with its name and title ( don't forget the |host_description| ) then click save. You will now be prompted with a new form onto which you add all the graph items you want. This part requires a little more information :
- temperature : I made 2 graph items for the temperature. The first one will fill an area from 0 to the current temperature. So basically, instead of having a single line for the temperature, the surface between 0 and current temperature will also be painted. This is not at all mandatory but it looks better. The second item is simply the line showing the temperature.
- fan speed : Because I wanted to display both fan speed and temperature on the same graph, I had to play a little bit with the scale. Fan speed is typically 1000 and temp should be around 30. So if we try to display both on the same graph with the same scale, temperature will be almost invisible. I decided to divide the fan speed by 100. So 1000 will show up as 10. This is achieve by creating a new CDEF function that I called divide by 100. To do that you go to GraphManagement and click right below on --- CDEF, then click "Add".
The CDEF function "Divide by 100" should be as follow :
So back to the graph template. Your definition should look like this :
Your temperature graph items should be :
And your fan speed graph item like this :
Note here the use of CDEF function "Divide by 100".
The last part of the template definition is the host template. This is basically to associate a type of host with a type of graph. So in our case, we are going to associate the host type "Summit" with the graph type "Extreme - Temp and fan speed - GT" :
Once done, all your templates have been created and this one time job is done. Now it's time to create devices. A device is the actual equipment you want the graph for. Click on Device and "Add" and fill in the form like this :
then the graph should show up in the graph section. Click on it to select then click on "Create graph for this host" :
You might have to wait for up to 5 mns for the graph to be created. Don't panic ! If after 5mns it is still not there then there might be an issue.
If everything is fine you will have something like this :
Hope this document will help.
Monday, March 11, 2013
Disk usage using awk
This command will give you the top 20 files or directories that take the most space in the current directory :
sudo du -k -x --max-depth=1 | sed 's/\.$/Total\n/g' | sort -rn | head -20 | awk 'BEGIN{printf "\n%20s %-30s","Size in Kbytes","file or directory"}{printf "\n%20'\''d %-30s", $1, $2} END{print "\n"}'
Here it is in action :)
sudo du -k -x --max-depth=1 | sed 's/\.$/Total\n/g' | sort -rn | head -20 | awk 'BEGIN{printf "\n%20s %-30s","Size in Kbytes","file or directory"}{printf "\n%20'\''d %-30s", $1, $2} END{print "\n"}'
Here it is in action :)
> sudo du -k -x --max-depth=1 | sed 's/\.$/Total\n/g' | sort -rn | head -20 | awk 'BEGIN{printf "\n%20s %-30s","Size in Kbytes","file or directory"}{printf "\n%20'\''d %-30s", $1, $2} END{print "\n"}'
Size in Kbytes file or directory
12,964,287 Total
455,377 ./Photos
238,572 ./realtek-linux-audiopack-5.17
235,719 ./IPMI
135,153 ./realtek-linux-audiopack-5.16
123,731 ./PCoIP_Driver_SW_v3-0-6_Linux(source
119,884 ./alsa-driver-1.0.25
97,912 ./pcoip_host_software
69,968 ./nagios-plugins-1.4.16
58,653 ./BMC
53,357 ./PCoIP-Test
50,866 ./scim-1.4.9
50,793 ./sunbird
48,648 ./leostream
41,160 ./teradici-firmware
24,886 ./cacti-0.8.8a
19,548 ./wqy-zenhei-0.9.45
16,258 ./leolog
15,888 ./PCoIP_Host_Software_Driver_Linux_r4-0-5
14,394 ./Leostream
>
Friday, February 8, 2013
Adding console output formatting to blogger
I have been looking for a way to display properly formatted command line output in blogger for quite some times now, and I finally have a solution.
Go to Design page of your blog, then click on the "advanced" link on the top left of the page. Scroll all the way down to "Add css". On the text field right below "Add custom CSS" Type the following :
Now each time you want to display command output prepend your text with <pre class="console">
and append your text with </pre>
It's not very pretty at the moment, but I will work on it ! Also this does not seem to work on mobile device....
Go to Design page of your blog, then click on the "advanced" link on the top left of the page. Scroll all the way down to "Add css". On the text field right below "Add custom CSS" Type the following :
pre.console {
background-color: #666666 ;
border: 1px solid #006600 ;
color: #FFFFFF ;
font-size:.8em ;
}
Now each time you want to display command output prepend your text with <pre class="console">
and append your text with </pre>
It's not very pretty at the moment, but I will work on it ! Also this does not seem to work on mobile device....
Cacti : How to use templates
Cacti is a pretty good tool to generate graph. It is developped using php and rrd to store the data collected. Its templates are very usefull and very powerfull.... if you figure out how to create them and in which order ;-)
I recently had to graph a family of devices using Cacti. Using templates was an absolute necessity so I spent time trying to figure out how to use them... It took me few days, so if I may spare that time to somebody else, I decided to write a little documentation on the subject. It's more a flow chart than anything else and it is not official documentation but it might help. Because the size of the flowchart is actually quite big, I only put a thumbsize image here but I included a link to a PDF version of the normal size one.
Link to the original post with PDF version of the document.
I recently had to graph a family of devices using Cacti. Using templates was an absolute necessity so I spent time trying to figure out how to use them... It took me few days, so if I may spare that time to somebody else, I decided to write a little documentation on the subject. It's more a flow chart than anything else and it is not official documentation but it might help. Because the size of the flowchart is actually quite big, I only put a thumbsize image here but I included a link to a PDF version of the normal size one.
Link to the original post with PDF version of the document.
LSI MegaRAID failed drive replacement
Installing command line tool
The command line tool to manage raid devices should be located at /opt/MegaRAID/MegaCli/MegaCli64. If not, you can download the RPM from IBM. It is an architecture independant package. I personnaly used it on Redhat and opensuse successfully. The one I'm using for this documentation is ibm_utl_sraidmr_megacli-8.04.08_linux_32-64.zip. So you have to untar, then do rpm -Uvh on both packages ( one for library and one for the actual command line tool ).Getting the big picture
To start with, the following command queries all adapters and returns information about the virtual drives defined, their status and all physical drives that they are made of. The command output a lot of information so I usually grep some keywords to shorten the text. Here is the command and an extract of the output :./MegaCli64 -LDPDInfo -aALL | egrep "Adapter|Virtual Disk|Name|RAID|State|^Number|^Span|PD:|^Device|Firmware|^$" Adapter #0 Number of Virtual Disks: 2 Virtual Disk: 0 (target id: 0) Name: RAID Level: Primary-5, Secondary-0, RAID Level Qualifier-3 State: Optimal Number Of Drives:9 Span Depth:1 Number of Spans: 1 Span: 0 - Number of PDs: 9 PD: 0 Information Device Id: 15 Firmware state: Online PD: 1 Information Device Id: 16 Firmware state: Online PD: 2 Information Device Id: 17 Firmware state: Online ... PD: 8 Information Device Id: 23 Firmware state: Online Virtual Disk: 1 (target id: 1) Name:data2 RAID Level: Primary-5, Secondary-0, RAID Level Qualifier-3 State: Degraded Number Of Drives:24 Span Depth:1 Number of Spans: 1 Span: 0 - Number of PDs: 24 PD: 0 Information Device Id: 42 Firmware state: Online PD: 1 Information Device Id: 43 Firmware state: Online ... PD: 22 Information Device Id: 64 Firmware state: Online PD: 23 Information Device Id: 65 Firmware state: Online Adapter #1 Number of Virtual Disks: 1 Virtual Disk: 0 (target id: 0) Name: RAID Level: Primary-5, Secondary-0, RAID Level Qualifier-3 State: Optimal Number Of Drives:11 Span Depth:1 Number of Spans: 1 Span: 0 - Number of PDs: 11 PD: 0 Information Device Id: 8 Firmware state: Online PD: 1 Information Device Id: 9 Firmware state: Online ... PD: 10 Information Device Id: 18 Firmware state: Online
Finding the drive to replace
It's a good idea to start gathering info about the Adapter :
/opt/MegaRAID/MegaCli> sudo ./MegaCli64 -AdpAllInfo -aALL
Adapter #0
==============================================================================
Versions
================
Product Name : PERC H700 Integrated
Serial No : 18P02M3
FW Package Build: 12.10.2-0004
...
Device Present
================
Virtual Drives : 1
Degraded : 0
Offline : 0
Physical Devices : 5
Disks : 4
Critical Disks : 0
Failed Disks : 0
...
So we know now that the current machine has one adapter : Adapter 0. So in the following command, we will specify -a0 for adpater 0. Then we get enclosure information :
/opt/MegaRAID/MegaCli> sudo ./MegaCli64 -EncInfo -a0
Number of enclosures on adapter 0 -- 1
Enclosure 0:
Device ID : 32
Number of Slots : 6
Number of Power Supplies : 0
Number of Fans : 0
Number of Temperature Sensors : 0
Number of Alarms : 0
Number of SIM Modules : 0
Number of Physical Drives : 4
Status : Normal
Position : 0
Connector Name : Unavailable
Enclosure type : SES
FRU Part Number : N/A
Enclosure Serial Number : N/A
ESM Serial Number : N/A
Enclosure Zoning Mode : N/A
Partner Device Id : 65535
Inquiry data :
Vendor Identification : DP
Product Identification : BACKPLANE
Product Revision Level : 1.07
Vendor Specific : 18NJ5VP
Exit Code: 0x00
So we have one adapter a0 and one enclosure with an id of 32. We now query for the logical drive information :
/opt/MegaRAID/MegaCli> sudo ./MegaCli64 -LDInfo -LALL -a0 Adapter 0 -- Virtual Drive Information: Virtual Drive: 0 (Target Id: 0) Name :server RAID Level : Primary-1, Secondary-0, RAID Level Qualifier-0 Size : 557.75 GB Mirror Data : 557.75 GB State : Degraded Strip Size : 64 KB Number Of Drives per span:2 Span Depth : 2 Default Cache Policy: WriteBack, ReadAdaptive, Direct, No Write Cache if Bad BBU Current Cache Policy: WriteBack, ReadAdaptive, Direct, No Write Cache if Bad BBU Default Access Policy: Read/Write Current Access Policy: Read/Write Disk Cache Policy : Disk's Default Encryption Type : None Bad Blocks Exist: No Is VD Cached: Yes Cache Cade Type : Read OnlyThis shows us the RAID level used ( 1-0 so a mirror of strippes ) and the status of this raid device : Degraded.
So now we look for the deffective drive with the following command. The field we need to watch is Firmware State : Failed.
/opt/MegaRAID/MegaCli> sudo ./MegaCli64 -PDList -a0 Adapter #0 ... Enclosure Device ID: 32 Slot Number: 3 ... Firmware state: Failed ...The output has been truncated to show only relevant information. So in our case, it's the drive in slot number 3 of enclosure ID 32 that needs to be replaced.
Replacing the drive
We prepare the drive for replacement :/opt/MegaRAID/MegaCli> sudo ./MegaCli64 -PDOffline -PhysDrv\[32:3\] -a0 Adapter: 0: EnclId-32 SlotId-3 state changed to OffLine. Exit Code: 0x00 /opt/MegaRAID/MegaCli> sudo ./MegaCli64 -PDMarkMissing -PhysDrv\[32:3\] -a0 EnclId-32 SlotId-3 is marked Missing. Exit Code: 0x00 /opt/MegaRAID/MegaCli> sudo ./MegaCli64 -PDPrpRmv -PhysDrv\[32:3\] -a0 Prepare for removal Success Exit Code: 0x00Now it's time for the physical replacement.
Then if everything went smoothly, you should see the array being rebuild :
/opt/MegaRAID/MegaCli> sudo ./MegaCli64 -PDInfo -PhysDrv\[32:3\] -a0 Enclosure Device ID: 32 Slot Number: 3 Drive's postion: DiskGroup: 0, Span: 1, Arm: 1 Enclosure position: N/A Device Id: 3 ... Firmware state: Rebuild ...We can query the controler to see the actual rebuild progress :
/opt/MegaRAID/MegaCli> sudo ./MegaCli64 -PDRbld -ShowProg -PhysDrv\[32:3\] -a0 Rebuild Progress on Device at Enclosure 32, Slot 3 Completed 7% in 3 Minutes. Exit Code: 0x00
Checking
Eventually, you should see something like that :/opt/MegaRAID/MegaCli> sudo ./MegaCli64 -PDRbld -ShowProg -PhysDrv\[32:3\] -a0 Device(Encl-32 Slot-3) is not in rebuild process Exit Code: 0x00 /opt/MegaRAID/MegaCli> sudo ./MegaCli64 -LDInfo -LALL -a0 Adapter 0 -- Virtual Drive Information: Virtual Drive: 0 (Target Id: 0) Name :server RAID Level : Primary-1, Secondary-0, RAID Level Qualifier-0 Size : 557.75 GB Mirror Data : 557.75 GB State : Optimal Strip Size : 64 KB Number Of Drives per span:2 Span Depth : 2 Default Cache Policy: WriteBack, ReadAdaptive, Direct, No Write Cache if Bad BBU Current Cache Policy: WriteBack, ReadAdaptive, Direct, No Write Cache if Bad BBU Default Access Policy: Read/Write Current Access Policy: Read/Write Disk Cache Policy : Disk's Default Encryption Type : None Bad Blocks Exist: No Is VD Cached: Yes Cache Cade Type : Read Only Exit Code: 0x00
Monday, October 22, 2012
Reformating output using perl and regex
Perl can be very handy when working with strings. once can reformat almost any string using regular expressions. I had to work on MIB values recently and input these values to Cacti. I would parse the MIB on a network device and get a list of values like :
TERADICI-PCOIPv2-MIB::pcoipGenDevicesName.1 = STRING: "pcoip-host-0030040e079e"
TERADICI-PCOIPv2-MIB::pcoipGenDevicesDescription.1 = ""
TERADICI-PCOIPv2-MIB::pcoipGenDevicesGenericTag.1 = ""
TERADICI-PCOIPv2-MIB::pcoipGenDevicesPartNumber.1 = STRING: "TERA1200 revision 1.0 (128 MB)"
TERADICI-PCOIPv2-MIB::pcoipGenDevicesFwPartNumber.1 = STRING: "Leadtek rev M host card with copper"
TERADICI-PCOIPv2-MIB::pcoipGenDevicesSerialNumber.1 = STRING: "L12060000489"
TERADICI-PCOIPv2-MIB::pcoipGenDevicesHardwareVersion.1 = STRING: "62917013120-D"
TERADICI-PCOIPv2-MIB::pcoipGenDevicesFirmwareVersion.1 = STRING: "4.0.2"
TERADICI-PCOIPv2-MIB::pcoipGenDevicesUniqueID.1 = STRING: "00-30-04-0E-07-9E"
TERADICI-PCOIPv2-MIB::pcoipGenDevicesMAC.1 = STRING: "00-30-04-0E-07-9E"
TERADICI-PCOIPv2-MIB::pcoipGenDevicesUptime.1 = Counter64: 264895
TERADICI-PCOIPv2-MIB::pcoipImagingDevicesIndex.1 = INTEGER: 1
TERADICI-PCOIPv2-MIB::pcoipImagingDevicesIndex.2 = INTEGER: 2
TERADICI-PCOIPv2-MIB::pcoipImagingDevicesIndex.3 = INTEGER: 3
TERADICI-PCOIPv2-MIB::pcoipImagingDevicesIndex.4 = INTEGER: 4
To pass these values to Cacti, I needed to reformat these lines so they would display:.
To replace a substring in perl, we use the =~ s///. We can also add an "i" at the end to make it case insensitive : =~ s///i.
A simple exemple would be :
would print out :
String replacement in perl
All the power comes from search operators that we can apply on the search part. These seach operators are :
TERADICI-PCOIPv2-MIB::pcoipGenDevicesName.1 = STRING: "pcoip-host-0030040e079e"
TERADICI-PCOIPv2-MIB::pcoipGenDevicesDescription.1 = ""
TERADICI-PCOIPv2-MIB::pcoipGenDevicesGenericTag.1 = ""
TERADICI-PCOIPv2-MIB::pcoipGenDevicesPartNumber.1 = STRING: "TERA1200 revision 1.0 (128 MB)"
TERADICI-PCOIPv2-MIB::pcoipGenDevicesFwPartNumber.1 = STRING: "Leadtek rev M host card with copper"
TERADICI-PCOIPv2-MIB::pcoipGenDevicesSerialNumber.1 = STRING: "L12060000489"
TERADICI-PCOIPv2-MIB::pcoipGenDevicesHardwareVersion.1 = STRING: "62917013120-D"
TERADICI-PCOIPv2-MIB::pcoipGenDevicesFirmwareVersion.1 = STRING: "4.0.2"
TERADICI-PCOIPv2-MIB::pcoipGenDevicesUniqueID.1 = STRING: "00-30-04-0E-07-9E"
TERADICI-PCOIPv2-MIB::pcoipGenDevicesMAC.1 = STRING: "00-30-04-0E-07-9E"
TERADICI-PCOIPv2-MIB::pcoipGenDevicesUptime.1 = Counter64: 264895
TERADICI-PCOIPv2-MIB::pcoipImagingDevicesIndex.1 = INTEGER: 1
TERADICI-PCOIPv2-MIB::pcoipImagingDevicesIndex.2 = INTEGER: 2
TERADICI-PCOIPv2-MIB::pcoipImagingDevicesIndex.3 = INTEGER: 3
TERADICI-PCOIPv2-MIB::pcoipImagingDevicesIndex.4 = INTEGER: 4
To pass these values to Cacti, I needed to reformat these lines so they would display
To replace a substring in perl, we use the =~ s/
A simple exemple would be :
$output = "Characters replacement in perl";
$output =~ s/Characters/String/i;
print $output;
would print out :
String replacement in perl
All the power comes from search operators that we can apply on the search part. These seach operators are :
. Match any character
\w Match "word" character (alphanumeric plus "_")
\W Match non-word character
\s Match whitespace character
\S Match non-whitespace character
\d Match digit character
\D Match non-digit character
\t Match tab
\n Match newline
\r Match return
\f Match formfeed
\a Match alarm (bell, beep, etc)
\e Match escape
\021 Match octal char ( in this case 21 octal)
\xf0 Match hex char ( in this case f0 hexidecimal)
You can follow any character, wildcard, or series of characters and/or wildcard
with a repetiton. Here's where you start getting some power:
* Match 0 or more times
+ Match 1 or more times
? Match 1 or 0 times
{n} Match exactly n times
{n,} Match at least n times
{n,m} Match at least n but not more than m times
So, if we want to get rid of some text in a line, we could use :
$output = "Today blabla is a 354446 nice day!";
$output =~ s/Today \w+ is a \d+ nice day!/Today is a nice day!/i;
print $output;
This would output :
Today is a nice day!
Another very powerful elements are (). They store the matching pattern in variables and name them \1 \2 etc...
Let see another exemple :
$output = "I want to keep this value and this other value"; $output =~ s/I want to keep (this value) and this (other value)/\1 AND \2/i; print $output;
Would print :
this value AND other value
so back to our MIB values. In order to replace :
TERADICI-PCOIPv2-MIB::pcoipImagingDevicesDisplayHeight.1 = INTEGER12: 1080
by :
pcoipImagingDevicesDisplayHeight.1:1080
We would use the following statement :
$_ =~ s/^TERADICI-PCOIPv2-MIB::(\w+\.\d) = \w+\d*: (\d+)$/\1 \2/i;
One last process. In the previous line, I wanted to keep only the OID name ( pcoipImagingDevicesDisplayHeight ) without the .1 for all OIDs ending with .1 and for every other OID name I wanted to append the .to the OID name. This is done with the following 2 lines :
$_ =~ s/^(\w+)\.1 (\d*)$/\1 \2/i;
$_ =~ s/^(\w+)\.([234567890]) (.*)$/\1\2 \3/i;
So because the first line will only match OID.1, it only affects these lines. Line 2 takes care of the others :
pcoipImagingDevicesDisplayProcessRate.1 -> pcoipImagingDevicesDisplayProcessRate
pcoipImagingDevicesDisplayProcessRate.2 -> pcoipImagingDevicesDisplayProcessRate2
Thursday, September 11, 2008
Parsing a text file line by line in ksh
This is how to parse a file line by line in ksh :
while read line
do
run you commands here
done < text_file.txt
Wednesday, September 3, 2008
Enabling xvid codec in Ubuntu 8.04
I usually convert video using a 2 pass process with ffmpeg. The command line is :
date;ffmpeg -i myinputfile.mpg -pass 1 -passlogfile vts.log -qscale 2 -vcodec xvid VTS_02_temp.avi;date;ffmpeg -i myinputfile.mpg -f avi -vcodec xvid -pass 2 -passlogfile vts.log -b 800 -g 300 -bf 2 -acodec mp3 -ab 128 myoutputfile.avi;dateWhen I tried to the first time on my new ubuntu 8.04, I got this error message :
Unknown codec 'xvid'
After googling on the web, I found the solution. The xvid codec along other non free codecs are not included in the Ubuntu repository. We need to use a separate repository call Medibuntu. This repository contains everything free and non-free for all the video processing needs. The web site is hosted on http://medibuntu.org.
Unknown codec 'xvid'
After googling on the web, I found the solution. The xvid codec along other non free codecs are not included in the Ubuntu repository. We need to use a separate repository call Medibuntu. This repository contains everything free and non-free for all the video processing needs. The web site is hosted on http://medibuntu.org.
A complete installation procedure is on the repository how-to section of the web site. In short, if you're using Ubuntu 8.04 on i386 architecture, these are the steps you need to enable the new repository :
sudo wget http://www.medibuntu.org/sources.list.d/hardy.list -O /etc/apt/sources.list.d/medibuntu.list
sudo apt-get update && sudo apt-get install medibuntu-keyring && sudo apt-get update
Then you open up Synaptic package manager and do a search on ffmpeg and xvid. you should see quite a few files that need upgrade (a little yellow star on the package icon). Upgrade all packages and you should now be able to encode using xvid codec.
Thursday, August 28, 2008
Install various linux partition on USB drive
If you want to bring your favorite Linux distro with you, why don't you prepare a USB stick ? UNetBootin will do it for you. There are a windows version and a linux version. Check it out : http://unetbootin.sourceforge.net/
Friday, July 18, 2008
Taking control on a PC stuck at GDM
Have you ever been in the situation where you PC at work have rebooted and is now sitting at the GDM display waiting for you to enter a username and password ? Well this happened few times to me. The solution is rather simple. You only need to have an ssh access to your PC.
1 ) Logon to your PC using your ssh access.
2 ) install (if not already there) x11vnc : sudo apt-get install x11vnc
3 ) The tricky part is that gdm using a different xauth file than X11 server. So you need to find out which and where this file is. A simple ps -ef | grep gdm will give you the answer :
The part you need is : -auth /var/lib/gdm/:0.Xauth
4 ) then you launch x11vnc with this argument. I usually use root :
jboismar-desktop ~ # x11vnc -auth /var/lib/gdm/:0.Xauth
The last lines should look like this :
18/07/2008 11:35:18 WARNING: the warning message printed above for more info.
18/07/2008 11:35:18
The VNC desktop is: jboismar-desktop:0
PORT=5900
******************************************************************************
Have you tried the x11vnc '-ncache' VNC client-side pixel caching feature yet?
The scheme stores pixel data offscreen on the VNC viewer side for faster
retrieval. It should work with any VNC viewer. Try it by running:
x11vnc -ncache 10 ...
more info: http://www.karlrunge.com/x11vnc/#faq-client-caching
5 ) You can then run a vnc client to access your remote screen. Once you login, GDM will terminate to start the X server. Your x11vnc program will also terminate at this point.
1 ) Logon to your PC using your ssh access.
2 ) install (if not already there) x11vnc : sudo apt-get install x11vnc
3 ) The tricky part is that gdm using a different xauth file than X11 server. So you need to find out which and where this file is. A simple ps -ef | grep gdm will give you the answer :
jboismar-desktop ~ # ps -ef | grep gdm root 5683 1 0 11:12 ? 00:00:00 gdm root 5684 5683 0 11:12 ? 00:00:00 gdm root 6300 5684 0 11:31 tty7 00:00:00 /usr/bin/X :0 -br -audit 0 -auth /var/lib/gdm/:0.Xauth -nolisten tcp vt7 gdm 6313 5684 0 11:31 ? 00:00:01 /usr/lib/gdm/gdmgreeter root 6320 5726 0 11:33 pts/0 00:00:00 grep --colour=auto gdm |
The part you need is : -auth /var/lib/gdm/:0.Xauth
4 ) then you launch x11vnc with this argument. I usually use root :
jboismar-desktop ~ # x11vnc -auth /var/lib/gdm/:0.Xauth
The last lines should look like this :
18/07/2008 11:35:18 WARNING: the warning message printed above for more info.
18/07/2008 11:35:18
The VNC desktop is: jboismar-desktop:0
PORT=5900
******************************************************************************
Have you tried the x11vnc '-ncache' VNC client-side pixel caching feature yet?
The scheme stores pixel data offscreen on the VNC viewer side for faster
retrieval. It should work with any VNC viewer. Try it by running:
x11vnc -ncache 10 ...
more info: http://www.karlrunge.com/x11vnc/#faq-client-caching
5 ) You can then run a vnc client to access your remote screen. Once you login, GDM will terminate to start the X server. Your x11vnc program will also terminate at this point.
Tuesday, July 15, 2008
Compiling Synergy on Ubuntu 8.04
I'm using a lot synergy at work to use one keyboard/mouse to control my laptop and my desktop. It's a wonderfull software. Unfortunately, it is buggy in Ubuntu 8.04. So I decided to re-compile and see if it is any better.
First, you need to get the latest cvs tree :
cvs -z3 -d:pserver:anonymous@synergy2.cvs.sourceforge.net:/cvsroot/synergy2 co -P synergy
now, go to synergy/src directory and try a ./configure. In my case it ended up like this :
checking for X... no
checking for XTestQueryExtension in -lXtst... no
configure: error: You must have the XTest library to build synergy
After googling everywhere, I finally found this page. So, to get the XTest library, we do :
sudo apt-get install libxtst-dev
Then we need to specify where synergy can get the X include and library files :
./configure -x-includes /usr/include -x-libraries /usr/lib --prefix=/usr
and voila ! The configure process should now be happy. You can then make and make install.
First, you need to get the latest cvs tree :
cvs -z3 -d:pserver:anonymous@synergy2.cvs.sourceforge.net:/cvsroot/synergy2 co -P synergy
now, go to synergy/src directory and try a ./configure. In my case it ended up like this :
checking for X... no
checking for XTestQueryExtension in -lXtst... no
configure: error: You must have the XTest library to build synergy
After googling everywhere, I finally found this page. So, to get the XTest library, we do :
sudo apt-get install libxtst-dev
Then we need to specify where synergy can get the X include and library files :
./configure -x-includes /usr/include -x-libraries /usr/lib --prefix=/usr
and voila ! The configure process should now be happy. You can then make and make install.
Tuesday, June 17, 2008
Determining version of Solaris
Ever wonder if you are running Solaris 32 or 64 bits ? You can find out with isainfo command.
[root@xxxxxx:/root]
#isainfo
sparcv9 sparc
sparcv9 means you are running 64bits version of the OS. To make sure, use :
#isainfo -b
64
This gives you the name of the instruction set(s) used by the operating system kernel components such as device drivers and STREAMS modules.
This command also gives you if your system runs 32 and 64 bits apps :
#isainfo -v
64-bit sparcv9 applications
32-bit sparc applications
[root@xxxxxx:/root]
#isainfo
sparcv9 sparc
sparcv9 means you are running 64bits version of the OS. To make sure, use :
#isainfo -b
64
This gives you the name of the instruction set(s) used by the operating system kernel components such as device drivers and STREAMS modules.
This command also gives you if your system runs 32 and 64 bits apps :
#isainfo -v
64-bit sparcv9 applications
32-bit sparc applications
Wednesday, May 21, 2008
Directory diff
Bridged networking in Ubuntu with VirtualBox
I got so frustrated with the installation of vmware on linux ( having to apply the any any patch + editing files.... ) that I decided to try VirtualBox. What a surprise ! I found a very mature virtualization software. The installation went smoothly and the gui is very simple yet efficient.
The only drawback is the networking part. Basically VirtualBox is fine if one wants to run a VM with any OS to access internet. But if you want to create VMs and use them to host network services like Web servers, mysql servers and so forth, then the default network mode NAT will not let you do that.
You want to setup host networking ( or bridged networking ). Here is how I did it on Ubuntu 8.04 and VirtualBox 1.6.
Note : This is actually from the user documentation of VirtualBox page 75, chapter 6.7.1.1.
First you installed the bridge utilities :
sudo apt-get install bridge-utils
Then you define the bridge by adding the following section to /etc/network/interfaces :
auto br0
iface br0 inet dhcp
bridge_ports eth0
And restart the network :
sudo /etc/init.d/networking restart
You define a virtual interface using the VirtualBox tools :
sudo VBoxAddIF vbox0 br0
Here is the user running VirtualBox ( the one you logged in with in your ubuntu/gnome session ).
You're done with the command line configuration.
To tell VirtualBox to use the interface, select the virtual machine which is to use it in the main window of the VirtualBox application, configure one of its network adapters to use Host Interface Networking (using “Settings”, “Network”, “Attached to”) and enter vbox0 into the “Interface name” field. You can only use a given interface (vbox0, vbox1 and so on) with a single virtual network adapter.
The only drawback is the networking part. Basically VirtualBox is fine if one wants to run a VM with any OS to access internet. But if you want to create VMs and use them to host network services like Web servers, mysql servers and so forth, then the default network mode NAT will not let you do that.
You want to setup host networking ( or bridged networking ). Here is how I did it on Ubuntu 8.04 and VirtualBox 1.6.
Note : This is actually from the user documentation of VirtualBox page 75, chapter 6.7.1.1.
First you installed the bridge utilities :
sudo apt-get install bridge-utils
Then you define the bridge by adding the following section to /etc/network/interfaces :
auto br0
iface br0 inet dhcp
bridge_ports eth0
And restart the network :
sudo /etc/init.d/networking restart
You define a virtual interface using the VirtualBox tools :
sudo VBoxAddIF vbox0
Here
You're done with the command line configuration.
To tell VirtualBox to use the interface, select the virtual machine which is to use it in the main window of the VirtualBox application, configure one of its network adapters to use Host Interface Networking (using “Settings”, “Network”, “Attached to”) and enter vbox0 into the “Interface name” field. You can only use a given interface (vbox0, vbox1 and so on) with a single virtual network adapter.
Saturday, May 3, 2008
View directory tree and disk usage in Windows

I know this isn't a unix software but it is similar to Kdiskview ! I missed so much this kind of tools when trying to find where windows disk space has gone. And I must say, this freeware is very well made. Congrats to the developers !!! here is their website.
Thursday, April 24, 2008
One mouse and keyboard to rule them all
If you have several boxes sitting at your desk and do not want to use one keyboard and mouse for each of them, you could install and setup Synergy software. It's a freeware and works great ! it's a client server architecture that communicates through IP. A daemon (synergys note the s for server) runs on the machine that has the keyboard and mouse and listen for clients. The client (synergyc note the c for client) connects to it.
The configuration is VERY easy. Take a look at my config file :
Now, few explanations about that config file. In the screen section, you list all your systems and call them by a convenient name. I used laptop and desktop but you can use whatever suits your environment.
The links section describes how your screen are physically setup.
The aliases section is here to translate the convenient machine names you choose to real name or ip. In my case the file /etc/hosts contains entries for laptoprealname and desktoprealhostname.
The switchDelay in the last section set the number of ms to wait when the mouse reaches a screen edge before it crosses over next screen. I put 1 there meaning there will be almost no wait.
Now, how do you start all these.... For the server, you run synergys -f. It should read the config file in $HOME/.synergy.conf.
Then, on the client, you run synergyc -f -1.
You should now be able to use only one mouse and keyboard to control your machines.
The configuration is VERY easy. Take a look at my config file :
| Section: | screens | |
| Laptop: | ||
| Desktop: | ||
| End | ||
| Section: | links | |
| Laptop: | ||
| right = Desktop | ||
| Desktop: | ||
| left = Laptop | ||
| End | ||
| Section: | aliases | |
| Laptop: | ||
| laptoprealname | ||
| Desktop: | ||
| desktoprealname | ||
| End | ||
| Section: | options | |
| switchDelay=1 | ||
| End |
Now, few explanations about that config file. In the screen section, you list all your systems and call them by a convenient name. I used laptop and desktop but you can use whatever suits your environment.
The links section describes how your screen are physically setup.
The aliases section is here to translate the convenient machine names you choose to real name or ip. In my case the file /etc/hosts contains entries for laptoprealname and desktoprealhostname.
The switchDelay in the last section set the number of ms to wait when the mouse reaches a screen edge before it crosses over next screen. I put 1 there meaning there will be almost no wait.
Now, how do you start all these.... For the server, you run synergys -f. It should read the config file in $HOME/.synergy.conf.
Then, on the client, you run synergyc -f -1
You should now be able to use only one mouse and keyboard to control your machines.
Thursday, April 10, 2008
Dual head with xrandr
This was posted by İlkin Ulaş BALKANAY, on his blog. Thank you very much İlkin Ulaş, it did work for me too ;-)
I've got Ubuntu 7.10(gutsy) running pretty well on my DELL Latitude D505 laptop. I'll try to explain how I configured extended desktop with a NEC 19'' LCD monitor.
We will use xrandr utility to configure multiple screens. Before using xrandr you must check xorg.conf file ( /etc/X11/xorg.conf )
The Virtual keyword is important. Sum of resolution widths and sum of resolution heights of two monitors are written in Virtual.
You must restart X server after updating xorg.conf file. ctrl-alt-backspace is the shortcut to restart X. After successfully restarting X server, run the following commands:
I've got Ubuntu 7.10(gutsy) running pretty well on my DELL Latitude D505 laptop. I'll try to explain how I configured extended desktop with a NEC 19'' LCD monitor.
We will use xrandr utility to configure multiple screens. Before using xrandr you must check xorg.conf file ( /etc/X11/xorg.conf )
Section "Screen"
Identifier "Default Screen"
Device "Intel Corporation 82852/855GM Integrated Graphics Device"
Monitor "Generic Monitor"
Defaultdepth 24
SubSection "Display"
Depth 24
Virtual 2304 1792
Modes "1280x1024@75" "1024x768@60"
EndSubSection
EndSection
The Virtual keyword is important. Sum of resolution widths and sum of resolution heights of two monitors are written in Virtual.
For example : 1280 + 1024 = 2304 and 1024 + 768 = 1792
You must restart X server after updating xorg.conf file. ctrl-alt-backspace is the shortcut to restart X. After successfully restarting X server, run the following commands:
First command sets VGA (19'' LCD monitor) resolution to 1280x1024. Second command sets laptop monitor resolution to 1024x768. The last command places the extended monitor (VGA) right of laptop monitor. That's it. At least it works for me.
xrandr --output VGA --mode 1280x1024
xrandr --output LVDS --mode 1024x768
xrandr --output VGA --right-of LVDS
Friday, April 4, 2008
Enabling compiz for X3100 graphic card
If you install Ubuntu on a PC with a X3100 (aka 965), the right driver will be in place. So don't do as I did ;-) trying to upgrade the driver or editing the xorg.conf to see what it going on...
The reason why it is not working out of the box is because it is meant that way. Developers have black listed the x3100 due to some limitation to the with the current intel driver. So if you want compiz, you have to take the X3100 out of the black list. To do so, edit the file /usr/bin/compiz and comment out (add a # sign at the beginning) the following line :
Thanks to this post : http://temporaryland.wordpress.com/2007/12/06/finding-the-right-distro-for-my-thinkpad-followup/
The reason why it is not working out of the box is because it is meant that way. Developers have black listed the x3100 due to some limitation to the with the current intel driver. So if you want compiz, you have to take the X3100 out of the black list. To do so, edit the file /usr/bin/compiz and comment out (add a # sign at the beginning) the following line :
T=”$T 8086:2982 8086:2992 8086:29a2 8086:2a02 8086:2a12″ # intel 965
So, in the end it should look like this:
#T=”$T 8086:2982 8086:2992 8086:29a2 8086:2a02 8086:2a12″ # intel 965
Then you can go to system->preferences->appearance and click on the "Visual Effect" tab to enable compiz. It worked like a charm for me (Toshiba A200 FT-1).Thanks to this post : http://temporaryland.wordpress.com/2007/12/06/finding-the-right-distro-for-my-thinkpad-followup/
Subscribe to:
Posts (Atom)















