Category: General information

General information

How to read Secret from Jenkins Secret

How to read Secret from Jenkins Secret

Introduction –

In Jenkins “Jenkins Secret” is used to store user credentials and similar secrets, like API keys, access tokens, or just usernames and passwords used in Jenkins pipeline or jobs.

Jenkins uses AES to encrypt and protect secrets, credentials, and their respective encryption keys. These encryption keys are stored in $JENKINS_HOME/secrets/ along with the master key used to protect said keys.

How to Add Secrets in Jenkins Secrets (JS) –

Login to Jenkins UI, then go to “Manage Jenkins“….

There are different types of secrets can be created in Jenkins Secrets as mentioned below…

Secrets in Jenkins has different type of scopes as mentioned below….

How to Read Jenkins Secrets from Jenkins pipeline or job –

Credentials Binding Plugin –

Ref – https://www.jenkins.io/doc/pipeline/steps/credentials-binding/

“Credentials Binding Plugin” plugin can be used to read secrets from Jenkins secrets and used in groovy pipeline. Also, this plugin mask secrets while printing in pipeline mask it for security!

1) Read Jenkins Secrets of Type “Secret text” –

Ref- https://github.com/arunbagul/jenkins-groovy/blob/main/Read-Jenkins-Secret-of-Type-Secret-text.groovy

//Read Jenkins Secret of Type "Secret text"
//version 1.0
//Plugin
//credentials-binding ~ https://www.jenkins.io/doc/pipeline/steps/credentials-binding/

node('master') {
	withCredentials([string(credentialsId: 'JS_SECRET_ID' , variable: 'password_from_js')]) {
		println "Secret from Jenkins Secret: ${password_from_js}"
	}
}

2) Read Jenkins Secrets of Type “Username with password” –

Ref – https://github.com/arunbagul/jenkins-groovy/blob/main/Read-Jenkins-Secret-of-Type-Username-with-password.groovy

//Read Jenkins Secret of Type "Username with password"
//version 1.0
//Plugin
//credentials-binding ~ https://www.jenkins.io/doc/pipeline/steps/credentials-binding/

node('master') {
	withCredentials([usernamePassword(credentialsId: GIT_TOKEN_JS_ID, usernameVariable: 'gitUserName', passwordVariable: 'github_token')]) {
      println "UserName/Password  from Jenkins Username: ${gitUserName} , Password: ${github_token}"
	}
}

3) Howto assign Jenkins Secrets  to Global variable

Ref – https://github.com/arunbagul/jenkins-groovy/blob/main/howto-assign-jenkins-secret-to-global-variable.groovy

//Howto assign Jenkins Secret to global variable
//version 1.0
//Plugin
//credentials-binding ~ https://www.jenkins.io/doc/pipeline/steps/credentials-binding/

//get secret from jenkins-secret
node('master') {
	withCredentials([usernamePassword(credentialsId: GIT_TOKEN_JS_ID, usernameVariable: 'gitUserName',passwordVariable: 'gtoken')]) {
      env.GIT_TOKEN = gtoken
	}
  println "GIT_TOKEN = ${env.GIT_TOKEN}"
}

4) How to retrieve (recover) secret from “Jenkins Secret” –

Sometimes we need to read secrets from Jenkins and use in different stages in pipeline. It is always recommended to use “withCredentials {}” scope at. But to simplify we can

Ref – https://github.com/arunbagul/jenkins-groovy/blob/main/howto-retrieve-recover-secret-from-jenkins-secret.groovy

//How to retrieve (recover) secret from "Jenkins Secret"
//version 1.0
//Plugin
//credentials-binding ~ https://www.jenkins.io/doc/pipeline/steps/credentials-binding

node('master') {
	withCredentials([string(credentialsId: 'JS_SECRET_ID' , variable: 'password_from_js')]) {
	 shell_output = sh(script: """  echo ${password_from_js} > write_to_file """, returnStdout: true ).trim()
	}        
}

Ref –

https://www.jenkins.io

https://www.jenkins.io/doc/developer/security/secrets

https://www.jenkins.io/doc/pipeline/steps/credentials-binding

Thank you,

Arun Bagul

Packer – How packer has simplified Cloud provisioning

Packer – How packer has simplified Cloud provisioning

What is Packer  –

Packer (HashiCorp) is an open source tool for creating identical machine images for multiple platforms from a single source configuration. Packer is lightweight, creating machine images for multiple platforms in parallel. Packer does not replace configuration management like Chef or Puppet. In fact, when building images, Packer can use tools like Chef or Puppet to install software onto the image.

A machine image is a single static unit that contains a per-configured operating system and installed software which is used to quickly create new running machines. Machine image formats change for each platform. Some examples include AMIs for EC2, VMDK/VMX files for VMware, OVF exports for VirtualBox, etc.

Packer and Continuous Delivery (CD) –

Packer is lightweight, portable, and command-line driven. This makes it the perfect tool to put in the middle of your continuous delivery pipeline. As part of this pipeline, the newly created images can then be launched and tested, verifying the infrastructure changes work. If the tests pass, you can be confident that the image will work when deployed. This brings a new level of stability and testability to infrastructure changes.

Packer template –

A Packer template is a configuration file that defines the image you want to build and how to build it. Packer templates use the Hashicorp Configuration Language (HCL). Packer configuration  has different block in configuration like mentioned below…

  • Packer Block –  The packer {} block contains Packer settings, including specifying a required Packer version.
  • Source Block – Thesource {} block configures a specific builder plugin, which is then invoked by a build block. Source blocks use builders and communicators to define what kind of virtualization to use, how to launch the image you want to provision, and how to connect to it.
  • Build block – The build  { } block defines what Packer should do with the Virtual Machine or Docker container after it launches.

Builders are responsible for creating machines and generating images from them for various platforms. For example, there are separate builders for EC2, VMware, VirtualBox, etc.

Please find the supported builder list here – https://www.packer.io/docs/builders

- virtualbox-iso
- vmware-iso
- hyperv-iso
- docker
  • Provisioner block – The provisioner { } block defines what Packer should do with the image build or Docker container after it launches.

Provisioners use builtin and third-party software to install and configure the machine image after booting. Provisioners prepare the system for use, so common use cases for provisioners include:

  • installing packages
  • patching the kernel
  • creating users
  • downloading application code
  • Post-Processors – Post-processors run after the image is built by the builder and provisioned by the provisioner(s). Post-processors are optional, and they can be used to upload artifacts, re-package, or more.
  • Communicators – are the mechanism Packer uses to upload files, execute scripts, etc. with the machine being created.

Communicators are configured within the builder section. Packer currently supports three kinds of communicators:

  • none – No communicator will be used. If this is set, most provisioners also can’t be used.
  • ssh – An SSH connection will be established to the machine. This is usually the default.
  • winrm – A WinRM connection will be established.

Packer Workflow –

The Packer workflow takes a defined source (usually an operating system installation media in ISO format or an existing machine), creates a machine on the builder, executes the Provisioner’s defined tasks and generates an output. Doing this on Hyper-V, VMWare workstation and Docker may look like what is shown below.

How to use Packer –

Initialize your Packer configuration and check and validate packer template…

$ packer init .
$ packer fmt .
$ packer validate .

Build the image with the packer build command. Packer will print output like what is shown below.

$ packer build new-os-image-template.hcl

Reference –

Packer software – https://www.packer.io

Thank you,

Arun Bagul

(Personal Blog and This is based on my knowledge)

IaC ~ Terraform and Pulumi

IaC ~ Terraform and Pulumi

Terraform and Pulumi

Before reading this blog I would recommend to read this blog – https://www.indiangnu.org/2017/top-5-infrastructure-as-code-iac-software/

Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom in-house solutions.

