{"id":323,"date":"2009-05-16T23:51:15","date_gmt":"2009-05-16T21:51:15","guid":{"rendered":"http:\/\/www.netexpertise.eu\/en\/?p=323"},"modified":"2021-04-18T09:07:48","modified_gmt":"2021-04-18T07:07:48","slug":"graph-freeradius-sessions","status":"publish","type":"post","link":"http:\/\/www.netexpertise.eu\/en\/networking\/freeradius\/graph-freeradius-sessions.html","title":{"rendered":"Graph Number of Freeradius Sessions with MRTG"},"content":{"rendered":"\n<p>You can easily graph <a href=\"\/en\/category\/networking\/freeradius\">Freeradius<\/a> number of active sessions with a simple shell script, if you store accounting data in a SQL database.<br><br>Use the script below for Mysql that you can easily adapt to other databases like Oracle or PostgreSQL. Check the complete list of <a href=\"https:\/\/wiki.freeradius.org\/features\/Databases\">supported databases by Freeradius<\/a>.<br>\u00a0<br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">#!\/bin\/bash\n\nSQL_USERNAME=radius_username\nSQL_DATABASE=radius\nSQL_PASSWORD=your_password\nSQL_SERVER=127.0.0.1\nSQL_ACCOUNTING_TABLE=radacct\nBACK_DAYS=5\n\nSESSIONS=`mysql -BN -u$SQL_USERNAME -p$SQL_PASSWORD -h $SQL_SERVER $SQL_DATABASE -e \\\n  \"SELECT COUNT(*) FROM $SQL_ACCOUNTING_TABLE \\\n  WHERE acctstoptime IS NULL \\\n  AND Acctstarttime > NOW() - INTERVAL $BACK_DAYS DAY;\"`\n\necho $SESSIONS<\/code><\/pre>\n\n\n\n<p><br>A certain number of sessions remain unclosed due to random packet losses, or network disconnections between the NAS and the Radius server. Sessions older than $BACK_DAYS are ignored to get the most accurate value.<br><br><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/www.netexpertise.eu\/images\/Freeradius_active_sessions.png\" alt=\"Freeradius active session graph\"\/><\/figure>\n\n\n\n<p><br>The script returns the number of active sessions. It is then possible to <a href=\"\/en\/monitoring\/mrtg-graph-only-one-value.html\">graph<\/a> this one value in <a href=\"http:\/\/oss.oetiker.ch\/mrtg\/\">MRTG<\/a> that normally ask for two of them.<br><br>Offer you users <a href=\"\/en\/networking\/freeradius\/usage-graphs.html\">upload\/download graphs<\/a> of their Internet network usage as well.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can easily graph Freeradius number of active sessions with a simple shell script, if you store accounting data in a SQL database. Use the script below for Mysql that you can easily adapt to other databases like Oracle or PostgreSQL. Check the complete list of supported databases by Freeradius.\u00a0 A certain number of sessions [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[3,202],"tags":[384,17,438,205],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.8.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Netexpertise - Graph Number of Freeradius Sessions with MRTG<\/title>\n<meta name=\"description\" content=\"Freeradius session graph. Visualize the number of active sessions of your Freeradius server as a graph with MRTG\" \/>\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.netexpertise.eu\/en\/networking\/freeradius\/graph-freeradius-sessions.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Netexpertise - Graph Number of Freeradius Sessions with MRTG\" \/>\n<meta property=\"og:description\" content=\"Freeradius session graph. Visualize the number of active sessions of your Freeradius server as a graph with MRTG\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.netexpertise.eu\/en\/networking\/freeradius\/graph-freeradius-sessions.html\" \/>\n<meta property=\"og:site_name\" content=\"Netexpertise\" \/>\n<meta property=\"article:published_time\" content=\"2009-05-16T21:51:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-04-18T07:07:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.netexpertise.eu\/images\/Freeradius_active_sessions.png\" \/>\n<meta name=\"author\" content=\"dave\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@netexpertise\" \/>\n<meta name=\"twitter:site\" content=\"@netexpertise\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.netexpertise.eu\/en\/networking\/freeradius\/graph-freeradius-sessions.html\",\"url\":\"https:\/\/www.netexpertise.eu\/en\/networking\/freeradius\/graph-freeradius-sessions.html\",\"name\":\"Netexpertise - Graph Number of Freeradius Sessions with MRTG\",\"isPartOf\":{\"@id\":\"https:\/\/www.netexpertise.eu\/en\/#website\"},\"datePublished\":\"2009-05-16T21:51:15+00:00\",\"dateModified\":\"2021-04-18T07:07:48+00:00\",\"author\":{\"@id\":\"https:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa\"},\"description\":\"Freeradius session graph. Visualize the number of active sessions of your Freeradius server as a graph with MRTG\",\"breadcrumb\":{\"@id\":\"https:\/\/www.netexpertise.eu\/en\/networking\/freeradius\/graph-freeradius-sessions.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.netexpertise.eu\/en\/networking\/freeradius\/graph-freeradius-sessions.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.netexpertise.eu\/en\/networking\/freeradius\/graph-freeradius-sessions.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.netexpertise.eu\/en\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Graph Number of Freeradius Sessions with MRTG\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.netexpertise.eu\/en\/#website\",\"url\":\"https:\/\/www.netexpertise.eu\/en\/\",\"name\":\"Netexpertise\",\"description\":\"Systems \/ Networks \/ DevOps\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.netexpertise.eu\/en\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa\",\"name\":\"dave\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g\",\"contentUrl\":\"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g\",\"caption\":\"dave\"},\"sameAs\":[\"http:\/\/www.netexpertise.eu\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Netexpertise - Graph Number of Freeradius Sessions with MRTG","description":"Freeradius session graph. Visualize the number of active sessions of your Freeradius server as a graph with MRTG","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.netexpertise.eu\/en\/networking\/freeradius\/graph-freeradius-sessions.html","og_locale":"en_US","og_type":"article","og_title":"Netexpertise - Graph Number of Freeradius Sessions with MRTG","og_description":"Freeradius session graph. Visualize the number of active sessions of your Freeradius server as a graph with MRTG","og_url":"https:\/\/www.netexpertise.eu\/en\/networking\/freeradius\/graph-freeradius-sessions.html","og_site_name":"Netexpertise","article_published_time":"2009-05-16T21:51:15+00:00","article_modified_time":"2021-04-18T07:07:48+00:00","og_image":[{"url":"https:\/\/www.netexpertise.eu\/images\/Freeradius_active_sessions.png"}],"author":"dave","twitter_card":"summary_large_image","twitter_creator":"@netexpertise","twitter_site":"@netexpertise","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.netexpertise.eu\/en\/networking\/freeradius\/graph-freeradius-sessions.html","url":"https:\/\/www.netexpertise.eu\/en\/networking\/freeradius\/graph-freeradius-sessions.html","name":"Netexpertise - Graph Number of Freeradius Sessions with MRTG","isPartOf":{"@id":"https:\/\/www.netexpertise.eu\/en\/#website"},"datePublished":"2009-05-16T21:51:15+00:00","dateModified":"2021-04-18T07:07:48+00:00","author":{"@id":"https:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa"},"description":"Freeradius session graph. Visualize the number of active sessions of your Freeradius server as a graph with MRTG","breadcrumb":{"@id":"https:\/\/www.netexpertise.eu\/en\/networking\/freeradius\/graph-freeradius-sessions.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.netexpertise.eu\/en\/networking\/freeradius\/graph-freeradius-sessions.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.netexpertise.eu\/en\/networking\/freeradius\/graph-freeradius-sessions.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.netexpertise.eu\/en"},{"@type":"ListItem","position":2,"name":"Graph Number of Freeradius Sessions with MRTG"}]},{"@type":"WebSite","@id":"https:\/\/www.netexpertise.eu\/en\/#website","url":"https:\/\/www.netexpertise.eu\/en\/","name":"Netexpertise","description":"Systems \/ Networks \/ DevOps","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.netexpertise.eu\/en\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa","name":"dave","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/image\/","url":"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g","contentUrl":"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g","caption":"dave"},"sameAs":["http:\/\/www.netexpertise.eu"]}]}},"_links":{"self":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/posts\/323"}],"collection":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/comments?post=323"}],"version-history":[{"count":0,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/posts\/323\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/media?parent=323"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/categories?post=323"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/tags?post=323"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}