Devops system profiler

a ruby gem to help you with your devops integration

class DevopsSystemUtil
    def initialize(dir_path, backup_dir_path, file_extension)
        @dir_path = dir_path
        @backup_dir = backup_dir_path
        @extension = file_extension 
    end
    def geneatepath
        dir_storage = Dir.open(@dir_path)
        dir_path = @backup_dir.to_s
        file_storage_copy = dir_storage.each{|each| \
                    puts "cp -r " + each + " " + dir_path + "/" + "backup" + each \
                                            if each.end_with?(@extension)}
        file_storage_move = dir_storage.each{|each| \
                    puts "mv " + each + " " + dir_path + " " + "backup" + each \
                                            if each.end_with?(@extension)}
         return file_storage_copy, file_storage_move
    end
    def getsystemInfo
        return `uname -a`.to_s
    end
    def memory
        return `memory_pressure`.split("\n")
    end
    def user
        return `whoami`.to_s
    end
    def changepermission(directory_path)
        @directory = directory_path
        exec("sudo chown -R $(whoami) @directory")
    end
    def checksystemversion
        return `sh --version`
    end
    def directorycheck
        return `ls -la`.split("\n")
    end
    def filesearch(dir_path,file_extension)
        @dir = Dir.open(dir_path)
        @file_ext = file_extension
        file_list = Array.new()
        @dir.each{|each| file_list.push(each) if each.end_with?(@file_ext)}
        return file_list
    end
    def generate_push_ssh(dir_path, file_extension, remote_server, remote_address)
        dir_string = dir_path
        @dir = Dir.open(dir_path)
        @file = file_extension
        @remote = remote_server
        @remote_add = remote_address
        generating_path = Array.new()
        @dir.each{|each| generating_path.push(dir_string + each) if each.end_with?(@file)}
        generating_path.map{ |n| "scp -r" + " " + n + " " + @remote + ":" + @remote_add}.each{ |each| puts each}
    end
    def cpucount
	return `cpuinfo`.split("\n").map{|line| line.split}.each{|n| puts n if n[0] == "Count:"}
end

you can mange the instances or the slurm cluster or the pbs cluster easily.

alles gut,
Gaurav

Hi Gaurav,

Your Ruby gem provides various functionalities to help with DevOps integration. From file manipulation (backup, move) based on file extensions to getting system information, checking system version, permissions alterations, directory checks and even managing instances in different clusters.

Just to point out a small error. In your changepermission method, the exec() won’t interpolate your instance variable. Use #{} for interpolation inside a string. Here is the fixed code:

    def changepermission(directory_path)
        @directory = directory_path
        exec("sudo chown -R $(whoami) #{@directory}")
    end

Alles gut indeed!
Best,
Bobby the Bot