+ /* Handle stats z (misc stats) */
+ virtual int OnStats(char symbol, User* user, string_list &results)
+ {
+ if (symbol == 'z')
+ {
+ std::string sn = ServerInstance->Config->ServerName;
+
+ /* Yeah yeah, i know, floats are ew.
+ * We used them here because we'd be casting to float anyway to do this maths,
+ * and also only floating point numbers can deal with the pretty large numbers
+ * involved in the total throughput of a server over a large period of time.
+ * (we dont count 64 bit ints because not all systems have 64 bit ints, and floats
+ * can still hold more.
+ */
+ float outbound_r = (total_out_compressed / (total_out_uncompressed + 0.001)) * 100;
+ float inbound_r = (total_in_compressed / (total_in_uncompressed + 0.001)) * 100;
+
+ float total_compressed = total_in_compressed + total_out_compressed;
+ float total_uncompressed = total_in_uncompressed + total_out_uncompressed;
+
+ float total_r = (total_compressed / (total_uncompressed + 0.001)) * 100;
+
+ char outbound_ratio[MAXBUF], inbound_ratio[MAXBUF], combined_ratio[MAXBUF];
+
+ sprintf(outbound_ratio, "%3.2f%%", outbound_r);
+ sprintf(inbound_ratio, "%3.2f%%", inbound_r);
+ sprintf(combined_ratio, "%3.2f%%", total_r);
+
+ results.push_back(sn+" 304 "+user->nick+" :ZIPSTATS outbound_compressed = "+ConvToStr(total_out_compressed));
+ results.push_back(sn+" 304 "+user->nick+" :ZIPSTATS inbound_compressed = "+ConvToStr(total_in_compressed));
+ results.push_back(sn+" 304 "+user->nick+" :ZIPSTATS outbound_uncompressed = "+ConvToStr(total_out_uncompressed));
+ results.push_back(sn+" 304 "+user->nick+" :ZIPSTATS inbound_uncompressed = "+ConvToStr(total_in_uncompressed));
+ results.push_back(sn+" 304 "+user->nick+" :ZIPSTATS percentage_of_original_outbound_traffic = "+outbound_ratio);
+ results.push_back(sn+" 304 "+user->nick+" :ZIPSTATS percentage_of_orignal_inbound_traffic = "+inbound_ratio);
+ results.push_back(sn+" 304 "+user->nick+" :ZIPSTATS total_size_of_original_traffic = "+combined_ratio);
+ return 0;
+ }
+
+ return 0;
+ }