Tuesday, December 9, 2014

LAUNCH JENKINS AGENT and DISCONNECT JENKINS AGENT using CURL post requests in LINUX / UNIX

WHY do we need this function?
This function helps when you have some changes made to .bashrc or .bash_profile and those changes need to be reloaded and taken into account by jenkins agent.



Bash Function to LAUNCH JENKINS AGENT and DISCONNECT JENKINS AGENT using CURL

function launch-jenkins-agent
{
        SERVERNAME="server00"
        #SERVERNAME="server01"
        echo "usage: launch-jenkins-agent "
        cat $1 | awk '{print "curl --form \"offlineMessage=Restarting_agent_after_P4_changes\" https://${SERVERNAME}/computer/"$1"/launchSlaveAgent "}' |sh -x
}


function disconnect-jenkins-agent
{
        SERVERNAME="server00"
        #SERVERNAME="server01"
        echo "usage: disconnect-jenkins-agent "
        cat $1 | awk '{print "curl --form \"offlineMessage=Restarting_agent_after_P4_changes\" https://${SERVERNAME}/computer/"$1"/launchSlaveAgent "}' |sh -x

}


FUNCTION USAGE:
# disconnect-jenkins-agent  /tmp/multiple-hostnames
# launch-jenkins-agent   /tmp/multiple-hostname



HTTP POST and GET using cURL in Linux

Linux provides a nice little command which makes our lives a lot easier.


GET:

with JSON:
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET http://hostname/resource

with XML:
curl -H "Accept: application/xml" -H "Content-Type: application/xml" -X GET http://hostname/resource


POST:
For posting data:
curl --data "param1=value1&param2=value2" http://hostname/resource

For file upload:
curl --form "fileupload=@filename.txt" http://hostname/resource

RESTful HTTP Post:
curl -X POST -d @filename http://hostname/resource

For logging into a site (auth):
curl -d "username=admin&password=admin&submit=Login" --dump-header headers http://localhost/Login
curl -L -b headers http://localhost/
 
 
In cases where the webservice responses are in JSON then it might be
 more useful to see the results in a clean JSON format instead of a very
 long string. Just add | grep }| python -mjson.tool  to the end of curl 
commands here is two examples:

GET approach with JSON result
curl -i -H "Accept: application/json" http://someHostName/someEndpoint | grep }| python -mjson.tool
POST approach with JSON result
curl -X POST -H "Accept: Application/json" -H "Content-Type: application/json" http://someHostName/someEndpoint -d '{"id":"IDVALUE","name":"Mike"}' | grep }| python -mjson.tool

enter image description here
 
 

Example:

curl --header "X-MyHeader: 123" www.google.com
You can see the request that curl sent by adding the -v option.
 
 
Ref: http://stackoverflow.com/questions/14978411/http-post-and-get-using-curl-in-linux 

Monday, September 29, 2014

Update the bash history file in real-time immediately

#Add the following 2 lines to #.bashrc file

shopt
-s histappend PROMPT_COMMAND="history -a;$PROMPT_COMMAND"

Thursday, August 28, 2014

SAFARI OS X MAC Corporate Single Sign On using Windows Credentials SSO LDAP Kerberos

Kerberos is built into Mac OS X as well, but isn't as simple to use and configure with Chrome and FireFox as it is with Explorer on a Windows workstation.
You need to do two things before you can use Kerberos for authentication in Chrome/FireFox:

  1. Create a Kerberos ticket with the Ticket Viewer application (/System/Library/CoreServices/Ticket Viewer)  
  2. OR via the command line (kinit username@example.com, then enter your password). See this article for more detailed instructions.

Thursday, August 14, 2014

Research on RPM DROP on AUDI A4 v6 3.0L- Replace PCV valve and Ignition Coil packs

  1. interchange spark plugs with the misfiring ones -
    - recheck the code and notice if the misfire codes move to different cylinder
  2. Interchange Ignition Coil packs
    - Recheck the scan codes if they change and if it moves to different cylinder
  3. A broken PCV valve can also be the reason. (Check the Intake Mainfold Runner Motor)