Key feature of Terraform and Pulumi are..

  1. IaC (Infrastructure as Code) for better management of
  2. Infrastructure and state management
  3. Supports all Cloud providers like Azure, GCP, AWS and virtualization infrastructure like VMware and HyperV
  4. Change Automation
  5. Help you to adapt IaaS, SaaS and PaaS

How to user Terraform –

Terraform has 3 steps . First is “terraform init” initialization step in which Terraform will check and download required providers and plugins. Second is “terraform plan” in this step Terraform will create plan of change in your infrastructure and user has choice to verify and confirm then plan and then start third step ie “terraform apply” this in step Terraform will create resources in providers infrastructure like azure, aws or gcp. Terraform will also save all objects created in Terraform stafe “.tfstate” file and we can use same configuration to add or delete or update resource in same workflow….

To Debug Terraform error we can define debug and log fails mentioned below-

export TF_LOG_PROVIDER=TRACE
export TF_LOG_CORE=TRACE
export TF_LOG_PATH=logs.txt
terraform init
terraform plan
terraform apply

For formatting and configuration validation use below command –

terraform validate
terraform fmt
 
terraform refresh

HashiCorp Configuration Language (HCL)

In Terraform we can define infrastructure required to deploy as code using HCL.

HCL is a toolkit for creating structured configuration languages that are both human- and machine-friendly, for use with command-line tools. Although intended to be generally useful, it is primarily targeted towards devops tools, servers, etc. HCL has both a native syntax, intended to be pleasant to read and write for humans, and a JSON-based variant that is easier for machines to generate and parse. HCL syntax is designed to be easily read and written by humans, and allows declarative logic to permit its use in more complex applications

What is Pulumi ?

Pulumi is a modern infrastructure as code platform that allows you to use familiar programming languages and tools to build, deploy, and manage cloud infrastructure.

Pulumi vs. Terraform

Here is a summary of the key differences between Pulumi and Terraform:

ComponentPulumiTerraform
Language SupportPython, TypeScript, JavaScript, Go, C#, F#Hashicorp Configuration Language (HCL)
State ManagementManaged through Pulumi Service by default, self-managed options availableSelf-managed by default, managed SaaS offering available
Provider SupportNative cloud providers with 100% same-day resource coverage plus Terraform-based providers for additional coverageSupport across multiple IaaS, SaaS, and PaaS providers
OSS LicenseApache License 2.0Mozilla Public License 2.0

Ref –

Pulumi  – https://www.pulumi.com

Terraform – https://www.terraform.io

HCL –  https://github.com/hashicorp/hcl

Terraform Error – https://learn.hashicorp.com/tutorials/terraform/troubleshooting-workflow

Thank you,

Arun Bagul

(Personal Blog and This is based on my knowledge)

Azure VM Inventory report

Azure VM Inventory report

Hi, This script will help you to pull Azure VM details. You can use this script for various purpose. This script makes use of AzureRM module, please install below prerequisite modules :-

Install-Module -Name AzureRM.Compute
Install-Module -Name AzureRM.Network

    # Sign into Azure Portal
    login-azurermaccount

    # Fetching subscription list
    $subscription_id = "xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx"      # Enter your subscription details

    # Fetch current working directory 
    $working_directory = "c:\AzureInventory"

    new-item $working_directory -ItemType Directory -Force

