Created
          October 25, 2021 19:50 
        
      - 
      
- 
        Save killerbees19/48829034e2f5a7ed01c786dfbb99e5b2 to your computer and use it in GitHub Desktop. 
    Munin plugin to monitor Nginx HTTP protocols
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | /var/log/nginx/misc/protocol.log { | |
| daily | |
| missingok | |
| rotate 0 | |
| notifempty | |
| create 0640 www-data adm | |
| sharedscripts | |
| prerotate | |
| if [ -d /etc/logrotate.d/httpd-prerotate ]; then \ | |
| run-parts /etc/logrotate.d/httpd-prerotate; \ | |
| fi \ | |
| endscript | |
| postrotate | |
| invoke-rc.d nginx rotate >/dev/null 2>&1 | |
| endscript | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | log_format protocol '$server_protocol'; | |
| access_log /var/log/nginx/misc/protocol.log protocol; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/bash | |
| if [[ "$1" == "autoconf" ]] | |
| then | |
| echo "no" | |
| exit 1 | |
| elif [[ "$1" != "config" ]] | |
| then | |
| sort /var/log/nginx/misc/protocol.log | uniq -c | sort -k 2 | \ | |
| awk '{ k=gensub(/[^a-z0-9_]/, "_", "g", tolower($2)); print k".value "$1; }' | |
| exit $? | |
| fi | |
| cat << EOF | |
| graph_title Nginx HTTP protocols | |
| graph_vlabel Requests per \${graph_period} | |
| graph_args --base 1000 --lower-limit 0 | |
| graph_category nginx | |
| _.label Unknown | |
| _.colour COLOUR7 | |
| _.draw AREA | |
| _.type DERIVE | |
| _.min 0 | |
| http_1_0.label HTTP/1.0 | |
| http_1_0.colour COLOUR3 | |
| http_1_0.draw STACK | |
| http_1_0.type DERIVE | |
| http_1_0.min 0 | |
| http_1_1.label HTTP/1.1 | |
| http_1_1.colour COLOUR1 | |
| http_1_1.draw STACK | |
| http_1_1.type DERIVE | |
| http_1_1.min 0 | |
| http_2_0.label HTTP/2.0 | |
| http_2_0.colour COLOUR0 | |
| http_2_0.draw STACK | |
| http_2_0.type DERIVE | |
| http_2_0.min 0 | |
| EOF | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment