{"id":546,"date":"2010-12-10T14:43:07","date_gmt":"2010-12-10T19:43:07","guid":{"rendered":"http:\/\/www.kickflop.net\/blog\/?p=546"},"modified":"2011-02-25T14:14:52","modified_gmt":"2011-02-25T19:14:52","slug":"any-metric-graphing-with-cron-some-code-syslog-and-splunk","status":"publish","type":"post","link":"https:\/\/www.kickflop.net\/blog\/2010\/12\/10\/any-metric-graphing-with-cron-some-code-syslog-and-splunk\/","title":{"rendered":"Any Metric Graphing with cron, some code, syslog, and Splunk"},"content":{"rendered":"<p>Sometimes (rarely), I get what I consider to be a clever idea.<\/p>\n<p>Today, while tying up an evaluation of <a title=\"Zenoss Core\" target=\"_blank\" href=\"http:\/\/community.zenoss.org\/index.jspa\">Zenoss Core<\/a> it occurred to me that one could get nice system performance graphs by simply syslogging the performance data to&nbsp;<a title=\"Splunk\" target=\"_blank\" href=\"http:\/\/www.splunk.com\">Splunk<\/a>, which provides for time series-based graphing.<!--more--><\/p>\n<p>Monitoring agent, schmonitoring schmagent.  We&#8217;ve got syslog, cron, and bash\/perl\/python\/ruby on the system already, and we&#8217;re syslogging to Splunk already.<\/p>\n<p>The selling feature here is that you can turn any metric&#8217;s data into a chart, and that data can be <em>anything you can gather from a UNIX shell<\/em> (in our case, spawned by cron).<\/p>\n<p>As a proof of concept, I spent 5 minutes and whipped up the following test script which runs out of cron repeatedly (choose your own interval).<\/p>\n<pre>#!\/bin\/sh\r\n\r\nVMSTAT=`vmstat 1 2 | tail -1 | awk '{print \"runqueue=\" $1 \" scanrate=\" $12 \" blockedprocs=\" $2}'`\r\nLOAD1=`uptime | sed 's\/.*load average: \\(.*\\), .*, .*\/load1=\\1\/g'`\r\nlogger -t stats -p user.info $VMSTAT $LOAD1\r\n<\/pre>\n<p>This syslogs a line like the following one at the chosen cron interval:<\/p>\n<pre>Dec  1 00:24:19 ourhost stats: [ID 702911 user.info] runqueue=1 scanrate=0 blockedprocs=0 load1=0.78<\/pre>\n<p>Now, since you&#8217;re syslogging all of your host data to Splunk (you are, right?), it&#8217;s just a matter of graphing the data against the event&#8217;s timestamp in Splunk.<\/p>\n<p>Our Splunk 4.1.6 search query was as follows for our proof of concept data:<\/p>\n<pre>\"ourhost stats:\" | multikv | table _time load1 runqueue blockedprocs scanrate<\/pre>\n<p>Clicking &#8220;Show Report&#8221;, setting Chart Type to &#8220;Area&#8221;, Multi-Series Mode to &#8220;Split&#8221;, and Null Values to &#8220;Treat as zero&#8221;, we get the following:<\/p>\n<p><a rel=\"lightbox\" href=\"https:\/\/www.kickflop.net\/blog\/wp-content\/uploads\/2010\/12\/splunk-perf-graph1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.kickflop.net\/blog\/wp-content\/uploads\/2010\/12\/splunk-perf-graph1-300x267.png\" alt=\"\" title=\"splunk-perf-graph1\" width=\"300\" height=\"267\" class=\"center size-medium wp-image-940\" srcset=\"https:\/\/www.kickflop.net\/blog\/wp-content\/uploads\/2010\/12\/splunk-perf-graph1-300x267.png 300w, https:\/\/www.kickflop.net\/blog\/wp-content\/uploads\/2010\/12\/splunk-perf-graph1.png 855w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>We&#8217;d love to hear your comments.  <em>Jeff Blaine with Splunk search brainstorming assistance from <a target=\"_blank\" href=\"http:\/\/twitter.com\/therealmaz\">Jeremy Maziarz<\/a><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes (rarely), I get what I consider to be a clever idea. Today, while tying up an evaluation of Zenoss&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-546","post","type-post","status-publish","format-standard","hentry","category-sysadmin"],"_links":{"self":[{"href":"https:\/\/www.kickflop.net\/blog\/wp-json\/wp\/v2\/posts\/546","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kickflop.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kickflop.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kickflop.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kickflop.net\/blog\/wp-json\/wp\/v2\/comments?post=546"}],"version-history":[{"count":9,"href":"https:\/\/www.kickflop.net\/blog\/wp-json\/wp\/v2\/posts\/546\/revisions"}],"predecessor-version":[{"id":1198,"href":"https:\/\/www.kickflop.net\/blog\/wp-json\/wp\/v2\/posts\/546\/revisions\/1198"}],"wp:attachment":[{"href":"https:\/\/www.kickflop.net\/blog\/wp-json\/wp\/v2\/media?parent=546"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kickflop.net\/blog\/wp-json\/wp\/v2\/categories?post=546"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kickflop.net\/blog\/wp-json\/wp\/v2\/tags?post=546"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}