function Get-AzureInventory{

# Selecting the subscription
Select-AzureRmSubscription -Subscription $subscription_id

# Fetch the Virtual Machines from the subscription
$azureVMDetails = get-azurermvm

# Fetch the NIC details from the subscription
$azureNICDetails = Get-AzureRmNetworkInterface | ?{ $_.VirtualMachine -NE $null}

# Fetch the Virtual Networks from the subscription
$azureVirtualNetworkDetails = Get-AzureRmVirtualNetwork


#-----------------Fetching Virtual Machine Details-----------------#

    $virtual_machine_object = $null
    $virtual_machine_object = @()


    # Iterating over the NIC Interfaces under the subscription
        
        foreach($azureNICDetail in $azureNICDetails){ 
        $azureVMDetail = $azureVMDetails | ? -Property Id -eq $azureNICDetail.VirtualMachine.id
        $vm_status = get-azurermvm -ResourceGroupName $azureVMDetail.resourcegroupname -name $azureVMDetail.name -Status
        $vm_tags = ($azureVMDetail.Tags.values) -join ';'
        $osversion = $azureVMDetail.StorageProfile.ImageReference.id
        $vmsize = Get-AzureRmVMSize -VMName $azureVMDetail.Name -ResourceGroupName $azureVMDetail.ResourceGroupName | ? {$_.Name -eq $azureVMDetail.HardwareProfile.VmSize}
        
        #Fetching the private IP
        #write-Host $vm.NetworkInterfaceIDs
        $private_ip_address = ($azureNICDetail.IpConfigurations | select-object -ExpandProperty PrivateIpAddress) -Join ';'
        $virturalnetwork = $azureNICDetail.IpConfigurations.subnet.Id.Split("/")[-3]
        $subnet = $azureNICDetail.IpConfigurations.subnet.Id.Split("/")[-1]
            
        #Fetching data disk names
        $data_disks = $azureVMDetail.StorageProfile.DataDisks
        $data_disk_name_list = ''

            foreach ($data_disk in $data_disks) {
            $data_disk_name_list_temp = $data_disk_name_list + "; " +$data_disk.name 
            #Trimming the first three characters which contain --> " ; "
            $data_disk_name_list = $data_disk_name_list_temp.Substring(2)
            #write-host $data_disk_name_list
            }

        #}            

            # Fetching OS Details (Managed / un-managed)

            if($azureVMDetail.StorageProfile.OsDisk.manageddisk -eq $null){
                # This is un-managed disk. It has VHD property

                $os_disk_details_unmanaged = $azureVMDetail.StorageProfile.OsDisk.Vhd.Uri
                $os_disk_details_managed = "This VM has un-managed OS Disk"

            }else{
                
                $os_disk_details_managed = $azureVMDetail.StorageProfile.OsDisk.ManagedDisk.Id
                $os_disk_details_unmanaged = "This VM has Managed OS Disk"
            }

            $virtual_machine_object_temp = new-object PSObject 
            $virtual_machine_object_temp | add-member -membertype NoteProperty -name "VMName" -Value $azureVMDetail.Name
            $virtual_machine_object_temp | add-member -membertype NoteProperty -name "ResourceGroupName" -Value $azureVMDetail.ResourceGroupName
            $virtual_machine_object_temp | add-member -membertype NoteProperty -name "Location" -Value $azureVMDetail.Location
#           $virtual_machine_object_temp | add-member -membertype NoteProperty -name "Zone" -Value $azureVMDetail.Zones
            $virtual_machine_object_temp | add-member -membertype NoteProperty -name "Tags" -Value $vm_tags
            $virtual_machine_object_temp | add-member -membertype NoteProperty -name "VMStatus" -Value $vm_status.Statuses[1].DisplayStatus
            $virtual_machine_object_temp | add-member -membertype NoteProperty -name "VMSize" -Value $azureVMDetail.HardwareProfile.VmSize
            $virtual_machine_object_temp | add-member -membertype NoteProperty -name "CPU" -Value $vmsize.NumberOfCores
            $virtual_machine_object_temp | add-member -membertype NoteProperty -name "RAM in MB" -Value $vmsize.MemoryInMB
            $virtual_machine_object_temp | add-member -membertype NoteProperty -name "OSFamily" -Value $azureVMDetail.StorageProfile.OsDisk.OsType
            $virtual_machine_object_temp | add-member -membertype NoteProperty -name "DiskCount" -Value $azureVMDetail.StorageProfile.DataDisks.Count
            $virtual_machine_object_temp | add-member -membertype NoteProperty -name "AdminUserName" -Value $azureVMDetail.OSProfile.AdminUsername
            $virtual_machine_object_temp | add-member -membertype NoteProperty -name "PrivateIP" -Value $private_ip_address
            $virtual_machine_object_temp | add-member -membertype NoteProperty -name "Vnet-Zone" -Value $virturalnetwork
            $virtual_machine_object_temp | add-member -membertype NoteProperty -name "Subnet" -Value $subnet
            $virtual_machine_object_temp | add-member -membertype NoteProperty -name "OSVersion" -Value $osversion
            $virtual_machine_object_temp | add-member -membertype NoteProperty -name "DataDiskNames" -Value $data_disk_name_list
            $virtual_machine_object_temp | add-member -membertype NoteProperty -name "ManagedOSDiskURI" -Value $os_disk_details_managed
                        


            $virtual_machine_object += $virtual_machine_object_temp

            
        }

        $virtual_machine_object | Export-Csv "$working_directory\Virtual_Machine_details_$(get-date -f yyyyMMdd).csv" -NoTypeInformation -Force

}

Get-AzureInventory

Openstack and networking Options

Openstack and networking Options

Introduction –

Before we start talking about Openstack and Networking options lets compare few Cloud and there terms..

 

Openstack AWS Azure
Cloud virtual networking Project VPC(Virtual Private Cloud) Azure VNet (Virtual Network)
Identity Mgmt Keystone AWS Key Management Service Azure KeyVault
Block Storage (Virtual Disk) Glance Amazon Elastic Block Storage (EBS) Azure Page Blobs / Premium Storage
Object Storage Swift Amazon Simple Storage Service (S3) Azure Blob Storage
Shared File System Manila Amazon Elastic File System (EFS) Azure File Storage
DNS Designate Route 53 Azure DNS
Private IP Address + DHCP/DNS Private IP Private IP DIP(Dynamic IP address)
External (NATed IPAddress) Floating IP NATed Elastic IP NATed VIP(Virtual IP address) NATed and PIP (instance-level Public IP address) Directly attached to VM

 

This document will help you to understand what the are different types of network option available in Openstack and how to use them.

 

LXC – Linux Container

LXC – Linux Container

Introduction-

What are the different Container technology?

Container technology has started after 2013. There is a high potential of getting confused about available container types like Docker , LXC/LXD and CoreOS rocket.

What’s LXC?
LXC (Linux Containers) is an operating-system-level virtualization method for running multiple isolated Linux systems (containers) on a control host using a single Linux kernel.
LXC is a userspace interface for the Linux kernel containment features. Through a powerful API and simple tools, it lets Linux users easily create and manage system or application containers.

Benefits of Linux Containers:
1 – Lightweight built-in virtualization
2 – Application/server isolation
3 – Easy deployment and management
4 – No additional licensing

Weaknesses of Linux Containers:
1 – Locked into the host kernel
2 – Supported only on Linux

Current LXC uses the following kernel features to contain processes:
– Kernel namespaces (ipc, uts, mount, pid, network and user)
– Apparmor and SELinux profiles
AppArmor is a Linux kernel security module that allows the system administrator to restrict programs’ capabilities with per-program profiles.
Security-Enhanced Linux is a Linux kernel security module that provides a mechanism for supporting access control security policies.
Seccomp policies
Chroots (using pivot_root)
Kernel capabilities
CGroups (control groups)

LXC is currently made of a few separate components:
– The liblxc library
– A set of standard tools to control the containers
– Distribution container templates
– Several language bindings for the API:
– python3
– Go
– ruby
– Haskell

The Linux kernel provides the cgroups functionality that allows limitation and prioritization of resources (CPU, memory, block I/O, network, etc.) without the need for starting any virtual machines, and also namespace isolation functionality that allows complete isolation of an applications’ view of the operating environment, including process trees, networking, user IDs and mounted file systems.

