Denis Khabarov avatar Denis Khabarov committed 47e9fc2

modified: check_nmdc.lua
Добавлен аргумент --randomnick,
При его использовании будет добавлено случайное число
В конец ника.

Comments (0)

Files changed (1)

 	--usersmaxwarn=VALUE      - Warning if userscount >= VALUE
 	--usersmaxcritical=VALUE  - Critical if userscount >= VALUE
 	--expecthubname           - Expect Hubname (Check md5 sum)
+	--randomnick              - Add random number in nick end
 Usage: ]]..arg[0]..[[ \ \
 		local available_args = {
 			["addr"] = true, ["port"] = true, ["nick"] = true, ["password"] = true, ["sharesize"] = true, ["help"]= true,
 			['perfdata']=true,['usersmaxwarn']=true, ['usersmaxcritical']=true,["expecthubname"]=true,
+			['randomnick'] = true,
 		for _, val in ipairs(arg) do
 			if val:find("=", 1, true) then
 	if not tArgs['nick'] then
 		tArgs['nick'] = 'nmdcnagios'
-	end
+	end	
 	if tArgs['sharesize'] then
 		tArgs['sharesize'] = convert_normal_size_to_bytes(tArgs['sharesize'])	
 local function main ()
 	cliarg_handler() -- Parse command line arguments
 	local nagstate,result = NAG_STATES['UNKNOWN'],'Unable to check '..tArgs['addr']..': Unknown error'
-	local hub = Ping(tArgs['addr'],(tArgs['port'] or 411),tArgs['nick']..math.random(1,1000),tArgs['password'],convert_normal_size_to_bytes(tArgs['sharesize']))
+	if tArgs['randomnick'] then
+		math.randomseed(os.time())
+		tArgs['nick'] = tArgs['nick']..tostring(math.random(1,33))
+	end
+	local hub = Ping(tArgs['addr'],(tArgs['port'] or 411),tArgs['nick'],tArgs['password'],convert_normal_size_to_bytes(tArgs['sharesize']))
 	if hub.Online then
 --		print('ONLINE')
 		if hub.State == 9 then
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.