<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Khalid Khan </title>
    <description>The latest articles on Forem by Khalid Khan  (@khalidkhan123).</description>
    <link>https://forem.com/khalidkhan123</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3929540%2Fa0644e18-7bcd-4325-81c4-afe7d0fc918c.jpeg</url>
      <title>Forem: Khalid Khan </title>
      <link>https://forem.com/khalidkhan123</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/khalidkhan123"/>
    <language>en</language>
    <item>
      <title>I Ran Gemma 4 on 10,000 Linux Security Logs Locally — Here's the Real Cost</title>
      <dc:creator>Khalid Khan </dc:creator>
      <pubDate>Wed, 13 May 2026 14:53:58 +0000</pubDate>
      <link>https://forem.com/khalidkhan123/i-ran-gemma-4-on-10000-linux-security-logs-locally-heres-the-real-cost-475l</link>
      <guid>https://forem.com/khalidkhan123/i-ran-gemma-4-on-10000-linux-security-logs-locally-heres-the-real-cost-475l</guid>
      <description>&lt;p&gt;I'm building SystemGuard, an open-source HIDS to replace $35/month CrowdStrike for freelancers. My biggest problem isn't detection — it's explaining alerts without sending logs to OpenAI.&lt;/p&gt;

&lt;p&gt;When Google dropped Gemma 4 with a 128K context window, I tested it for one job: summarizing security events on-prem.&lt;/p&gt;

&lt;p&gt;This is what actually worked, what didn't, and why I chose the 4B model.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which Gemma 4 Model I Chose (And Why)
&lt;/h2&gt;

&lt;p&gt;Gemma 4 comes in three flavors:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;2B/4B&lt;/strong&gt; — runs on Raspberry Pi / phone&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;31B Dense&lt;/strong&gt; — server-grade&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;26B MoE&lt;/strong&gt; — high-throughput reasoning&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I picked &lt;strong&gt;Gemma 4 4B Instruct&lt;/strong&gt;. Not 2B (too many hallucinations on Linux paths), not 31B (needs 24GB VRAM, my test server has 8GB), not MoE (I need low latency, not batch reasoning).&lt;/p&gt;

&lt;p&gt;For a security agent that runs on a $20 VPS, 4B is the sweet spot: 3.5GB RAM, ~4 seconds per batch, Apache 2.0 license.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I Set It Up (Free, Local, No API Keys)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
bash
# 1. Install Ollama
curl -fsSL https://ollama.com/install.sh | sh

# 2. Pull Gemma 4
ollama pull gemma3:4b  # Ollama uses gemma3 tag for Gemma 4 family

# 3. Test
ollama run gemma3:4b "Explain this log: nginx uid=33 opened /etc/shadow"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>devchallenge</category>
      <category>gemmachallenge</category>
      <category>gemma</category>
    </item>
    <item>
      <title>Building SystemGuard: Why I'm Writing an Open-Source CrowdStrike Alternative in Rust</title>
      <dc:creator>Khalid Khan </dc:creator>
      <pubDate>Wed, 13 May 2026 14:34:44 +0000</pubDate>
      <link>https://forem.com/khalidkhan123/building-systemguard-why-im-writing-an-open-source-crowdstrike-alternative-in-rust-a7</link>
      <guid>https://forem.com/khalidkhan123/building-systemguard-why-im-writing-an-open-source-crowdstrike-alternative-in-rust-a7</guid>
      <description>&lt;p&gt;I manage infrastructure for clients across Pakistan. Last month, a freelancer friend got a $1,400 bill from CrowdStrike for 40 Linux servers. That's more than his monthly revenue.&lt;/p&gt;

&lt;p&gt;Enterprise EDR is broken for the rest of the world. So I'm building an alternative.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SystemGuard&lt;/strong&gt; is a lightweight, self-hosted HIDS I'm open-sourcing. It's not another wrapper around OSSEC — it's built from the kernel up with eBPF and Rust.&lt;/p&gt;

&lt;p&gt;GitHub: &lt;a href="https://github.com/systemguard-io/systemguard" rel="noopener noreferrer"&gt;https://github.com/systemguard-io/systemguard&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem Nobody Talks About
&lt;/h2&gt;

&lt;p&gt;Western security tools assume:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can afford $35/host/month&lt;/li&gt;
&lt;li&gt;You want to send all your telemetry to US clouds&lt;/li&gt;
&lt;li&gt;You have a SOC team to tune 10,000 alerts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In Karachi, Lahore, and Islamabad, we run 5-100 servers on tight margins. We need:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Real-time detection (&amp;lt;100ms)&lt;/li&gt;
&lt;li&gt;Self-hosted (data sovereignty)&lt;/li&gt;
&lt;li&gt;&amp;lt;2% CPU overhead&lt;/li&gt;
&lt;li&gt;Free&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;OSSEC hasn't had a meaningful commit since 2019. Wazuh is great but requires Elasticsearch cluster (overkill for 10 servers).&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Rust, Not Go?
&lt;/h2&gt;

&lt;p&gt;I prototyped in Go first. It worked — until I hit 15k syscalls/sec during a stress test. GC pause: 8ms. In that window, we lost 120 events. For a security tool, that's unacceptable.&lt;/p&gt;

&lt;p&gt;I rewrote the agent in Rust with &lt;code&gt;aya-rs&lt;/code&gt;. Same workload: 1.4% CPU, zero allocations in hot path, 5MB static binary.&lt;/p&gt;

&lt;p&gt;The decision is documented here: &lt;a href="https://github.com/systemguard-io/systemguard/blob/main/docs/adr/001-why-rust.md" rel="noopener noreferrer"&gt;ADR-001&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Key trade-off: steeper learning curve, but memory safety is non-negotiable when your agent runs as root.&lt;/p&gt;

&lt;h2&gt;
  
  
  eBPF vs auditd: The Numbers
&lt;/h2&gt;

&lt;p&gt;I benchmarked both on a t3.medium:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Method&lt;/th&gt;
&lt;th&gt;CPU&lt;/th&gt;
&lt;th&gt;Events Lost&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;auditd&lt;/td&gt;
&lt;td&gt;22%&lt;/td&gt;
&lt;td&gt;4.2%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;eBPF&lt;/td&gt;
&lt;td&gt;1.6%&lt;/td&gt;
&lt;td&gt;0%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;auditd copies every event to userspace. eBPF filters in-kernel. For monitoring &lt;code&gt;openat()&lt;/code&gt; and &lt;code&gt;execve()&lt;/code&gt;, eBPF is 14x more efficient.&lt;/p&gt;

&lt;p&gt;Full analysis: &lt;a href="https://github.com/systemguard-io/systemguard/blob/main/docs/adr/002-why-ebpf-not-auditd.md" rel="noopener noreferrer"&gt;ADR-002&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's the actual probe (simplified):&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
c
SEC("tracepoint/syscalls/sys_enter_openat")
int trace_openat(void *ctx) {
    struct event *e = bpf_ringbuf_reserve(&amp;amp;events, sizeof(*e), 0);
    if (!e) return 0;
    e-&amp;gt;pid = bpf_get_current_pid_tgid() &amp;gt;&amp;gt; 32;
    bpf_get_current_comm(&amp;amp;e-&amp;gt;comm, 16);
    // Filter in kernel: ignore /proc, /sys
    bpf_ringbuf_submit(e, 0);
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>opensource</category>
      <category>rust</category>
      <category>security</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
