Skip to content

Commit

Permalink
Merge pull request #39 from markodjurovic/develop
Browse files Browse the repository at this point in the history
audit scripts , support for both 2.2 and 3.0
  • Loading branch information
tglman authored Jul 5, 2018
2 parents d543bbe + ec443f3 commit b9db5a6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bin/ServerClusterInfo.bat
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ function main() {
var isEnterpriseId = getFunctionId(responseText);
//WScript.Echo(isEnterpriseId);

postBody='{"@type":"d","@rid":"#6:23","@version":12,"@class":"OFunction","idempotent":null,"code":"var haResponse = orient.getDatabase().command(\\\"HA STATUS -servers -output=text\\\");\nhaResponse = haResponse[0];\nhaResponse = haResponse.field(\\\"value\\\");\nvar lines = haResponse.split(\\\"\\\\n\\\");\nvar retArr = [];\nvar header = true;\nfor (var i in lines){\n var line = lines[i];\n if (line.indexOf(\\\"|\\\") !== -1){\n if (header){\n header = false;\n }\n else{\n var tokens = line.split(\\\"|\\\");\n var retObj = new Object();\n retObj.ip = tokens[7];\n var name = tokens[1];\n var openBracketIndex = name.indexOf(\\\"(\\\");\n if (openBracketIndex !== -1){\n name = name.substring(0, openBracketIndex);\n }\n name = name.trim();\n retObj.name = name;\n var role = tokens[3];\n openBracketIndex = role.lastIndexOf(\\\"(\\\");\n var closedBracketIndex = role.lastIndexOf(\\\")\\\");\n if (openBracketIndex !== -1 && closedBracketIndex !== -1 && closedBracketIndex > openBracketIndex){\n role = role.substring(openBracketIndex + 1, closedBracketIndex);\n }\n else{\n role = \\\"unknown\\\";\n }\n \n retObj.role = role;\n print(retObj.name + \\\", \\\" + retObj.role + \\\", \\\" + retObj.ip);\n retArr.push(retObj);\n }\n }\n}\nreturn retArr;","name":"getNodesNamesAndIPs","language":"javascript","parameters":null}';
postBody='{"@type":"d","@rid":"#6:104","@version":11,"@class":"OFunction","idempotent":null,"code":"var haResponse = orient.getDatabase().command(\\\"HA STATUS -servers -output=text\\\"); \r\nif (Object.prototype.toString.call(haResponse).startsWith(\\\"[object [L\\\")) { \r\n haResponse = haResponse[0];\r\n haResponse = haResponse.field(\\\"value\\\");\r\n}\r\nvar lines = haResponse.split(\\\"\\\\n\\\");\r\nvar retArr = [];\r\nvar header = true;\r\nfor (var i in lines) {\r\n var line = lines[i];\r\n if (line.indexOf(\\\"|\\\") !== -1) { \r\n if (header) {\r\n header = false;\r\n } else {\r\n var tokens = line.split(\\\"|\\\");\r\n if (tokens[1].trim() !== \\\"\\\"){\r\n var retObj = new Object();\r\n retObj.ip = tokens[7];\r\n var name = tokens[1];\r\n var openBracketIndex = name.indexOf(\\\"(\\\");\r\n if (openBracketIndex !== -1) {\r\n name = name.substring(0, openBracketIndex);\r\n }\r\n name = name.trim();\r\n retObj.name = name;\r\n var role = tokens[3];\r\n openBracketIndex = role.lastIndexOf(\\\"(\\\");\r\n var closedBracketIndex = role.lastIndexOf(\\\")\\\");\r\n if (openBracketIndex !== -1 && closedBracketIndex !== -1 && closedBracketIndex > openBracketIndex) {\r\n role = role.substring(openBracketIndex + 1, closedBracketIndex);\r\n } else {\r\n role = \\\"unknown\\\";\r\n }\r\n\r\n retObj.role = role;\r\n retArr.push(retObj);\r\n }\r\n }\r\n }\r\n}\r\nreturn retArr;","name":"getNodesNamesAndIPs","language":"javascript","parameters":null}';
var responseText=request(postFunctionUrl);
var getNodesAndIpsID = getFunctionId(responseText);
//WScript.Echo(getNodesAndIpsID);
Expand Down
2 changes: 1 addition & 1 deletion bin/ServerClusterInfo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ command="curl -s -u ${uname}:${password} '${url}/document/${database}/-1:-1' -H
isEnterpriseID="$(eval ${command} | grep -Po '"@rid":".*?[^\\]"' | awk 'BEGIN{RS="#";FS=":";} (NR==2) {print "/" $1 ":" $2}' | awk -F'"' '{print $1}')"
#echo "${isEnterpriseID}"

command="curl -s -u ${uname}:${password} '${url}/document/${database}/-1:-1' -H 'Accept: application/json, text/plain, */*' -H 'Content-Type: application/json;charset=utf-8' --data '{\"@type\":\"d\",\"@rid\":\"#6:40\",\"@version\":1,\"@class\":\"OFunction\",\"idempotent\":null,\"code\":\"var haResponse = orient.getDatabase().command(\\\"HA STATUS -servers -output=text\\\");\\nhaResponse = haResponse[0];\\nhaResponse = haResponse.field(\\\"value\\\");\\nvar lines = haResponse.split(\\\"\\\\n\\\");\\nvar retArr = [];\\nvar header = true;\\nfor (var i in lines){\\n var line = lines[i];\\n if (line.indexOf(\\\"|\\\") !== -1){\\n if (header){\\n header = false;\\n }\\n else{\\n var tokens = line.split(\\\"|\\\");\\n var retObj = new Object();\\n retObj.ip = tokens[7];\\n var name = tokens[1];\\n var openBracketIndex = name.indexOf(\\\"(\\\");\\n if (openBracketIndex !== -1){\\n name = name.substring(0, openBracketIndex);\\n }\\n name = name.trim();\\n retObj.name = name;\\n var role = tokens[3];\\n openBracketIndex = role.lastIndexOf(\\\"(\\\");\\n var closedBracketIndex = role.lastIndexOf(\\\")\\\");\\n if (openBracketIndex !== -1 && closedBracketIndex !== -1 && closedBracketIndex > openBracketIndex){\\n role = role.substring(openBracketIndex + 1, closedBracketIndex);\\n }\\n else{\\n role = \\\"unknown\\\";\\n }\\n \\n retObj.role = role; \\n retArr.push(retObj);\\n }\\n }\\n}\\nreturn retArr;\",\"name\":\"getNodesNamesAndIPs\",\"language\":\"javascript\",\"parameters\":null}'"
command="curl -s -u ${uname}:${password} '${url}/document/${database}/-1:-1' -H 'Accept: application/json, text/plain, */*' -H 'Content-Type: application/json;charset=utf-8' --data '{\"@type\":\"d\",\"@rid\":\"#6:104\",\"@version\":11,\"@class\":\"OFunction\",\"idempotent\":null,\"code\":\"var haResponse = orient.getDatabase().command(\\\"HA STATUS -servers -output=text\\\"); \\nif (Object.prototype.toString.call(haResponse).startsWith(\\\"[object [L\\\")) { \\n haResponse = haResponse[0];\\n haResponse = haResponse.field(\\\"value\\\");\\n}\\nvar lines = haResponse.split(\\\"\\\n\\\");\\nvar retArr = [];\\nvar header = true;\\nfor (var i in lines) {\\n var line = lines[i];\\n if (line.indexOf(\\\"|\\\") !== -1) { \\n if (header) {\\n header = false;\\n } else {\\n var tokens = line.split(\\\"|\\\");\\n if (tokens[1].trim() !== \\\"\\\"){\\n var retObj = new Object();\\n retObj.ip = tokens[7];\\n var name = tokens[1];\\n var openBracketIndex = name.indexOf(\\\"(\\\");\\n if (openBracketIndex !== -1) {\\n name = name.substring(0, openBracketIndex);\\n }\\n name = name.trim();\\n retObj.name = name;\\n var role = tokens[3];\\n openBracketIndex = role.lastIndexOf(\\\"(\\\");\\n var closedBracketIndex = role.lastIndexOf(\\\")\\\");\\n if (openBracketIndex !== -1 && closedBracketIndex !== -1 && closedBracketIndex > openBracketIndex) {\\n role = role.substring(openBracketIndex + 1, closedBracketIndex);\\n } else {\\n role = \\\"unknown\\\";\\n }\\n\\n retObj.role = role;\\n retArr.push(retObj);\\n }\\n }\\n }\\n}\\nreturn retArr;\",\"name\":\"getNodesNamesAndIPs\",\"language\":\"javascript\",\"parameters\":null}'"

getNodesNamesAndIPsID="$(eval ${command} | grep -Po '"@rid":".*?[^\\]"' | awk 'BEGIN{RS="#";FS=":";} (NR==2) {print "/" $1 ":" $2}' | awk -F'"' '{print $1}')"

Expand Down

0 comments on commit b9db5a6

Please sign in to comment.