LXC containers are often considered as something in the middle between a chroot and a full fledged virtual machine. The goal of LXC is to create an environment as close as possible to a standard Linux installation but without the need for a separate kernel.
LXC combines the kernel’s cgroups and support for isolated namespaces to provide an isolated environment for applications. Docker can also use LXC as one of its execution drivers, enabling image management and providing deployment services.

What’s LXD?
LXD is a next generation system container manager. It offers a user experience similar to virtual machines but using Linux containers instead. LXD isn’t a rewrite of LXC, in fact it’s building on top of LXC to provide a new, better user experience. Under the hood, LXD uses LXC through liblxc and its Go binding to create and manage the containers.

What is difference between LXD vs Docker?
– Docker focuses on application delivery from development to production, while LXD’s focus is system containers.
– LXC in market since 2008 as compare to Docker 2013.
– Earlier Docker was based on LXC. Later Docker replaced it with libcontainer.
– Docker specializes in deploying apps
– LXD specializes in deploying (Linux) Virtual Machines

Application build using LXC?
Anbox – Android in a Box
Anbox is a container-based approach to boot a full Android system on a regular GNU/Linux system like Ubuntu. In other words: Anbox will let you run Android on your Linux system without the slowness of virtualization.

Reference –
WebSite: https://linuxcontainers.org
Version: LXC 2.1.x
https://linuxcontainers.org/lxd/getting-started-cli
http://www.tothenew.com/blog/lxc-linux-containers

Thank you,
Arun Bagul

How to login to Windows and Run command from Linux

How to login to Windows and Run command from Linux

Introduction –
In many cloud application you need to login to Windows from Linux server and run Windows native command or Powershell command to perform certain task.
There are two options to do this.

1) Winexe (outdated)-
NOTE – You can use it if it works for you!
Winexe remotely executes commands on Windows NT/2000/XP/2003 systems from GNU/Linux

    eg - winexe --user='<USERNAME>' //<HOSTNAME or IPADDRESS> "ipconfig /all"

2) Ruby or Python and WinRM –

* What is Windows Remote Management (WinRM)?
Windows Remote Management (WinRM) is the Microsoft implementation of WS-Management Protocol, a standard Simple Object Access Protocol (SOAP)-based, firewall-friendly protocol that    allows hardware and operating systems, from different vendors, to interoperate. Refere https://msdn.microsoft.com/en-us/library/aa384426.aspx for more information.

* What is PowerShell Remoting Protocol?
PowerShell Remoting allows me to run commands on a remote system as if I was sitting in front of it. It provides a consistent framework for managing computers across a network.
Windows PowerShell Remoting Protocol, which encodes messages prior to sending them over the Web Services Management Protocol Extensions for the Windows.

NOTE- “Enable-PSRemoting” service should be running on Windows server. (Command: Enable-PSRemoting -Force)

* WinRM and the Python library pywinrm (https://github.com/diyan/pywinrm)
   * WinRM and the Ruby library winrm

In this blog, we will use Ruby winrm library and see how we can monitor Windows service. Please find installation steps.

# yum install ruby-devel
# gem install -r winrm

Scripts-

#!/usr/bin/env /usr/bin/ruby

require 'rubygems'
require 'fileutils'
require 'highline/import'
require 'optparse'
require 'winrm'

############
options = {}
args = OptionParser.new do |opts|
  opts.on('-h', '--help', 'Show help') do
     puts opts
     exit
  end

  opts.on('-', /\A-\Z/) do
    puts opts
    exit(1)
  end

  opts.on('-H', '--hostname HOSTNAME', 'Hostname') do |hostname|
    options[:hostname] = hostname
  end

  opts.on('-u', '--username USERNAME', 'Username') do |username|
    options[:username] = username
  end

  opts.on('-s', '--service SERVICE', 'Window Service') do |winsrv|
    options[:winsrv] = winsrv
  end

  opts.on('-f', '--passfile FILE', 'File with Password') do |v|
    options[:passfile] = v
  end
end
args.parse!
args.banner = "\nUsage: #{$PROGRAM_NAME} <options>\n\n"
#puts options

if !options[:hostname].nil? && !options[:username].nil? && !options[:winsrv].nil?
   my_service = options[:winsrv].to_s
   my_user = options[:username].to_s
   my_pass = nil
   if File.exist?(options[:passfile].to_s)
     windata = File.read(options[:passfile].to_s)
     my_pass = windata.chomp.strip
   else
     print 'Enter Password: '
     pass = ask('Password: ') { |q| q.echo = '*' }
     my_pass = pass.chomp
   end

   ## windows code ##
   win_host = File.join('http://', options[:hostname], ':5985/wsman')
   opts = {
     endpoint: win_host.to_s, user: my_user.to_s, password: my_pass.to_s
   }
   conn = WinRM::Connection.new(opts)

   # powershell
   # ps_cmd = "Get-WMIObject Win32_Service -filter \"name = '#{my_service}'\" "
   #shell = conn.shell(:powershell)
   #output = shell.run(ps_cmd)
   ##puts output.stdout.chomp
   #data = output.stdout.gsub(/\s+|\n+/, ' ')
   #data = data.gsub(/\s+:/, ':')
   #if ( data =~ /ExitCode\s+:\s+0/ ) || ( data =~ /ExitCode:\s+0/ )
   # puts "OK - #{data}"
   # exit 0
   #else
   # puts "CRITICAL - #{data}"
   # exit 2
   #end

  # normal shell
   my_cmd = "sc query #{my_service}"
   shell_cmd = conn.shell(:cmd)
   output1 = shell_cmd.run(my_cmd)
   data1 = output1.to_s.chomp
   data1 = output1.stdout.gsub(/\s+|\n+/, ' ')
   data1 = data1.gsub(/\s+:/, ':')
   #puts data1
   if ( data1 =~ /.*STATE\s+:.*RUNNING/ ) || ( data1 =~ /.*STATE:.*RUNNING/ )
     puts "OK - #{data1}"
     exit 0
   else
     puts "CRITICAL - #{data1}"
     exit 2
   end
else
 STDERR.puts args.banner
 STDERR.puts args.summarize
 exit(1)
end

#eof

* How to user Script

root@localhost# ./winservice-monitoring.rb -u ‘XXXXX’ -H <MYHOST> -f /tmp/password.txt  -s xagt
OK – SERVICE_NAME: xagt TYPE: 10 WIN32_OWN_PROCESS STATE: 4 RUNNING (STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN) WIN32_EXIT_CODE: 0 (0x0) SERVICE_EXIT_CODE: 0 (0x0) CHECKPOINT: 0x0 WAIT_HINT: 0x0
root@localhost #

root@localhost # ./winservice-monitoring.rb -u ‘XXXXX’ -H <MYHOST> -f /tmp/password.txt  -s xxx
CRITICAL – [SC] EnumQueryServicesStatus:OpenService FAILED 1060: The specified service does not exist as an installed service.
root@localhost #

Reference:
https://github.com/WinRb/WinRM
https://sourceforge.net/projects/winexe
http://blogs.msdn.com/PowerShell

Thank you,
Arun Bagul

DevOps – Comparison of different Configuration Management Software

DevOps – Comparison of different Configuration Management Software

Introduction-

I’m working as DevOps since 2010. Many colleagues, friends asked me about comparison of different Configuration Management Software like Chef, Puppet or Ansible/Salt etc.

It is very important and difficult task to choose right CM(configuration management) software for managing Infrastructure and Application deployments.

I’m attaching pdf file with comparison of different CM hope it will help you.

Document – Devops-Comparison-v3

NOTE: This comparison is purely based on my knowledge and experience. Please feel free to share your updates.

Thank You,

Arun Bagul

Ravi co-founder of IndianGNU @ 2nd Check_MK Conference in Munich, Germany

Ravi co-founder of IndianGNU @ 2nd Check_MK Conference in Munich, Germany

Introduction-

Ravi Bhure co-founder of IndianGNU attended  2nd Check_MK Conference in Munich, Germany last October,2015 as delegate.

Ravi talked about “Migration from Solarwinds to Check_MK” in Check_MK Munich Conference.

For more information on presentation please visit https://www.linkedin.com/pulse/open-source-monitering-deadly-combo-migration-from-checkmk-burkule

 

Thank you,

Arun

 

 

Website Functional testing using Browser automation

Website Functional testing using Browser automation

Introduction-

Website Functional testing using Browser automation is very important and better than just monitoring url with 200 OK! Your Application or Website URL may be working fine but this doesn’t mean that all components are working fine. So testing your Web Application functionalities with screenshot is important in cloud based product and Uptime Reporting for Customers.

Few years back I wrote article “Firefox yslow and Showslow for Website testing and performance” Ref url- http://www.indiangnu.org/2012/firefox-yslow-and-showslow-for-website-testing-and-automation/

The Mechanize library is used for automating interaction with websites and available for Perl, Python and Ruby..
URL-
http://search.cpan.org/~ether/WWW-Mechanize-1.75/lib/WWW/Mechanize.pm
http://wwwsearch.sourceforge.net/mechanize/
https://pypi.python.org/pypi/mechanize/
http://mechanize.rubyforge.org/

There are several wrappers around “Mechanize” designed for functional testing of web applications: zope.testbrowser and twill

Top 5 Products for “Website Functional testing using Browser automation”…

1) Selenium Browser Automation (http://www.seleniumhq.org) –
Selenium automates browsers. Selenium is a portable software testing framework for web applications. Selenium provides a record/playback tool for authoring tests without learning a test scripting language (Selenium IDE). Selenium WebDriver is the successor to Selenium RC. Selenium WebDriver accepts commands (sent in Selenese, or via a Client API) and sends them to a browser. This is implemented through a browser-specific browser driver, which sends commands to a browser, and retrieves results. Most browser drivers actually launch and access a browser application (such as Firefox or Internet Explorer); there is also an HtmlUnit browser driver, which simulates a browser using HtmlUnit.

Selenium Grid- Selenium Grid is a server that allows tests to use web browser instances running on remote machines. With Selenium Grid, one server acts as the hub. the hub has a list of servers that provide access to browser instances (WebDriver nodes)

2) Splinter (https://splinter.readthedocs.org) –
Splinter is an open source tool for testing web applications using Python. It lets you automate browser actions, such as visiting URLs and interacting with their items. It supports multi webdrivers (chrome webdriver, firefox webdriver, phantomjs webdriver, zopetestbrowser, remote webdriver), support to iframe and alert and execute javascripts.

3) twill (http://twill.idyll.org) –
twill: a simple scripting language for Web browsing. twill is a simple language that allows users to browse the Web from a command-line interface. With twill, you can navigate through Web sites that use forms, cookies, and most standard Web features.

4) zope.testbrowser (https://pypi.python.org/pypi?:action=display&name=zope.testbrowser) –
zope.testbrowser provides an easy-to-use programmable web browser with special focus on testing. It is used in Zope, but it’s not Zope specific at all. For instance, it can be used to test or otherwise interact with any web site.

5) PAMIE  (http://pamie.sourceforge.net) –
P.A.M.I.E. – stands for Python Automated Module For I.E.  Pamie’s main use is for testing web sites by which you automate the Internet Explorer client using the Pamie scripting language. Simply create a script using the free PythonWin IDE that comes with the win32all extensions. import cPAMIE and use the Pamie Scripting Language (PSL) to write a script that simulates a user navigating a web site. It’s simple to use.

There are many product available for web site monitoring…

http://www.monitor.us/
https://ghostinspector.com/
https://www.browserstack.com
https://www.alertbot.com/
https://www.pingdom.com/

Thank you,
Arun Bagul