Forum Discussion here

http://www.audizine.com/forum/showthread.php/479493-Bouncing-RPM-and-Dropping-RPMs-at-stop
The most common ones are:

PCV
Intake Manifold Runner Motor
Fuel Pressure Sensor

Might be missing one.

Just had the first two done a few weeks ago, car is driving better than ever!

DIY Videos


Order here
http://www.autopartswarehouse.com/shop_parts/ignition_coil/audi/a4.html

*- Nirav -*

Wednesday, August 13, 2014

GSmartControl : GUI for smartctl

GSmartControl : GUI for smartctl


GSmartControl is a graphical user interface for Linux smartctl, which is a tool for querying and controlling S.M.A.R.T. (Self-Monitoring, Analysis, and Reporting Technology) data on modern hard disk drives.  You can read about smartctl at : http://unixfoo.blogspot.com/2007/11/disk-information-using-smartctl.html . It allows you to inspect the drive's S.M.A.R.T. data to determine its health, as well as run various tests on it.

GSmartControl features include

  • Automatically report and highlight any abnormal SMART information.
  • Ability to enable / disable SMART.
  • Ability to enable / disable Automatic Offline Data Collection – A short self-check that the drive will perform automatically every four hours with no impact on performance.
  • Ability to set global and per-drive options for smartctl.
  • Display drive identity, capabilities, attributes, error and self-test logs.
  • Perform SMART self-tests.
  • Ability to load smartctl output as a "virtual" device, which acts just like a real (read-only) device.
  • Works on most smartctl-supported operating systems.

inode deleting table entry for item pointing to free inode/ or used inode

Force XFS to repair!

$xfs_repair -L /dev/mapper/Data   

And got following inode error about pointing to either used block or free block

Phase 1 - find and verify superblock...
Phase 2 - using internal log
- zero log...
- scan filesystem freespace and inode maps...
- found root inode chunk
Phase 3 - for each AG...
- scan and clear agi unlinked lists...
- process known inodes and perform inode discovery...
- agno = 0
data fork in regular inode 4497195 claims used block 4832288037
data fork in regular inode 349982619 claims used block 4832288030
- agno = 1
- agno = 2
- agno = 3
- agno = 4
- agno = 5
- agno = 6
- agno = 7
- agno = 8
- agno = 9
- agno = 10
- agno = 11
- agno = 12
- agno = 13
- agno = 14
- agno = 15
- agno = 16
- agno = 17
- agno = 18
- agno = 19
- agno = 20
- process newly discovered inodes...
Phase 4 - check for duplicate blocks...
- setting up duplicate extent list...
- check for inodes claiming duplicate blocks...
- agno = 0
- agno = 1
- agno = 3
- agno = 7
- agno = 8
- agno = 9
- agno = 10
- agno = 11
- agno = 12
- agno = 6
- agno = 14
- agno = 4
- agno = 5
- agno = 16
- agno = 2
- agno = 19
- agno = 20
- agno = 13
- agno = 17
- agno = 18
- agno = 15
data fork in regular inode 4497195 claims used block 4832288037
data fork in regular inode 349982619 claims used block 4832288030
Phase 5 - rebuild AG headers and trees...
- reset superblock...
Phase 6 - check inode connectivity...
- resetting contents of realtime bitmap and summary inodes
- traversing filesystem ...
- traversal finished ...
- moving disconnected inodes to lost+found ...
Phase 7 - verify and correct link counts...
done




Very hesitantly, I ran xfs_db on the two inodes that xfs_repair complained about. Then ran xfs_repair again, and this time it didn't mention them.... and now I can delete the files I could not delete before...

Hopefully nothing else is missing...

(in my case below instead of mapper/data its md0)

$ xfs_db -x -c 'inode 4497195' -c 'write core.nextents 0' -c 'write core.size 0' /dev/mapper/Data

core.nextents = 0
core.size = 0


$ xfs_db -x -c 'inode 349982619' -c 'write core.nextents 0' -c 'write core.size 0' /dev/mapper/Data

core.nextents = 0
core.size = 0