Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8761613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:19:35+00:00 2026-06-13T15:19:35+00:00

I’m have an instance of graphite configured on one server, and i’m using it

  • 0

I’m have an instance of graphite configured on one server, and i’m using it to monitor my environment which sadly consists of both linux and windows machines. I want monitor the well-being of my servers so i have opted for collectl on my linux machines which does a nice job collecting system stats.

Sadly for windows there don’t seem to be so many solution for getting system stats and sending them to graphite, but i’ve manage to handle this situation with powershell. I’m using the a script which was suggested here http://josh.behrends.us/2012/07/windows-powershell-graphite-awesome/ for the graphite connection and also for getting metrics out of the computer
i’m using get-counter comandlet which, surprisingly, can gather a lot of info.

My script looks like this:

while (1 -eq 1)
{
$carbonServer = "hostname"
$carbonServerPort = 2003 
$epochtime = [int][double]::Parse((Get-Date -UFormat %s))

$socket = New-Object System.Net.Sockets.TCPClient
$socket.connect($carbonServer, $carbonServerPort)
$stream = $socket.GetStream()
$writer = new-object System.IO.StreamWriter($stream)
#Write out metric to the stream.

$DiskQue =  [int]((get-counter -Counter "\PhysicalDisk(1 e: f:)\Current Disk Queue Length" ).countersamples | select -property cookedvalue).cookedvalue
$BytesReceived = [int]((get-counter -Counter "\Server\Bytes Received/sec" ).countersamples | select -property cookedvalue).cookedvalue
$BytesSent =  [int]((get-counter -Counter "\Server\Bytes Transmitted/sec").countersamples | select -property cookedvalue).cookedvalue
$MemAvail = ((get-counter -Counter "\Memory\Available Bytes").countersamples | select -property cookedvalue).cookedvalue
$MemCommit = ((get-counter -Counter "\Memory\Committed Bytes").countersamples | select -property cookedvalue).cookedvalue
$ReadOp =  [int]((get-counter -Counter "\System\File Read Operations/sec").countersamples | select -property cookedvalue).cookedvalue
$WriteOp = [int]((get-counter -Counter "\System\File Write Operations/sec").countersamples | select -property cookedvalue).cookedvalue

$metric7 = ("hostname.metrics.WriteOp " + $WriteOp + " " + $epochTime+"`n")
$metric7

$writer.WriteLine($metric7)
$writer.Flush() #Flush and write our metrics.
$writer.Close()
$stream.Close()
sleep 5
}

Now this script outputs what it’s supposed to at first glance. The output has the format hostname.metrics.name $metric_value $epochTime but there are no graphs being graphed. They apear in the graphite dashboard but they are empty. I’ve inspected the output sent to the graphite server with wireshark. It seams that in windows the message gets appended with CRLF as opposed to linux where you only have LF. I have added \n by hand and for a small period of time it did the trick but now it stopped working.

My question is am i doing something wrong in the transmission because i’ve been analysing the trafic and the only difference between traffic coming form linux machines that gets graphed and from windows that doesn’t get graphed is the line terminators. In linux its LF(0a) and in windows is CRLF(0d0a), but again i’ve tried to send from linux LFCRLF(0a0d0a)
hoping the graphite server will read only until the first LF and than interepret the message but still i’m not geting graphs.

Also when I transmit from linux i have only one message, and when i transmit form powershell i have three messages. From what i’ve saw with strace on the carbon-cache process i have one recvfrom system call with the message i want, and the I have an other one which is empty and the the write syscall(when transmitting from powershell) as opposed yo anly one recvfrom with the message and a write(when transmitting with netcat on linux) ,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T15:19:38+00:00Added an answer on June 13, 2026 at 3:19 pm

    Seems that nobody provided any suggestions and as such i have followed another approach. I am still very curious as to why Graphite doesn’t interpret my sent message. The solution to this problem was using a UDP socket instead of a TCP one and sending the metrics to statsd which in term sends them to Graphite. This seems to work without any complications, and in if you think about it it’s better for your network because it minimizes traffic(if you keep statsd and Graphite on the same node).

    I’m posting the script in case anyone encounters my problem and his environment resembles mine. Here is the script

    [int] $Port = 8125
    $IP = "here is your IP" 
    $Address = [system.net.IPAddress]::Parse($IP) 
    $End = New-Object System.Net.IPEndPoint $address, $port 
    $Saddrf   = [System.Net.Sockets.AddressFamily]::InterNetwork 
    $Stype    = [System.Net.Sockets.SocketType]::Dgram 
    $Ptype    = [System.Net.Sockets.ProtocolType]::UDP 
    $Sock     = New-Object System.Net.Sockets.Socket $saddrf, $stype, $ptype 
    $sock.Connect($end) 
    
    function Send_Graphite
    {param ($Metric)
    
    $Enc     = [System.Text.Encoding]::ASCII 
    $Buffer  = $Enc.GetBytes($Metric) 
    $Sent   = $Sock.Send($Buffer) 
    "{0} characters sent to: {1} " -f $Sent,$IP 
    "Message is:" 
    $Metric
    sleep 1
    
    }  
    
    while (1 -eq 1)
    {
        $DiskQue =  [int]((get-counter -Counter "\PhysicalDisk(1 e: f:)\Current Disk Queue Length" ).countersamples | select -property cookedvalue).cookedvalue
        $BytesReceived = [int]((get-counter -Counter "\Server\Bytes Received/sec" ).countersamples | select -property cookedvalue).cookedvalue
        $BytesSent =  [int]((get-counter -Counter "\Server\Bytes Transmitted/sec").countersamples | select -property cookedvalue).cookedvalue
        $MemAvail = ((get-counter -Counter "\Memory\Available Bytes").countersamples | select -property cookedvalue).cookedvalue
        $MemCommit = ((get-counter -Counter "\Memory\Committed Bytes").countersamples | select -property cookedvalue).cookedvalue
        $ReadOp =  [int]((get-counter -Counter "\System\File Read Operations/sec").countersamples | select -property cookedvalue).cookedvalue
        $WriteOp = [int]((get-counter -Counter "\System\File Write Operations/sec").countersamples | select -property cookedvalue).cookedvalue
    
        $Message1 = "MAIN.OSmetrics.DiscQueue:"+$DiskQue+"|c"
        $Message2 = "MAIN.OSmetrics.BytesReceived:"+$BytesReceived+"|c"
        $Message3 = "MAIN.OSmetrics.BytesSent:"+$BytesSent+"|c"
        $Message4 = "MAIN.OSmetrics.MemAvail:"+$MemAvail+"|c"
        $Message5 = "MAIN.OSmetrics.MemCommit:"+$MemCommit+"|c"
        $Message6 = "MAIN.OSmetrics.ReadOp:"+$ReadOp+"|c"
        $Message7 = "MAIN.OSmetrics.WriteOp:"+$WriteOp+"|c"
    
        $Mesages = $Message1, $Message2, $Message3, $Message4, $Message5, $Message6, $Message7
        foreach($Message in $Mesages)
        {
            Send_Graphite $Message 
        }
    }
    

    The script is extensible and you can monitor a lot of things, just run get-counter -ListSet * and you will see. I’ve installed the script with TaskScheduler, and you can control the frequency with the while loop by inserting a sleep.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an autohotkey script which looks up a word in a bilingual dictionary
I have an array which has BIG numbers and small numbers in it. I
I have a text area in my form which accepts all possible characters from
I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.