{"id":7483,"date":"2020-11-23T22:02:02","date_gmt":"2020-11-24T03:02:02","guid":{"rendered":"https:\/\/www.redline13.com\/blog\/?page_id=7483"},"modified":"2022-08-08T20:41:14","modified_gmt":"2022-08-09T00:41:14","slug":"custom-jmeter-plugin","status":"publish","type":"page","link":"https:\/\/www.redline13.com\/blog\/custom-jmeter-plugin\/","title":{"rendered":"Custom JMeter Plugin for Running a Shell Script Before Your Test"},"content":{"rendered":"<p>Here are some reasons you may need a shell script to run before your test runs:<\/p>\n<ul>\n<li>Run a security scan<\/li>\n<li>Change \/ets\/hosts<\/li>\n<li>Download misc files<\/li>\n<li>Install custom packages<\/li>\n<\/ul>\n<p>Redline13 load agents handle all the setup for distributing packages, preparing test, running test, monitoring test but we don&#8217;t predict all your needs.<\/p>\n<p>To handle a customers\u00a0 setup which we have not predicted, we have a an all-purpose generic plugin which allows you to run a shell script before your test runs.<\/p>\n<p>Three steps<\/p>\n<ol>\n<li>How to Write the custom JMeter plugin<\/li>\n<li>How to enable<\/li>\n<li>How to use for a test run.<\/li>\n<\/ol>\n<h2>Write custom JMeter plugin<\/h2>\n<ul>\n<li>It&#8217;s a bash script<\/li>\n<li>Implement &#8220;function _plugin_install()&#8221;<\/li>\n<li>Here is an example<\/li>\n<li>\n<pre>Source Example : <a href=\"https:\/\/gist.github.com\/richardfriedman\/e706cdca880a8698228422c89b0b254e\">Agent Plugin (Gist)<\/a><br \/><br \/># only one function is required\n# Your parameters \n# $1 = home dir for user that will run test\n# $2 = user, this is user[NUMBER] \nfunction _plugin_install() {\n\n\tuserHome=$1\n  \n  # Functions you can use to find other services\n  # $(plugin_getJMeterHome) - Gets path to jmeter version to be used.\n\tjmeterHome=$(plugin_getJMeterHome)\n\n  # other calls\n  # plugin_getJMeterVersion\n  # plugin_getGatlingHome\n  # plugin_getGatlingVersion\n  # plugin_setting \"NAME\"  &lt;- This will get config bundled in load test package.\n  # ## plugin_setting serverCount &lt;- how many servers used for this test run\n  # ## plugin_setting testName &lt;- test name set in UI\n\n  # Not useful, but an example\n  echo \"Hello World\"\n  \n  # Change \/ets\/hosts, you can use sudo - its your load agent\n  echo \"127.0.0.1 my-load-agent\" | sudo tee -a \/etc\/hosts<br \/>}<\/pre>\n<\/li>\n<\/ul>\n<h2>Enable custom plugins<\/h2>\n<ul>\n<li>Go to account plugins <a href=\"https:\/\/www.redline13.com\/Account\/plugins\">https:\/\/www.redline13.com\/Account\/plugins<\/a><\/li>\n<li>Make sure your account has the custom dev plugins added<\/li>\n<li><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-7486 size-full\" src=\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2020\/11\/PluginManager.png\" alt=\"\" width=\"1111\" height=\"477\" srcset=\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2020\/11\/PluginManager.png 1111w, https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2020\/11\/PluginManager-300x129.png 300w, https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2020\/11\/PluginManager-1024x440.png 1024w, https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2020\/11\/PluginManager-768x330.png 768w\" sizes=\"auto, (max-width: 1111px) 100vw, 1111px\" \/><\/li>\n<\/ul>\n<h2>Using Plugin For Test<\/h2>\n<ul>\n<li>You need a public link to the file, we use raw github links\n<ul>\n<li>The plugin we have above has\n<ul>\n<li>Gist: https:\/\/gist.github.com\/richardfriedman\/e706cdca880a8698228422c89b0b254e<\/li>\n<li><strong>Raw:<\/strong> https:\/\/gist.githubusercontent.com\/richardfriedman\/e706cdca880a8698228422c89b0b254e\/raw\/fbf5bb8ff6b69525289a057868104c4f75887197\/agent.sh<\/li>\n<\/ul>\n<\/li>\n<li>We need the &#8216;Raw&#8217; url.<\/li>\n<\/ul>\n<\/li>\n<li>In your JMeter test go to Advanced JMeter Options -&gt; Plugins<\/li>\n<li>Enable &#8216;JMeter Dev&#8217;<\/li>\n<li>Paste in public URL (Raw gist from above)<\/li>\n<li><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-7487 size-full\" src=\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2020\/11\/AgentPluginJMeter.png\" alt=\"\" width=\"1014\" height=\"316\" srcset=\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2020\/11\/AgentPluginJMeter.png 1014w, https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2020\/11\/AgentPluginJMeter-300x93.png 300w, https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2020\/11\/AgentPluginJMeter-768x239.png 768w\" sizes=\"auto, (max-width: 1014px) 100vw, 1014px\" \/><\/li>\n<\/ul>\n<h2>Now run your test as usual.<\/h2>\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here are some reasons you may need a shell script to run before your test runs: Run a security scan Change \/ets\/hosts Download misc files Install custom packages Redline13 load agents handle all the setup for distributing packages, preparing test, running test, monitoring test but we don&#8217;t predict all your needs. To handle a customers\u00a0 setup which we have not predicted, we have a an all-purpose generic plugin which allows you to run a shell script<a class=\"more-link\" href=\"https:\/\/www.redline13.com\/blog\/custom-jmeter-plugin\/\">Read More &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":2,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["entry","page","publish","author-user","post-7483"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.12 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Custom JMeter Plugin - RedLine13<\/title>\n<meta name=\"description\" content=\"You may need a script to run before your test runs. RedLine13 has a custom JMeter plugin which allows you to run a shell script before your test kicks off.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.redline13.com\/blog\/custom-jmeter-plugin\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Custom JMeter Plugin - RedLine13\" \/>\n<meta property=\"og:description\" content=\"You may need a script to run before your test runs. RedLine13 has a custom JMeter plugin which allows you to run a shell script before your test kicks off.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.redline13.com\/blog\/custom-jmeter-plugin\/\" \/>\n<meta property=\"og:site_name\" content=\"RedLine13\" \/>\n<meta property=\"article:modified_time\" content=\"2022-08-09T00:41:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2020\/11\/PluginManager.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.redline13.com\/blog\/custom-jmeter-plugin\/\",\"url\":\"https:\/\/www.redline13.com\/blog\/custom-jmeter-plugin\/\",\"name\":\"Custom JMeter Plugin - RedLine13\",\"isPartOf\":{\"@id\":\"https:\/\/www.redline13.com\/blog\/#website\"},\"datePublished\":\"2020-11-24T03:02:02+00:00\",\"dateModified\":\"2022-08-09T00:41:14+00:00\",\"description\":\"You may need a script to run before your test runs. RedLine13 has a custom JMeter plugin which allows you to run a shell script before your test kicks off.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.redline13.com\/blog\/custom-jmeter-plugin\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.redline13.com\/blog\/custom-jmeter-plugin\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.redline13.com\/blog\/custom-jmeter-plugin\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.redline13.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Custom JMeter Plugin for Running a Shell Script Before Your Test\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.redline13.com\/blog\/#website\",\"url\":\"https:\/\/www.redline13.com\/blog\/\",\"name\":\"RedLine13\",\"description\":\"(Almost) Free Load Testing in the Cloud\",\"publisher\":{\"@id\":\"https:\/\/www.redline13.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.redline13.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.redline13.com\/blog\/#organization\",\"name\":\"RedLine13\",\"url\":\"https:\/\/www.redline13.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.redline13.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2013\/06\/cropped-rl13-header-logo.jpg\",\"contentUrl\":\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2013\/06\/cropped-rl13-header-logo.jpg\",\"width\":300,\"height\":68,\"caption\":\"RedLine13\"},\"image\":{\"@id\":\"https:\/\/www.redline13.com\/blog\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Custom JMeter Plugin - RedLine13","description":"You may need a script to run before your test runs. RedLine13 has a custom JMeter plugin which allows you to run a shell script before your test kicks off.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.redline13.com\/blog\/custom-jmeter-plugin\/","og_locale":"en_US","og_type":"article","og_title":"Custom JMeter Plugin - RedLine13","og_description":"You may need a script to run before your test runs. RedLine13 has a custom JMeter plugin which allows you to run a shell script before your test kicks off.","og_url":"https:\/\/www.redline13.com\/blog\/custom-jmeter-plugin\/","og_site_name":"RedLine13","article_modified_time":"2022-08-09T00:41:14+00:00","og_image":[{"url":"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2020\/11\/PluginManager.png"}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.redline13.com\/blog\/custom-jmeter-plugin\/","url":"https:\/\/www.redline13.com\/blog\/custom-jmeter-plugin\/","name":"Custom JMeter Plugin - RedLine13","isPartOf":{"@id":"https:\/\/www.redline13.com\/blog\/#website"},"datePublished":"2020-11-24T03:02:02+00:00","dateModified":"2022-08-09T00:41:14+00:00","description":"You may need a script to run before your test runs. RedLine13 has a custom JMeter plugin which allows you to run a shell script before your test kicks off.","breadcrumb":{"@id":"https:\/\/www.redline13.com\/blog\/custom-jmeter-plugin\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.redline13.com\/blog\/custom-jmeter-plugin\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.redline13.com\/blog\/custom-jmeter-plugin\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.redline13.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Custom JMeter Plugin for Running a Shell Script Before Your Test"}]},{"@type":"WebSite","@id":"https:\/\/www.redline13.com\/blog\/#website","url":"https:\/\/www.redline13.com\/blog\/","name":"RedLine13","description":"(Almost) Free Load Testing in the Cloud","publisher":{"@id":"https:\/\/www.redline13.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.redline13.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.redline13.com\/blog\/#organization","name":"RedLine13","url":"https:\/\/www.redline13.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.redline13.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2013\/06\/cropped-rl13-header-logo.jpg","contentUrl":"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2013\/06\/cropped-rl13-header-logo.jpg","width":300,"height":68,"caption":"RedLine13"},"image":{"@id":"https:\/\/www.redline13.com\/blog\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/pages\/7483","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/comments?post=7483"}],"version-history":[{"count":2,"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/pages\/7483\/revisions"}],"predecessor-version":[{"id":9928,"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/pages\/7483\/revisions\/9928"}],"wp:attachment":[{"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/media?parent=7483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}