Skip to content

Instantly share code, notes, and snippets.

@maethor
Last active January 24, 2022 11:51
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save maethor/8714514 to your computer and use it in GitHub Desktop.
Save maethor/8714514 to your computer and use it in GitHub Desktop.
<?php
#
# Copyright (c) 2014 Guillaume <maethor> Subiron (http://www.sysnove.fr/)
# Plugin: check_nginx_status
#
$colors = array(
'read' => '#5a3d99',
'write' => '#ff0000',
'wait' => '#e5ca44',
);
$opt[1] = "--vertical-label \"Nginx Requests\" --title \"Server $hostname\" ";
$ds_name[1] = "Nginx Requests";
$def[1] = rrd::def("var5", $RRDFILE[5], $DS[5]);
$def[1] .= rrd::def("var6", $RRDFILE[6], $DS[6]);
$def[1] .= rrd::gradient("var5", "#66CCFFdd", "0000ffdd", "ReqPerSec");
$def[1] .= rrd::gprint("var5", array("LAST", "AVERAGE", "MAX"), "%.3lf");
$def[1] .= rrd::line1("var5", "#000000");
$def[1] .= rrd::gradient("var6", "#ff5c00dd", "#ffdc00dd", "ConnPerSec");
$def[1] .= rrd::gprint("var6", array("LAST", "AVERAGE", "MAX"), "%.3lf");
$def[1] .= rrd::line1("var6", "#000000");
$opt[2] = "--vertical-label \"Req/Conn\" --title \"Server $hostname\" ";
$ds_name[2] = "Nginx Requests";
$def[2] = rrd::def("var7", $RRDFILE[7], $DS[7]);
$def[2] .= rrd::line1("var7", "#000000", "ReqPerConn ");
$def[2] .= rrd::gprint("var7", array("LAST", "AVERAGE", "MAX"), "%.3lf");
$opt[3] = "--vertical-label \"Threads\" --title \"Nginx Statistics\" ";
$ds_name[3] = "Nginx Thread Statistics";
$def[3] = rrd::def("var1", $RRDFILE[1], $DS[1]);
$def[3] .= rrd::def("var2", $RRDFILE[2], $DS[2]);
$def[3] .= rrd::def("var3", $RRDFILE[3], $DS[3]);
$def[3] .= rrd::def("var4", $RRDFILE[4], $DS[4]);
$def[3] .= rrd::area("var3", $colors["wait"], "Waiting");
$def[3] .= rrd::gprint("var3", array("LAST", "AVERAGE", "MAX"), "%.0lf");
$def[3] .= rrd::area("var1", $colors["read"], "Reading", $stack=True);
$def[3] .= rrd::gprint("var1", array("LAST", "AVERAGE", "MAX"), "%.0lf");
$def[3] .= rrd::area("var2", $colors["write"], "Writing", $stack=True);
$def[3] .= rrd::gprint("var2", array("LAST", "AVERAGE", "MAX"), "%.0lf");
$def[3] .= rrd::line1("var4", "#000000", "Total Active");
$def[3] .= rrd::gprint("var4", array("LAST", "AVERAGE", "MAX"), "%.0lf");
?>
@deepak-kosaraju
Copy link

Thanks for the Graph Template. It looks neat, Even colors are not odd as you where thinking. I will play with few colors when I get time.

@volga629
Copy link

Thanks for template,

pnp4nagios starts reports Undefined offset: 6 . Is this matter of checks output ?

@volga629
Copy link

Ok I found, check_mk truncate some performance data, Which need check why

Writing=1;Reading=0;Waiting=0;Active=1;ReqPerSec=0.037037 [check_nginx_status.pl]

@volga629
Copy link

And this real line, without check_mk

|Writing=1;Reading=0;Waiting=0;Active=1;ReqPerSec=0.039216;ConnPerSec=0.039216;ReqPerConn=0.962590

@JeffChien
Copy link

In the thread statistics, 'Reading' and 'Writing' were put in the wrong order. Please correct it;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment