--- /dev/null
+/*
+ * SQUID Web Proxy Cache http://www.squid-cache.org/
+ * ----------------------------------------------------------
+ *
+ * Squid is the result of efforts by numerous individuals from
+ * the Internet community; see the CONTRIBUTORS file for full
+ * details. Many organizations have provided support for Squid's
+ * development; see the SPONSORS file for full details. Squid is
+ * Copyrighted (C) 2001 by the Regents of the University of
+ * California; see the COPYRIGHT file for full details. Squid
+ * incorporates software developed and/or copyrighted by other
+ * sources; see the CREDITS file for full details.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ */
+
+#include "squid.h"
+#include "ipc/Messages.h"
+#include "ipc/TypedMsgHdr.h"
+#include "mgr/Registration.h"
+#include "SBufStatsAction.h"
+#include "StoreEntryStream.h"
+
+SBufStatsAction::SBufStatsAction(const Mgr::CommandPointer &cmd_):
+ Action(cmd_)
+{ } //default constructor is OK for data member
+
+SBufStatsAction::Pointer
+SBufStatsAction::Create(const Mgr::CommandPointer &cmd)
+{
+ return new SBufStatsAction(cmd);
+}
+
+void
+SBufStatsAction::add(const Mgr::Action& action)
+{
+ sbdata += dynamic_cast<const SBufStatsAction&>(action).sbdata;
+ mbdata += dynamic_cast<const SBufStatsAction&>(action).mbdata;
+}
+
+void
+SBufStatsAction::collect()
+{
+ sbdata = SBuf::GetStats();
+ mbdata = MemBlob::GetStats();
+}
+
+void
+SBufStatsAction::dump(StoreEntry* entry)
+{
+ StoreEntryStream ses(entry);
+ sbdata.dump(ses);
+ mbdata.dump(ses);
+ ses << "\n\n\nThese statistics are experimental; their format and contents "
+ "should not be relied upon, they are bound to change as "
+ "the SBuf feature is evolved";
+}
+
+void
+SBufStatsAction::pack(Ipc::TypedMsgHdr& msg) const
+{
+ msg.setType(Ipc::mtCacheMgrResponse);
+ msg.putPod(sbdata);
+ msg.putPod(mbdata);
+}
+
+void
+SBufStatsAction::unpack(const Ipc::TypedMsgHdr& msg)
+{
+ msg.checkType(Ipc::mtCacheMgrResponse);
+ msg.getPod(sbdata);
+ msg.getPod(mbdata);
+}
+
+static const bool Registered = (Mgr::RegisterAction("sbuf",
+ "String-Buffer statistics", &SBufStatsAction::Create, 0 , 1),
+ true);
--- /dev/null
+/*
+ * SQUID Web Proxy Cache http://www.squid-cache.org/
+ * ----------------------------------------------------------
+ *
+ * Squid is the result of efforts by numerous individuals from
+ * the Internet community; see the CONTRIBUTORS file for full
+ * details. Many organizations have provided support for Squid's
+ * development; see the SPONSORS file for full details. Squid is
+ * Copyrighted (C) 2001 by the Regents of the University of
+ * California; see the COPYRIGHT file for full details. Squid
+ * incorporates software developed and/or copyrighted by other
+ * sources; see the CREDITS file for full details.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ */
+
+#ifndef SQUID_SBUFEXTRAS_H
+#define SQUID_SBUFEXTRAS_H
+
+#include "mgr/Action.h"
+#include "SBuf.h"
+
+class StoreEntry;
+
+/// SBuf stats for cachemgr
+class SBufStatsAction: public Mgr::Action
+{
+public:
+ /// Mgr::ClassActionCreationHandler for Mgr::RegisterAction()
+ static Pointer Create(const Mgr::CommandPointer &cmd);
+
+protected:
+ explicit SBufStatsAction(const Mgr::CommandPointer &cmd);
+ /* Mgr::Action API */
+ virtual void collect();
+ virtual void dump(StoreEntry* entry);
+
+private:
+ /* Mgr::Action API */
+ virtual void add(const Mgr::Action& action);
+ virtual void pack(Ipc::TypedMsgHdr& msg) const;
+ virtual void unpack(const Ipc::TypedMsgHdr& msg);
+
+ SBufStats sbdata;
+ MemBlobStats mbdata;
+};
+
+#endif /* SQUID_SBUFSTATSACTION_H */